diff --git a/spec/controllers/ajax/mute_rule_controller_spec.rb b/spec/controllers/ajax/mute_rule_controller_spec.rb index 096e2a74..f5b504b5 100644 --- a/spec/controllers/ajax/mute_rule_controller_spec.rb +++ b/spec/controllers/ajax/mute_rule_controller_spec.rb @@ -1,20 +1,21 @@ -require 'rails_helper' +# frozen_string_literal: true + +require "rails_helper" describe Ajax::MuteRuleController, :ajax_controller, type: :controller do - describe "#create" do - subject { post(:create, params: params) } + subject { post(:create, params:) } context "when user is signed in" do before(:each) { sign_in(user) } - let(:params) { { muted_phrase: 'test' } } + let(:params) { { muted_phrase: "test" } } let(:expected_response) do { "success" => true, - "status" => "okay", - "id" => MuteRule.last.id.to_s, - "message" => "Rule added successfully.", + "status" => "okay", + "id" => MuteRule.last.id.to_s, + "message" => "Rule added successfully." } end @@ -24,7 +25,7 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do rule = MuteRule.first expect(rule.user_id).to eq(user.id) - expect(rule.muted_phrase).to eq('test') + expect(rule.muted_phrase).to eq("test") end include_examples "returns the expected response" @@ -32,17 +33,17 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do end describe "#update" do - subject { post(:update, params: params) } + subject { post(:update, params:) } context "when user is signed in" do before(:each) { sign_in(user) } - let(:rule) { MuteRule.create(user: user, muted_phrase: 'test') } - let(:params) { { id: rule.id, muted_phrase: 'dogs' } } + let(:rule) { MuteRule.create(user:, muted_phrase: "test") } + let(:params) { { id: rule.id, muted_phrase: "dogs" } } let(:expected_response) do { "success" => true, - "status" => "okay", + "status" => "okay", "message" => "Rule updated successfully." } end @@ -51,7 +52,7 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do subject expect(response).to have_http_status(:success) - expect(rule.reload.muted_phrase).to eq('dogs') + expect(rule.reload.muted_phrase).to eq("dogs") end include_examples "returns the expected response" @@ -59,17 +60,17 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do end describe "#destroy" do - subject { delete(:destroy, params: params) } + subject { delete(:destroy, params:) } context "when user is signed in" do before(:each) { sign_in(user) } - let(:rule) { MuteRule.create(user: user, muted_phrase: 'test') } + let(:rule) { MuteRule.create(user:, muted_phrase: "test") } let(:params) { { id: rule.id } } let(:expected_response) do { "success" => true, - "status" => "okay", + "status" => "okay", "message" => "Rule deleted successfully." } end @@ -79,11 +80,9 @@ describe Ajax::MuteRuleController, :ajax_controller, type: :controller do expect(response).to have_http_status(:success) expect(MuteRule.exists?(rule.id)).to eq(false) - end include_examples "returns the expected response" end end - end