diff --git a/spec/controllers/settings/privacy_controller_spec.rb b/spec/controllers/settings/privacy_controller_spec.rb new file mode 100644 index 00000000..86333220 --- /dev/null +++ b/spec/controllers/settings/privacy_controller_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe Settings::PrivacyController, type: :controller do + let(:user) { FactoryBot.create(:user) } + + describe "#edit" do + subject { get :edit } + + context "user signed in" do + before(:each) { sign_in user } + + it "renders the edit template" do + subject + expect(response).to render_template("edit") + end + end + end + + describe "#update" do + subject { patch :update, params: { user: user_params } } + let(:user_params) do + { + privacy_allow_anonymous_questions: false, + privacy_allow_public_timeline: false, + privacy_allow_stranger_answers: false, + privacy_show_in_search: false, + } + end + + context "user signed in" do + before(:each) { sign_in user } + + it "updates the user's profile" do + subject + user.reload + expect(user.privacy_allow_anonymous_questions).to eq(false) + expect(user.privacy_allow_public_timeline).to eq(false) + expect(user.privacy_allow_stranger_answers).to eq(false) + expect(user.privacy_show_in_search).to eq(false) + end + + it "redirects to the privacy settings page" do + subject + expect(response).to redirect_to(:settings_privacy) + end + end + end +end \ No newline at end of file diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index b75234d2..b563e6bf 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -63,49 +63,6 @@ describe UserController, type: :controller do end end - describe "#edit_privacy" do - subject { get :edit_privacy } - - context "user signed in" do - before(:each) { sign_in user } - - it "renders the user/edit_privacy template" do - subject - expect(response).to render_template("user/edit_privacy") - end - end - end - - describe "#update_privacy" do - subject { patch :update_privacy, params: { user: user_params } } - let(:user_params) do - { - privacy_allow_anonymous_questions: false, - privacy_allow_public_timeline: false, - privacy_allow_stranger_answers: false, - privacy_show_in_search: false, - } - end - - context "user signed in" do - before(:each) { sign_in user } - - it "updates the user's profile" do - subject - user.reload - expect(user.privacy_allow_anonymous_questions).to eq(false) - expect(user.privacy_allow_public_timeline).to eq(false) - expect(user.privacy_allow_stranger_answers).to eq(false) - expect(user.privacy_show_in_search).to eq(false) - end - - it "redirects to the edit_user_profile page" do - subject - expect(response).to redirect_to(:edit_user_privacy) - end - end - end - describe "#edit_security" do subject { get :edit_security }