DEV: s/JSON.parse(response.body)/response.parsed_body
This commit is contained in:
parent
77f3077d62
commit
d483f4ae5a
|
@ -64,7 +64,7 @@ module DiscourseChat
|
|||
if !response.kind_of?(Net::HTTPSuccess)
|
||||
error_key = nil
|
||||
begin
|
||||
responseData = JSON.parse(response.body)
|
||||
responseData = response.parsed_body
|
||||
if responseData['errcode'] == "M_UNKNOWN_TOKEN"
|
||||
error_key = 'chat_integration.provider.matrix.errors.unknown_token'
|
||||
elsif responseData['errcode'] == "M_UNKNOWN"
|
||||
|
|
|
@ -125,7 +125,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||
raise ::DiscourseChat::ProviderError.new info: { request: uri, response_code: response.code, response_body: response.body }
|
||||
end
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
unless json["ok"] == true
|
||||
if json.key?("error") && (json["error"] == ('channel_not_found') || json["error"] == ('is_archived'))
|
||||
|
|
|
@ -208,7 +208,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||
req.set_form_data(token: SiteSetting.chat_integration_slack_access_token, limit: 200, cursor: cursor)
|
||||
response = http.request(req)
|
||||
return false unless response.kind_of? Net::HTTPSuccess
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
return false unless json['ok']
|
||||
cursor = json['response_metadata']['next_cursor']
|
||||
json['members'].each do |user|
|
||||
|
@ -244,7 +244,7 @@ module DiscourseChat::Provider::SlackProvider
|
|||
req.set_form_data(data)
|
||||
response = http.request(req)
|
||||
return false unless response.kind_of? Net::HTTPSuccess
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
return false unless json['ok']
|
||||
|
||||
raw_messages = json['messages']
|
||||
|
|
|
@ -44,7 +44,7 @@ module DiscourseChat
|
|||
req.body = message.to_json
|
||||
response = http.request(req)
|
||||
|
||||
responseData = JSON.parse(response.body)
|
||||
responseData = response.parsed_body
|
||||
|
||||
responseData
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ describe 'Mattermost Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to eq(I18n.t("chat_integration.provider.mattermost.create.created"))
|
||||
|
||||
|
@ -103,7 +103,7 @@ describe 'Mattermost Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to eq(I18n.t("chat_integration.provider.mattermost.create.created"))
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ describe 'Slack Command Controller', type: :request do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["text"]).to be_present
|
||||
expect(response.parsed_body["text"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -98,7 +98,7 @@ describe 'Slack Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to eq(I18n.t("chat_integration.provider.slack.create.created"))
|
||||
|
||||
|
@ -117,7 +117,7 @@ describe 'Slack Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to eq(I18n.t("chat_integration.provider.slack.create.created"))
|
||||
|
||||
|
@ -317,7 +317,7 @@ describe 'Slack Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to include(I18n.t("chat_integration.provider.slack.transcript.loading"))
|
||||
end
|
||||
|
@ -333,7 +333,7 @@ describe 'Slack Command Controller', type: :request do
|
|||
token: token
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["text"]).to include(I18n.t("chat_integration.provider.slack.transcript.api_required"))
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ describe 'Chat Controller', type: :request do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json['providers'].size).to eq(2)
|
||||
|
||||
|
@ -76,8 +76,6 @@ describe 'Chat Controller', type: :request do
|
|||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
JSON.parse(response.body)
|
||||
end
|
||||
|
||||
it 'should fail for invalid channel' do
|
||||
|
@ -110,7 +108,7 @@ describe 'Chat Controller', type: :request do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
channels = JSON.parse(response.body)['channels']
|
||||
channels = response.parsed_body['channels']
|
||||
|
||||
expect(channels.count).to eq(1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue