diff --git a/plugins/poll/spec/controllers/posts_controller_spec.rb b/plugins/poll/spec/controllers/posts_controller_spec.rb index 917592e53c2..96ccc97e7c2 100644 --- a/plugins/poll/spec/controllers/posts_controller_spec.rb +++ b/plugins/poll/spec/controllers/posts_controller_spec.rb @@ -16,7 +16,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be @@ -29,7 +29,7 @@ describe PostsController do topic_id: post_1.topic.id, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be @@ -43,7 +43,7 @@ describe PostsController do title: title, raw: "[poll name=#{name} close=#{close_date.iso8601}]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["polls"][name]["close"]).to be @@ -99,7 +99,7 @@ describe PostsController do title: title, raw: "[poll name=]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["cooked"]).to include("<script>") @@ -111,7 +111,7 @@ describe PostsController do title: title, raw: "[Polls are awesome](/foobar)\n[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]).to be @@ -122,7 +122,7 @@ describe PostsController do title: title, raw: "[poll name=1]\n- A\n[poll name=2]\n- B\n- C\n[/poll]\n- D\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["1"]).to_not be @@ -148,7 +148,7 @@ describe PostsController do id: post_id, post: { raw: "[poll]\n- A\n- B\n- C\n[/poll]" } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls"]["poll"]["options"][2]["html"]).to eq("C") end @@ -160,7 +160,7 @@ describe PostsController do id: post_id, post: { raw: "[poll]\n- A\n- B\n- C\n[/poll]" } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls_votes"]).to_not be end @@ -196,7 +196,7 @@ describe PostsController do id: post_id, post: { raw: new_option } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C") end @@ -208,14 +208,14 @@ describe PostsController do id: post_id, post: { raw: new_option } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C") end it "support changes on the post" do put :update, params: { id: post_id, post: { raw: updated } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["cooked"]).to match("before") end @@ -248,7 +248,7 @@ describe PostsController do id: post_id, post: { raw: new_option } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C") expect(json["post"]["polls"]["poll"]["voters"]).to eq(1) @@ -267,7 +267,7 @@ describe PostsController do id: post_id, post: { raw: new_option } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["polls"]["poll"]["options"][1]["html"]).to eq("C") @@ -278,7 +278,7 @@ describe PostsController do it "support changes on the post" do put :update, params: { id: post_id, post: { raw: updated } }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["post"]["cooked"]).to match("before") end @@ -322,7 +322,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]\n[poll name=foo]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be @@ -363,7 +363,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to eq("

[poll]

