From 6b5e59fa1c243a0d022514b71737a37e48effd57 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 3 Jul 2022 21:12:18 +0200 Subject: [PATCH] Move tests for mute view into own controller spec file --- .../settings/mutes_controller_spec.rb | 39 +++++++++++++++++++ spec/controllers/user_controller_spec.rb | 32 --------------- 2 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 spec/controllers/settings/mutes_controller_spec.rb diff --git a/spec/controllers/settings/mutes_controller_spec.rb b/spec/controllers/settings/mutes_controller_spec.rb new file mode 100644 index 00000000..a87c8cd3 --- /dev/null +++ b/spec/controllers/settings/mutes_controller_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe Settings::MutesController, type: :controller do + let(:user) { FactoryBot.create(:user) } + + describe "#index" do + subject { get :index } + + context "user signed in" do + before(:each) { sign_in user } + + it "shows the edit_blocks page" do + subject + expect(response).to have_rendered(:index) + end + + it "only contains blocks of the signed in user" do + other_user = create(:user) + other_user.block(user) + + subject + + expect(assigns(:blocks)).to eq(user.active_block_relationships) + end + + it "only contains anonymous blocks of the signed in user" do + other_user = create(:user) + question = create(:question) + other_user.anonymous_blocks.create(identifier: "very-real-identifier", question_id: question.id) + + subject + + expect(assigns(:anonymous_blocks)).to eq(user.anonymous_blocks) + end + end + end +end diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index bb403cb3..dfe28009 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -62,36 +62,4 @@ describe UserController, type: :controller do end end end - - describe "#edit_blocks" do - subject { get :edit_blocks } - - context "user signed in" do - before(:each) { sign_in user } - - it "shows the edit_blocks page" do - subject - expect(response).to have_rendered(:edit_blocks) - end - - it "only contains blocks of the signed in user" do - other_user = create(:user) - other_user.block(user) - - subject - - expect(assigns(:blocks)).to eq(user.active_block_relationships) - end - - it "only contains anonymous blocks of the signed in user" do - other_user = create(:user) - question = create(:question) - other_user.anonymous_blocks.create(identifier: "very-real-identifier", question_id: question.id) - - subject - - expect(assigns(:anonymous_blocks)).to eq(user.anonymous_blocks) - end - end - end end