Skip to content

Commit

Permalink
add test case of questionnares_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbibiwang committed Dec 6, 2019
1 parent 876c0ad commit 9fbd58f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions spec/controllers/questionnaires_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ def check_access username
let(:questionnaire) { build(:questionnaire, id: 1) }
let(:instructor) { build(:instructor, id: 1) }
let(:ta) { build(:teaching_assistant, id: 10, parent_id: 66) }
context 'when params action is edit or update' do
let(:student) {build(:student, id: 1)}
context 'when params action is edit or update and role current user is not student' do
before(:each) do
controller.params = {id: '1', action: 'edit'}
controller.request.session[:user] = instructor
end

context 'when the role name of current user is super admin or admin' do
it 'allows certain action' do
check_access(admin).to be true
Expand Down Expand Up @@ -70,6 +71,14 @@ def check_access username
end
end
end
context 'when params action is edit or update and role current user is student and questionnaire is Supplementary Review Questionnaire' do

it 'allows certain action' do
questionnaire = create(:questionnaire, type: "SupplementaryReviewQuestionnaire")
check_access(student).to be true
end

end
context 'when params action is not edit and update' do
before(:each) do
controller.params = {id: '1', action: 'new'}
Expand Down

0 comments on commit 9fbd58f

Please sign in to comment.