This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing allocation decorator and adding AllocationController tests
- Loading branch information
Showing
4 changed files
with
60 additions
and
38 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
49 changes: 49 additions & 0 deletions
49
spec/controllers/new_admin/allocation_chart_controller_spec.rb
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,49 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe NewAdmin::AllocationChartController do | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
allow(controller).to receive(:authenticate_user!) | ||
allow(controller).to receive(:current_user).and_return(user) | ||
end | ||
|
||
describe 'GET #index' do | ||
context 'when there are no allocations' do | ||
it 'returns successful status' do | ||
get :index | ||
|
||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'returns users within an empty allocation' do | ||
get :index | ||
|
||
expect(subject.instance_variable_get(:@allocations)).to include(having_attributes(user_id: user.id)) | ||
end | ||
end | ||
|
||
context 'when there are active allocations' do | ||
let!(:allocation) { create(:allocation, | ||
start_at: 2.months.after, | ||
end_at: 3.months.after, | ||
user: user, | ||
ongoing: true) } | ||
|
||
|
||
it 'returns successful status' do | ||
get :index | ||
|
||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'returns allocations' do | ||
get :index | ||
|
||
expect(subject.instance_variable_get(:@allocations)).to include(allocation) | ||
end | ||
end | ||
end | ||
end |
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