-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
- Loading branch information
1 parent
6d6ad56
commit 91de341
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ContestsController do | ||
describe '#contest' do | ||
context 'when variable assigned' do | ||
before { controller.instance_variable_set :@contest, :contest } | ||
|
||
its(:contest) { should eq :contest } | ||
end | ||
|
||
context 'when created' do | ||
let(:contest) { create :contest } | ||
|
||
before do | ||
allow(controller).to receive(:params).and_return(id: contest.id.to_s) | ||
end | ||
|
||
its(:contest) { should eq contest } | ||
end | ||
end | ||
|
||
describe '#collection' do | ||
context 'when variable assigned' do | ||
before { controller.instance_variable_set :@collection, :collection } | ||
|
||
its(:collection) { should eq :collection } | ||
end | ||
|
||
context 'without active contest' do | ||
let(:contest) { create :contest, archived: true } | ||
|
||
before do | ||
create :contest, archived: false, upload_open: false, registration_open: false | ||
end | ||
|
||
its(:collection) { should eq [contest] } | ||
end | ||
|
||
context 'with active contest' do | ||
before do | ||
create :contest, archived: true | ||
create :contest, archived: false, upload_open: true, registration_open: true | ||
end | ||
|
||
its(:collection) { should be_empty } | ||
end | ||
end | ||
end |