Add tests for privacy settings

This commit is contained in:
Karina Kwiatek 2022-01-12 02:51:18 +01:00 committed by Karina Kwiatek
parent 9c84f946ff
commit b167c4e938
1 changed files with 43 additions and 0 deletions

View File

@ -76,6 +76,19 @@ describe UserController, type: :controller do
end end
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" do describe "#update" do
subject { patch :update, params: { user: avatar_params } } subject { patch :update, params: { user: avatar_params } }
let(:avatar_params) do let(:avatar_params) do
@ -121,6 +134,36 @@ describe UserController, type: :controller do
end 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 "#update" do describe "#update" do
subject { patch :update, params: { user: header_params } } subject { patch :update, params: { user: header_params } }
let(:header_params) do let(:header_params) do