\n") end @@ -399,7 +399,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be @@ -418,7 +418,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be @@ -437,7 +437,7 @@ describe PostsController do title: title, raw: "[poll]\n- A\n- B\n[/poll]" }, format: :json - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["cooked"]).to match("data-poll-") expect(json["polls"]["poll"]).to be diff --git a/spec/controllers/admin/api_controller_spec.rb b/spec/controllers/admin/api_controller_spec.rb index 27d73ea3ea1..48f63ed739b 100644 --- a/spec/controllers/admin/api_controller_spec.rb +++ b/spec/controllers/admin/api_controller_spec.rb @@ -11,7 +11,7 @@ describe Admin::ApiController do context '.index' do it "succeeds" do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end diff --git a/spec/controllers/admin/backups_controller_spec.rb b/spec/controllers/admin/backups_controller_spec.rb index a4f1757a464..f3ebecd1476 100644 --- a/spec/controllers/admin/backups_controller_spec.rb +++ b/spec/controllers/admin/backups_controller_spec.rb @@ -28,7 +28,7 @@ describe Admin::BackupsController do get :index, format: :html, xhr: true - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -40,7 +40,7 @@ describe Admin::BackupsController do get :index, format: :json, xhr: true - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json[0]["filename"]).to eq("backup1") @@ -58,7 +58,7 @@ describe Admin::BackupsController do get :status, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -72,7 +72,7 @@ describe Admin::BackupsController do with_uploads: false, client_id: "foo" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -139,7 +139,7 @@ describe Admin::BackupsController do delete :destroy, params: { id: backup_filename }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end it "doesn't remove the backup if not found" do @@ -162,7 +162,7 @@ describe Admin::BackupsController do get :logs, format: :html, xhr: true - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -175,7 +175,7 @@ describe Admin::BackupsController do post :restore, params: { id: backup_filename, client_id: "foo" }, format: :json expect(SiteSetting.disable_emails).to eq(true) - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -188,7 +188,7 @@ describe Admin::BackupsController do expect { put :readonly, params: { enable: true }, format: :json } .to change { UserHistory.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) user_history = UserHistory.last @@ -202,7 +202,7 @@ describe Admin::BackupsController do expect { put :readonly, params: { enable: false }, format: :json } .to change { UserHistory.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) user_history = UserHistory.last diff --git a/spec/controllers/admin/badges_controller_spec.rb b/spec/controllers/admin/badges_controller_spec.rb index 6751072d3a4..441d366f087 100644 --- a/spec/controllers/admin/badges_controller_spec.rb +++ b/spec/controllers/admin/badges_controller_spec.rb @@ -9,7 +9,7 @@ describe Admin::BadgesController do context 'index' do it 'returns badge index' do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -79,7 +79,7 @@ describe Admin::BadgesController do it 'returns JSON' do get :badge_types, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)["badge_types"]).to be_present end end @@ -87,7 +87,7 @@ describe Admin::BadgesController do context '.destroy' do it 'deletes the badge' do delete :destroy, params: { id: badge.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(Badge.where(id: badge.id).exists?).to eq(false) expect(UserHistory.where(acting_user_id: user.id, action: UserHistory.actions[:delete_badge]).exists?).to eq(true) end @@ -104,7 +104,7 @@ describe Admin::BadgesController do name: "123456" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) editor_badge.reload expect(editor_badge.name).to eq(editor_badge_name) @@ -127,7 +127,7 @@ describe Admin::BadgesController do enabled: true }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) badge.reload expect(badge.name).to eq('123456') expect(badge.query).to eq('select 123') @@ -147,7 +147,7 @@ describe Admin::BadgesController do enabled: true }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) badge.reload expect(badge.name).to eq('123456') expect(badge.query).to eq(sql) diff --git a/spec/controllers/admin/color_schemes_controller_spec.rb b/spec/controllers/admin/color_schemes_controller_spec.rb index e748d1e002c..efc1a488108 100644 --- a/spec/controllers/admin/color_schemes_controller_spec.rb +++ b/spec/controllers/admin/color_schemes_controller_spec.rb @@ -21,7 +21,7 @@ describe Admin::ColorSchemesController do Fabricate(:color_scheme) get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)).to be_present end end @@ -30,7 +30,7 @@ describe Admin::ColorSchemesController do it "returns JSON" do post :create, params: valid_params, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['id']).to be_present end @@ -51,7 +51,7 @@ describe Admin::ColorSchemesController do it "returns success" do ColorSchemeRevisor.expects(:revise).returns(existing) put :update, params: valid_params.merge(id: existing.id), format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end it "returns JSON" do @@ -78,7 +78,7 @@ describe Admin::ColorSchemesController do expect { delete :destroy, params: { id: existing.id }, format: :json }.to change { ColorScheme.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end end end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index cfde3a4ef5f..f10397a345d 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -23,7 +23,7 @@ describe Admin::DashboardController do it 'returns discourse version info' do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['version_check']).to be_present end end @@ -50,7 +50,7 @@ describe Admin::DashboardController do it 'returns an empty array' do get :problems, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json['problems'].size).to eq(0) end diff --git a/spec/controllers/admin/email_controller_spec.rb b/spec/controllers/admin/email_controller_spec.rb index 7f881f974ff..a8f838f64dc 100644 --- a/spec/controllers/admin/email_controller_spec.rb +++ b/spec/controllers/admin/email_controller_spec.rb @@ -76,7 +76,7 @@ describe Admin::EmailController do last_seen_at: 1.week.ago, username: user.username }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end diff --git a/spec/controllers/admin/emojis_controller_spec.rb b/spec/controllers/admin/emojis_controller_spec.rb index 7a1f3618c62..5faafdfeb34 100644 --- a/spec/controllers/admin/emojis_controller_spec.rb +++ b/spec/controllers/admin/emojis_controller_spec.rb @@ -23,7 +23,7 @@ describe Admin::EmojisController do it "returns a list of custom emojis" do Emoji.expects(:custom).returns([custom_emoji]) get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json[0]["name"]).to eq(custom_emoji.name) expect(json[0]["url"]).to eq(custom_emoji.url) diff --git a/spec/controllers/admin/impersonate_controller_spec.rb b/spec/controllers/admin/impersonate_controller_spec.rb index b9793cc80c2..2a43778f632 100644 --- a/spec/controllers/admin/impersonate_controller_spec.rb +++ b/spec/controllers/admin/impersonate_controller_spec.rb @@ -13,7 +13,7 @@ describe Admin::ImpersonateController do context 'index' do it 'returns success' do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -48,7 +48,7 @@ describe Admin::ImpersonateController do it "returns success" do post :create, params: { username_or_email: user.email }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end it "also works with an email address" do diff --git a/spec/controllers/admin/permalinks_controller_spec.rb b/spec/controllers/admin/permalinks_controller_spec.rb index 3befb17ff5c..1084eed2103 100644 --- a/spec/controllers/admin/permalinks_controller_spec.rb +++ b/spec/controllers/admin/permalinks_controller_spec.rb @@ -17,7 +17,7 @@ describe Admin::PermalinksController do get :index, params: { filter: "topic" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) expect(result.length).to eq(2) end @@ -30,7 +30,7 @@ describe Admin::PermalinksController do get :index, params: { filter: "discourse" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) expect(result.length).to eq(2) end @@ -43,7 +43,7 @@ describe Admin::PermalinksController do get :index, params: { filter: "discourse" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) expect(result.length).to eq(3) end diff --git a/spec/controllers/admin/plugins_controller_spec.rb b/spec/controllers/admin/plugins_controller_spec.rb index 7e599c55337..a1907c23748 100644 --- a/spec/controllers/admin/plugins_controller_spec.rb +++ b/spec/controllers/admin/plugins_controller_spec.rb @@ -11,7 +11,7 @@ describe Admin::PluginsController do it 'should return JSON' do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body).has_key?('plugins')).to eq(true) end end diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index 021576405ed..d440b941026 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -45,7 +45,7 @@ describe Admin::ReportsController do end it "renders the report as JSON" do - expect(response).to be_successful + expect(response.status).to eq(200) end it "renders the report as JSON" do @@ -67,7 +67,7 @@ describe Admin::ReportsController do get :show, params: { type: 'topics', category_id: category.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) report = JSON.parse(response.body)["report"] @@ -87,7 +87,7 @@ describe Admin::ReportsController do get :show, params: { type: 'signups', group_id: group.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) report = JSON.parse(response.body)["report"] diff --git a/spec/controllers/admin/screened_ip_addresses_controller_spec.rb b/spec/controllers/admin/screened_ip_addresses_controller_spec.rb index 4176173d3be..fb4ed1e9bb5 100644 --- a/spec/controllers/admin/screened_ip_addresses_controller_spec.rb +++ b/spec/controllers/admin/screened_ip_addresses_controller_spec.rb @@ -18,13 +18,13 @@ describe Admin::ScreenedIpAddressesController do get :index, params: { filter: "1.2.*" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) expect(result.length).to eq(3) get :index, params: { filter: "4.5.6.7" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) expect(result.length).to eq(1) end @@ -45,7 +45,7 @@ describe Admin::ScreenedIpAddressesController do SiteSetting.min_ban_entries_for_roll_up = 3 post :roll_up, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) subnet = ScreenedIpAddress.where(ip_address: "1.2.3.0/24").first expect(subnet).to be_present @@ -65,7 +65,7 @@ describe Admin::ScreenedIpAddressesController do SiteSetting.min_ban_entries_for_roll_up = 5 post :roll_up, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) subnet = ScreenedIpAddress.where(ip_address: "1.2.0.0/16").first expect(subnet).to be_present diff --git a/spec/controllers/admin/site_texts_controller_spec.rb b/spec/controllers/admin/site_texts_controller_spec.rb index 6acb89da03c..d9bce364879 100644 --- a/spec/controllers/admin/site_texts_controller_spec.rb +++ b/spec/controllers/admin/site_texts_controller_spec.rb @@ -14,7 +14,7 @@ describe Admin::SiteTextsController do context '.index' do it 'returns json' do get :index, params: { q: 'title' }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)).to be_present end end @@ -22,7 +22,7 @@ describe Admin::SiteTextsController do context '.show' do it 'returns a site text for a key that exists' do get :show, params: { id: 'title' }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -71,7 +71,7 @@ describe Admin::SiteTextsController do orig_title = I18n.t(:title) put :update, params: { id: 'title', site_text: { value: 'hello' } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -84,7 +84,7 @@ describe Admin::SiteTextsController do # Revert put :revert, params: { id: 'title' }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present diff --git a/spec/controllers/admin/staff_action_logs_controller_spec.rb b/spec/controllers/admin/staff_action_logs_controller_spec.rb index 5f12839e38e..0950429f62e 100644 --- a/spec/controllers/admin/staff_action_logs_controller_spec.rb +++ b/spec/controllers/admin/staff_action_logs_controller_spec.rb @@ -17,7 +17,7 @@ describe Admin::StaffActionLogsController do get :index, params: { action_id: UserHistory.actions[:delete_topic] }, format: :json json = JSON.parse(response.body) - expect(response).to be_successful + expect(response.status).to eq(200) expect(json["staff_action_logs"].length).to eq(1) expect(json["staff_action_logs"][0]["action_name"]).to eq("delete_topic") @@ -41,7 +41,7 @@ describe Admin::StaffActionLogsController do .log_theme_change(original_json, theme) get :diff, params: { id: record.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) parsed = JSON.parse(response.body) expect(parsed["side_by_side"]).to include("up") diff --git a/spec/controllers/admin/themes_controller_spec.rb b/spec/controllers/admin/themes_controller_spec.rb index e129499d4cf..30625c7d570 100644 --- a/spec/controllers/admin/themes_controller_spec.rb +++ b/spec/controllers/admin/themes_controller_spec.rb @@ -66,7 +66,7 @@ describe Admin::ThemesController do upload.destroy post :import, params: { theme: uploaded_json }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) temp.unlink theme = Theme.last @@ -79,7 +79,7 @@ describe Admin::ThemesController do it 'imports a theme' do post :import, params: { theme: theme_file }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) @@ -113,7 +113,7 @@ describe Admin::ThemesController do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) @@ -133,7 +133,7 @@ describe Admin::ThemesController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) @@ -186,7 +186,7 @@ describe Admin::ThemesController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) diff --git a/spec/controllers/admin/user_fields_controller_spec.rb b/spec/controllers/admin/user_fields_controller_spec.rb index b885c8b3894..47ed6de465b 100644 --- a/spec/controllers/admin/user_fields_controller_spec.rb +++ b/spec/controllers/admin/user_fields_controller_spec.rb @@ -16,7 +16,7 @@ describe Admin::UserFieldsController do user_field: { name: 'hello', description: 'hello desc', field_type: 'text' } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) }.to change(UserField, :count).by(1) end @@ -31,7 +31,7 @@ describe Admin::UserFieldsController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end.to change(UserField, :count).by(1) expect(UserFieldOption.count).to eq(3) @@ -43,7 +43,7 @@ describe Admin::UserFieldsController do it "returns a list of user fields" do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['user_fields']).to be_present end @@ -55,7 +55,7 @@ describe Admin::UserFieldsController do it "deletes the user field" do expect { delete :destroy, params: { id: user_field.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) }.to change(UserField, :count).by(-1) end end @@ -69,7 +69,7 @@ describe Admin::UserFieldsController do user_field: { name: 'fraggle', field_type: 'confirm', description: 'muppet' } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user_field.reload expect(user_field.name).to eq('fraggle') expect(user_field.field_type).to eq('confirm') @@ -86,7 +86,7 @@ describe Admin::UserFieldsController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user_field.reload expect(user_field.name).to eq('fraggle') expect(user_field.field_type).to eq('dropdown') @@ -105,7 +105,7 @@ describe Admin::UserFieldsController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user_field.reload expect(user_field.user_field_options.size).to eq(2) @@ -119,7 +119,7 @@ describe Admin::UserFieldsController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user_field.reload expect(user_field.user_field_options.size).to eq(2) end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index d82e74e06fd..8288d07675e 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -15,7 +15,7 @@ describe Admin::UsersController do context '#index' do it 'returns success' do get :index, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end it 'returns JSON' do @@ -48,7 +48,7 @@ describe Admin::UsersController do context 'an existing user' do it 'returns success' do get :show, params: { id: @user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -135,7 +135,7 @@ describe Admin::UsersController do format: :json } ) - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user).to be_suspended @@ -160,7 +160,7 @@ describe Admin::UsersController do it "can have an associated post" do put(:suspend, params: suspend_params) - expect(response).to be_successful + expect(response.status).to eq(200) log = UserHistory.where(target_user_id: user.id).order('id desc').first expect(log).to be_present @@ -171,7 +171,7 @@ describe Admin::UsersController do put(:suspend, params: suspend_params.merge(post_action: 'delete')) post.reload expect(post.deleted_at).to be_present - expect(response).to be_successful + expect(response.status).to eq(200) end it "can edit an associated post" do @@ -182,7 +182,7 @@ describe Admin::UsersController do post.reload expect(post.deleted_at).to be_blank expect(post.raw).to eq("this is the edited content") - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -205,7 +205,7 @@ describe Admin::UsersController do format: :json } ) - expect(response).to be_successful + expect(response.status).to eq(200) log = UserHistory.where(target_user_id: user.id).order('id desc').first expect(log).to be_present @@ -274,7 +274,7 @@ describe Admin::UsersController do group_id: group.id, user_id: user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) expect(GroupUser.where(user_id: user.id, group_id: group.id).exists?).to eq(true) group_history = GroupHistory.last @@ -288,7 +288,7 @@ describe Admin::UsersController do group_id: group.id, user_id: user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -378,7 +378,7 @@ describe Admin::UsersController do @another_user.reload expect(@another_user.trust_level).to eq(2) - expect(response).to be_successful + expect(response.status).to eq(200) end it "raises no error when demoting a user below their current trust level (locks trust level)" do @@ -394,7 +394,7 @@ describe Admin::UsersController do level: TrustLevel[0] }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) @another_user.reload expect(@another_user.trust_level).to eq(TrustLevel[0]) expect(@another_user.manual_locked_trust_level).to eq(TrustLevel[0]) @@ -474,7 +474,7 @@ describe Admin::UsersController do users: [reject_me.id, reject_me_too.id] }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['success'].to_i).to eq(2) expect(json['failed'].to_i).to eq(0) @@ -493,7 +493,7 @@ describe Admin::UsersController do users: [reject_me.id, reject_me_too.id] }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['success'].to_i).to eq(1) expect(json['failed'].to_i).to eq(1) @@ -506,7 +506,7 @@ describe Admin::UsersController do users: [reject_me.id] }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['success'].to_i).to eq(0) expect(json['failed'].to_i).to eq(1) @@ -538,7 +538,7 @@ describe Admin::UsersController do it "doesn't return an error if delete_posts == true" do delete :destroy, params: { id: delete_me.id, delete_posts: true }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -555,7 +555,7 @@ describe Admin::UsersController do it "returns success" do put :activate, params: { user_id: @reg_user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['success']).to eq("OK") end @@ -567,7 +567,7 @@ describe Admin::UsersController do expect(@reg_user.email_confirmed?).to eq(false) put :activate, params: { user_id: @reg_user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) @reg_user.reload expect(@reg_user.email_confirmed?).to eq(true) @@ -581,7 +581,7 @@ describe Admin::UsersController do it "returns success" do put :log_out, params: { user_id: @reg_user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['success']).to eq("OK") end @@ -612,7 +612,7 @@ describe Admin::UsersController do it "punishes the user for spamming" do put :silence, params: { user_id: @reg_user.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) @reg_user.reload expect(@reg_user).to be_silenced end @@ -626,7 +626,7 @@ describe Admin::UsersController do post_action: 'edit', post_edit: "this is the new contents for the post" }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) silence_post.reload expect(silence_post.raw).to eq("this is the new contents for the post") @@ -742,7 +742,7 @@ describe Admin::UsersController do name: 'Bill', username: 'bill22', email: 'bill@bill.com' }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) u = User.find_by_email('bill@bill.com') expect(u.name).to eq("Bill") @@ -758,7 +758,7 @@ describe Admin::UsersController do name: 'Bill', username: 'bill22', email: 'bill@bill.com', send_email: '0' }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["password_url"]).to be_present end @@ -806,7 +806,7 @@ describe Admin::UsersController do sso.email = "bob2@bob.com" post :sync_sso, params: Rack::Utils.parse_query(sso.payload), format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.email).to eq("bob2@bob.com") @@ -820,7 +820,7 @@ describe Admin::UsersController do sso.email = "dr@claw.com" sso.external_id = "2" post :sync_sso, params: Rack::Utils.parse_query(sso.payload), format: :json - expect(response).to be_successful + expect(response.status).to eq(200) user = User.find_by_email('dr@claw.com') expect(user).to be_present diff --git a/spec/controllers/admin/web_hooks_controller_spec.rb b/spec/controllers/admin/web_hooks_controller_spec.rb index 1d87cb43ce1..3cd84de6e9b 100644 --- a/spec/controllers/admin/web_hooks_controller_spec.rb +++ b/spec/controllers/admin/web_hooks_controller_spec.rb @@ -28,7 +28,7 @@ describe Admin::WebHooksController do } }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["web_hook"]["payload_url"]).to be_present @@ -62,7 +62,7 @@ describe Admin::WebHooksController do post :ping, params: { id: web_hook.id }, format: :json - expect(response).to be_successful + expect(response.status).to eq(200) end end end diff --git a/spec/requests/about_controller_spec.rb b/spec/requests/about_controller_spec.rb index ec4e07d4bc9..cf7ab39d5eb 100644 --- a/spec/requests/about_controller_spec.rb +++ b/spec/requests/about_controller_spec.rb @@ -8,7 +8,7 @@ describe AboutController do SiteSetting.login_required = false get "/about" - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should redirect to login page for anonymous user when login_required is true' do @@ -23,7 +23,7 @@ describe AboutController do sign_in(Fabricate(:user)) get "/about" - expect(response).to be_successful + expect(response.status).to eq(200) end end end diff --git a/spec/requests/admin/backups_controller_spec.rb b/spec/requests/admin/backups_controller_spec.rb index d4be1f1674a..e83e149c590 100644 --- a/spec/requests/admin/backups_controller_spec.rb +++ b/spec/requests/admin/backups_controller_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Admin::BackupsController do post "/admin/backups/rollback.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should not allow rollback via a GET request' do @@ -36,7 +36,7 @@ RSpec.describe Admin::BackupsController do delete "/admin/backups/cancel.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should not allow cancel via a GET request' do @@ -59,7 +59,7 @@ RSpec.describe Admin::BackupsController do put "/admin/backups/#{backup_filename}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "returns 404 when the backup does not exist" do diff --git a/spec/requests/admin/email_templates_controller_spec.rb b/spec/requests/admin/email_templates_controller_spec.rb index 8957a567172..b37a5e65a23 100644 --- a/spec/requests/admin/email_templates_controller_spec.rb +++ b/spec/requests/admin/email_templates_controller_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Admin::EmailTemplatesController do sign_in(admin) get '/admin/customize/email_templates.json' - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['email_templates']).to be_present @@ -169,7 +169,7 @@ RSpec.describe Admin::EmailTemplatesController do email_template: { subject: email_subject, body: email_body } }, headers: headers - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -265,7 +265,7 @@ RSpec.describe Admin::EmailTemplatesController do it "returns the restored email template" do delete '/admin/customize/email_templates/user_notifications.admin_login', headers: headers - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present diff --git a/spec/requests/admin/flagged_topics_controller_spec.rb b/spec/requests/admin/flagged_topics_controller_spec.rb index 87dfde84e38..3d27ac33af6 100644 --- a/spec/requests/admin/flagged_topics_controller_spec.rb +++ b/spec/requests/admin/flagged_topics_controller_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Admin::FlaggedTopicsController do shared_examples "successfully retrieve list of flagged topics" do it "returns a list of flagged topics" do get "/admin/flagged_topics.json" - expect(response).to be_successful + expect(response.status).to eq(200) data = ::JSON.parse(response.body) expect(data['flagged_topics']).to be_present diff --git a/spec/requests/admin/flags_controller_spec.rb b/spec/requests/admin/flags_controller_spec.rb index 1d711d590ba..c8ebc0ea779 100644 --- a/spec/requests/admin/flags_controller_spec.rb +++ b/spec/requests/admin/flags_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Admin::FlagsController do it 'should return the right response when nothing is flagged' do get '/admin/flags.json' - expect(response).to be_successful + expect(response.status).to eq(200) data = ::JSON.parse(response.body) expect(data["users"]).to eq([]) @@ -25,7 +25,7 @@ RSpec.describe Admin::FlagsController do get '/admin/flags.json' - expect(response).to be_successful + expect(response.status).to eq(200) data = ::JSON.parse(response.body) expect(data["users"].length).to eq(2) diff --git a/spec/requests/admin/moderation_history_controller_spec.rb b/spec/requests/admin/moderation_history_controller_spec.rb index 1b73f386688..b35989ad307 100644 --- a/spec/requests/admin/moderation_history_controller_spec.rb +++ b/spec/requests/admin/moderation_history_controller_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Admin::BackupsController do describe "for a post" do it "returns an empty array when the post doesn't exist" do get "/admin/moderation_history.json?filter=post&post_id=99999999" - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['moderation_history']).to be_blank end @@ -31,7 +31,7 @@ RSpec.describe Admin::BackupsController do p = Fabricate(:post, topic: p.topic) PostDestroyer.new(Discourse.system_user, p).destroy get "/admin/moderation_history.json?filter=post&post_id=#{p.id}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['moderation_history']).to be_present end @@ -40,7 +40,7 @@ RSpec.describe Admin::BackupsController do describe "for a topic" do it "returns empty history when the topic doesn't exist" do get "/admin/moderation_history.json?filter=topic&topic_id=1234" - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['moderation_history']).to be_blank end @@ -48,7 +48,7 @@ RSpec.describe Admin::BackupsController do p = Fabricate(:post) PostDestroyer.new(Discourse.system_user, p).destroy get "/admin/moderation_history.json?filter=topic&topic_id=#{p.topic_id}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['moderation_history']).to be_present end end diff --git a/spec/requests/admin/search_logs_spec.rb b/spec/requests/admin/search_logs_spec.rb index f872fb87001..b234ea2abff 100644 --- a/spec/requests/admin/search_logs_spec.rb +++ b/spec/requests/admin/search_logs_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Admin::SearchLogsController do sign_in(admin) get '/admin/logs/search_logs.json' - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json[0]['term']).to eq('ruby') @@ -51,7 +51,7 @@ RSpec.describe Admin::SearchLogsController do sign_in(admin) get '/admin/logs/search_logs/term/ruby.json' - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['term']['type']).to eq('search_log_term') diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb index be6039564bf..e3a76cacbf8 100644 --- a/spec/requests/categories_controller_spec.rb +++ b/spec/requests/categories_controller_spec.rb @@ -136,7 +136,7 @@ describe CategoriesController do expect do delete "/categories/#{category.slug}.json" end.to change(Category, :count).by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) expect(UserHistory.count).to eq(1) end end @@ -321,14 +321,14 @@ describe CategoriesController do it 'accepts valid custom slug' do put "/category/#{category.id}/slug.json", params: { slug: 'valid-slug' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(category.reload.slug).to eq('valid-slug') end it 'accepts not well formed custom slug' do put "/category/#{category.id}/slug.json", params: { slug: ' valid slug' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(category.reload.slug).to eq('valid-slug') end @@ -336,7 +336,7 @@ describe CategoriesController do SiteSetting.slug_generation_method = 'none' put "/category/#{category.id}/slug.json", params: { slug: ' another !_ slug @' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(category.reload.slug).to eq('another-slug') SiteSetting.slug_generation_method = 'ascii' end diff --git a/spec/requests/directory_items_controller_spec.rb b/spec/requests/directory_items_controller_spec.rb index f9b0e08b888..8a188db1071 100644 --- a/spec/requests/directory_items_controller_spec.rb +++ b/spec/requests/directory_items_controller_spec.rb @@ -24,7 +24,7 @@ describe DirectoryItemsController do it "succeeds" do get '/directory_items.json', params: { period: 'all' } - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -37,7 +37,7 @@ describe DirectoryItemsController do it "succeeds with a valid value" do get '/directory_items.json', params: { period: 'all' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -58,7 +58,7 @@ describe DirectoryItemsController do it "finds user by name" do get '/directory_items.json', params: { period: 'all', name: 'eviltrout' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -69,7 +69,7 @@ describe DirectoryItemsController do it "finds staged user by name" do get '/directory_items.json', params: { period: 'all', name: 'stage_user' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -80,7 +80,7 @@ describe DirectoryItemsController do it "excludes users by username" do get '/directory_items.json', params: { period: 'all', exclude_usernames: "stage_user,eviltrout" } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -92,7 +92,7 @@ describe DirectoryItemsController do it "filters users by group" do get '/directory_items.json', params: { period: 'all', group: group.name } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present diff --git a/spec/requests/email_controller_spec.rb b/spec/requests/email_controller_spec.rb index 062c24461a0..3b6a1a8f308 100644 --- a/spec/requests/email_controller_spec.rb +++ b/spec/requests/email_controller_spec.rb @@ -145,7 +145,7 @@ RSpec.describe EmailController do key = SecureRandom.hex $redis.set(key, user.email) get '/email/unsubscribed', params: { key: key, topic_id: topic.id } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(topic.title) end end @@ -155,7 +155,7 @@ RSpec.describe EmailController do key = SecureRandom.hex $redis.set(key, user.email) get '/email/unsubscribed', params: { key: key, topic_id: private_topic.id } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to_not include(private_topic.title) end end diff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rb index c62222a8cc7..f6cb42e88cf 100644 --- a/spec/requests/embed_controller_spec.rb +++ b/spec/requests/embed_controller_spec.rb @@ -27,7 +27,7 @@ describe EmbedController do it "allows a topic to be embedded by id" do topic = Fabricate(:topic) get '/embed/comments', params: { topic_id: topic.id }, headers: headers - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -85,7 +85,7 @@ describe EmbedController do end after do - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.headers['X-Frame-Options']).to eq("ALLOWALL") end @@ -139,7 +139,7 @@ describe EmbedController do params: { embed_url: embed_url }, headers: { 'REFERER' => "http://eviltrout.com/wat/1-2-3.html" } - expect(response).to be_successful + expect(response.status).to eq(200) end it "works with the second host" do @@ -147,7 +147,7 @@ describe EmbedController do params: { embed_url: embed_url }, headers: { 'REFERER' => "http://eviltrout.com/wat/1-2-3.html" } - expect(response).to be_successful + expect(response.status).to eq(200) end it "works with a host with a path" do @@ -155,7 +155,7 @@ describe EmbedController do params: { embed_url: embed_url }, headers: { 'REFERER' => "https://example.com/some-other-path" } - expect(response).to be_successful + expect(response.status).to eq(200) end it "contains custom class name" do diff --git a/spec/requests/export_csv_controller_spec.rb b/spec/requests/export_csv_controller_spec.rb index cc84bd0403a..1fe2a15e7c5 100644 --- a/spec/requests/export_csv_controller_spec.rb +++ b/spec/requests/export_csv_controller_spec.rb @@ -10,7 +10,7 @@ describe ExportCsvController do describe ".export_entity" do it "enqueues export job" do post "/export_csv/export_entity.json", params: { entity: "user_archive" } - expect(response).to be_success + expect(response.status).to eq(200) expect(Jobs::ExportCsvFile.jobs.size).to eq(1) job_data = Jobs::ExportCsvFile.jobs.first["args"].first @@ -40,7 +40,7 @@ describe ExportCsvController do describe ".export_entity" do it "enqueues export job" do post "/export_csv/export_entity.json", params: { entity: "staff_action" } - expect(response).to be_success + expect(response.status).to eq(200) expect(Jobs::ExportCsvFile.jobs.size).to eq(1) job_data = Jobs::ExportCsvFile.jobs.first["args"].first @@ -51,7 +51,7 @@ describe ExportCsvController do it "should not rate limit export for staff" do UserExport.create(file_name: "screened-email-150116-010145", user_id: admin.id) post "/export_csv/export_entity.json", params: { entity: "staff_action" } - expect(response).to be_success + expect(response.status).to eq(200) expect(Jobs::ExportCsvFile.jobs.size).to eq(1) job_data = Jobs::ExportCsvFile.jobs.first["args"].first diff --git a/spec/requests/extra_locales_controller_spec.rb b/spec/requests/extra_locales_controller_spec.rb index 3093d9f38fe..a190489f4f5 100644 --- a/spec/requests/extra_locales_controller_spec.rb +++ b/spec/requests/extra_locales_controller_spec.rb @@ -42,7 +42,7 @@ describe ExtraLocalesController do get "/extra-locales/admin" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body.include?("github_badges")).to eq(true) end end diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index 7e2b69fc776..cae3ae4c7f1 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -152,7 +152,7 @@ describe GroupsController do staff_group get "/groups.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) @@ -382,7 +382,7 @@ describe GroupsController do sign_in(user) get "/groups/#{group.name}/mentionable.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) expect(response_body["mentionable"]).to eq(false) @@ -393,7 +393,7 @@ describe GroupsController do ) get "/groups/#{group.name}/mentionable.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) expect(response_body["mentionable"]).to eq(true) @@ -405,7 +405,7 @@ describe GroupsController do sign_in(user) get "/groups/#{group.name}/messageable.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) expect(response_body["messageable"]).to eq(false) @@ -416,7 +416,7 @@ describe GroupsController do ) get "/groups/#{group.name}/messageable.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) expect(response_body["messageable"]).to eq(true) @@ -645,7 +645,7 @@ describe GroupsController do order: 'last_seen_at', desc: true } - expect(response).to be_successful + expect(response.status).to eq(200) members = JSON.parse(response.body)["members"] @@ -653,7 +653,7 @@ describe GroupsController do get "/groups/#{group.name}/members.json", params: { order: 'last_seen_at' } - expect(response).to be_successful + expect(response.status).to eq(200) members = JSON.parse(response.body)["members"] @@ -663,7 +663,7 @@ describe GroupsController do order: 'last_posted_at', desc: true } - expect(response).to be_successful + expect(response.status).to eq(200) members = JSON.parse(response.body)["members"] @@ -673,7 +673,7 @@ describe GroupsController do it "should not allow members to be sorted by columns that are not allowed" do get "/groups/#{group.name}/members.json", params: { order: 'email' } - expect(response).to be_successful + expect(response.status).to eq(200) members = JSON.parse(response.body)["members"] @@ -808,7 +808,7 @@ describe GroupsController do put "/groups/#{group.id}/members.json", params: { usernames: user2.username } end.to change { group.users.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) group_history = GroupHistory.last @@ -834,7 +834,7 @@ describe GroupsController do params: { usernames: [user1.username, user2.username].join(",") } end.to change { group.users.count }.by(2) - expect(response).to be_successful + expect(response.status).to eq(200) end it "adds by id" do @@ -843,7 +843,7 @@ describe GroupsController do params: { user_ids: [user1.id, user2.id].join(",") } end.to change { group.users.count }.by(2) - expect(response).to be_successful + expect(response.status).to eq(200) end it "adds by email" do @@ -852,7 +852,7 @@ describe GroupsController do params: { user_emails: [user1.email, user2.email].join(",") } end.to change { group.users.count }.by(2) - expect(response).to be_successful + expect(response.status).to eq(200) end it 'fails when multiple member already exists' do @@ -920,7 +920,7 @@ describe GroupsController do params: { usernames: other_user.username } end.to change { group.users.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) group_history = GroupHistory.last @@ -938,7 +938,7 @@ describe GroupsController do params: { usernames: other_user.username } end.to change { group.users.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should not allow an underprivilege user to add another user to a group' do @@ -971,7 +971,7 @@ describe GroupsController do delete "/groups/#{group.id}/members.json", params: { user_id: user.id } end.to change { group.users.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end it "removes by username" do @@ -979,7 +979,7 @@ describe GroupsController do delete "/groups/#{group.id}/members.json", params: { username: user.username } end.to change { group.users.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end it "removes user.primary_group_id when user is removed from group" do @@ -996,7 +996,7 @@ describe GroupsController do params: { user_email: user.email } end.to change { group.users.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end context 'public group' do @@ -1010,7 +1010,7 @@ describe GroupsController do params: { username: other_user.username } end.to change { group.users.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -1022,7 +1022,7 @@ describe GroupsController do params: { username: other_user.username } end.to change { group.users.count }.by(-1) - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should not allow a underprivilege user to leave a group for another user' do @@ -1077,7 +1077,7 @@ describe GroupsController do it 'should allow group owner to view history' do get "/groups/#{group.name}/logs.json" - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body)["logs"].last @@ -1109,7 +1109,7 @@ describe GroupsController do get "/groups/#{group.name}/logs.json" - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body)["logs"].first @@ -1132,7 +1132,7 @@ describe GroupsController do filters: { "action" => "add_user_to_group" } } - expect(response).to be_successful + expect(response.status).to eq(200) logs = JSON.parse(response.body)["logs"] @@ -1167,7 +1167,7 @@ describe GroupsController do post "/groups/#{group.name}/request_membership.json", params: { reason: 'Please add me in' } - expect(response).to be_successful + expect(response.status).to eq(200) post = Post.last topic = post.topic @@ -1217,7 +1217,7 @@ describe GroupsController do get '/groups/search.json' - expect(response).to be_successful + expect(response.status).to eq(200) groups = JSON.parse(response.body) expected_ids = Group::AUTO_GROUPS.map { |name, id| id } @@ -1229,7 +1229,7 @@ describe GroupsController do ['GO', 'nerys'].each do |term| get "/groups/search.json?term=#{term}" - expect(response).to be_successful + expect(response.status).to eq(200) groups = JSON.parse(response.body) expect(groups.length).to eq(1) @@ -1238,7 +1238,7 @@ describe GroupsController do get "/groups/search.json?term=KingOfTheNorth" - expect(response).to be_successful + expect(response.status).to eq(200) groups = JSON.parse(response.body) expect(groups).to eq([]) @@ -1255,7 +1255,7 @@ describe GroupsController do get "/groups/search.json?term=north" - expect(response).to be_successful + expect(response.status).to eq(200) groups = JSON.parse(response.body) expect(groups.length).to eq(1) @@ -1269,7 +1269,7 @@ describe GroupsController do get '/groups/search.json?ignore_automatic=true' - expect(response).to be_successful + expect(response.status).to eq(200) groups = JSON.parse(response.body) expect(groups.length).to eq(2) diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb index b945453b712..4b4586ce134 100644 --- a/spec/requests/invites_controller_spec.rb +++ b/spec/requests/invites_controller_spec.rb @@ -8,7 +8,7 @@ describe InvitesController do it "returns error if invite not found" do get "/invites/nopeNOPEnope" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body expect(body).to_not have_tag(:script, with: { src: '/assets/application.js' }) @@ -18,7 +18,7 @@ describe InvitesController do it "renders the accept invite page if invite exists" do get "/invites/#{invite.invite_key}" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body expect(body).to have_tag(:script, with: { src: '/assets/application.js' }) @@ -29,7 +29,7 @@ describe InvitesController do invite.update_attributes!(redeemed_at: 1.day.ago) get "/invites/#{invite.invite_key}" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body expect(body).to_not have_tag(:script, with: { src: '/assets/application.js' }) @@ -100,7 +100,7 @@ describe InvitesController do group = Fabricate(:group) sign_in(Fabricate(:admin)) post "/invites.json", params: { email: email, group_names: group.name } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Invite.find_by(email: email).invited_groups.count).to eq(1) end @@ -112,7 +112,7 @@ describe InvitesController do post "/invites.json", params: { email: email, group_names: group.name } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Invite.find_by(email: email).invited_groups.count).to eq(1) end @@ -120,7 +120,7 @@ describe InvitesController do user = sign_in(Fabricate(:admin)) invite = Invite.invite_by_email("invite@example.com", user) post "/invites.json", params: { email: invite.email } - expect(response).to be_successful + expect(response.status).to eq(200) end it "responds with error message in case of validation failure" do @@ -182,7 +182,7 @@ describe InvitesController do email: email, group_names: group.name } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Invite.find_by(email: email).invited_groups.count).to eq(1) end @@ -195,7 +195,7 @@ describe InvitesController do email: email, group_names: "security,support" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Invite.find_by(email: email).invited_groups.count).to eq(2) end end @@ -205,7 +205,7 @@ describe InvitesController do context 'with an invalid invite id' do it "redirects to the root and doesn't change the session" do put "/invites/show/doesntexist.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["success"]).to eq(false) expect(json["message"]).to eq(I18n.t('invite.not_found')) @@ -223,7 +223,7 @@ describe InvitesController do it "redirects to the root" do put "/invites/show/#{invite.invite_key}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["success"]).to eq(false) expect(json["message"]).to eq(I18n.t('invite.not_found')) @@ -254,7 +254,7 @@ describe InvitesController do :user_logged_in, :user_first_logged_in ) invite.reload - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(invite.user_id) expect(invite.redeemed?).to be_truthy end @@ -271,7 +271,7 @@ describe InvitesController do context 'failure' do it "doesn't log in the user if there's a validation error" do put "/invites/show/#{invite.invite_key}.json", params: { password: "password" } - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["success"]).to eq(false) expect(json["errors"]["password"]).to be_present @@ -286,13 +286,13 @@ describe InvitesController do it 'sends a welcome message if set' do user.send_welcome_message = true put "/invites/show/#{invite.invite_key}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::SendSystemMessage.jobs.size).to eq(1) end it "sends password reset email if password is not set" do put "/invites/show/#{invite.invite_key}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(1) end @@ -300,20 +300,20 @@ describe InvitesController do SiteSetting.sso_url = "https://www.example.com/sso" SiteSetting.enable_sso = true put "/invites/show/#{invite.invite_key}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0) end it "does not send password reset email if local login is disabled" do SiteSetting.enable_local_logins = false put "/invites/show/#{invite.invite_key}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0) end it 'sends an activation email if password is set' do put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::InvitePasswordInstructionsEmail.jobs.size).to eq(0) expect(Jobs::CriticalUserEmail.jobs.size).to eq(1) end @@ -381,7 +381,7 @@ describe InvitesController do it "resends the invite" do SiteSetting.queue_jobs = true post "/invites/reinvite.json", params: { email: invite.email } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::InviteEmail.jobs.size).to eq(1) end end @@ -412,7 +412,7 @@ describe InvitesController do SiteSetting.queue_jobs = true sign_in(Fabricate(:admin)) post "/invites/upload_csv.json", params: { file: file, name: filename } - expect(response).to be_successful + expect(response.status).to eq(200) expect(Jobs::BulkInvite.jobs.size).to eq(1) end end diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb index f7bb4286cfc..0f72cedfa03 100644 --- a/spec/requests/list_controller_spec.rb +++ b/spec/requests/list_controller_spec.rb @@ -13,19 +13,19 @@ RSpec.describe ListController do describe '#index' do it "doesn't throw an error with a negative page" do get "/#{Discourse.anonymous_filters[1]}", params: { page: -1024 } - expect(response).to be_successful + expect(response.status).to eq(200) end it "doesn't throw an error with page params as an array" do get "/#{Discourse.anonymous_filters[1]}", params: { page: ['7'] } - expect(response).to be_successful + expect(response.status).to eq(200) end (Discourse.anonymous_filters - [:categories]).each do |filter| context "#{filter}" do it "succeeds" do get "/#{filter}" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -34,7 +34,7 @@ RSpec.describe ListController do p = create_post get "/latest.json", params: { topic_ids: "#{p.topic_id}" } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = JSON.parse(response.body) expect(parsed["topic_list"]["topics"].length).to eq(1) end @@ -238,20 +238,20 @@ RSpec.describe ListController do describe 'RSS feeds' do it 'renders latest RSS' do get "/latest.rss" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end it 'renders top RSS' do get "/top.rss" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end TopTopic.periods.each do |period| it "renders #{period} top RSS" do get "/top/#{period}.rss" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end end @@ -312,7 +312,7 @@ RSpec.describe ListController do it 'uses the correct category' do get "/c/#{other_category.slug}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) body = JSON.parse(response.body) expect(body["topic_list"]["topics"].first["category_id"]) .to eq(other_category.id) @@ -340,7 +340,7 @@ RSpec.describe ListController do describe 'feed' do it 'renders RSS' do get "/c/#{category.slug}.rss" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end end @@ -349,7 +349,7 @@ RSpec.describe ListController do it "has a top default view" do category.update_attributes!(default_view: 'top', default_top_period: 'monthly') get "/c/#{category.slug}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["for_period"]).to eq("monthly") end @@ -357,7 +357,7 @@ RSpec.describe ListController do it "has a default view of nil" do category.update_attributes!(default_view: nil) get "/c/#{category.slug}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["for_period"]).to be_blank end @@ -365,7 +365,7 @@ RSpec.describe ListController do it "has a default view of ''" do category.update_attributes!(default_view: '') get "/c/#{category.slug}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["for_period"]).to be_blank end @@ -373,7 +373,7 @@ RSpec.describe ListController do it "has a default view of latest" do category.update_attributes!(default_view: 'latest') get "/c/#{category.slug}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["for_period"]).to be_blank end @@ -382,13 +382,13 @@ RSpec.describe ListController do describe "renders canonical tag" do it 'for category default view' do get "/c/#{category.slug}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(css_select("link[rel=canonical]").length).to eq(1) end it 'for category latest view' do get "/c/#{category.slug}/l/latest" - expect(response).to be_successful + expect(response.status).to eq(200) expect(css_select("link[rel=canonical]").length).to eq(1) end end @@ -403,7 +403,7 @@ RSpec.describe ListController do it "should respond with a list" do get "/topics/created-by/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["topics"].size).to eq(1) end @@ -421,7 +421,7 @@ RSpec.describe ListController do pm.topic_allowed_users.create!(user: user) sign_in(user) get "/topics/private-messages/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["topics"].size).to eq(1) end @@ -442,7 +442,7 @@ RSpec.describe ListController do it "succeeds when the user can see private messages" do sign_in(user) get "/topics/private-messages-sent/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["topics"].size).to eq(1) end @@ -465,7 +465,7 @@ RSpec.describe ListController do it "succeeds when the user can see private messages" do sign_in(user) get "/topics/private-messages-unread/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["topic_list"]["topics"].size).to eq(1) end @@ -481,7 +481,7 @@ RSpec.describe ListController do it "succeeds" do sign_in(user) get "/read" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -546,7 +546,7 @@ RSpec.describe ListController do it "suppresses categories from the latest list" do get "/#{SiteSetting.homepage}.json" - expect(response).to be_successful + expect(response.status).to eq(200) topic_titles = JSON.parse(response.body)["topic_list"]["topics"].map { |t| t["title"] } expect(topic_titles).not_to include(topic_in_sub_category.title, topic_in_category_two.title) @@ -554,7 +554,7 @@ RSpec.describe ListController do it "does not suppress" do get "/#{SiteSetting.homepage}.json", params: { category: category_one.id } - expect(response).to be_successful + expect(response.status).to eq(200) topic_titles = JSON.parse(response.body)["topic_list"]["topics"].map { |t| t["title"] } expect(topic_titles).to include(topic_in_sub_category.title) diff --git a/spec/requests/notifications_controller_spec.rb b/spec/requests/notifications_controller_spec.rb index f7dede2aa5c..e22721f82b5 100644 --- a/spec/requests/notifications_controller_spec.rb +++ b/spec/requests/notifications_controller_spec.rb @@ -36,12 +36,12 @@ describe NotificationsController do describe '#index' do it 'should succeed for recent' do get "/notifications", params: { recent: true } - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should succeed for history' do get "/notifications" - expect(response).to be_successful + expect(response.status).to eq(200) end it 'should mark notifications as viewed' do @@ -72,14 +72,14 @@ describe NotificationsController do it 'should succeed' do put "/notifications/mark-read.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "can update a single notification" do notification = Fabricate(:notification, user: user) notification2 = Fabricate(:notification, user: user) put "/notifications/mark-read.json", params: { id: notification.id } - expect(response).to be_successful + expect(response.status).to eq(200) notification.reload notification2.reload diff --git a/spec/requests/omniauth_callbacks_controller_spec.rb b/spec/requests/omniauth_callbacks_controller_spec.rb index a7316c76517..c4deba0b83e 100644 --- a/spec/requests/omniauth_callbacks_controller_spec.rb +++ b/spec/requests/omniauth_callbacks_controller_spec.rb @@ -80,7 +80,7 @@ RSpec.describe Users::OmniauthCallbacksController do expect(events.map { |event| event[:event_name] }).to include(:user_logged_in, :user_first_logged_in) - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) @@ -106,7 +106,7 @@ RSpec.describe Users::OmniauthCallbacksController do expect(events.map { |event| event[:event_name] }).to include(:user_logged_in, :user_first_logged_in) - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.email_confirmed?).to eq(true) @@ -125,7 +125,7 @@ RSpec.describe Users::OmniauthCallbacksController do expect(events.map { |event| event[:event_name] }).to include(:user_logged_in, :user_first_logged_in) - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.staged).to eq(false) @@ -185,7 +185,7 @@ RSpec.describe Users::OmniauthCallbacksController do it 'should return the right response' do get "/auth/google_oauth2/callback.json" - expect(response).to be_successful + expect(response.status).to eq(200) response_body = JSON.parse(response.body) diff --git a/spec/requests/onebox_controller_spec.rb b/spec/requests/onebox_controller_spec.rb index 04d9da91fc1..21728df3e75 100644 --- a/spec/requests/onebox_controller_spec.rb +++ b/spec/requests/onebox_controller_spec.rb @@ -56,13 +56,13 @@ describe OneboxController do bypass_limiting Rails.cache.delete("onebox__#{url}") get "/onebox.json", params: { url: url } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include("Onebox1") bypass_limiting stub_request(:get, url).to_return(status: 200, body: html2).then.to_raise get "/onebox.json", params: { url: url, refresh: 'true' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include("Onebox2") end @@ -75,12 +75,12 @@ describe OneboxController do get "/onebox.json", params: { url: url, refresh: "true" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include('Onebox1') expect(response.body).to include('bodycontent') get "/onebox.json", params: { url: url } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include('Onebox1') expect(response.body).to include('bodycontent') end @@ -104,7 +104,7 @@ describe OneboxController do stub_request(:get, url).to_return(body: html).then.to_raise get "/onebox.json", params: { url: url, refresh: "true" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include("Onebox1") end end diff --git a/spec/requests/post_action_users_controller_spec.rb b/spec/requests/post_action_users_controller_spec.rb index 04d40eb866c..1fdf4bb529a 100644 --- a/spec/requests/post_action_users_controller_spec.rb +++ b/spec/requests/post_action_users_controller_spec.rb @@ -53,7 +53,7 @@ describe PostActionUsersController do id: post.id, post_action_type_id: PostActionType.types[:like] } - expect(response).to be_successful + expect(response.status).to eq(200) end it "paginates post actions" do diff --git a/spec/requests/post_actions_controller_spec.rb b/spec/requests/post_actions_controller_spec.rb index f3e8a385576..6be7be749ff 100644 --- a/spec/requests/post_actions_controller_spec.rb +++ b/spec/requests/post_actions_controller_spec.rb @@ -37,7 +37,7 @@ RSpec.describe PostActionsController do it 'returns success' do delete "/post_actions/#{post.id}.json", params: { post_action_type_id: PostActionType.types[:bookmark] } - expect(response).to be_success + expect(response.status).to eq(200) end it 'deletes the action' do @@ -45,7 +45,7 @@ RSpec.describe PostActionsController do post_action_type_id: PostActionType.types[:bookmark] } - expect(response).to be_success + expect(response.status).to eq(200) expect(PostAction.exists?( user_id: user.id, post_id: post.id, @@ -137,7 +137,7 @@ RSpec.describe PostActionsController do post_action = PostAction.last - expect(response).to be_success + expect(response.status).to eq(200) expect(post_action.post_id).to eq(post_1.id) expect(post_action.post_action_type_id).to eq(PostActionType.types[:like]) end @@ -165,7 +165,7 @@ RSpec.describe PostActionsController do message: message } - expect(response).to be_success + expect(response.status).to eq(200) expect(PostAction.last.post_id).to eq(post_1.id) expect(Post.last.raw).to include(message) end @@ -180,7 +180,7 @@ RSpec.describe PostActionsController do is_warning: true } - expect(response).to be_success + expect(response.status).to eq(200) expect(PostAction.last.post_id).to eq(post_1.id) post = Post.last @@ -209,7 +209,7 @@ RSpec.describe PostActionsController do take_action: 'true' } - expect(response).to be_successful + expect(response.status).to eq(200) post_action = PostAction.last @@ -225,7 +225,7 @@ RSpec.describe PostActionsController do post_action_type_id: PostActionType.types[:like] } - expect(response).to be_successful + expect(response.status).to eq(200) post_action = PostAction.last @@ -282,7 +282,7 @@ RSpec.describe PostActionsController do id: flagged_post.id, post_action_type_id: PostActionType.types[:spam] } - expect(response).to be_success + expect(response.status).to eq(200) flag.reload expect(flag.deferred_at).to be_present end @@ -294,7 +294,7 @@ RSpec.describe PostActionsController do id: flagged_post.id, post_action_type_id: PostActionType.types[:spam] } - expect(response).to be_success + expect(response.status).to eq(200) flag.reload expect(flag.deferred_at).to be_present end diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rb index 74d6c3ea35f..7f6620bd05a 100644 --- a/spec/requests/posts_controller_spec.rb +++ b/spec/requests/posts_controller_spec.rb @@ -14,7 +14,7 @@ shared_examples 'finding and showing post' do it 'succeeds' do get url - expect(response).to be_successful + expect(response.status).to eq(200) end context "deleted post" do @@ -36,13 +36,13 @@ shared_examples 'finding and showing post' do it "can find posts as a moderator" do sign_in(Fabricate(:moderator)) get url - expect(response).to be_successful + expect(response.status).to eq(200) end it "can find posts as a admin" do sign_in(Fabricate(:admin)) get url - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -277,7 +277,7 @@ describe PostsController do it 'passes the edit reason through' do put "/posts/#{post.id}.json", params: update_params - expect(response).to be_successful + expect(response.status).to eq(200) post.reload expect(post.edit_reason).to eq("typo") expect(post.raw).to eq("edited body") @@ -307,7 +307,7 @@ describe PostsController do put "/posts/#{post.id}.json", params: param - expect(response).to be_successful + expect(response.status).to eq(200) expect(TopicLink.count).to eq(1) end @@ -330,7 +330,7 @@ describe PostsController do PostDestroyer.new(moderator, first_post).destroy put "/posts/#{first_post.id}.json", params: update_params - expect(response).to be_successful + expect(response.status).to eq(200) post.reload expect(post.raw).to eq('edited body') @@ -373,7 +373,7 @@ describe PostsController do it 'creates a bookmark' do put "/posts/#{post.id}/bookmark.json", params: { bookmarked: "true" } - expect(response).to be_successful + expect(response.status).to eq(200) post_action = PostAction.find_by(user: user, post: post) expect(post_action.post_action_type_id).to eq(PostActionType.types[:bookmark]) @@ -435,7 +435,7 @@ describe PostsController do api_key: api_key.key } - expect(response).to be_successful + expect(response.status).to eq(200) expect(PostAction.where( post: post, user: user, @@ -460,7 +460,7 @@ describe PostsController do api_username: user.username } - expect(response).to be_successful + expect(response.status).to eq(200) expect(PostAction.where( post: post, user: user, @@ -587,7 +587,7 @@ describe PostsController do it "can rebake the post" do sign_in(Fabricate(:moderator)) put "/posts/#{post.id}/rebake.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -617,7 +617,7 @@ describe PostsController do wpid: 1 } - expect(response).to be_successful + expect(response.status).to eq(200) original = response.body post "/posts.json", params: { @@ -628,7 +628,7 @@ describe PostsController do wpid: 2 } - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to eq(original) end @@ -647,7 +647,7 @@ describe PostsController do reply_to_post_number: 1 } - expect(response).to be_successful + expect(response.status).to eq(200) expect(post_1.topic.user.notifications.count).to eq(1) post_1.topic.user.notifications.destroy_all @@ -660,7 +660,7 @@ describe PostsController do import_mode: true } - expect(response).to be_successful + expect(response.status).to eq(200) expect(post_1.topic.user.notifications.count).to eq(0) post "/posts.json", params: { @@ -672,7 +672,7 @@ describe PostsController do import_mode: false } - expect(response).to be_successful + expect(response.status).to eq(200) expect(post_1.topic.user.notifications.count).to eq(1) end end @@ -694,7 +694,7 @@ describe PostsController do title: 'this is the test title for the topic' } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = ::JSON.parse(response.body) expect(parsed["action"]).to eq("enqueued") @@ -747,7 +747,7 @@ describe PostsController do title: 'when I eat s3 sometimes when not looking' } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = ::JSON.parse(response.body) expect(parsed["action"]).to eq("enqueued") @@ -780,7 +780,7 @@ describe PostsController do archetype: Archetype.private_message } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = ::JSON.parse(response.body) post = Post.find(parsed['id']) @@ -796,7 +796,7 @@ describe PostsController do nested_post: true } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = ::JSON.parse(response.body) expect(parsed['post']).to be_present expect(parsed['post']['cooked']).to be_present @@ -807,7 +807,7 @@ describe PostsController do title = "this is a title #{SecureRandom.hash}" post "/posts.json", params: { raw: raw, title: title, wpid: 1 } - expect(response).to be_successful + expect(response.status).to eq(200) post "/posts.json", params: { raw: raw, title: title, wpid: 2 } expect(response).not_to be_successful @@ -835,7 +835,7 @@ describe PostsController do meta_data: { xyz: 'abc' } } - expect(response).to be_successful + expect(response.status).to eq(200) new_post = Post.last topic = new_post.topic @@ -858,7 +858,7 @@ describe PostsController do image_sizes: { width: '100', height: '200' } } - expect(response).to be_successful + expect(response.status).to eq(200) new_post = Post.last topic = new_post.topic @@ -883,7 +883,7 @@ describe PostsController do target_usernames: "#{user_2.username},#{user_3.username}" } - expect(response).to be_successful + expect(response.status).to eq(200) new_post = Post.last new_topic = Topic.last @@ -956,7 +956,7 @@ describe PostsController do category: destination_category.id, shared_draft: 'true' } - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) topic = Topic.find(result['topic_id']) expect(topic.category_id).to eq(shared_category.id) @@ -983,7 +983,7 @@ describe PostsController do is_warning: true } - expect(response).to be_successful + expect(response.status).to eq(200) new_topic = Topic.last @@ -1000,7 +1000,7 @@ describe PostsController do is_warning: false } - expect(response).to be_successful + expect(response.status).to eq(200) new_topic = Topic.last @@ -1020,7 +1020,7 @@ describe PostsController do is_warning: true } - expect(response).to be_successful + expect(response.status).to eq(200) new_topic = Topic.last @@ -1058,7 +1058,7 @@ describe PostsController do it "ensures staff can see the revisions" do sign_in(Fabricate(:admin)) get "/posts/#{post.id}/revisions/#{post_revision.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "ensures poster can see the revisions" do @@ -1069,13 +1069,13 @@ describe PostsController do pr = Fabricate(:post_revision, user: user, post: post) get "/posts/#{pr.post_id}/revisions/#{pr.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "ensures trust level 4 can see the revisions" do sign_in(Fabricate(:user, trust_level: 4)) get "/posts/#{post_revision.post_id}/revisions/#{post_revision.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -1085,7 +1085,7 @@ describe PostsController do it "ensures anyone can see the revisions" do get "/posts/#{post_revision.post_id}/revisions/#{post_revision.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -1099,7 +1099,7 @@ describe PostsController do it "also work on deleted post" do sign_in(admin) get "/posts/#{deleted_post_revision.post_id}/revisions/#{deleted_post_revision.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -1114,7 +1114,7 @@ describe PostsController do it "also work on deleted topic" do sign_in(admin) get "/posts/#{post_revision.post_id}/revisions/#{post_revision.number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -1173,7 +1173,7 @@ describe PostsController do it "works!" do put "/posts/#{post_id}/revisions/#{revision_id}/revert.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "supports reverting posts in deleted topics" do @@ -1181,7 +1181,7 @@ describe PostsController do PostDestroyer.new(moderator, first_post).destroy put "/posts/#{post_id}/revisions/#{revision_id}/revert.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -1202,7 +1202,7 @@ describe PostsController do it "retrieves the body when you can see the post" do TopicEmbed.expects(:expanded_for).with(post).returns("full content") get "/posts/#{post.id}/expand-embed.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['cooked']).to eq("full content") end end @@ -1220,7 +1220,7 @@ describe PostsController do it "can see the flagged posts when authorized" do sign_in(Fabricate(:moderator)) get "/posts/system/flagged.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "only shows agreed and deferred flags" do @@ -1241,7 +1241,7 @@ describe PostsController do sign_in(Fabricate(:moderator)) get "/posts/#{user.username}/flagged.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body).length).to eq(2) end @@ -1261,7 +1261,7 @@ describe PostsController do it "can see the deleted posts when authorized" do sign_in(Fabricate(:moderator)) get "/posts/system/deleted.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "doesn't return secured categories for moderators if they don't have access" do @@ -1278,7 +1278,7 @@ describe PostsController do sign_in(Fabricate(:moderator)) get "/posts/#{user.username}/deleted.json" - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data.length).to eq(0) @@ -1294,7 +1294,7 @@ describe PostsController do sign_in(Fabricate(:moderator)) get "/posts/#{user.username}/deleted.json" - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data.length).to eq(0) @@ -1313,7 +1313,7 @@ describe PostsController do sign_in(Fabricate(:admin)) get "/posts/#{user.username}/deleted.json" - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data.length).to eq(1) @@ -1327,7 +1327,7 @@ describe PostsController do it "can be viewed by anonymous" do post = Fabricate(:post, raw: "123456789") get "/posts/#{post.id}/raw.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to eq("123456789") end end @@ -1338,7 +1338,7 @@ describe PostsController do post = Fabricate(:post, topic: topic, post_number: 1, raw: "123456789") post.save get "/raw/#{topic.id}/1.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to eq("123456789") end end @@ -1366,7 +1366,7 @@ describe PostsController do get "/u/#{user.username}/activity.rss" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body @@ -1384,7 +1384,7 @@ describe PostsController do private_post get "/private-posts.rss" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body @@ -1398,7 +1398,7 @@ describe PostsController do public_post private_post get "/private-posts.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) post_ids = json['private_posts'].map { |p| p['id'] } @@ -1415,7 +1415,7 @@ describe PostsController do get "/posts.rss" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body @@ -1431,7 +1431,7 @@ describe PostsController do topicless_post get "/posts.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) post_ids = json['latest_posts'].map { |p| p['id'] } @@ -1448,7 +1448,7 @@ describe PostsController do post = Fabricate(:post, cooked: "WAt") get "/posts/#{post.id}/cooked.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json).to be_present @@ -1473,7 +1473,7 @@ describe PostsController do sign_in(Fabricate(:moderator)) get "/posts/#{post.id}/raw-email.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['raw_email']).to eq('email_content') @@ -1488,12 +1488,12 @@ describe PostsController do it 'can lock and unlock the post' do put "/posts/#{public_post.id}/locked.json", params: { locked: "true" } - expect(response).to be_successful + expect(response.status).to eq(200) public_post.reload expect(public_post).to be_locked put "/posts/#{public_post.id}/locked.json", params: { locked: "false" } - expect(response).to be_successful + expect(response.status).to eq(200) public_post.reload expect(public_post).not_to be_locked end diff --git a/spec/requests/queued_posts_controller_spec.rb b/spec/requests/queued_posts_controller_spec.rb index 421c0d9bc70..d8911e52e10 100644 --- a/spec/requests/queued_posts_controller_spec.rb +++ b/spec/requests/queued_posts_controller_spec.rb @@ -24,7 +24,7 @@ describe QueuedPostsController do it 'returns the queued posts' do get "/queued-posts.json" - expect(response).to be_success + expect(response.status).to eq(200) end end @@ -53,7 +53,7 @@ describe QueuedPostsController do queued_post: { state: 'approved' } } - expect(response).to be_success + expect(response.status).to eq(200) qp.reload expect(qp.state).to eq(QueuedPost.states[:approved]) @@ -67,7 +67,7 @@ describe QueuedPostsController do queued_post: { state: 'rejected' } } - expect(response).to be_success + expect(response.status).to eq(200) qp.reload expect(qp.state).to eq(QueuedPost.states[:rejected]) @@ -92,7 +92,7 @@ describe QueuedPostsController do queued_post: changes } - expect(response).to be_success + expect(response.status).to eq(200) queued_topic.reload expect(queued_topic.raw).to eq(changes[:raw]) @@ -111,7 +111,7 @@ describe QueuedPostsController do } original_category = queued_reply.post_options['category'] - expect(response).to be_success + expect(response.status).to eq(200) queued_reply.reload expect(queued_reply.raw).to eq(changes[:raw]) diff --git a/spec/requests/search_controller_spec.rb b/spec/requests/search_controller_spec.rb index 1a5ab80d240..0990a0c1e85 100644 --- a/spec/requests/search_controller_spec.rb +++ b/spec/requests/search_controller_spec.rb @@ -17,7 +17,7 @@ describe SearchController do term: 'awesome', include_blurb: true } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data['posts'][0]['id']).to eq(my_post.id) expect(data['posts'][0]['blurb']).to eq('this is my really awesome post') @@ -32,7 +32,7 @@ describe SearchController do term: user.username, type_filter: 'topic' } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data['posts'][0]['id']).to eq(my_post.id) @@ -42,7 +42,7 @@ describe SearchController do term: user.username, type_filter: 'user' } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data['posts']).to be_blank @@ -61,7 +61,7 @@ describe SearchController do search_for_id: true } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data['topics'][0]['id']).to eq(post.topic_id) @@ -77,7 +77,7 @@ describe SearchController do search_for_id: true } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data['topics'][0]['id']).to eq(my_post.topic_id) @@ -90,7 +90,7 @@ describe SearchController do SiteSetting.log_search_queries = true get "/search/query.json", params: { term: 'wookie' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.where(term: 'wookie')).to be_present json = JSON.parse(response.body) @@ -105,7 +105,7 @@ describe SearchController do it "doesn't log when disabled" do SiteSetting.log_search_queries = false get "/search/query.json", params: { term: 'wookie' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.where(term: 'wookie')).to be_blank end end @@ -114,14 +114,14 @@ describe SearchController do it "logs the search term" do SiteSetting.log_search_queries = true get "/search.json", params: { q: 'bantha' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.where(term: 'bantha')).to be_present end it "doesn't log when disabled" do SiteSetting.log_search_queries = false get "/search.json", params: { q: 'bantha' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.where(term: 'bantha')).to be_blank end end @@ -155,7 +155,7 @@ describe SearchController do term: 'test', search_context: { type: 'user', id: user.username } } - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -187,7 +187,7 @@ describe SearchController do search_result_type: 'topic' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to be_blank end @@ -207,7 +207,7 @@ describe SearchController do search_result_type: 'user' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to eq(12345) expect(SearchLog.find(search_log_id).search_result_type).to eq(SearchLog.search_result_types[:user]) end @@ -228,7 +228,7 @@ describe SearchController do search_result_type: 'topic' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to eq(22222) expect(SearchLog.find(search_log_id).search_result_type).to eq(SearchLog.search_result_types[:topic]) end @@ -246,7 +246,7 @@ describe SearchController do search_result_type: 'topic' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to be_blank end @@ -266,7 +266,7 @@ describe SearchController do search_result_type: 'category' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to eq(23456) expect(SearchLog.find(search_log_id).search_result_type).to eq(SearchLog.search_result_types[:category]) end @@ -288,7 +288,7 @@ describe SearchController do search_result_type: 'tag' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SearchLog.find(search_log_id).search_result_id).to eq(tag.id) expect(SearchLog.find(search_log_id).search_result_type).to eq(SearchLog.search_result_types[:tag]) end diff --git a/spec/requests/session_controller_spec.rb b/spec/requests/session_controller_spec.rb index 51bff909d03..2cb726282a1 100644 --- a/spec/requests/session_controller_spec.rb +++ b/spec/requests/session_controller_spec.rb @@ -28,7 +28,7 @@ RSpec.describe SessionController do it 'returns the right response' do get "/session/email-login/adasdad" - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to match( I18n.t('email_login.invalid_token') @@ -41,7 +41,7 @@ RSpec.describe SessionController do get "/session/email-login/#{email_token.token}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to match( I18n.t('email_login.invalid_token') @@ -823,7 +823,7 @@ RSpec.describe SessionController do login: user.username, password: 'sssss' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['error']).to eq( I18n.t("login.incorrect_username_email_or_password") ) @@ -837,7 +837,7 @@ RSpec.describe SessionController do login: user.username, password: ('s' * (User.max_password_length + 1)) } - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['error']).to eq( I18n.t("login.incorrect_username_email_or_password") ) @@ -855,7 +855,7 @@ RSpec.describe SessionController do login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq(I18n.t('login.suspended_with_reason', date: I18n.l(user.suspended_till, format: :date_only), reason: Rack::Utils.escape_html(user.suspend_reason) @@ -872,7 +872,7 @@ RSpec.describe SessionController do login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq(I18n.t('login.not_activated')) end end @@ -885,7 +885,7 @@ RSpec.describe SessionController do } end - expect(response).to be_successful + expect(response.status).to eq(200) expect(events.map { |event| event[:event_name] }).to contain_exactly( :user_logged_in, :user_first_logged_in ) @@ -908,7 +908,7 @@ RSpec.describe SessionController do password: 'myawesomepassword', } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq(I18n.t( 'login.invalid_second_factor_code' )) @@ -923,7 +923,7 @@ RSpec.describe SessionController do second_factor_token: '00000000' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq(I18n.t( 'login.invalid_second_factor_code' )) @@ -937,7 +937,7 @@ RSpec.describe SessionController do password: 'myawesomepassword', second_factor_token: ROTP::TOTP.new(user_second_factor.data).now } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(session[:current_user_id]).to eq(user.id) @@ -957,7 +957,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: "@" + user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(session[:current_user_id]).to be_nil @@ -969,7 +969,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: "@" + user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(session[:current_user_id]).to eq(user.id) @@ -981,7 +981,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: user.email, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(user.id) end end @@ -994,7 +994,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['error']).not_to be_present end @@ -1002,7 +1002,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: email, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(::JSON.parse(response.body)['error']).not_to be_present end end @@ -1020,12 +1020,12 @@ RSpec.describe SessionController do end it "doesn't log in the user" do - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to be_blank end it "shows the 'not approved' error message" do - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq( I18n.t('login.not_approved') ) @@ -1040,7 +1040,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: user.email, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(user.id) end end @@ -1063,7 +1063,7 @@ RSpec.describe SessionController do post "/session.json", params: { login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(user.id) end @@ -1076,7 +1076,7 @@ RSpec.describe SessionController do login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to be_present expect(session[:current_user_id]).not_to eq(user.id) end @@ -1090,7 +1090,7 @@ RSpec.describe SessionController do login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(user.id) end end @@ -1105,13 +1105,13 @@ RSpec.describe SessionController do it "doesn't log in the user" do post_login - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to be_blank end it "shows the 'not activated' error message" do post_login - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq( I18n.t 'login.not_activated' ) @@ -1122,7 +1122,7 @@ RSpec.describe SessionController do it "shows the 'not approved' error message" do post_login - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)['error']).to eq( I18n.t 'login.not_approved' ) @@ -1141,7 +1141,7 @@ RSpec.describe SessionController do login: user.username, password: 'myawesomepassword' } - expect(response).to be_successful + expect(response.status).to eq(200) end post "/session.json", params: { @@ -1164,7 +1164,7 @@ RSpec.describe SessionController do second_factor_token: '000000' } - expect(response).to be_successful + expect(response.status).to eq(200) end post "/session.json", params: { @@ -1285,7 +1285,7 @@ RSpec.describe SessionController do it "returns the JSON for the user" do get "/session/current.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['current_user']).to be_present expect(json['current_user']['id']).to eq(user.id) diff --git a/spec/requests/similar_topics_controller_spec.rb b/spec/requests/similar_topics_controller_spec.rb index d6692bab3fb..93e234f22e5 100644 --- a/spec/requests/similar_topics_controller_spec.rb +++ b/spec/requests/similar_topics_controller_spec.rb @@ -30,7 +30,7 @@ describe SimilarTopicsController do reindex_posts get "/topics/similar_to.json", params: { title: title, raw: raw } - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["similar_topics"].size).to eq(0) end @@ -48,7 +48,7 @@ describe SimilarTopicsController do get "/topics/similar_to.json", params: { title: title, raw: raw } - expect(response).to be_success + expect(response.status).to eq(200) similar_topics = ::JSON.parse(response.body)["similar_topics"] expect(similar_topics.size).to eq(1) expect(similar_topics.first["topic_id"]).to eq(topic.id) @@ -66,7 +66,7 @@ describe SimilarTopicsController do it "passes a user through if logged in" do get "/topics/similar_to.json", params: { title: title, raw: raw } - expect(response).to be_success + expect(response.status).to eq(200) similar_topics = ::JSON.parse(response.body)["similar_topics"].map { |topic| topic["topic_id"] } expect(similar_topics.size).to eq(2) expect(similar_topics).to include(topic.id) @@ -82,7 +82,7 @@ describe SimilarTopicsController do get "/topics/similar_to.json", params: { title: title, raw: raw } - expect(response).to be_success + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["similar_topics"].size).to eq(0) end diff --git a/spec/requests/site_controller_spec.rb b/spec/requests/site_controller_spec.rb index d57ca36da85..b084dec7b19 100644 --- a/spec/requests/site_controller_spec.rb +++ b/spec/requests/site_controller_spec.rb @@ -32,7 +32,7 @@ describe SiteController do get "/site/statistics.json" json = JSON.parse(response.body) - expect(response).to be_successful + expect(response.status).to eq(200) expect(json["topic_count"]).to be_present expect(json["post_count"]).to be_present expect(json["user_count"]).to be_present diff --git a/spec/requests/static_controller_spec.rb b/spec/requests/static_controller_spec.rb index 994167fad76..490d2966dcf 100644 --- a/spec/requests/static_controller_spec.rb +++ b/spec/requests/static_controller_spec.rb @@ -98,7 +98,7 @@ describe StaticController do it "should return the right response" do get "/faq" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(I18n.t('js.faq')) end end @@ -113,7 +113,7 @@ describe StaticController do it "renders the #{id} page" do get "/#{id}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(text) end end @@ -150,7 +150,7 @@ describe StaticController do get "/login" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(PrettyText.cook(I18n.t( 'login_required.welcome_message', title: SiteSetting.title @@ -177,7 +177,7 @@ describe StaticController do get '/faq' - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(I18n.t('js.faq')) end @@ -186,7 +186,7 @@ describe StaticController do get '/guidelines' - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(I18n.t('guidelines')) end end diff --git a/spec/requests/steps_controller_spec.rb b/spec/requests/steps_controller_spec.rb index 44a6c9bdff0..6f304bf70a3 100644 --- a/spec/requests/steps_controller_spec.rb +++ b/spec/requests/steps_controller_spec.rb @@ -40,7 +40,7 @@ describe StepsController do fields: { contact_email: "eviltrout@example.com" } } - expect(response).to be_successful + expect(response.status).to eq(200) expect(SiteSetting.contact_email).to eq("eviltrout@example.com") end diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb index 3b58b6e89a4..9be7b71022c 100644 --- a/spec/requests/tags_controller_spec.rb +++ b/spec/requests/tags_controller_spec.rb @@ -16,7 +16,7 @@ describe TagsController do it "should return the right response" do get "/tags.json" - expect(response).to be_successful + expect(response.status).to eq(200) tags = JSON.parse(response.body)["tags"] expect(tags.length).to eq(1) @@ -41,7 +41,7 @@ describe TagsController do get "/tags.json" - expect(response).to be_successful + expect(response.status).to eq(200) tags = JSON.parse(response.body)["tags"] expect(tags.length).to eq(2) @@ -57,7 +57,7 @@ describe TagsController do it "should return the right response" do get "/tags/test" - expect(response).to be_successful + expect(response.status).to eq(200) end it "should handle invalid tags" do @@ -72,7 +72,7 @@ describe TagsController do it "should return the right response" do get "/tags/check.json", params: { tag_values: [tag.name] } - expect(response).to be_successful + expect(response.status).to eq(200) tag = JSON.parse(response.body)["valid"].first expect(tag["value"]).to eq('test') @@ -141,7 +141,7 @@ describe TagsController do it "can see their own pm tags" do get "/tags/personal_messages/#{moderator.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) tag = JSON.parse(response.body)['tags'] expect(tag[0]["id"]).to eq('test') @@ -156,7 +156,7 @@ describe TagsController do it "can see pm tags for regular user" do get "/tags/personal_messages/#{regular_user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) tag = JSON.parse(response.body)['tags'] expect(tag[0]["id"]).to eq('test') @@ -165,7 +165,7 @@ describe TagsController do it "can see their own pm tags" do get "/tags/personal_messages/#{admin.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) tag = JSON.parse(response.body)['tags'] expect(tag[0]["id"]).to eq('test') @@ -195,7 +195,7 @@ describe TagsController do context 'tagging enabled' do it "can filter by tag" do get "/tags/#{tag.name}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "can filter by two tags" do @@ -205,7 +205,7 @@ describe TagsController do additional_tag_ids: other_tag.name } - expect(response).to be_successful + expect(response.status).to eq(200) topic_ids = JSON.parse(response.body)["topic_list"]["topics"] .map { |topic| topic["id"] } @@ -222,7 +222,7 @@ describe TagsController do additional_tag_ids: "#{other_tag.name}/#{third_tag.name}" } - expect(response).to be_successful + expect(response.status).to eq(200) topic_ids = JSON.parse(response.body)["topic_list"]["topics"] .map { |topic| topic["id"] } @@ -239,7 +239,7 @@ describe TagsController do additional_tag_ids: "notatag" } - expect(response).to be_successful + expect(response.status).to eq(200) topic_ids = JSON.parse(response.body)["topic_list"]["topics"] .map { |topic| topic["id"] } @@ -249,17 +249,17 @@ describe TagsController do it "can filter by category and tag" do get "/tags/c/#{category.slug}/#{tag.name}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "can filter by category, sub-category, and tag" do get "/tags/c/#{category.slug}/#{subcategory.slug}/#{tag.name}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "can filter by category, no sub-category, and tag" do get "/tags/c/#{category.slug}/none/#{tag.name}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "can handle subcategories with the same name" do @@ -272,7 +272,7 @@ describe TagsController do t = Fabricate(:topic, category_id: subcategory2.id, tags: [other_tag]) get "/tags/c/#{category2.slug}/#{subcategory2.slug}/#{other_tag.name}/l/latest.json" - expect(response).to be_successful + expect(response.status).to eq(200) topic_ids = JSON.parse(response.body)["topic_list"]["topics"] .map { |topic| topic["id"] } @@ -284,7 +284,7 @@ describe TagsController do sign_in(Fabricate(:user)) get "/tags/#{tag.name}/l/bookmarks.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -303,7 +303,7 @@ describe TagsController do tag_names = ['stuff', 'stinky', 'stumped'] tag_names.each { |name| Fabricate(:tag, name: name) } get "/tags/filter/search.json", params: { q: 'stu' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["results"].map { |j| j["id"] }.sort).to eq(['stuff', 'stumped']) end @@ -312,7 +312,7 @@ describe TagsController do yup, nope = Fabricate(:tag, name: 'yup'), Fabricate(:tag, name: 'nope') category = Fabricate(:category, tags: [yup]) get "/tags/filter/search.json", params: { q: 'nope', categoryId: category.id } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["results"].map { |j| j["id"] }.sort).to eq([]) expect(json["forbidden"]).to be_present @@ -322,7 +322,7 @@ describe TagsController do c = Fabricate(:private_category, group: Fabricate(:group)) Fabricate(:topic, category: c, tags: [Fabricate(:tag, name: "cooltag")]) get "/tags/filter/search.json", params: { q: "cool" } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["results"].map { |j| j["id"] }).to eq(['cooltag']) end @@ -332,12 +332,12 @@ describe TagsController do tag_names.each { |name| Fabricate(:tag, name: name) } get "/tags/filter/search.json", params: { q: '房' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["results"].map { |j| j["id"] }).to eq(['房地产']) get "/tags/filter/search.json", params: { q: 'тема' } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json["results"].map { |j| j["id"] }).to eq(['тема-в-разработке']) end @@ -354,7 +354,7 @@ describe TagsController do it 'deletes the tag' do tag = Fabricate(:tag) delete "/tags/#{tag.name}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(Tag.where(id: tag.id)).to be_empty end end diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb index f23881b74c5..39b8e3288e9 100644 --- a/spec/requests/topics_controller_spec.rb +++ b/spec/requests/topics_controller_spec.rb @@ -15,7 +15,7 @@ RSpec.describe TopicsController do get "/t/#{topic.id}/wordpress.json", params: { best: 3 } - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) # The JSON has the data the wordpress plugin needs @@ -105,7 +105,7 @@ RSpec.describe TopicsController do } end.to change { Topic.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) @@ -127,7 +127,7 @@ RSpec.describe TopicsController do } end.to change { Topic.count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) result = JSON.parse(response.body) @@ -143,7 +143,7 @@ RSpec.describe TopicsController do post "/t/#{topic.id}/move-posts.json", params: { post_ids: [p2.id] } - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(false) expect(result['url']).to be_blank @@ -193,7 +193,7 @@ RSpec.describe TopicsController do destination_topic_id: dest_topic.id } - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(true) expect(result['url']).to be_present @@ -207,7 +207,7 @@ RSpec.describe TopicsController do post_ids: [p2.id] } - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(false) expect(result['url']).to be_blank @@ -251,7 +251,7 @@ RSpec.describe TopicsController do destination_topic_id: dest_topic.id } - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(true) expect(result['url']).to be_present @@ -317,7 +317,7 @@ RSpec.describe TopicsController do } topic.reload p1.reload - expect(response).to be_successful + expect(response.status).to eq(200) expect(topic.user.username).to eq(user_a.username) expect(p1.user.username).to eq(user_a.username) end @@ -327,7 +327,7 @@ RSpec.describe TopicsController do username: user_a.username_lower, post_ids: [p1.id, p2.id] } - expect(response).to be_successful + expect(response.status).to eq(200) p1.reload p2.reload @@ -347,7 +347,7 @@ RSpec.describe TopicsController do username: user_a.username_lower, post_ids: [p3.id] } - expect(response).to be_successful + expect(response.status).to eq(200) t2.reload p3.reload expect(t2.deleted_at).to be_nil @@ -392,7 +392,7 @@ RSpec.describe TopicsController do timestamp: new_timestamp.to_f } - expect(response).to be_successful + expect(response.status).to eq(200) expect(topic.reload.created_at).to be_within_one_second_of(new_timestamp) expect(p1.reload.created_at).to be_within_one_second_of(new_timestamp) expect(p2.reload.created_at).to be_within_one_second_of(old_timestamp) @@ -424,7 +424,7 @@ RSpec.describe TopicsController do expect do put "/t/#{topic.id}/clear-pin.json" end.to change { TopicUser.where(topic_id: topic.id, user_id: user.id).count }.by(1) - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -479,7 +479,7 @@ RSpec.describe TopicsController do status: 'closed', enabled: 'false' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(topic.reload.closed).to eq(false) expect(topic.topic_timers).to eq([]) @@ -560,7 +560,7 @@ RSpec.describe TopicsController do put "/t/#{topic.id}/recover.json" topic.reload post.reload - expect(response).to be_successful + expect(response.status).to eq(200) expect(topic.trashed?).to be_falsey expect(post.trashed?).to be_falsey end @@ -595,7 +595,7 @@ RSpec.describe TopicsController do it 'succeeds' do delete "/t/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.trashed?).to be_truthy end @@ -609,7 +609,7 @@ RSpec.describe TopicsController do it "returns JSON for the slug" do get "/t/id_for/#{topic.slug}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = ::JSON.parse(response.body) expect(json['topic_id']).to eq(topic.id) expect(json['url']).to eq(topic.url) @@ -785,7 +785,7 @@ RSpec.describe TopicsController do it 'correctly renders canoicals' do get "/t/#{topic.id}", params: { slug: topic.slug } - expect(response).to be_successful + expect(response.status).to eq(200) expect(css_select("link[rel=canonical]").length).to eq(1) expect(response.headers["Cache-Control"]).to eq("no-cache, no-store") end @@ -802,7 +802,7 @@ RSpec.describe TopicsController do Fabricate(:post, topic: topic) get "/t/#{topic.id}.json", params: { slug: topic.slug } - expect(response).to be_successful + expect(response.status).to eq(200) get "/t/#{topic.id}.json", params: { slug: "just-guessing" } expect(response.status).to eq(301) @@ -813,7 +813,7 @@ RSpec.describe TopicsController do it 'shows a topic correctly' do get "/t/#{topic.slug}/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it 'return 404 for an invalid page' do @@ -1042,7 +1042,7 @@ RSpec.describe TopicsController do SiteSetting.max_prints_per_hour_per_user = 10 get "/t/#{topic.slug}/#{topic.id}/print", headers: { HTTP_USER_AGENT: "Rails Testing" } - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body expect(body).to have_tag(:body, class: 'crawler') @@ -1108,20 +1108,20 @@ RSpec.describe TopicsController do it 'grabs the correct set of posts' do get "/t/#{topic.slug}/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(extract_post_stream).to eq(@post_ids[0..1]) get "/t/#{topic.slug}/#{topic.id}.json", params: { page: 1 } - expect(response).to be_successful + expect(response.status).to eq(200) expect(extract_post_stream).to eq(@post_ids[0..1]) get "/t/#{topic.slug}/#{topic.id}.json", params: { page: 2 } - expect(response).to be_successful + expect(response.status).to eq(200) expect(extract_post_stream).to eq(@post_ids[2..3]) post_number = topic.posts.pluck(:post_number).sort[3] get "/t/#{topic.slug}/#{topic.id}/#{post_number}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(extract_post_stream).to eq(@post_ids[-2..-1]) end end @@ -1134,7 +1134,7 @@ RSpec.describe TopicsController do it 'shows the topic' do get "/t/#{topic.slug}/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end @@ -1150,7 +1150,7 @@ RSpec.describe TopicsController do it 'shows the topic if valid api key is provided' do get "/t/#{topic.slug}/#{topic.id}.json", params: { api_key: api_key.key } - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.views).to eq(1) end @@ -1226,7 +1226,7 @@ RSpec.describe TopicsController do expect { get "/t/#{topic.id}.json" }.not_to change(IncomingLink, :count) - expect(response).to be_successful + expect(response.status).to eq(200) end it "doesn't raise an error on a very long link" do @@ -1245,7 +1245,7 @@ RSpec.describe TopicsController do body = response.body - expect(response).to be_successful + expect(response.status).to eq(200) expect(body).to have_tag(:script, with: { src: '/assets/application.js' }) expect(body).to_not have_tag(:meta, with: { name: 'fragment' }) end @@ -1272,7 +1272,7 @@ RSpec.describe TopicsController do body = response.body - expect(response).to be_successful + expect(response.status).to eq(200) expect(body).to have_tag(:body, with: { class: 'crawler' }) expect(body).to_not have_tag(:meta, with: { name: 'fragment' }) end @@ -1288,7 +1288,7 @@ RSpec.describe TopicsController do get "/t/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.cookies['cn']).to eq(nil) notification.reload @@ -1301,7 +1301,7 @@ RSpec.describe TopicsController do get "/t/#{topic.id}.json", headers: { "Discourse-Clear-Notifications" => "2828,100,#{notification.id}" } - expect(response).to be_successful + expect(response.status).to eq(200) notification.reload expect(notification.read).to eq(true) end @@ -1323,7 +1323,7 @@ RSpec.describe TopicsController do it "uses the default locale" do get "/t/#{topic.id}.json", headers: headers("fr") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:en) end end @@ -1335,7 +1335,7 @@ RSpec.describe TopicsController do get "/t/#{topic.id}.json", headers: headers("fr") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:en) end end @@ -1353,7 +1353,7 @@ RSpec.describe TopicsController do context "with an anonymous user" do it "uses the locale from the headers" do get "/t/#{topic.id}.json", headers: headers("fr") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:fr) end end @@ -1364,7 +1364,7 @@ RSpec.describe TopicsController do sign_in(user) get "/t/#{topic.id}.json", headers: headers("fr") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:fr) end end @@ -1377,7 +1377,7 @@ RSpec.describe TopicsController do SiteSetting.default_locale = "en" get "/t/#{topic.id}.json", headers: headers("zh-CN") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:zh_CN) end end @@ -1388,7 +1388,7 @@ RSpec.describe TopicsController do SiteSetting.default_locale = 'en' get "/t/#{topic.id}.json", headers: headers("") - expect(response).to be_successful + expect(response.status).to eq(200) expect(I18n.locale).to eq(:en) end end @@ -1398,14 +1398,14 @@ RSpec.describe TopicsController do describe "read only header" do it "returns no read only header by default" do get "/t/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.headers['Discourse-Readonly']).to eq(nil) end it "returns a readonly header if the site is read only" do Discourse.received_readonly! get "/t/#{topic.id}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.headers['Discourse-Readonly']).to eq('true') end end @@ -1416,7 +1416,7 @@ RSpec.describe TopicsController do it 'returns first posts of the topic' do get "/t/#{topic.id}/posts.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/json') end end @@ -1426,7 +1426,7 @@ RSpec.describe TopicsController do it 'renders rss of the topic' do get "/t/foo/#{topic.id}.rss" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.content_type).to eq('application/rss+xml') end end @@ -1473,7 +1473,7 @@ RSpec.describe TopicsController do topic = Fabricate(:topic, user: sign_in(Fabricate(:admin))) put "/t/#{topic.id}/make-banner.json" - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.archetype).to eq(Archetype.banner) end @@ -1492,7 +1492,7 @@ RSpec.describe TopicsController do topic = Fabricate(:topic, user: sign_in(Fabricate(:admin)), archetype: Archetype.banner) put "/t/#{topic.id}/remove-banner.json" - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.archetype).to eq(Archetype.default) end @@ -1601,7 +1601,7 @@ RSpec.describe TopicsController do user.user_stat.update_column(:new_since, old_date) put "/topics/reset-new.json" - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.user_stat.new_since.to_date).not_to eq(old_date.to_date) end @@ -1611,7 +1611,7 @@ RSpec.describe TopicsController do it "works" do get "/topics/feature_stats.json", params: { category_id: 1 } - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["pinned_in_category_count"]).to eq(0) expect(json["pinned_globally_count"]).to eq(0) @@ -1676,7 +1676,7 @@ RSpec.describe TopicsController do topic.reload expect(topic.archetype).to eq(Archetype.private_message) - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(true) @@ -1702,7 +1702,7 @@ RSpec.describe TopicsController do topic.reload expect(topic.archetype).to eq(Archetype.default) - expect(response).to be_successful + expect(response.status).to eq(200) result = ::JSON.parse(response.body) expect(result['success']).to eq(true) @@ -1724,7 +1724,7 @@ RSpec.describe TopicsController do timings: { post_1.post_number => 2 } } - expect(response).to be_successful + expect(response.status).to eq(200) post_timing = PostTiming.first @@ -1772,7 +1772,7 @@ RSpec.describe TopicsController do status_type: TopicTimer.types[1] } - expect(response).to be_successful + expect(response.status).to eq(200) topic_status_update = TopicTimer.last @@ -1798,7 +1798,7 @@ RSpec.describe TopicsController do status_type: TopicTimer.types[1] } - expect(response).to be_successful + expect(response.status).to eq(200) expect(topic.reload.public_topic_timer).to eq(nil) json = JSON.parse(response.body) @@ -1816,7 +1816,7 @@ RSpec.describe TopicsController do category_id: topic.category_id } - expect(response).to be_successful + expect(response.status).to eq(200) topic_status_update = TopicTimer.last @@ -2036,7 +2036,7 @@ RSpec.describe TopicsController do let!(:shared_draft) { Fabricate(:shared_draft, topic: topic, category: category) } it "allows staff to update the category id" do put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id } - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.shared_draft.category_id).to eq(other_cat.id) end @@ -2045,7 +2045,7 @@ RSpec.describe TopicsController do context "without a shared draft" do it "allows staff to update the category id" do put "/t/#{topic.id}/shared-draft.json", params: { category_id: other_cat.id } - expect(response).to be_successful + expect(response.status).to eq(200) topic.reload expect(topic.shared_draft.category_id).to eq(other_cat.id) end diff --git a/spec/requests/uploads_controller_spec.rb b/spec/requests/uploads_controller_spec.rb index 9fa184f0e5c..fac1a98d8d2 100644 --- a/spec/requests/uploads_controller_spec.rb +++ b/spec/requests/uploads_controller_spec.rb @@ -122,7 +122,7 @@ describe UploadsController do for_private_message: "true", } - expect(response).to be_successful + expect(response.status).to eq(200) id = JSON.parse(response.body)["id"] expect(id).to be_present end @@ -137,7 +137,7 @@ describe UploadsController do type: "composer", } - expect(response).to be_successful + expect(response.status).to eq(200) data = JSON.parse(response.body) expect(data["id"]).to be_present end diff --git a/spec/requests/user_avatars_controller_spec.rb b/spec/requests/user_avatars_controller_spec.rb index 0d86117abc4..be10954e8aa 100644 --- a/spec/requests/user_avatars_controller_spec.rb +++ b/spec/requests/user_avatars_controller_spec.rb @@ -59,7 +59,7 @@ describe UserAvatarsController do get "/user_avatar/default/#{user.username}/51/#{upload.id}.png" - expect(response).to be_successful + expect(response.status).to eq(200) end end end diff --git a/spec/requests/user_badges_controller_spec.rb b/spec/requests/user_badges_controller_spec.rb index 84b1b2ebbb7..f565caa1a7f 100644 --- a/spec/requests/user_badges_controller_spec.rb +++ b/spec/requests/user_badges_controller_spec.rb @@ -11,7 +11,7 @@ describe UserBadgesController do UserBadge.create!(badge: badge, user: user, post_id: p.id, granted_by_id: -1, granted_at: Time.now) get "/user_badges.json", params: { badge_id: badge.id } - expect(response).to be_successful + expect(response.status).to eq(200) parsed = JSON.parse(response.body) expect(parsed["topics"]).to eq(nil) diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 1714816a005..a99aacba9ac 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -64,7 +64,7 @@ describe UsersController do :user_logged_in, :user_first_logged_in ) - expect(response).to be_successful + expect(response.status).to eq(200) expect(flash[:error]).to be_blank expect(session[:current_user_id]).to be_present @@ -81,7 +81,7 @@ describe UsersController do end it 'should return the right response' do - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)) .to include(I18n.t('activation.approval_required')) @@ -116,7 +116,7 @@ describe UsersController do it "returns success" do SiteSetting.login_required = true get "/u/password-reset/#{token}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include(I18n.t('password_reset.no_token')) end end @@ -127,7 +127,7 @@ describe UsersController do end it 'disallows login' do - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)) .to include(I18n.t('password_reset.no_token')) @@ -144,7 +144,7 @@ describe UsersController do it 'disallows login' do get "/u/password-reset/ev!l_trout@!" - expect(response).to be_successful + expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)) .to include(I18n.t('password_reset.no_token')) @@ -159,7 +159,7 @@ describe UsersController do it "responds with proper error message" do put "/u/password-reset/evil_trout!.json", params: { password: "awesomeSecretPassword" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["message"]).to eq(I18n.t('password_reset.no_token')) expect(session[:current_user_id]).to be_blank end @@ -189,7 +189,7 @@ describe UsersController do :user_logged_in, :user_first_logged_in ) - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include('{"is_developer":false,"admin":false,"second_factor_required":false}') expect(session["password-#{token}"]).to be_blank @@ -294,7 +294,7 @@ describe UsersController do it "fails when the password is blank" do put "/u/password-reset/#{token}.json", params: { password: '' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["errors"]).to be_present expect(session[:current_user_id]).to be_blank end @@ -302,7 +302,7 @@ describe UsersController do it "fails when the password is too long" do put "/u/password-reset/#{token}.json", params: { password: ('x' * (User.max_password_length + 1)) } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["errors"]).to be_present expect(session[:current_user_id]).to be_blank end @@ -310,7 +310,7 @@ describe UsersController do it "logs in the user" do put "/u/password-reset/#{token}.json", params: { password: 'ksjafh928r' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["errors"]).to be_blank expect(session[:current_user_id]).to be_present end @@ -331,14 +331,14 @@ describe UsersController do it "token doesn't match any records" do email_token = user.email_tokens.create(email: user.email) get "/u/confirm-email-token/#{SecureRandom.hex}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(email_token.reload.confirmed).to eq(false) end it "token matches" do email_token = user.email_tokens.create(email: user.email) get "/u/confirm-email-token/#{email_token.token}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(email_token.reload.confirmed).to eq(true) end end @@ -442,11 +442,11 @@ describe UsersController do user.save! post "/u/toggle-anon.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(AnonymousShadowCreator.get(user).id) post "/u/toggle-anon.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(session[:current_user_id]).to eq(user.id) end end @@ -934,7 +934,7 @@ describe UsersController do it "should succeed without the optional field" do post "/u.json", params: create_params - expect(response).to be_successful + expect(response.status).to eq(200) inserted = User.find_by_email(@user.email) expect(inserted).to be_present expect(inserted.custom_fields).to be_present @@ -946,7 +946,7 @@ describe UsersController do it "should succeed with the optional field" do create_params[:user_fields][optional_field.id.to_s] = 'value3' post "/u.json", params: create_params.merge(create_params) - expect(response).to be_successful + expect(response.status).to eq(200) inserted = User.find_by_email(@user.email) expect(inserted).to be_present expect(inserted.custom_fields).to be_present @@ -958,7 +958,7 @@ describe UsersController do it "trims excessively long fields" do create_params[:user_fields][optional_field.id.to_s] = ('x' * 3000) post "/u.json", params: create_params.merge(create_params) - expect(response).to be_successful + expect(response.status).to eq(200) inserted = User.find_by_email(@user.email) val = inserted.custom_fields["user_field_#{optional_field.id}"] @@ -980,7 +980,7 @@ describe UsersController do it "should succeed" do post "/u.json", params: create_params - expect(response).to be_successful + expect(response.status).to eq(200) inserted = User.find_by_email(@user.email) expect(inserted).to be_present expect(inserted.custom_fields).not_to be_present @@ -1073,7 +1073,7 @@ describe UsersController do it 'should succeed in normal circumstances' do put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.username).to eq(new_username) end @@ -1097,7 +1097,7 @@ describe UsersController do put "/u/#{user.username}/preferences/username.json", params: { new_username: new_username } - expect(response).to be_successful + expect(response.status).to eq(200) expect(UserHistory.where(action: UserHistory.actions[:change_username], target_user_id: user.id, acting_user_id: acting_user.id)).to be_present expect(user.reload.username).to eq(new_username) end @@ -1221,7 +1221,7 @@ describe UsersController do user = Fabricate(:user) get "/u/#{user.username}/invited.json", params: { username: user.username } - expect(response).to be_successful + expect(response.status).to eq(200) end it 'filters by email' do @@ -1366,14 +1366,14 @@ describe UsersController do it "should be able to update a user" do put "/u/#{user.username}.json", params: { name: 'test.test' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.name).to eq('test.test') end it "should be able to update a user" do put "/u/#{user.username}.json", params: { name: 'testing123' } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.name).to eq('testing123') end end @@ -1391,7 +1391,7 @@ describe UsersController do user_fields: { user_field.id.to_s => 'happy' } } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload @@ -1417,7 +1417,7 @@ describe UsersController do watched_tags: "#{tags[0].name},#{tags[1].name}" } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload @@ -1460,7 +1460,7 @@ describe UsersController do it "should update the user field" do put "/u/#{user.username}.json", params: { name: 'Jim Tom', user_fields: { user_field.id.to_s => 'happy' } } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.user_fields[user_field.id.to_s]).to eq 'happy' end @@ -1480,13 +1480,13 @@ describe UsersController do it "should retain existing user fields" do put "/u/#{user.username}.json", params: { name: 'Jim Tom', user_fields: { user_field.id.to_s => 'happy', optional_field.id.to_s => 'feet' } } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.user_fields[user_field.id.to_s]).to eq('happy') expect(user.user_fields[optional_field.id.to_s]).to eq('feet') put "/u/#{user.username}.json", params: { name: 'Jim Tom', user_fields: { user_field.id.to_s => 'sad' } } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload @@ -1501,7 +1501,7 @@ describe UsersController do it "does not update the user field" do put "/u/#{user.username}.json", params: { name: 'Jim Tom', user_fields: { user_field.id.to_s => 'happy' } } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.user_fields[user_field.id.to_s]).to be_blank end end @@ -1748,7 +1748,7 @@ describe UsersController do it 'can successfully pick the system avatar' do put "/u/#{user.username}/preferences/avatar/pick.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.uploaded_avatar_id).to eq(nil) end @@ -1757,7 +1757,7 @@ describe UsersController do upload_id: upload.id, type: "gravatar" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.uploaded_avatar_id).to eq(upload.id) expect(user.user_avatar.reload.gravatar_upload_id).to eq(upload.id) end @@ -1767,7 +1767,7 @@ describe UsersController do upload_id: upload.id, type: "custom" } - expect(response).to be_successful + expect(response.status).to eq(200) expect(user.reload.uploaded_avatar_id).to eq(upload.id) expect(user.user_avatar.reload.custom_upload_id).to eq(upload.id) end @@ -1807,7 +1807,7 @@ describe UsersController do delete "/u/#{user.username}/preferences/user_image.json", params: { type: 'profile_background' } expect(user.reload.user_profile.profile_background).to eq("") - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -1843,7 +1843,7 @@ describe UsersController do it "deletes your account when you're allowed to" do UserDestroyer.any_instance.expects(:destroy).with(user, anything).returns(user) delete "/u/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end end end @@ -1894,7 +1894,7 @@ describe UsersController do get "/u/#{Fabricate(:user).username}/emails.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["email"]).to be_present expect(json["associated_accounts"]).to be_present @@ -1906,7 +1906,7 @@ describe UsersController do get "/u/#{inactive_user.username}/emails.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["email"]).to be_present expect(json["associated_accounts"]).to be_present @@ -2034,7 +2034,7 @@ describe UsersController do create_post(user: user) get "/u/#{user.username_lower}/summary.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["user_summary"]["topic_count"]).to eq(1) @@ -2058,7 +2058,7 @@ describe UsersController do ac = AdminConfirmation.new(user, Fabricate(:admin)) ac.create_confirmation get "/u/confirm-admin/#{ac.token}.josn" - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.admin?).to eq(false) @@ -2071,7 +2071,7 @@ describe UsersController do ac = AdminConfirmation.new(user, admin) ac.create_confirmation get "/u/confirm-admin/#{ac.token}.josn", params: { token: ac.token } - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.admin?).to eq(false) @@ -2096,7 +2096,7 @@ describe UsersController do ac = AdminConfirmation.new(user, Fabricate(:admin)) ac.create_confirmation post "/u/confirm-admin/#{ac.token}.josn" - expect(response).to be_successful + expect(response.status).to eq(200) user.reload expect(user.admin?).to eq(true) @@ -2285,7 +2285,7 @@ describe UsersController do it "returns success" do get "/u/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["user"]["username"]).to eq(user.username) end @@ -2320,7 +2320,7 @@ describe UsersController do it 'returns success' do get "/u/#{user.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json["user"]["has_title_badges"]).to eq(false) @@ -2341,7 +2341,7 @@ describe UsersController do SiteSetting.show_inactive_accounts = true inactive = Fabricate(:user, active: false) get "/u/#{inactive.username}.json" - expect(response).to be_successful + expect(response.status).to eq(200) end it "raises an error on invalid access" do @@ -2374,7 +2374,7 @@ describe UsersController do it "returns fetch for a matching external_id" do get "/u/by-external/997.json" - expect(response).to be_successful + expect(response.status).to eq(200) expect(JSON.parse(response.body)["user"]["username"]).to eq(user.username) end @@ -2414,7 +2414,7 @@ describe UsersController do it "should be able to view a user" do get "/u/#{user.username}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(user.username) end @@ -2426,7 +2426,7 @@ describe UsersController do it "should be able to view a user" do get "/u/#{user.username}" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include(user.username) end end @@ -2435,7 +2435,7 @@ describe UsersController do describe '#badges' do it "renders fine by default" do get "/u/#{user.username}/badges" - expect(response).to be_successful + expect(response.status).to eq(200) end it "fails if badges are disabled" do @@ -2449,7 +2449,7 @@ describe UsersController do it "returns a message when no session is present" do get "/u/account-created" - expect(response).to be_successful + expect(response.status).to eq(200) body = response.body @@ -2470,7 +2470,7 @@ describe UsersController do user = create_user get "/u/account-created" - expect(response).to be_successful + expect(response.status).to eq(200) expect(response.body).to include( "{\"message\":\"#{I18n.t("login.activate_email", email: user.email).gsub!(" signature } - expect(response).to be_successful + expect(response.status).to eq(200) email_log.reload expect(email_log.bounced).to eq(true) @@ -51,7 +51,7 @@ describe WebhooksController do ] } - expect(response).to be_successful + expect(response.status).to eq(200) email_log.reload expect(email_log.bounced).to eq(true) @@ -71,7 +71,7 @@ describe WebhooksController do "CustomID" => message_id } - expect(response).to be_successful + expect(response.status).to eq(200) email_log.reload expect(email_log.bounced).to eq(true) @@ -96,7 +96,7 @@ describe WebhooksController do }] } - expect(response).to be_successful + expect(response.status).to eq(200) email_log.reload expect(email_log.bounced).to eq(true) @@ -123,7 +123,7 @@ describe WebhooksController do }] } - expect(response).to be_successful + expect(response.status).to eq(200) email_log.reload expect(email_log.bounced).to eq(true) diff --git a/spec/support/integration_helpers.rb b/spec/support/integration_helpers.rb index 7269dcd5305..f2d72771c65 100644 --- a/spec/support/integration_helpers.rb +++ b/spec/support/integration_helpers.rb @@ -2,7 +2,7 @@ module IntegrationHelpers def create_user get "/u/hp.json" - expect(response).to be_successful + expect(response.status).to eq(200) body = JSON.parse(response.body) honeypot = body["value"] @@ -17,7 +17,7 @@ module IntegrationHelpers challenge: challenge.reverse } - expect(response).to be_successful + expect(response.status).to eq(200) body = JSON.parse(response.body) User.find(body["user_id"])