Skip to content

Commit

Permalink
Add controller specs to test moderators blocking users from commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Mar 4, 2024
1 parent 1377902 commit 5bf131f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/api/spec/controllers/webui/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,35 @@
it { expect(user.email).to eq('new_valid@email.es') }
end
end

context 'for a moderator' do
let(:moderator) { create(:moderator) }

context 'blocking the ability of a user to create comments' do
before do
login(moderator)
post :update, params: { login: user.login, user: { blocked_from_commenting: 'true' } }
user.reload
end

it { expect(user.blocked_from_commenting).to be(true) }
it { expect(flash[:success]).to eq("User data for user '#{user.login}' successfully updated.") }
end

context 'passing parameters other than the blocked_from_commenting' do
before do
login(moderator)
post :update, params: { login: user.login, user: { blocked_from_commenting: 'true', email: 'foo@bar.baz' } }
user.reload
end

it 'leaves the other attributes untouched' do
expect(user.email).not_to eq('foo@bar.baz')
expect(user.blocked_from_commenting).to be(true)
expect(flash[:success]).to eq("User data for user '#{user.login}' successfully updated.")
end
end
end
end

describe 'GET #autocomplete' do
Expand Down

0 comments on commit 5bf131f

Please sign in to comment.