Skip to content

Commit

Permalink
Turn the user into a moderator only on requests
Browse files Browse the repository at this point in the history
  • Loading branch information
roschaefer committed Oct 27, 2018
1 parent 0d96dfa commit dcf3649
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
26 changes: 0 additions & 26 deletions backend/spec/models/broadcast_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,30 +353,4 @@
it { is_expected.to_not be_valid }
end
end

context 'a write action of a non-moderator user' do
let(:user) { create(:user, role: :contributor) }
describe '#create' do
it 'turns the author into a moderator' do
expect do
PaperTrail.request(whodunnit: user.id) do
broadcast = build(:broadcast)
broadcast.save
end
end.to(change{user.role}.from('contributor').to('moderator'))
end
end

describe '#update' do
it 'turns the editor into a moderator' do
broadcast = create(:broadcast)
expect do
PaperTrail.request(whodunnit: user.id) do
broadcast.title = 'I just changed the title'
broadcast.save
end
end.to(change{user.role}.from('contributor').to('moderator'))
end
end
end
end
18 changes: 18 additions & 0 deletions backend/spec/requests/broadcasts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@
end
end

context 'as contributor' do
let(:user) { create(:user, role: :contributor) }
describe '#create' do
it 'turns the author into a moderator' do
expect { action }.to(change{user.role}.from('contributor').to('moderator'))
end
end
end

%i[contributor moderator admin].each do |role|
context "as #{role}" do
let(:user) { create(:user, role: role) }
Expand Down Expand Up @@ -268,6 +277,15 @@
it 'is allowed to add a new station to a broadcasts' do
expect { action }.to(change { Broadcast.find(0).stations.to_a }.from([]).to([dasErste]))
end

context 'as contributor' do
let(:user) { create(:user, role: :contributor) }
describe '#create' do
it 'turns the editor into a moderator' do
expect { action }.to(change{user.role}.from('contributor').to('moderator'))
end
end
end
end

describe 'remove stations' do
Expand Down

0 comments on commit dcf3649

Please sign in to comment.