diff --git a/Gemfile b/Gemfile index 3a5e5a77..7a2c1f37 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ group :test do gem 'factory_bot_rails' gem 'mocha' + gem 'rails-controller-testing' gem 'shoulda-matchers' gem 'timecop' end diff --git a/Gemfile.lock b/Gemfile.lock index e7139dd0..b706e450 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,6 +177,10 @@ GEM bundler (>= 1.3.0) railties (= 5.0.7.2) sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -289,6 +293,7 @@ DEPENDENCIES pg puma rails (~> 5.0.7.2) + rails-controller-testing render_anywhere rollbar rspec-rails (~> 3.8) diff --git a/test/controllers/admin/svie_controller_test.rb b/test/controllers/admin/svie_controller_test.rb index d4b74c1b..cbe0d842 100644 --- a/test/controllers/admin/svie_controller_test.rb +++ b/test/controllers/admin/svie_controller_test.rb @@ -1,7 +1,7 @@ require 'test_helper' module Admin - class SvieControllerTest < ActionController::TestCase + class SvieControllerTest < ActionDispatch::IntegrationTest test 'applications page enabled for rvt members' do login_as_user(:rvt_member) get :index diff --git a/test/controllers/auth_sch_services_controller_test.rb b/test/controllers/auth_sch_services_controller_test.rb index 6447396c..908c6fc6 100644 --- a/test/controllers/auth_sch_services_controller_test.rb +++ b/test/controllers/auth_sch_services_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class AuthSchServicesControllerTest < ActionController::TestCase +class AuthSchServicesControllerTest < ActionDispatch::IntegrationTest test 'basic data with invalid id' do get :sync, id: 'invalidid' diff --git a/test/controllers/evaluations_controller_test.rb b/test/controllers/evaluations_controller_test.rb index da55a8c9..c4b8affd 100644 --- a/test/controllers/evaluations_controller_test.rb +++ b/test/controllers/evaluations_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class EvaluationsControllerTest < ActionController::TestCase +class EvaluationsControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:evaluation_giver) end diff --git a/test/controllers/groups_controller_test.rb b/test/controllers/groups_controller_test.rb index c59872d6..b9725351 100644 --- a/test/controllers/groups_controller_test.rb +++ b/test/controllers/groups_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class GroupsControllerTest < ActionController::TestCase +class GroupsControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:sanyi) end diff --git a/test/controllers/membership_controller_test.rb b/test/controllers/membership_controller_test.rb index bb0ee179..6477a2ad 100644 --- a/test/controllers/membership_controller_test.rb +++ b/test/controllers/membership_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class MembershipsControllerTest < ActionController::TestCase +class MembershipsControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:babhamozo_leader) request.env['HTTP_REFERER'] = 'http://test.host/groups/1' diff --git a/test/controllers/post_types_controller_test.rb b/test/controllers/post_types_controller_test.rb index 1d88d498..530399b2 100644 --- a/test/controllers/post_types_controller_test.rb +++ b/test/controllers/post_types_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class PostTypesControllerTest < ActionController::TestCase +class PostTypesControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:babhamozo_leader) request.env['HTTP_REFERER'] = 'http://test.host/groups/1' diff --git a/test/controllers/profiles_controller_test.rb b/test/controllers/profiles_controller_test.rb index 723179b1..7b37a90d 100644 --- a/test/controllers/profiles_controller_test.rb +++ b/test/controllers/profiles_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ProfilesControllerTest < ActionController::TestCase +class ProfilesControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:sanyi) end diff --git a/test/controllers/registration_controller_test.rb b/test/controllers/registration_controller_test.rb index 1ac374a3..59208eba 100644 --- a/test/controllers/registration_controller_test.rb +++ b/test/controllers/registration_controller_test.rb @@ -1,13 +1,13 @@ require 'test_helper' -class RegistrationControllerTest < ActionController::TestCase +class RegistrationControllerTest < ActionDispatch::IntegrationTest setup do - session[:oauth_data] = { - 'internal_id' => 'abc', - 'mail' => 'abc@def.gh', - 'givenName' => 'Károly', - 'sn' => 'Alma' - } + # session[:oauth_data] = { + # 'internal_id' => 'abc', + # 'mail' => 'abc@def.gh', + # 'givenName' => 'Károly', + # 'sn' => 'Alma' + # } end test 'show registration page' do diff --git a/test/controllers/search_controller_test.rb b/test/controllers/search_controller_test.rb index fb958dba..047363e0 100644 --- a/test/controllers/search_controller_test.rb +++ b/test/controllers/search_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class SearchControllerTest < ActionController::TestCase +class SearchControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:sanyi) end diff --git a/test/controllers/svie_controller_test.rb b/test/controllers/svie_controller_test.rb index 5b957223..5a74a93e 100644 --- a/test/controllers/svie_controller_test.rb +++ b/test/controllers/svie_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class SvieControllerTest < ActionController::TestCase +class SvieControllerTest < ActionDispatch::IntegrationTest setup do login_as_user(:user_with_primary_membership) end diff --git a/test/integration/point_history_calculation_test.rb b/test/integration/point_history_calculation_test.rb index 05b79d89..d6293223 100644 --- a/test/integration/point_history_calculation_test.rb +++ b/test/integration/point_history_calculation_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class PointHistoryCalculationTest < ActionController::TestCase +class PointHistoryCalculationTest < ActionDispatch::IntegrationTest test 'calculate point history at changing to offseason' do point_history_count = PointHistory.count diff --git a/test/models/group_test.rb b/test/models/group_test.rb index 4dc8292f..a3f6522b 100644 --- a/test/models/group_test.rb +++ b/test/models/group_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class GroupTest < ActionController::TestCase +class GroupTest < ActionDispatch::IntegrationTest test 'group is active when newly founded' do group = create(:group, :with_additional_info) time = Time.new(group.founded) diff --git a/test/models/membership_test.rb b/test/models/membership_test.rb index 468be140..40f2cd9f 100644 --- a/test/models/membership_test.rb +++ b/test/models/membership_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class MembershipTest < ActionController::TestCase +class MembershipTest < ActionDispatch::IntegrationTest test 'delegation became false when archive' do user = create(:user, :who_delegated) membership = user.primary_membership diff --git a/test/models/point_detail_test.rb b/test/models/point_detail_test.rb index 9c1c71e0..423a0ae9 100644 --- a/test/models/point_detail_test.rb +++ b/test/models/point_detail_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class PointDetailTest < ActionController::TestCase +class PointDetailTest < ActionDispatch::IntegrationTest test 'save point less then zero will be zero' do point_detail = create(:point_detail) diff --git a/test/models/semester_test.rb b/test/models/semester_test.rb index f907cc1b..8a891544 100644 --- a/test/models/semester_test.rb +++ b/test/models/semester_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class SemesterTest < ActionController::TestCase +class SemesterTest < ActionDispatch::IntegrationTest test 'converting from and to string' do assert_equal '201620171', Semester.new('201620171').to_s end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index a501c806..5f2081ab 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class UserTest < ActionController::TestCase +class UserTest < ActionDispatch::IntegrationTest # test 'test cellphone format invalid' do # user = users(:sanyi) # user.cell_phone = 'asdf' diff --git a/test/test_helper.rb b/test/test_helper.rb index f4c31869..3d1d3144 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,7 @@ require File.expand_path('../config/environment', __dir__) require 'rails/test_help' require 'mocha/minitest' +require_relative '../spec/support/authentication_helper.rb' module ActiveSupport class TestCase @@ -15,6 +16,7 @@ class TestCase # Add more helper methods to be used by all tests here... def login_as_user(user_name) + # AuthenticationHelper.login_as(users(user_name)) session[:user_id] = users(user_name).id end end