From 37c84451ed24ae4c81f2422bcfe2267b1e87ce01 Mon Sep 17 00:00:00 2001 From: OsamaSayegh Date: Mon, 11 Jun 2018 07:37:06 +0300 Subject: [PATCH] REFACTOR: admin staff action logs controller specs to requests (#5971) --- .../admin/staff_action_logs_controller_spec.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) rename spec/{controllers => requests}/admin/staff_action_logs_controller_spec.rb (78%) diff --git a/spec/controllers/admin/staff_action_logs_controller_spec.rb b/spec/requests/admin/staff_action_logs_controller_spec.rb similarity index 78% rename from spec/controllers/admin/staff_action_logs_controller_spec.rb rename to spec/requests/admin/staff_action_logs_controller_spec.rb index 0950429f62e..12acd222442 100644 --- a/spec/controllers/admin/staff_action_logs_controller_spec.rb +++ b/spec/requests/admin/staff_action_logs_controller_spec.rb @@ -5,16 +5,18 @@ describe Admin::StaffActionLogsController do expect(Admin::StaffActionLogsController < Admin::AdminController).to eq(true) end - let!(:user) { log_in(:admin) } + let(:admin) { Fabricate(:admin) } - context '.index' do + before do + sign_in(admin) + end + describe '#index' do it 'generates logs' do - topic = Fabricate(:topic) - _record = StaffActionLogger.new(Discourse.system_user).log_topic_delete_recover(topic, "delete_topic") + StaffActionLogger.new(Discourse.system_user).log_topic_delete_recover(topic, "delete_topic") - get :index, params: { action_id: UserHistory.actions[:delete_topic] }, format: :json + get "/admin/logs/staff_action_logs.json", params: { action_id: UserHistory.actions[:delete_topic] } json = JSON.parse(response.body) expect(response.status).to eq(200) @@ -23,11 +25,10 @@ describe Admin::StaffActionLogsController do expect(json["staff_action_logs"][0]["action_name"]).to eq("delete_topic") expect(json["user_history_actions"]).to include("id" => UserHistory.actions[:delete_topic], "name" => 'delete_topic') - end end - context '.diff' do + describe '#diff' do it 'can generate diffs for theme changes' do theme = Theme.new(user_id: -1, name: 'bob') theme.set_field(target: :mobile, name: :scss, value: 'body {.up}') @@ -40,7 +41,7 @@ describe Admin::StaffActionLogsController do record = StaffActionLogger.new(Discourse.system_user) .log_theme_change(original_json, theme) - get :diff, params: { id: record.id }, format: :json + get "/admin/logs/staff_action_logs/#{record.id}/diff.json" expect(response.status).to eq(200) parsed = JSON.parse(response.body)