implemented partial batch update for exercises
This commit is contained in:
@@ -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 } }
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user