implemented partial batch update for exercises

This commit is contained in:
Hauke Klement
2015-03-12 11:05:11 +01:00
parent f1de18141a
commit 6ee0b6bf81
9 changed files with 105 additions and 4 deletions

View File

@@ -5,6 +5,20 @@ describe ExercisesController do
let(:user) { FactoryGirl.create(:admin) }
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
describe 'PUT #batch_update' do
let(:attributes) { {public: true} }
let(:request) { proc { put :batch_update, exercises: {0 => attributes.merge(id: exercise.id)} } }
before(:each) { request.call }
it 'updates the exercises' do
expect_any_instance_of(Exercise).to receive(:update).with(attributes)
request.call
end
expect_json
expect_status(200)
end
describe 'POST #clone' do
let(:request) { proc { post :clone, id: exercise.id } }

View File

@@ -5,6 +5,15 @@ describe ExercisePolicy do
let(:exercise) { FactoryGirl.build(:dummy, team: FactoryGirl.create(:team)) }
permissions :batch_update? do
it 'grants access to admins only' do
expect(subject).to permit(FactoryGirl.build(:admin), exercise)
[:external_user, :teacher].each do |factory_name|
expect(subject).not_to permit(FactoryGirl.build(factory_name), exercise)
end
end
end
[:create?, :index?, :new?].each do |action|
permissions(action) do
it 'grants access to admins' do