From 71c8dd412749c32bd8c708d61286cff8f0b41cb4 Mon Sep 17 00:00:00 2001 From: Nishanth Vijayan Date: Sat, 6 Aug 2016 18:48:36 +0530 Subject: [PATCH] Add controller tests for admin::versions#index --- .../controllers/admin/versions_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/controllers/admin/versions_controller_spec.rb b/spec/controllers/admin/versions_controller_spec.rb index 4694837d..d2baec3d 100644 --- a/spec/controllers/admin/versions_controller_spec.rb +++ b/spec/controllers/admin/versions_controller_spec.rb @@ -97,5 +97,20 @@ describe Admin::VersionsController do expect(flash[:error]).to match('Revert failed. Attribute missing or invalid') end end + + describe 'GET #index' do + it 'raises error if conference_id is invalid' do + sign_in admin + get :index, conference_id: 88 + expect(flash[:error]).to match('Conference with ID 88 does not exist!') + end + + it 'raises error if user is not an organizer of specified conference' do + user = create(:user) + sign_in user + get :index, conference_id: conference.id + expect(flash[:alert]).to match('You are not authorized to access this area.') + end + end end end