Sha256: d930f0aedcde665c2fbc6d0567224ffbe37b94a57362f1d328e813991e9d2418
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require 'support/models/authorizy_cop' require 'support/models/empty_cop' require 'support/controllers/admin/dummy_controller' RSpec.describe Admin::DummyController, '#authorizy', type: :controller do let!(:parameters) { ActionController::Parameters.new(key: 'value', controller: 'admin/users', action: 'action') } let!(:user) { User.new } context 'when cop responds to the controller name' do context 'when method resturns false' do it 'denies the access' do config_mock(cop: AuthorizyCop, current_user: user) do get :action, params: { admin: false } end expect(response).to redirect_to('/') end end context 'when method resturns true' do it 'denies the access' do config_mock(cop: AuthorizyCop, current_user: user) do get :action, params: { admin: true } end expect(response.body).to eq('{"message":"authorized"}') end end end context 'when cop responds to the controller name' do it 'denies the access' do config_mock(cop: EmptyCop, current_user: user) do get :action end expect(response).to redirect_to('/') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
authorizy-0.1.0 | spec/authorizy/cop/namespaced_controller_spec.rb |