Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a spec for Admin::AwardsController #448

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions spec/controllers/admin/awards_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'rails_helper'

RSpec.describe Admin::AwardsController, type: :controller do
include Devise::Test::ControllerHelpers

let(:contest) { create(:contest_holding) }

describe 'GET #index' do
subject { get :index, params: { contest_id: contest.id } }

context 'when the user does not login' do
it 'raise routing error' do
expect { subject }.to raise_error(ActionController::RoutingError, 'not found')
end
end

context 'when the normal user logins' do
before { sign_in(user) }
let(:user) { create(:user) }
it 'raise routing error' do
expect { subject }.to raise_error(ActionController::RoutingError, 'not found')
end
end

context 'when the admin user logins' do
before { sign_in(user) }
let(:user) { create(:admin_user) }
it 'return 200' do
expect(response.status).to eq 200
end
end
end
end