adds controller check for anonymous votes
This commit is contained in:
@@ -12,7 +12,6 @@ describe DebatesController do
|
||||
end
|
||||
|
||||
describe 'POST create' do
|
||||
|
||||
it 'should create an ahoy event' do
|
||||
|
||||
sign_in create(:user)
|
||||
@@ -22,4 +21,26 @@ describe DebatesController do
|
||||
expect(Ahoy::Event.last.properties['debate_id']).to eq Debate.last.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "Vote with too many anonymous votes" do
|
||||
it 'should allow vote if user is allowed' do
|
||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 100)
|
||||
debate = create(:debate)
|
||||
sign_in create(:user)
|
||||
|
||||
expect do
|
||||
xhr :post, :vote, id: debate.id, value: 'yes'
|
||||
end.to change { debate.reload.votes_for.size }.by(1)
|
||||
end
|
||||
|
||||
it 'should not allow vote if user is not allowed' do
|
||||
Setting.find_by(key: "max_ratio_anon_votes_on_debates").update(value: 0)
|
||||
debate = create(:debate)
|
||||
sign_in create(:user)
|
||||
|
||||
expect do
|
||||
xhr :post, :vote, id: debate.id, value: 'yes'
|
||||
end.to_not change { debate.reload.votes_for.size }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user