Skip to content

Commit

Permalink
Merge pull request #823 from sparc-request/saw-dashboard-subsidy-specs
Browse files Browse the repository at this point in the history
SAW - Some dashboard subsidy specs
  • Loading branch information
jayhardee9 committed Dec 15, 2016
2 parents 3f8b662 + e827b4d commit ed12e4d
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
68 changes: 68 additions & 0 deletions spec/controllers/dashboard/subsidies/get_edit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright © 2011-2016 MUSC Foundation for Research Development~
# All rights reserved.~

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.~

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following~
# disclaimer in the documentation and/or other materials provided with the distribution.~

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products~
# derived from this software without specific prior written permission.~

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,~
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT~
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL~
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

require 'rails_helper'

RSpec.describe Dashboard::SubsidiesController do
describe 'GET #edit' do
before(:each) do
@current_user = build_stubbed(:identity)
log_in_dashboard_identity(obj: @current_user)
@protocol = create(:protocol_without_validations,
primary_pi: @current_user)
@organization = create(:organization)
@subsidy_map = create(:subsidy_map,
default_percentage: 5,
organization: @organization)
@service_request = create(:service_request_without_validations,
protocol: @protocol)
@ssr = create(:sub_service_request_without_validations,
service_request: @service_request,
organization: @organization,
status: 'draft')
@pending_subsidy = create(:pending_subsidy,
sub_service_request_id: @ssr.id,
percent_subsidy: 0.1)
xhr :get, :edit, admin: 'true', id: @pending_subsidy.id, format: :js
end

it { is_expected.to render_template "dashboard/subsidies/edit" }

it 'should set @admin to params[:admin]' do
expect(assigns(:admin)).to eq(true)
end

it 'should set @subsidy to the existing PendingSubsidy' do
expect(assigns(:subsidy)).to eq(PendingSubsidy.find(@pending_subsidy.id))
end

it 'should set @path to the dashboard subsidy path for @subsidy' do
expect(assigns(:path)).to eq(dashboard_subsidy_path(assigns(:subsidy)))
end

it 'should assign header text' do
expect(assigns(:header_text)).to be
end

it 'should assign @action to edit' do
expect(assigns(:action)).to eq('edit')
end
end
end
63 changes: 63 additions & 0 deletions spec/controllers/dashboard/subsidies/get_new_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright © 2011-2016 MUSC Foundation for Research Development~
# All rights reserved.~

# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:~

# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.~

# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following~
# disclaimer in the documentation and/or other materials provided with the distribution.~

# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products~
# derived from this software without specific prior written permission.~

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,~
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT~
# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL~
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS~
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR~
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.~

require 'rails_helper'

RSpec.describe Dashboard::SubsidiesController do
describe 'GET #new' do
before(:each) do
@current_user = build_stubbed(:identity)
log_in_dashboard_identity(obj: @current_user)
@protocol = create(:protocol_without_validations,
primary_pi: @current_user)
@organization = create(:organization)
@subsidy_map = create(:subsidy_map,
default_percentage: 5,
organization: @organization)
@service_request = create(:service_request_without_validations,
protocol: @protocol)
@ssr = create(:sub_service_request_without_validations,
service_request: @service_request,
organization: @organization,
status: 'draft')
xhr :get, :new, admin: 'true', sub_service_request_id: @ssr.id, format: :js
end

it { is_expected.to render_template "dashboard/subsidies/new" }

it 'should set @admin to params[:admin]' do
expect(assigns(:admin)).to eq(true)
end

it 'should set @subsidy to a new PendingSubsidy with default percentage and the current SSR id' do
expect(assigns(:subsidy).class.name).to eq('PendingSubsidy')
expect(assigns(:subsidy).sub_service_request_id).to eq(@ssr.id)
expect(assigns(:subsidy).percent_subsidy).to eq(@subsidy_map.default_percentage)
end

it 'should assign header text' do
expect(assigns(:header_text)).to be
end

it 'should assign @action to new' do
expect(assigns(:action)).to eq('new')
end
end
end

0 comments on commit ed12e4d

Please sign in to comment.