Skip to content

Commit

Permalink
Change permissions for updating
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalshah committed Feb 26, 2018
1 parent 08d0873 commit 659540c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions dashboard/app/models/ability.rb
Expand Up @@ -106,6 +106,7 @@ def initialize(user)
workshop.facilitators.include? user
end
can [:read, :start, :end, :workshop_survey_report, :summary, :filter], Pd::Workshop, facilitators: {id: user.id}
can [:read, :update], Pd::Workshop, organizer_id: user.id
can :create, Pd::Workshop do |_|
Pd::CourseFacilitator.exists?(facilitator: user, course: Pd::Workshop::COURSE_CSF)
end
Expand Down
Expand Up @@ -327,9 +327,20 @@ class Api::V1::Pd::WorkshopsControllerTest < ::ActionController::TestCase
assert_response :forbidden
end

test 'Facilitators can update workshops they organized' do
sign_in(@facilitator)

workshop = create :pd_workshop, organizer: @facilitator
put :update, params: {
id: workshop.id,
pd_workshop: workshop_params
}
assert_response :success
end

test_user_gets_response_for(
:update,
name: 'facilitators cannot update workshops',
name: 'facilitators cannot update workshops they did not organize',
method: :put,
response: :forbidden,
user: -> {@facilitator},
Expand Down

0 comments on commit 659540c

Please sign in to comment.