mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
DEV: Use response.parsed_body
in specs (#9615)
Most of it was autofixed with rubocop-discourse 2.1.1.
This commit is contained in:
@ -22,7 +22,7 @@ describe Admin::ApiController do
|
||||
it "succeeds" do
|
||||
get "/admin/api/keys.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["keys"].length).to eq(2)
|
||||
expect(response.parsed_body["keys"].length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ describe Admin::ApiController do
|
||||
it "succeeds" do
|
||||
get "/admin/api/keys/#{key1.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
data = JSON.parse(response.body)["key"]
|
||||
data = response.parsed_body["key"]
|
||||
expect(data["id"]).to eq(key1.id)
|
||||
expect(data["key"]).to eq(nil)
|
||||
expect(data["truncated_key"]).to eq(key1.key[0..3])
|
||||
@ -92,7 +92,7 @@ describe Admin::ApiController do
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['key']['description']).to eq("master key description")
|
||||
expect(data['key']['user']).to eq(nil)
|
||||
@ -117,7 +117,7 @@ describe Admin::ApiController do
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
|
||||
expect(data['key']['description']).to eq("restricted key description")
|
||||
expect(data['key']['user']['username']).to eq(user.username)
|
||||
|
@ -67,7 +67,7 @@ RSpec.describe Admin::BackupsController do
|
||||
get "/admin/backups.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
filenames = JSON.parse(response.body).map { |backup| backup["filename"] }
|
||||
filenames = response.parsed_body.map { |backup| backup["filename"] }
|
||||
expect(filenames).to include(backup_filename)
|
||||
expect(filenames).to include(backup_filename2)
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ describe Admin::BadgesController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["grant_count"]).to be > 0
|
||||
expect(response.parsed_body["grant_count"]).to be > 0
|
||||
end
|
||||
|
||||
it 'does not allow anything if enable_badge_sql is disabled' do
|
||||
@ -49,7 +49,7 @@ describe Admin::BadgesController do
|
||||
name: 'test', query: 'select 1 as user_id, null as granted_at', badge_type_id: 1
|
||||
}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["badge"]["name"]).to eq('test')
|
||||
expect(json["badge"]["query"]).to eq('select 1 as user_id, null as granted_at')
|
||||
@ -76,7 +76,7 @@ describe Admin::BadgesController do
|
||||
|
||||
expect(groupings2.map { |g| g.name }).to eq(names)
|
||||
expect((groupings.map(&:id) - groupings2.map { |g| g.id }).compact).to be_blank
|
||||
expect(::JSON.parse(response.body)["badge_groupings"].length).to eq(groupings2.length)
|
||||
expect(response.parsed_body["badge_groupings"].length).to eq(groupings2.length)
|
||||
end
|
||||
end
|
||||
|
||||
@ -85,7 +85,7 @@ describe Admin::BadgesController do
|
||||
get "/admin/badges/types.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)["badge_types"]).to be_present
|
||||
expect(response.parsed_body["badge_types"]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -28,7 +28,7 @@ describe Admin::ColorSchemesController do
|
||||
get "/admin/color_schemes.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
schemes = JSON.parse(response.body).map { |scheme| scheme["name"] }
|
||||
schemes = response.parsed_body.map { |scheme| scheme["name"] }
|
||||
expect(schemes).to include(scheme_name)
|
||||
end
|
||||
end
|
||||
@ -38,7 +38,7 @@ describe Admin::ColorSchemesController do
|
||||
post "/admin/color_schemes.json", params: valid_params
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body)['id']).to be_present
|
||||
expect(response.parsed_body['id']).to be_present
|
||||
end
|
||||
|
||||
it "returns failure with invalid params" do
|
||||
@ -48,7 +48,7 @@ describe Admin::ColorSchemesController do
|
||||
post "/admin/color_schemes.json", params: valid_params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(::JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@ -77,7 +77,7 @@ describe Admin::ColorSchemesController do
|
||||
put "/admin/color_schemes/#{color_scheme.id}.json", params: params
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
expect(::JSON.parse(response.body)['errors']).to be_present
|
||||
expect(response.parsed_body['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ describe Admin::DashboardController do
|
||||
get "/admin/dashboard.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['version_check']).to be_present
|
||||
expect(response.parsed_body['version_check']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@ -41,7 +41,7 @@ describe Admin::DashboardController do
|
||||
it 'does not return discourse version info' do
|
||||
get "/admin/dashboard.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['version_check']).not_to be_present
|
||||
end
|
||||
end
|
||||
@ -57,7 +57,7 @@ describe Admin::DashboardController do
|
||||
get "/admin/dashboard/problems.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['problems'].size).to eq(0)
|
||||
end
|
||||
end
|
||||
@ -70,7 +70,7 @@ describe Admin::DashboardController do
|
||||
it 'returns an array of strings' do
|
||||
get "/admin/dashboard/problems.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['problems'].size).to eq(2)
|
||||
expect(json['problems'][0]).to be_a(String)
|
||||
expect(json['problems'][1]).to be_a(String)
|
||||
|
@ -26,7 +26,7 @@ describe Admin::EmailController do
|
||||
|
||||
it 'does not include the password in the response' do
|
||||
get "/admin/email.json"
|
||||
mail_settings = JSON.parse(response.body)['settings']
|
||||
mail_settings = response.parsed_body['settings']
|
||||
|
||||
expect(
|
||||
mail_settings.select { |setting| setting['name'] == 'password' }
|
||||
@ -47,7 +47,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/sent.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
log = JSON.parse(response.body).first
|
||||
log = response.parsed_body.first
|
||||
expect(log["id"]).to eq(email_log.id)
|
||||
expect(log["reply_key"]).to eq(nil)
|
||||
|
||||
@ -56,7 +56,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/sent.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
log = JSON.parse(response.body).first
|
||||
log = response.parsed_body.first
|
||||
expect(log["id"]).to eq(email_log.id)
|
||||
expect(log["reply_key"]).to eq(post_reply_key.reply_key)
|
||||
end
|
||||
@ -80,7 +80,7 @@ describe Admin::EmailController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.size).to eq(1)
|
||||
expect(logs.first["reply_key"]).to eq(post_reply_key_2.reply_key)
|
||||
@ -98,7 +98,7 @@ describe Admin::EmailController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.first["id"]).to eq(log2.id)
|
||||
expect(logs.last["id"]).to eq(log1.id)
|
||||
@ -112,7 +112,7 @@ describe Admin::EmailController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
logs = JSON.parse(response.body)
|
||||
logs = response.parsed_body
|
||||
|
||||
expect(logs.count).to eq(1)
|
||||
expect(logs.first["id"]).to eq(log1.id)
|
||||
@ -147,7 +147,7 @@ describe Admin::EmailController do
|
||||
admin.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
|
||||
@ -160,7 +160,7 @@ describe Admin::EmailController do
|
||||
eviltrout.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
|
||||
@ -173,7 +173,7 @@ describe Admin::EmailController do
|
||||
eviltrout.email
|
||||
)
|
||||
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['sent_test_email_message']).to eq(I18n.t("admin.email.sent_test"))
|
||||
end
|
||||
end
|
||||
@ -214,7 +214,7 @@ describe Admin::EmailController do
|
||||
Fabricate(:incoming_email, error: "")
|
||||
get "/admin/email/rejected.json"
|
||||
expect(response.status).to eq(200)
|
||||
rejected = JSON.parse(response.body)
|
||||
rejected = response.parsed_body
|
||||
expect(rejected.first['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
|
||||
end
|
||||
end
|
||||
@ -224,7 +224,7 @@ describe Admin::EmailController do
|
||||
incoming_email = Fabricate(:incoming_email, error: "")
|
||||
get "/admin/email/incoming/#{incoming_email.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['error']).to eq(I18n.t("emails.incoming.unrecognized_error"))
|
||||
end
|
||||
end
|
||||
@ -234,7 +234,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/12345.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
@ -242,7 +242,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
@ -262,7 +262,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error"]).to eq(error_message)
|
||||
end
|
||||
|
||||
@ -276,7 +276,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["error"]).to eq(error_message)
|
||||
end
|
||||
|
||||
@ -286,7 +286,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::InvalidParameters")
|
||||
end
|
||||
|
||||
@ -294,7 +294,7 @@ describe Admin::EmailController do
|
||||
get "/admin/email/incoming_from_bounced/#{email_log.id}.json"
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["errors"]).to include("Discourse::NotFound")
|
||||
end
|
||||
end
|
||||
@ -317,7 +317,7 @@ describe Admin::EmailController do
|
||||
EMAIL
|
||||
post "/admin/email/advanced-test.json", params: { email: email }
|
||||
expect(response.status).to eq(200)
|
||||
incoming = JSON.parse(response.body)
|
||||
incoming = response.parsed_body
|
||||
expect(incoming['format']).to eq(1)
|
||||
expect(incoming['text']).to eq("Hello, this is a test!")
|
||||
expect(incoming['elided']).to eq("---\n\nThis part should be elided.")
|
||||
|
@ -21,7 +21,7 @@ describe Admin::EmailStylesController do
|
||||
get '/admin/customize/email_style.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)['email_style']
|
||||
json = response.parsed_body['email_style']
|
||||
expect(json['html']).to eq(default_html)
|
||||
expect(json['css']).to eq(default_css)
|
||||
end
|
||||
@ -32,7 +32,7 @@ describe Admin::EmailStylesController do
|
||||
get '/admin/customize/email_style.json'
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)['email_style']
|
||||
json = response.parsed_body['email_style']
|
||||
expect(json['html']).to eq("For you: %{email_content}")
|
||||
expect(json['css']).to eq(".user-name { font-size: 24px; }")
|
||||
end
|
||||
@ -59,7 +59,7 @@ describe Admin::EmailStylesController do
|
||||
email_style: valid_params.merge(html: 'No email content')
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['errors']).to include(
|
||||
I18n.t(
|
||||
'email_style.html_missing_placeholder',
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['email_templates']).to be_present
|
||||
end
|
||||
|
||||
@ -51,7 +51,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
|
||||
get '/admin/customize/email_templates.json'
|
||||
expect(response.status).to eq(200)
|
||||
templates = JSON.parse(response.body)['email_templates']
|
||||
templates = response.parsed_body['email_templates']
|
||||
template = templates.find { |t| t['id'] == 'user_notifications.admin_login' }
|
||||
expect(template['can_revert']).to eq(true)
|
||||
|
||||
@ -59,7 +59,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
|
||||
get '/admin/customize/email_templates.json'
|
||||
expect(response.status).to eq(200)
|
||||
templates = JSON.parse(response.body)['email_templates']
|
||||
templates = response.parsed_body['email_templates']
|
||||
template = templates.find { |t| t['id'] == 'user_notifications.admin_login' }
|
||||
expect(template['can_revert']).to eq(false)
|
||||
end
|
||||
@ -93,7 +93,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
|
||||
expect(response).not_to be_successful
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
@ -103,7 +103,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
email_template: { subject: email_subject, body: email_body }
|
||||
}, headers: headers
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
errors = json['errors']
|
||||
@ -196,7 +196,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
template = json['email_template']
|
||||
@ -279,7 +279,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
delete '/admin/customize/email_templates/non_existent_template', headers: headers
|
||||
expect(response).not_to be_successful
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
@ -307,7 +307,7 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||
delete '/admin/customize/email_templates/user_notifications.admin_login', headers: headers
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
template = json['email_template']
|
||||
|
@ -18,7 +18,7 @@ RSpec.describe Admin::EmojisController do
|
||||
get "/admin/customize/emojis.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]["name"]).to eq("osama-test-emoji")
|
||||
expect(json[0]["url"]).to eq(upload.url)
|
||||
end
|
||||
@ -34,7 +34,7 @@ RSpec.describe Admin::EmojisController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["errors"]).to eq([I18n.t('upload.images.size_not_found')])
|
||||
end
|
||||
end
|
||||
@ -49,7 +49,7 @@ RSpec.describe Admin::EmojisController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["errors"]).to eq([
|
||||
"Name #{I18n.t('activerecord.errors.models.custom_emoji.attributes.name.taken')}"
|
||||
])
|
||||
@ -69,7 +69,7 @@ RSpec.describe Admin::EmojisController do
|
||||
|
||||
expect(upload.original_filename).to eq('logo.png')
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(data["errors"]).to eq(nil)
|
||||
expect(data["name"]).to eq(custom_emoji.name)
|
||||
@ -88,7 +88,7 @@ RSpec.describe Admin::EmojisController do
|
||||
|
||||
custom_emoji = CustomEmoji.last
|
||||
|
||||
data = JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(custom_emoji.group).to eq("foo")
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ RSpec.describe Admin::GroupsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["usernames"]).to contain_exactly(user.username, admin.username)
|
||||
|
||||
@ -190,7 +190,7 @@ RSpec.describe Admin::GroupsController do
|
||||
expect(user2.title).to eq("WAT")
|
||||
expect(user2.trust_level).to eq(4)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['message']).to eq("2 users have been added to the group.")
|
||||
expect(json['users_not_added'][0]).to eq("doesnt_exist")
|
||||
end
|
||||
|
@ -24,7 +24,7 @@ describe Admin::PermalinksController do
|
||||
get "/admin/permalinks.json", params: { filter: "topic" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(2)
|
||||
end
|
||||
|
||||
@ -37,7 +37,7 @@ describe Admin::PermalinksController do
|
||||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(2)
|
||||
end
|
||||
|
||||
@ -50,7 +50,7 @@ describe Admin::PermalinksController do
|
||||
get "/admin/permalinks.json", params: { filter: "discourse" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(3)
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ describe Admin::PluginsController do
|
||||
it 'should return JSON' do
|
||||
get "/admin/plugins.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(::JSON.parse(response.body).has_key?('plugins')).to eq(true)
|
||||
expect(response.parsed_body.has_key?('plugins')).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ describe Admin::ReportsController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["reports"].count).to eq(2)
|
||||
expect(response.parsed_body["reports"].count).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
@ -42,9 +42,9 @@ describe Admin::ReportsController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["reports"].count).to eq(2)
|
||||
expect(JSON.parse(response.body)["reports"][0]["type"]).to eq("topics")
|
||||
expect(JSON.parse(response.body)["reports"][1]["type"]).to eq("not_found")
|
||||
expect(response.parsed_body["reports"].count).to eq(2)
|
||||
expect(response.parsed_body["reports"][0]["type"]).to eq("topics")
|
||||
expect(response.parsed_body["reports"][1]["type"]).to eq("not_found")
|
||||
end
|
||||
end
|
||||
|
||||
@ -92,7 +92,7 @@ describe Admin::ReportsController do
|
||||
get "/admin/reports/topics.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["report"]["total"]).to eq(1)
|
||||
expect(response.parsed_body["report"]["total"]).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -107,7 +107,7 @@ describe Admin::ReportsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
report = response.parsed_body["report"]
|
||||
|
||||
expect(report["type"]).to eq('topics')
|
||||
expect(report["data"].count).to eq(1)
|
||||
@ -126,7 +126,7 @@ describe Admin::ReportsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
report = JSON.parse(response.body)["report"]
|
||||
report = response.parsed_body["report"]
|
||||
|
||||
expect(report["type"]).to eq('signups')
|
||||
expect(report["data"].count).to eq(1)
|
||||
|
@ -38,7 +38,7 @@ describe Admin::RobotsTxtController do
|
||||
it "returns default content if there are no overrides" do
|
||||
get "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to be_present
|
||||
expect(json["overridden"]).to eq(false)
|
||||
end
|
||||
@ -47,7 +47,7 @@ describe Admin::RobotsTxtController do
|
||||
SiteSetting.overridden_robots_txt = "something"
|
||||
get "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to eq("something")
|
||||
expect(json["overridden"]).to eq(true)
|
||||
end
|
||||
@ -59,7 +59,7 @@ describe Admin::RobotsTxtController do
|
||||
it "overrides the site's default robots.txt" do
|
||||
put "/admin/customize/robots.json", params: { robots_txt: "new_content" }
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).to eq("new_content")
|
||||
expect(json["overridden"]).to eq(true)
|
||||
expect(SiteSetting.overridden_robots_txt).to eq("new_content")
|
||||
@ -82,7 +82,7 @@ describe Admin::RobotsTxtController do
|
||||
SiteSetting.overridden_robots_txt = "overridden_content"
|
||||
delete "/admin/customize/robots.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["robots_txt"]).not_to include("overridden_content")
|
||||
expect(json["overridden"]).to eq(false)
|
||||
expect(SiteSetting.overridden_robots_txt).to eq("")
|
||||
|
@ -16,7 +16,7 @@ describe Admin::ScreenedEmailsController do
|
||||
Fabricate(:screened_email)
|
||||
get "/admin/logs/screened_emails.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -24,13 +24,13 @@ describe Admin::ScreenedIpAddressesController do
|
||||
get "/admin/logs/screened_ip_addresses.json", params: { filter: "1.2.*" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(3)
|
||||
|
||||
get "/admin/logs/screened_ip_addresses.json", params: { filter: "4.5.6.7" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
result = JSON.parse(response.body)
|
||||
result = response.parsed_body
|
||||
expect(result.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ describe Admin::ScreenedUrlsController do
|
||||
Fabricate(:screened_url)
|
||||
get "/admin/logs/screened_urls.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json.size).to eq(1)
|
||||
end
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe Admin::SearchLogsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json[0]['term']).to eq('ruby')
|
||||
expect(json[0]['searches']).to eq(1)
|
||||
expect(json[0]['ctr']).to eq(0)
|
||||
@ -67,7 +67,7 @@ RSpec.describe Admin::SearchLogsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['term']['type']).to eq('search_log_term')
|
||||
expect(json['term']['search_result']).to be_present
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ describe Admin::SiteSettingsController do
|
||||
it 'returns valid info' do
|
||||
get "/admin/site_settings.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["site_settings"].length).to be > 100
|
||||
|
||||
locale = json["site_settings"].select do |s|
|
||||
@ -183,7 +183,7 @@ describe Admin::SiteSettingsController do
|
||||
default_categories_watching: category_id
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count)
|
||||
|
||||
CategoryUser.create!(category_id: category_id, notification_level: tracking, user: user)
|
||||
|
||||
@ -191,7 +191,7 @@ describe Admin::SiteSettingsController do
|
||||
default_categories_watching: category_id
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count - 1)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count - 1)
|
||||
|
||||
SiteSetting.setting(:default_categories_watching, "")
|
||||
end
|
||||
@ -203,7 +203,7 @@ describe Admin::SiteSettingsController do
|
||||
default_tags_watching: tag.name
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count)
|
||||
|
||||
TagUser.create!(tag_id: tag.id, notification_level: tracking, user: user)
|
||||
|
||||
@ -211,7 +211,7 @@ describe Admin::SiteSettingsController do
|
||||
default_tags_watching: tag.name
|
||||
}
|
||||
|
||||
expect(JSON.parse(response.body)["user_count"]).to eq(User.count - 1)
|
||||
expect(response.parsed_body["user_count"]).to eq(User.count - 1)
|
||||
|
||||
SiteSetting.setting(:default_tags_watching, "")
|
||||
end
|
||||
|
@ -48,35 +48,35 @@ RSpec.describe Admin::SiteTextsController do
|
||||
it 'returns json' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'title' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "title"))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "title"))
|
||||
end
|
||||
|
||||
it 'sets has_more to true if more than 50 results were found' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts'].size).to eq(50)
|
||||
expect(JSON.parse(response.body)['extras']['has_more']).to be_truthy
|
||||
expect(response.parsed_body['site_texts'].size).to eq(50)
|
||||
expect(response.parsed_body['extras']['has_more']).to be_truthy
|
||||
end
|
||||
|
||||
it 'works with pages' do
|
||||
texts = Set.new
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e' }
|
||||
JSON.parse(response.body)['site_texts'].each { |text| texts << text['id'] }
|
||||
response.parsed_body['site_texts'].each { |text| texts << text['id'] }
|
||||
expect(texts.size).to eq(50)
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'e', page: 1 }
|
||||
JSON.parse(response.body)['site_texts'].each { |text| texts << text['id'] }
|
||||
response.parsed_body['site_texts'].each { |text| texts << text['id'] }
|
||||
expect(texts.size).to eq(100)
|
||||
end
|
||||
|
||||
it 'works with locales' do
|
||||
get "/admin/customize/site_texts.json", params: { q: 'yes_value', locale: 'en' }
|
||||
value = JSON.parse(response.body)['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
expect(value).to eq(I18n.with_locale(:en) { I18n.t('js.yes_value') })
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'yes_value', locale: 'de' }
|
||||
value = JSON.parse(response.body)['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'js.yes_value' }['value']
|
||||
expect(value).to eq(I18n.with_locale(:de) { I18n.t('js.yes_value') })
|
||||
end
|
||||
|
||||
@ -99,7 +99,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
].each do |search_term|
|
||||
get "/admin/customize/site_texts.json", params: { q: search_term }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "title", "value" => value))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "title", "value" => value))
|
||||
end
|
||||
end
|
||||
|
||||
@ -114,7 +114,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
].each do |search_term|
|
||||
get "/admin/customize/site_texts.json", params: { q: search_term }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to include(include("id" => "embed.loading", "value" => value))
|
||||
expect(response.parsed_body['site_texts']).to include(include("id" => "embed.loading", "value" => value))
|
||||
end
|
||||
end
|
||||
|
||||
@ -125,11 +125,11 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'missing_plural_key' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to be_empty
|
||||
expect(response.parsed_body['site_texts']).to be_empty
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'another_missing_key' }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['site_texts']).to be_empty
|
||||
expect(response.parsed_body['site_texts']).to be_empty
|
||||
end
|
||||
|
||||
context 'plural keys' do
|
||||
@ -205,7 +205,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
get "/admin/customize/site_texts/js.topic.list.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
@ -217,7 +217,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
get "/admin/customize/site_texts/js.emoji_picker.food_&_drink.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
@ -239,14 +239,14 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
get "/admin/customize/site_texts/#{key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['overridden']).to eq(true)
|
||||
|
||||
TranslationOverride.destroy_all
|
||||
|
||||
get "/admin/customize/site_texts/#{key}.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['overridden']).to eq(false)
|
||||
end
|
||||
|
||||
@ -265,7 +265,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
get "/admin/customize/site_texts/#{id}.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json).to be_present
|
||||
|
||||
site_text = json['site_text']
|
||||
@ -312,7 +312,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('not_found')
|
||||
end
|
||||
|
||||
@ -323,7 +323,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
site_text = json['site_text']
|
||||
|
||||
expect(site_text['id']).to eq('js.emoji_picker.animals_&_nature')
|
||||
@ -337,7 +337,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['error_type']).to eq('invalid_access')
|
||||
expect(json['errors'].size).to eq(1)
|
||||
expect(json['errors'].first).to eq(I18n.t('email_template_cant_be_modified'))
|
||||
@ -352,7 +352,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
|
||||
body = JSON.parse(response.body)
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body['message']).to eq(I18n.t(
|
||||
'activerecord.errors.models.translation_overrides.attributes.value.invalid_interpolation_keys',
|
||||
@ -390,7 +390,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
put "/admin/customize/site_texts/title.json", params: { site_text: { value: 'hello' } }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
@ -401,7 +401,7 @@ RSpec.describe Admin::SiteTextsController do
|
||||
delete "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
site_text = json['site_text']
|
||||
|
||||
@ -422,24 +422,24 @@ RSpec.describe Admin::SiteTextsController do
|
||||
|
||||
get "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to eq(ru_title)
|
||||
|
||||
get "/admin/customize/site_texts/js.topic.read_more_MF.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to eq(ru_mf_text)
|
||||
|
||||
SiteSetting.default_locale = :en
|
||||
|
||||
get "/admin/customize/site_texts/title.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to_not eq(ru_title)
|
||||
|
||||
get "/admin/customize/site_texts/js.topic.read_more_MF.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['site_text']['value']).to_not eq(ru_mf_text)
|
||||
end
|
||||
|
||||
|
@ -20,7 +20,7 @@ describe Admin::StaffActionLogsController do
|
||||
|
||||
get "/admin/logs/staff_action_logs.json", params: { action_id: UserHistory.actions[:delete_topic] }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(json["staff_action_logs"].length).to eq(1)
|
||||
@ -38,14 +38,14 @@ describe Admin::StaffActionLogsController do
|
||||
|
||||
get "/admin/logs/staff_action_logs.json", params: { limit: 3 }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["staff_action_logs"].length).to eq(3)
|
||||
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 4")
|
||||
|
||||
get "/admin/logs/staff_action_logs.json", params: { limit: 3, page: 1 }
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json["staff_action_logs"].length).to eq(1)
|
||||
expect(json["staff_action_logs"][0]["new_value"]).to eq("value 1")
|
||||
@ -59,7 +59,7 @@ describe Admin::StaffActionLogsController do
|
||||
it 'Uses the custom_staff id' do
|
||||
get "/admin/logs/staff_action_logs.json", params: {}
|
||||
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
action = json['extras']['user_history_actions'].first
|
||||
|
||||
expect(action['id']).to eq plugin_extended_action.to_s
|
||||
@ -84,7 +84,7 @@ describe Admin::StaffActionLogsController do
|
||||
get "/admin/logs/staff_action_logs/#{record.id}/diff.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
parsed = JSON.parse(response.body)
|
||||
parsed = response.parsed_body
|
||||
expect(parsed["side_by_side"]).to include("up")
|
||||
expect(parsed["side_by_side"]).to include("down")
|
||||
|
||||
|
@ -17,7 +17,7 @@ describe Admin::ThemesController do
|
||||
it 'can generate key pairs' do
|
||||
post "/admin/themes/generate_key_pair.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["private_key"]).to include("RSA PRIVATE KEY")
|
||||
expect(json["public_key"]).to include("ssh-rsa ")
|
||||
end
|
||||
@ -35,12 +35,12 @@ describe Admin::ThemesController do
|
||||
upload = Upload.find_by(original_filename: "fake.woff2")
|
||||
|
||||
expect(upload.id).not_to be_nil
|
||||
expect(JSON.parse(response.body)["upload_id"]).to eq(upload.id)
|
||||
expect(response.parsed_body["upload_id"]).to eq(upload.id)
|
||||
end
|
||||
|
||||
context "when trying to upload an existing file" do
|
||||
let(:uploaded_file) { Upload.find_by(original_filename: "fake.woff2") }
|
||||
let(:response_json) { JSON.parse(response.body) }
|
||||
let(:response_json) { response.parsed_body }
|
||||
|
||||
before do
|
||||
post "/admin/themes/upload_asset.json", params: { file: upload }
|
||||
@ -77,7 +77,7 @@ describe Admin::ThemesController do
|
||||
expect(response.status).to eq(201)
|
||||
end.to change { Theme.count }.by (1)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Awesome Theme")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(3)
|
||||
@ -110,7 +110,7 @@ describe Admin::ThemesController do
|
||||
post "/admin/themes/import.json", params: { theme: theme_json_file }
|
||||
expect(response.status).to eq(201)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Sam's Simple Theme")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(2)
|
||||
@ -124,7 +124,7 @@ describe Admin::ThemesController do
|
||||
post "/admin/themes/import.json", params: { theme: theme_archive }
|
||||
end.to change { Theme.count }.by (1)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(5)
|
||||
@ -139,7 +139,7 @@ describe Admin::ThemesController do
|
||||
post "/admin/themes/import.json", params: { bundle: theme_archive }
|
||||
end.to change { Theme.count }.by (0)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["theme_fields"].length).to eq(5)
|
||||
@ -157,7 +157,7 @@ describe Admin::ThemesController do
|
||||
end.to change { Theme.count }.by (0)
|
||||
end
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
# Ensure only one refresh message is sent.
|
||||
# More than 1 is wasteful, and can trigger unusual race conditions in the client
|
||||
@ -179,7 +179,7 @@ describe Admin::ThemesController do
|
||||
post "/admin/themes/import.json", params: { bundle: theme_archive, theme_id: nil }
|
||||
end.to change { Theme.count }.by (1)
|
||||
expect(response.status).to eq(201)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["name"]).to eq("Header Icons")
|
||||
expect(json["theme"]["id"]).not_to eq(existing_theme.id)
|
||||
@ -213,7 +213,7 @@ describe Admin::ThemesController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["extras"]["color_schemes"].length).to eq(2)
|
||||
theme_json = json["themes"].find { |t| t["id"] == theme.id }
|
||||
@ -233,7 +233,7 @@ describe Admin::ThemesController do
|
||||
|
||||
expect(response.status).to eq(201)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(json["theme"]["theme_fields"].length).to eq(1)
|
||||
expect(UserHistory.where(action: UserHistory.actions[:change_theme]).count).to eq(1)
|
||||
@ -293,7 +293,7 @@ describe Admin::ThemesController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
fields = json["theme"]["theme_fields"].sort { |a, b| a["value"] <=> b["value"] }
|
||||
|
||||
@ -329,7 +329,7 @@ describe Admin::ThemesController do
|
||||
|
||||
# Response correct
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["translations"][0]["value"]).to eq("overridenstring")
|
||||
|
||||
# Database correct
|
||||
@ -347,7 +347,7 @@ describe Admin::ThemesController do
|
||||
}
|
||||
# Response correct
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["translations"][0]["value"]).to eq("defaultstring")
|
||||
|
||||
# Database correct
|
||||
@ -380,7 +380,7 @@ describe Admin::ThemesController do
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["theme"]["enabled"]).to eq(false)
|
||||
expect(UserHistory.where(
|
||||
context: child.id.to_s,
|
||||
@ -415,7 +415,7 @@ describe Admin::ThemesController do
|
||||
}
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
|
||||
expect(UserHistory.where(
|
||||
context: child.id.to_s,
|
||||
@ -441,7 +441,7 @@ describe Admin::ThemesController do
|
||||
theme: { remote_update: true }
|
||||
}
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["errors"].first).to eq("error message")
|
||||
expect(response.parsed_body["errors"].first).to eq("error message")
|
||||
end
|
||||
|
||||
it 'returns the right error message' do
|
||||
@ -452,7 +452,7 @@ describe Admin::ThemesController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(400)
|
||||
expect(JSON.parse(response.body)["errors"].first).to include(I18n.t("themes.errors.component_no_default"))
|
||||
expect(response.parsed_body["errors"].first).to include(I18n.t("themes.errors.component_no_default"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -512,7 +512,7 @@ describe Admin::ThemesController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["bg"]).to eq("green")
|
||||
expect(response.parsed_body["bg"]).to eq("green")
|
||||
|
||||
theme.reload
|
||||
expect(theme.included_settings[:bg]).to eq("green")
|
||||
|
@ -49,7 +49,7 @@ describe Admin::UserFieldsController do
|
||||
it "returns a list of user fields" do
|
||||
get "/admin/customize/user_fields.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['user_fields']).to be_present
|
||||
end
|
||||
end
|
||||
|
@ -19,14 +19,14 @@ RSpec.describe Admin::UsersController do
|
||||
it 'returns success with JSON' do
|
||||
get "/admin/users/list.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)).to be_present
|
||||
expect(response.parsed_body).to be_present
|
||||
end
|
||||
|
||||
context 'when showing emails' do
|
||||
it "returns email for all the users" do
|
||||
get "/admin/users/list.json", params: { show_emails: "true" }
|
||||
expect(response.status).to eq(200)
|
||||
data = ::JSON.parse(response.body)
|
||||
data = response.parsed_body
|
||||
data.each do |user|
|
||||
expect(user["email"]).to be_present
|
||||
end
|
||||
@ -582,7 +582,7 @@ RSpec.describe Admin::UsersController do
|
||||
it "returns an api response that the user can't be deleted because it has posts" do
|
||||
delete "/admin/users/#{delete_me.id}.json"
|
||||
expect(response.status).to eq(403)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['deleted']).to eq(false)
|
||||
end
|
||||
|
||||
@ -608,7 +608,7 @@ RSpec.describe Admin::UsersController do
|
||||
it "returns success" do
|
||||
put "/admin/users/#{reg_user.id}/activate.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
reg_user.reload
|
||||
expect(reg_user.active).to eq(true)
|
||||
@ -634,7 +634,7 @@ RSpec.describe Admin::UsersController do
|
||||
it "returns success" do
|
||||
put "/admin/users/#{reg_user.id}/deactivate.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
reg_user.reload
|
||||
expect(reg_user.active).to eq(false)
|
||||
@ -647,7 +647,7 @@ RSpec.describe Admin::UsersController do
|
||||
it "returns success" do
|
||||
post "/admin/users/#{reg_user.id}/log_out.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['success']).to eq("OK")
|
||||
end
|
||||
|
||||
@ -765,7 +765,7 @@ RSpec.describe Admin::UsersController do
|
||||
|
||||
get "/admin/users/ip-info.json", params: { ip: ip }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body).symbolize_keys).to eq(
|
||||
expect(response.parsed_body.symbolize_keys).to eq(
|
||||
city: "London",
|
||||
country: "United Kingdom",
|
||||
country_code: "GB",
|
||||
@ -848,7 +848,7 @@ RSpec.describe Admin::UsersController do
|
||||
|
||||
post "/admin/users/sync_sso.json", params: Rack::Utils.parse_query(sso.payload)
|
||||
expect(response.status).to eq(403)
|
||||
expect(JSON.parse(response.body)["message"]).to include("Primary email can't be blank")
|
||||
expect(response.parsed_body["message"]).to include("Primary email can't be blank")
|
||||
end
|
||||
|
||||
it 'should return the right message if the signature is invalid' do
|
||||
@ -860,8 +860,8 @@ RSpec.describe Admin::UsersController do
|
||||
correct_payload = Rack::Utils.parse_query(sso.payload)
|
||||
post "/admin/users/sync_sso.json", params: correct_payload.merge(sig: "someincorrectsignature")
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["message"]).to include(I18n.t('sso.login_error'))
|
||||
expect(JSON.parse(response.body)["message"]).not_to include(correct_payload["sig"])
|
||||
expect(response.parsed_body["message"]).to include(I18n.t('sso.login_error'))
|
||||
expect(response.parsed_body["message"]).not_to include(correct_payload["sig"])
|
||||
end
|
||||
|
||||
it "returns 404 if the external id does not exist" do
|
||||
@ -871,7 +871,7 @@ RSpec.describe Admin::UsersController do
|
||||
sso.external_id = ""
|
||||
post "/admin/users/sync_sso.json", params: Rack::Utils.parse_query(sso.payload)
|
||||
expect(response.status).to eq(422)
|
||||
expect(JSON.parse(response.body)["message"]).to include(I18n.t('sso.blank_id_error'))
|
||||
expect(response.parsed_body["message"]).to include(I18n.t('sso.blank_id_error'))
|
||||
end
|
||||
end
|
||||
|
||||
@ -975,7 +975,7 @@ RSpec.describe Admin::UsersController do
|
||||
it 'returns how many posts were deleted' do
|
||||
put "/admin/users/#{user.id}/delete_posts_batch.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["posts_deleted"]).to eq(3)
|
||||
expect(response.parsed_body["posts_deleted"]).to eq(3)
|
||||
end
|
||||
end
|
||||
|
||||
@ -983,7 +983,7 @@ RSpec.describe Admin::UsersController do
|
||||
it "returns correct json" do
|
||||
put "/admin/users/#{user.id}/delete_posts_batch.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["posts_deleted"]).to eq(0)
|
||||
expect(response.parsed_body["posts_deleted"]).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -25,13 +25,13 @@ describe Admin::VersionsController do
|
||||
it 'should return the currently available version' do
|
||||
get "/admin/version_check.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json['latest_version']).to eq('1.2.33')
|
||||
end
|
||||
|
||||
it "should return the installed version" do
|
||||
get "/admin/version_check.json"
|
||||
json = JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(response.status).to eq(200)
|
||||
expect(json['installed_version']).to eq(Discourse::VERSION::STRING)
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ describe Admin::WebHooksController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = ::JSON.parse(response.body)
|
||||
json = response.parsed_body
|
||||
expect(json["web_hook"]["payload_url"]).to eq("https://meta.discourse.org/")
|
||||
expect(UserHistory.where(acting_user_id: admin.id, action: UserHistory.actions[:web_hook_create]).count).to eq(1)
|
||||
end
|
||||
@ -54,7 +54,7 @@ describe Admin::WebHooksController do
|
||||
}
|
||||
|
||||
expect(response.status).to eq(422)
|
||||
response_body = JSON.parse(response.body)
|
||||
response_body = response.parsed_body
|
||||
|
||||
expect(response_body["errors"]).to be_present
|
||||
end
|
||||
|
Reference in New Issue
Block a user