Skip to content

Commit

Permalink
Add Controller Tests
Browse files Browse the repository at this point in the history
Co-authored-by: viehlieb <[email protected]>
Co-authored-by: Tobias Kneuker <[email protected]>
  • Loading branch information
3 people committed Nov 28, 2022
1 parent 427561e commit e34bf55
Showing 16 changed files with 1,119 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -112,6 +112,7 @@ group :test do
gem 'rspec-core'
gem 'rspec-rerun'
gem 'i18n-spec'
gem 'rails-controller-testing'
# code coverage
gem 'simplecov', require: false
gem 'simplecov-lcov', require: false
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -350,6 +350,10 @@ GEM
sprockets-rails (>= 2.0.0)
rails-assets-listjs (0.2.0.beta.4)
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)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
@@ -606,6 +610,7 @@ DEPENDENCIES
rack-cors
rails (~> 5.2)
rails-assets-listjs (= 0.2.0.beta.4)
rails-controller-testing
rails-i18n
rails-settings-cached (= 0.4.3)
rails_tokeninput
6 changes: 3 additions & 3 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ def reference_calculator
@bank_accounts = @types.includes(:bank_account).map(&:bank_account).uniq.compact
@bank_accounts = [BankAccount.last] if @bank_accounts.empty?
else
redirect_to root_url, alert: I18n.t('group_orders.errors.no_member')
redirect_to root_path, alert: I18n.t('group_orders.errors.no_member')
end
end

def update_profile
if @current_user.update(user_params)
@current_user.ordergroup.update(ordergroup_params) if ordergroup_params
session[:locale] = @current_user.locale
redirect_to my_profile_url, notice: I18n.t('home.changes_saved')
redirect_to my_profile_path, notice: I18n.t('home.changes_saved')
else
render :profile
end
@@ -64,7 +64,7 @@ def ordergroup
# cancel personal memberships direct from the myProfile-page
def cancel_membership
if params[:membership_id]
membership = @current_user.memberships.find!(params[:membership_id])
membership = @current_user.memberships.find(params[:membership_id])
else
membership = @current_user.memberships.find_by_group_id!(params[:group_id])
end
12 changes: 12 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'spec_helper'

describe ApplicationController, type: :controller do
describe 'current' do
it 'returns current ApplicationController' do
described_class.new.send(:store_controller)
expect(described_class.current).to be_instance_of described_class
end
end
end
Loading

0 comments on commit e34bf55

Please sign in to comment.