Appease the robot dog

This commit is contained in:
Andreas Nedbal 2022-09-02 20:08:11 +02:00
parent 13c275b189
commit c979a7211d
1 changed files with 17 additions and 18 deletions

View File

@ -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.",
"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,13 +33,13 @@ 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,
@ -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,12 +60,12 @@ 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
{
@ -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