remove assigns, render_template to respect controller test boundaries
This commit is contained in:
parent
f2965e6673
commit
33eec7aa25
3 changed files with 8 additions and 51 deletions
1
Gemfile
1
Gemfile
|
@ -112,7 +112,6 @@ group :test do
|
||||||
gem 'rspec-core'
|
gem 'rspec-core'
|
||||||
gem 'rspec-rerun'
|
gem 'rspec-rerun'
|
||||||
gem 'i18n-spec'
|
gem 'i18n-spec'
|
||||||
gem 'rails-controller-testing'
|
|
||||||
# code coverage
|
# code coverage
|
||||||
gem 'simplecov', require: false
|
gem 'simplecov', require: false
|
||||||
gem 'simplecov-lcov', require: false
|
gem 'simplecov-lcov', require: false
|
||||||
|
|
|
@ -350,10 +350,6 @@ GEM
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-assets-listjs (0.2.0.beta.4)
|
rails-assets-listjs (0.2.0.beta.4)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
rails-controller-testing (1.0.5)
|
|
||||||
actionpack (>= 5.0.1.rc1)
|
|
||||||
actionview (>= 5.0.1.rc1)
|
|
||||||
activesupport (>= 5.0.1.rc1)
|
|
||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
|
@ -610,7 +606,6 @@ DEPENDENCIES
|
||||||
rack-cors
|
rack-cors
|
||||||
rails (~> 5.2)
|
rails (~> 5.2)
|
||||||
rails-assets-listjs (= 0.2.0.beta.4)
|
rails-assets-listjs (= 0.2.0.beta.4)
|
||||||
rails-controller-testing
|
|
||||||
rails-i18n
|
rails-i18n
|
||||||
rails-settings-cached (= 0.4.3)
|
rails-settings-cached (= 0.4.3)
|
||||||
rails_tokeninput
|
rails_tokeninput
|
||||||
|
@ -647,4 +642,4 @@ DEPENDENCIES
|
||||||
whenever
|
whenever
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.17.3
|
2.4.5
|
||||||
|
|
|
@ -14,16 +14,12 @@ describe HomeController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'logegd in' do
|
describe 'logged in' do
|
||||||
before { login user }
|
before { login user }
|
||||||
|
|
||||||
it 'assigns tasks' do
|
it 'succeeds' do
|
||||||
get_with_defaults :index
|
get_with_defaults :index
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
expect(assigns(:unaccepted_tasks)).not_to be_nil
|
|
||||||
expect(assigns(:next_tasks)).not_to be_nil
|
|
||||||
expect(assigns(:unassigned_tasks)).not_to be_nil
|
|
||||||
expect(response).to render_template('home/index')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -31,10 +27,9 @@ describe HomeController, type: :controller do
|
||||||
describe 'GET profile' do
|
describe 'GET profile' do
|
||||||
before { login user }
|
before { login user }
|
||||||
|
|
||||||
it 'renders dashboard' do
|
it 'succeeds' do
|
||||||
get_with_defaults :profile
|
get_with_defaults :profile
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to render_template('home/profile')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,10 +49,9 @@ describe HomeController, type: :controller do
|
||||||
|
|
||||||
before { login og_user }
|
before { login og_user }
|
||||||
|
|
||||||
it 'renders reference calculator' do
|
it 'succeeds' do
|
||||||
get_with_defaults :reference_calculator
|
get_with_defaults :reference_calculator
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to render_template('home/reference_calculator')
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -70,11 +64,9 @@ describe HomeController, type: :controller do
|
||||||
|
|
||||||
before { login user }
|
before { login user }
|
||||||
|
|
||||||
it 'renders profile after update with invalid attributes' do
|
it 'stays on profile after update with invalid attributes' do
|
||||||
get_with_defaults :update_profile, params: { user: invalid_attributes }
|
get_with_defaults :update_profile, params: { user: invalid_attributes }
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to render_template('home/profile')
|
|
||||||
expect(assigns(:current_user).errors.present?).to be true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to profile after update with unchanged attributes' do
|
it 'redirects to profile after update with unchanged attributes' do
|
||||||
|
@ -124,38 +116,9 @@ describe HomeController, type: :controller do
|
||||||
|
|
||||||
before { login og_user }
|
before { login og_user }
|
||||||
|
|
||||||
it 'renders ordergroup' do
|
it 'succeeds' do
|
||||||
get_with_defaults :ordergroup
|
get_with_defaults :ordergroup
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(response).to render_template('home/ordergroup')
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'assigns sortings' do
|
|
||||||
let(:fin_trans1) { create :financial_transaction, user: og_user, ordergroup: og_user.ordergroup, note: 'A', amount: 200, created_on: Time.now }
|
|
||||||
let(:fin_trans2) { create :financial_transaction, user: og_user, ordergroup: og_user.ordergroup, note: 'B', amount: 100, created_on: Time.now + 2.minutes }
|
|
||||||
let(:fin_trans3) { create :financial_transaction, user: og_user, ordergroup: og_user.ordergroup, note: 'C', amount: 50, created_on: Time.now + 1.minute }
|
|
||||||
|
|
||||||
before do
|
|
||||||
fin_trans1
|
|
||||||
fin_trans2
|
|
||||||
fin_trans3
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'by criteria' do
|
|
||||||
sortings = [
|
|
||||||
['date', [fin_trans1, fin_trans3, fin_trans2]],
|
|
||||||
['note', [fin_trans1, fin_trans2, fin_trans3]],
|
|
||||||
['amount', [fin_trans3, fin_trans2, fin_trans1]],
|
|
||||||
['date_reverse', [fin_trans2, fin_trans3, fin_trans1]],
|
|
||||||
['note_reverse', [fin_trans3, fin_trans2, fin_trans1]],
|
|
||||||
['amount_reverse', [fin_trans1, fin_trans2, fin_trans3]]
|
|
||||||
]
|
|
||||||
sortings.each do |sorting|
|
|
||||||
get_with_defaults :ordergroup, params: { sort: sorting[0] }
|
|
||||||
expect(response).to have_http_status(:success)
|
|
||||||
expect(assigns(:financial_transactions).to_a).to eq(sorting[1])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue