From e18d6f47b58251f264203be5919dc192b3878a24 Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 21 Nov 2021 19:08:50 +0100 Subject: [PATCH 1/4] ImportExportHelper ignores unknown attributes --- app/lib/import_export_helper.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/lib/import_export_helper.rb b/app/lib/import_export_helper.rb index c976acb7e..bdd68fdfe 100644 --- a/app/lib/import_export_helper.rb +++ b/app/lib/import_export_helper.rb @@ -68,7 +68,7 @@ def run_import(export_dir = EXPORT_DIR) unpack_paperclip_files restore_all_data end - + enable_callbacks end @@ -191,7 +191,7 @@ def restore_conference_data obj.attachable_id = @conference_id obj.save! end - + restore_multiple('conference_review_metrics', ReviewMetric) do |id, obj| obj.conference_id = @conference_id obj.save! @@ -330,7 +330,9 @@ def restore(name, obj) def restore_multiple(name, obj) records = read_yaml_from_file(name) records.each do |record| - tmp = obj.new(record) + tmp = obj.new + record.select! { |k, _| tmp.attributes.keys.member?(k.to_s) } + tmp.attributes = record tmp.id = nil yield record['id'], tmp end @@ -397,7 +399,7 @@ def disable_callbacks EventRating.skip_callback(:save, :after, :update_average) EventFeedback.skip_callback(:save, :after, :update_average) end - + def enable_callbacks EventPerson.set_callback(:save, :after, :update_speaker_count) Event.set_callback(:save, :after, :update_conflicts) @@ -405,7 +407,7 @@ def enable_callbacks EventRating.set_callback(:save, :after, :update_average) EventFeedback.set_callback(:save, :after, :update_average) end - + def update_counters ActiveRecord::Base.connection.execute("UPDATE events SET speaker_count=(SELECT count(*) FROM event_people WHERE events.id=event_people.event_id AND event_people.event_role='speaker')") update_event_average('event_ratings', 'average_rating') From 210213af876f81c2e9ef549872000cfe9efa2210 Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sat, 27 Nov 2021 22:49:28 +0100 Subject: [PATCH 2/4] Less rubocop style hints --- .rubocop.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7fe3daa6d..37cbf9f88 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 Exclude: - bin/**/* - contrib/**/* @@ -94,3 +94,9 @@ Layout/MultilineMethodCallIndentation: # Load order is important Bundler/OrderedGems: Enabled: false + +Style/PercentLiteralDelimiters: + Enabled: false + +Layout/EmptyLineAfterGuardClause: + Enabled: false From cc6ba653dd768a5401fa8bb7ff91a844953df7ff Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 14 Nov 2021 15:02:15 +0100 Subject: [PATCH 3/4] Fix global locale change in static export --- app/lib/static_schedule/export.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/lib/static_schedule/export.rb b/app/lib/static_schedule/export.rb index 05fe0e620..64ccad3ab 100644 --- a/app/lib/static_schedule/export.rb +++ b/app/lib/static_schedule/export.rb @@ -16,9 +16,10 @@ def initialize(conference, locale = 'en', destination = EXPORT_PATH) @locale = locale || 'en' @destination = destination || EXPORT_PATH - I18n.locale = @locale - @renderer = ProgramRenderer.new(@conference, @locale) - @pages = Pages.new(@renderer, @conference) + I18n.with_locale(@locale) do + @renderer = ProgramRenderer.new(@conference, @locale) + @pages = Pages.new(@renderer, @conference) + end end # create a tarball from the conference export directory @@ -46,7 +47,9 @@ def run_export unlock_schedule unless @original_schedule_public setup_directories - download_pages + I18n.with_locale(@locale) do + download_pages + end copy_stripped_assets copy_static_assets From b42a3d4c439300d10c7b0c2d78e794e3bd760f54 Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 28 Nov 2021 15:58:44 +0100 Subject: [PATCH 4/4] Replace feature tests with Rails system tests * poltergeist is deprecated * Rails 5 has good support for selenium --- .github/workflows/ci.yaml | 8 ++ Gemfile | 7 +- Gemfile.lock | 57 ++++++------ app/helpers/events_helper.rb | 14 +-- test/application_system_test_case.rb | 17 ++++ test/features/can_access_home_test.rb | 13 --- test/features/editing_event_review_test.rb | 49 ---------- test/support/capybara_helper.rb | 9 +- test/{features => system}/bulk_edit_test.rb | 12 +-- test/system/can_access_home_test.rb | 13 +++ .../can_delete_conference_test.rb | 10 ++- test/{features => system}/can_login_test.rb | 4 +- test/{features => system}/cfp_account_test.rb | 4 +- .../cfp_can_edit_event_test.rb | 6 +- .../classifiers_ui_test.rb | 8 +- .../editing_conference_test.rb | 14 +-- .../editing_event_people_test.rb} | 17 ++-- .../editing_event_rating_test.rb | 10 ++- test/system/editing_event_review_test.rb | 51 +++++++++++ .../editing_events_test.rb | 4 +- .../editing_users_test.rb | 6 +- test/{features => system}/event_join_test.rb | 10 +-- .../export_profile_test.rb | 7 +- .../filter_and_send_mail_test.rb | 24 ++--- .../filtering_event_list_test.rb} | 30 +++---- test/{features => system}/ldap_test.rb | 6 +- .../orga_adds_conference_user_test.rb | 6 +- .../sorting_event_list_test.rb | 6 +- .../{features => system}/submit_event_test.rb | 4 +- .../rake_task_export_attachments_test.rb | 41 ++++----- ...rake_task_export_import_conference_test.rb | 90 +++++++++---------- test/test_helper.rb | 16 ++-- 32 files changed, 302 insertions(+), 271 deletions(-) create mode 100644 test/application_system_test_case.rb delete mode 100644 test/features/can_access_home_test.rb delete mode 100644 test/features/editing_event_review_test.rb rename test/{features => system}/bulk_edit_test.rb (78%) create mode 100644 test/system/can_access_home_test.rb rename test/{features => system}/can_delete_conference_test.rb (54%) rename test/{features => system}/can_login_test.rb (78%) rename test/{features => system}/cfp_account_test.rb (85%) rename test/{features => system}/cfp_can_edit_event_test.rb (90%) rename test/{features => system}/classifiers_ui_test.rb (91%) rename test/{features => system}/editing_conference_test.rb (82%) rename test/{features/editing_event_people.rb => system/editing_event_people_test.rb} (61%) rename test/{features => system}/editing_event_rating_test.rb (76%) create mode 100644 test/system/editing_event_review_test.rb rename test/{features => system}/editing_events_test.rb (90%) rename test/{features => system}/editing_users_test.rb (88%) rename test/{features => system}/event_join_test.rb (96%) rename test/{features => system}/export_profile_test.rb (71%) rename test/{features => system}/filter_and_send_mail_test.rb (83%) rename test/{features/filtering_event_list.rb => system/filtering_event_list_test.rb} (84%) rename test/{features => system}/ldap_test.rb (93%) rename test/{features => system}/orga_adds_conference_user_test.rb (83%) rename test/{features => system}/sorting_event_list_test.rb (93%) rename test/{features => system}/submit_event_test.rb (95%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6e8cbae3c..b169faf20 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -85,5 +85,13 @@ jobs: sh -c "[ '$DB' != 'sqlite' ] || diff db/schema.rb db/schema.rb.original " bundle exec rails db:test:prepare bundle exec rails test + bundle exec rails test:system env: DB: ${{ matrix.db }} + + - uses: actions/upload-artifact@v2 + if: failure() + with: + name: screenshots-${{matrix.ruby_version}}-${{matrix.db}} + path: tmp/screenshots/* + retention-days: 5 diff --git a/Gemfile b/Gemfile index 79b229668..1a62ff7ff 100644 --- a/Gemfile +++ b/Gemfile @@ -105,8 +105,11 @@ group :test do gem 'factory_bot_rails', '~> 6.2' gem 'database_cleaner-active_record' gem 'rails-controller-testing' - gem 'minitest-rails-capybara' - gem 'poltergeist' + + gem 'capybara', '>= 3.26' + gem 'selenium-webdriver' + # Easy installation and use of web drivers to run system tests with browsers + gem 'webdrivers' end group :doc, optional: true do diff --git a/Gemfile.lock b/Gemfile.lock index 15a5be7b0..732d2012a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,7 +74,7 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) aes_key_wrap (1.0.1) airbrussh (1.4.0) @@ -108,17 +108,18 @@ GEM capistrano (~> 3.7) capistrano-bundler puma (~> 4.0) - capybara (3.32.2) + capybara (3.36.0) addressable + matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.5) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (4.1.0) chunky_png (1.4.0) climate_control (0.2.0) - cliver (0.3.2) cocoon (1.2.15) coderay (1.1.3) coffee-rails (5.0.0) @@ -232,6 +233,7 @@ GEM mail (2.6.6) mime-types (>= 1.16, < 4) marcel (1.0.1) + matrix (0.4.2) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) @@ -239,23 +241,9 @@ GEM mimemagic (0.3.10) nokogiri (~> 1) rake - mini_mime (1.0.2) - mini_portile2 (2.5.3) + mini_mime (1.1.2) + mini_portile2 (2.6.1) minitest (5.14.4) - minitest-capybara (0.9.0) - capybara - minitest (~> 5.0) - rake - minitest-metadata (0.6.0) - minitest (>= 4.7, < 6.0) - minitest-rails (3.0.0) - minitest (~> 5.8) - railties (~> 5.0) - minitest-rails-capybara (3.0.2) - capybara (>= 2.7, <= 4) - minitest-capybara (~> 0.8) - minitest-metadata (~> 0.6) - minitest-rails (~> 3.0) msgpack (1.4.2) multi_json (1.15.0) multi_xml (0.6.0) @@ -266,8 +254,8 @@ GEM net-ssh (>= 2.6.5, < 7.0.0) net-ssh (6.1.0) nio4r (2.5.8) - nokogiri (1.11.7) - mini_portile2 (~> 2.5.0) + nokogiri (1.12.5) + mini_portile2 (~> 2.6.1) racc (~> 1.4) oauth2 (1.4.7) faraday (>= 0.8, < 2.0) @@ -311,10 +299,6 @@ GEM ast (~> 2.4.1) pdf-core (0.1.6) pg (1.2.3) - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) prawn (0.15.0) pdf-core (~> 0.1.3) ttfunk (~> 1.1.0) @@ -329,13 +313,13 @@ GEM pry (~> 0.13.0) pry-rails (0.3.9) pry (>= 0.10.4) - public_suffix (4.0.5) + public_suffix (4.0.6) puma (4.3.10) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) pyu-ruby-sasl (0.0.3.3) - racc (1.5.2) + racc (1.6.0) rack (2.2.3) rack-oauth2 (1.10.1) activesupport @@ -389,13 +373,14 @@ GEM rb-kqueue (0.2.6) ffi (>= 0.5.0) redcarpet (3.5.1) - regexp_parser (1.7.1) + regexp_parser (2.1.1) repost (0.3.8) request_store (1.5.0) rack (>= 1.4) responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) + rexml (3.2.5) ri_cal (0.8.8) rqrcode (1.2.0) chunky_png (~> 1.0) @@ -403,6 +388,7 @@ GEM rqrcode_core (0.2.0) ruby2_keywords (0.0.4) rubyntlm (0.6.2) + rubyzip (2.3.2) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -415,6 +401,10 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) scanf (1.0.0) + selenium-webdriver (4.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2) simple_form (5.1.0) actionpack (>= 5.2) activemodel (>= 5.2) @@ -459,6 +449,10 @@ GEM public_suffix warden (1.2.9) rack (>= 2.0.9) + webdrivers (5.0.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0) webfinger (1.1.0) activesupport httpclient (>= 2.4) @@ -485,6 +479,7 @@ DEPENDENCIES capistrano-rails capistrano-rvm capistrano3-puma + capybara (>= 3.26) cocoon coffee-rails dalli @@ -508,7 +503,6 @@ DEPENDENCIES letter_opener listen localized_language_select! - minitest-rails-capybara mysql2 nokogiri omniauth-google-oauth2 @@ -516,7 +510,6 @@ DEPENDENCIES omniauth_openid_connect paper_trail pg - poltergeist prawn (< 1.0) prawn_rails pry-byebug @@ -535,11 +528,13 @@ DEPENDENCIES rqrcode sass-rails (< 6) scanf + selenium-webdriver simple_form sqlite3 sucker_punch transitions uglifier + webdrivers will_paginate yard diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index b307918f7..084def0de 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -8,7 +8,7 @@ def fix_http_proto(url) end def showing_my_events? - params[:events]=='my' + params[:events] == 'my' end def event_start_time @@ -23,7 +23,7 @@ def timeslots end slots end - + def timeslots_for_cfp @conference.allowed_event_timeslots.map{|slots| [format_time_slots(slots), slots]} end @@ -73,12 +73,12 @@ def show_filters_pane? end false end - + def localized_filter_options(c, i18n_scope) c = split_filter_string(c) if c.is_a? String - options = (c - ['',nil]).map{|v| [ if i18n_scope + options = (c - ['',nil]).map{|v| [ if i18n_scope t(v, scope: i18n_scope, default: v) - else + else v end, v] }.sort @@ -87,7 +87,7 @@ def localized_filter_options(c, i18n_scope) end options end - + def split_filter_string(s) return [''] if s=='' s.split('|', -1) @@ -98,7 +98,7 @@ def filter_link(qname, text='') class: [ 'show_events_modal', ('filter_icon' unless text.present?), params[qname].present? ] , data: { url: filter_modal_events_url(request.query_parameters.merge(which_filter: qname)) } end - + def get_op_and_val(str) /^(?[≤≥=]?)(?.*)$/ =~ str return op, val diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 000000000..43997733e --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,17 @@ +require "test_helper" + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + include CapybaraHelper + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] + + DatabaseCleaner.strategy = :truncation + + def setup + DatabaseCleaner.start + I18n.locale = I18n.default_locale + end + + def teardown + DatabaseCleaner.clean + end +end diff --git a/test/features/can_access_home_test.rb b/test/features/can_access_home_test.rb deleted file mode 100644 index 7f78b22a7..000000000 --- a/test/features/can_access_home_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'test_helper' - -feature 'CanAccessHome' do - scenario 'home page shows' do - visit root_path - assert_content page, 'frab' - end - - scenario 'home page shows when js is enabled', js: true do - visit root_path - assert_content page, 'frab' - end -end diff --git a/test/features/editing_event_review_test.rb b/test/features/editing_event_review_test.rb deleted file mode 100644 index 814d05822..000000000 --- a/test/features/editing_event_review_test.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'test_helper' - -class EditingEventReviewTest < FeatureTest - REVIEW_METRIC_NAME = 'optimistic :-)' - - setup do - @conference = create(:three_day_conference_with_review_metrics_and_events) - @event = @conference.events.last - @review_metric = @conference.review_metrics.first - - # When test start, three people already reviewed it - [2, 4, 5].each do |score| - reviewer = create(:conference_coordinator, conference: @conference) - event_rating = create(:event_rating, event: @event, person: reviewer.person) - create(:review_score, event_rating: event_rating, review_metric: @review_metric, score: score) - end - @event.save - - @coordinator = create(:conference_coordinator, conference: @conference) - @user = @coordinator.user - end - - it 'can edit review metrics and delete, calculate average', js:true do - # Test that when @user updates the review score, the average is updated correctly - sign_in_user(@user) - visit "/#{@conference.acronym}/events/#{@event.id}/event_rating" - find('form').find('div', text: @review_metric.name).find('span', text: '4').find('input').click() - click_on 'Create Event rating' - assert_content page, 'saved successfully' - - visit "/#{@conference.acronym}/events/ratings" - assert_content page, @review_metric.name - assert_content page, '3.75' # average([2,4,4,5]) - - # Test that filtering by review metric works - click_on '3.75' - assert_content page, '≥ 3.75' - assert_content page, @event.title - - # Test that when @user deletes the review, the average is updated correctly - visit "/#{@conference.acronym}/events/#{@event.id}/event_rating" - click_on 'Delete Event rating' - assert_content page, 'deleted successfully' - - visit "/#{@conference.acronym}/events/ratings" - assert_content page, @review_metric.name - assert_content page, '3.67' # average([2,4,5]) - end -end diff --git a/test/support/capybara_helper.rb b/test/support/capybara_helper.rb index feae92546..f112ad0c4 100644 --- a/test/support/capybara_helper.rb +++ b/test/support/capybara_helper.rb @@ -11,11 +11,8 @@ def sign_in_user(user) sign_in(user.email, 'frab123') end - def visit_conference_settings_for(conference) - click_on 'Conferences' - within find('tr', text: conference.title) do - click_on 'Show' - end - find('ul.nav:eq(2)').click_link('Settings') + def sign_out + click_on 'Account' + click_on 'Logout' end end diff --git a/test/features/bulk_edit_test.rb b/test/system/bulk_edit_test.rb similarity index 78% rename from test/features/bulk_edit_test.rb rename to test/system/bulk_edit_test.rb index 43f1e4325..48ef70515 100644 --- a/test/features/bulk_edit_test.rb +++ b/test/system/bulk_edit_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class BulkEditTest < FeatureTest +class BulkEditTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events_and_speakers) @event = @conference.events.last @@ -8,19 +8,21 @@ class BulkEditTest < FeatureTest @admin = create(:admin_user) end - it 'can bulk edit', js: true do + test 'can bulk edit' do sign_in_user(@admin) visit "/#{@conference.acronym}/events" click_on "odium" # podium or Podium assert_content page, 'Listing 1 of 3' - find('a', text: 'Edit these events').trigger('click') + find('a', text: 'Edit these events').click assert_content page, 'Edit 1 event:' select 'Change event type' find('form.bulk_edit_event_type').select 'Film', from: 'bulk_set_value' - find('form.bulk_edit_event_type').click_on 'Set' + accept_alert do + find('form.bulk_edit_event_type').click_on 'Set' + end assert_content page, 'edit completed successfully' assert_content page, 'yielded no results' diff --git a/test/system/can_access_home_test.rb b/test/system/can_access_home_test.rb new file mode 100644 index 000000000..8801b5708 --- /dev/null +++ b/test/system/can_access_home_test.rb @@ -0,0 +1,13 @@ +require 'application_system_test_case' + +class CanAccessHomeTest < ApplicationSystemTestCase + test 'home page shows' do + visit root_path + assert_content page, 'frab' + end + + test 'home page shows when js is enabled' do + visit root_path + assert_content page, 'frab' + end +end diff --git a/test/features/can_delete_conference_test.rb b/test/system/can_delete_conference_test.rb similarity index 54% rename from test/features/can_delete_conference_test.rb rename to test/system/can_delete_conference_test.rb index 6013893e1..1cf75f05a 100644 --- a/test/features/can_delete_conference_test.rb +++ b/test/system/can_delete_conference_test.rb @@ -1,17 +1,19 @@ -require 'test_helper' +require 'application_system_test_case' -class CanDeleteConferenceTest < FeatureTest +class CanDeleteConferenceTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference) @admin = create(:admin_user) end - it 'can delete conference', js: true do + test 'can delete conference' do sign_in_user(@admin) visit "/conferences?term=#{@conference.acronym}" assert_content page, @conference.acronym - find('tr', text: @conference.title).find('a', text: 'destroy').click + accept_alert do + find('tr', text: @conference.title).find('a', text: 'destroy').click + end assert_no_content page, @conference.acronym end diff --git a/test/features/can_login_test.rb b/test/system/can_login_test.rb similarity index 78% rename from test/features/can_login_test.rb rename to test/system/can_login_test.rb index e0495ab23..e63a466a6 100644 --- a/test/features/can_login_test.rb +++ b/test/system/can_login_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class CanLoginTest < FeatureTest +class CanLoginTest < ApplicationSystemTestCase setup do @admin = create(:admin_user) end diff --git a/test/features/cfp_account_test.rb b/test/system/cfp_account_test.rb similarity index 85% rename from test/features/cfp_account_test.rb rename to test/system/cfp_account_test.rb index 834ff5a44..4baee4ea8 100644 --- a/test/features/cfp_account_test.rb +++ b/test/system/cfp_account_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class CfpAccountTest < FeatureTest +class CfpAccountTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last diff --git a/test/features/cfp_can_edit_event_test.rb b/test/system/cfp_can_edit_event_test.rb similarity index 90% rename from test/features/cfp_can_edit_event_test.rb rename to test/system/cfp_can_edit_event_test.rb index 8c5b8b7c8..e6d009358 100644 --- a/test/features/cfp_can_edit_event_test.rb +++ b/test/system/cfp_can_edit_event_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class CfpCanEditEventTest < FeatureTest +class CfpCanEditEventTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last @@ -21,7 +21,7 @@ class CfpCanEditEventTest < FeatureTest assert_content page, 'A new title' #save_and_open_page end - + test 'presented with limited set of durations' do sign_in_user(@user) click_on 'Participate' diff --git a/test/features/classifiers_ui_test.rb b/test/system/classifiers_ui_test.rb similarity index 91% rename from test/features/classifiers_ui_test.rb rename to test/system/classifiers_ui_test.rb index 2944d707c..d8e75649b 100644 --- a/test/features/classifiers_ui_test.rb +++ b/test/system/classifiers_ui_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class ClassifiersUiTest < FeatureTest +class ClassifiersUiTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @admin = create(:admin_user) @@ -10,7 +10,7 @@ class ClassifiersUiTest < FeatureTest @classifier2 = create(:classifier, name: 'TestClassifier2', conference: @conference) end - it 'can toggle classifier', js: true do + test 'can toggle classifier' do sign_in_user(@admin) visit "/#{@conference.acronym}/events/#{@event.id}/edit" @@ -29,7 +29,7 @@ class ClassifiersUiTest < FeatureTest assert_content page, 'TestClassifier2' end - it 'can toggle off classifiers', js: true do + test 'can toggle off classifiers' do sign_in_user(@admin) visit "/#{@conference.acronym}/events/#{@event.id}/edit" assert_selector('.event_event_classifiers_value', count: 0) diff --git a/test/features/editing_conference_test.rb b/test/system/editing_conference_test.rb similarity index 82% rename from test/features/editing_conference_test.rb rename to test/system/editing_conference_test.rb index c352067a0..fcc316c12 100644 --- a/test/features/editing_conference_test.rb +++ b/test/system/editing_conference_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingConferenceTest < FeatureTest +class EditingConferenceTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events_and_speakers) create(:event_ticket, object: @conference.events.first) @@ -10,7 +10,12 @@ class EditingConferenceTest < FeatureTest test 'set ticket server to RT' do assert_content page, 'Conferences' - visit_conference_settings_for(@conference) + click_on 'Conferences' + within find('tr', text: @conference.title) do + click_on 'Show' + end + click_on 'Settings' + choose('Request Tracker') click_on 'Update conference' assert_content page, 'Conference was successfully updated.' @@ -27,8 +32,7 @@ class EditingConferenceTest < FeatureTest assert_content page, Event.last.title end - it 'edit classifiers', js: true do - sign_in_user(@admin) + test 'edit classifiers' do visit "/#{@conference.acronym}/conference/edit_classifiers" assert_content page, 'Here you can create and edit the classifiers' click_on 'Update conference' diff --git a/test/features/editing_event_people.rb b/test/system/editing_event_people_test.rb similarity index 61% rename from test/features/editing_event_people.rb rename to test/system/editing_event_people_test.rb index b89886c78..e2feab6a4 100644 --- a/test/features/editing_event_people.rb +++ b/test/system/editing_event_people_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingEventsPeopleTest < FeatureTest +class EditingEventsPeopleTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last @@ -8,16 +8,23 @@ class EditingEventsPeopleTest < FeatureTest @admin = create(:admin_user) end - it 'admin can add user to event', js: true do + test 'admin can add user to event' do sign_in_user(@admin) visit "/#{@conference.acronym}/events/#{@event.id}/edit_people" + @user.reload + assert_content page, 'Editing People' click_on 'Add person' - find('input', id: 'filter').click() - find('input', id: 'filter').send_keys("#{@user.id}") + find('input', id: 'filter').click + fill_in 'filter', with: @user.person.email select 'Speaker' + + Capybara.using_wait_time(10) do + assert_content page, @user.person.public_name + end click_on 'Update event' + assert_content page, 'Event was successfully updated.' assert_content page, @user.person.public_name end diff --git a/test/features/editing_event_rating_test.rb b/test/system/editing_event_rating_test.rb similarity index 76% rename from test/features/editing_event_rating_test.rb rename to test/system/editing_event_rating_test.rb index 259cb746f..8104b9aa8 100644 --- a/test/features/editing_event_rating_test.rb +++ b/test/system/editing_event_rating_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingEventRatingTest < FeatureTest +class EditingEventRatingTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last @@ -10,7 +10,7 @@ class EditingEventRatingTest < FeatureTest end - it 'can create event rating and delete it', js: true do + test 'can create event rating and delete it' do sign_in_user(@user) visit "/#{@conference.acronym}/events/#{@event.id}/event_rating" assert_content page, 'My rating' @@ -21,7 +21,9 @@ class EditingEventRatingTest < FeatureTest assert_content page, 'My rating' assert_content page, 'Quite good event' - click_on 'Delete Event rating' + accept_alert do + click_on 'Delete Event rating' + end assert_content page, 'My rating' refute_content page, 'Quite good event' diff --git a/test/system/editing_event_review_test.rb b/test/system/editing_event_review_test.rb new file mode 100644 index 000000000..d45aa82db --- /dev/null +++ b/test/system/editing_event_review_test.rb @@ -0,0 +1,51 @@ +require 'application_system_test_case' + +class EditingEventReviewTest < ApplicationSystemTestCase + REVIEW_METRIC_NAME = 'optimistic :-)' + + setup do + @conference = create(:three_day_conference_with_review_metrics_and_events) + @event = @conference.events.last + @review_metric = @conference.review_metrics.first + + # When test start, three people already reviewed it + [2, 4, 5].each do |score| + reviewer = create(:conference_coordinator, conference: @conference) + event_rating = create(:event_rating, event: @event, person: reviewer.person) + create(:review_score, event_rating: event_rating, review_metric: @review_metric, score: score) + end + @event.save + + @coordinator = create(:conference_coordinator, conference: @conference) + @user = @coordinator.user + end + + test 'can edit review metrics and delete, calculate average' do + # Test that when @user updates the review score, the average is updated correctly + sign_in_user(@user) + visit "/#{@conference.acronym}/events/#{@event.id}/event_rating" + find('form').find('div', text: @review_metric.name).find('span', text: '4').find('input').click + click_on 'Create Event rating' + assert_content page, 'saved successfully' + + visit "/#{@conference.acronym}/events/ratings" + assert_content page, @review_metric.name + assert_content page, '3.75' # average([2,4,4,5]) + + # Test that filtering by review metric works + click_on '3.75' + assert_content page, '≥ 3.75' + assert_content page, @event.title + + # Test that when @user deletes the review, the average is updated correctly + visit "/#{@conference.acronym}/events/#{@event.id}/event_rating" + accept_alert do + click_on 'Delete Event rating' + end + assert_content page, 'deleted successfully' + + visit "/#{@conference.acronym}/events/ratings" + assert_content page, @review_metric.name + assert_content page, '3.67' # average([2,4,5]) + end +end diff --git a/test/features/editing_events_test.rb b/test/system/editing_events_test.rb similarity index 90% rename from test/features/editing_events_test.rb rename to test/system/editing_events_test.rb index 3155d7231..d411c5896 100644 --- a/test/features/editing_events_test.rb +++ b/test/system/editing_events_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingEventsTest < FeatureTest +class EditingEventsTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last diff --git a/test/features/editing_users_test.rb b/test/system/editing_users_test.rb similarity index 88% rename from test/features/editing_users_test.rb rename to test/system/editing_users_test.rb index bfbc93cfd..84637c4cf 100644 --- a/test/features/editing_users_test.rb +++ b/test/system/editing_users_test.rb @@ -1,13 +1,13 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingUsersTest < FeatureTest +class EditingUsersTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference) @admin = create(:admin_user) @person = create(:person, public_name: 'FakeName') end - it 'creates and makes user into crew', js: true do + test 'creates and makes user into crew' do sign_in_user(@admin) visit "/#{@conference.acronym}/people/all" assert_content page, @person.email diff --git a/test/features/event_join_test.rb b/test/system/event_join_test.rb similarity index 96% rename from test/features/event_join_test.rb rename to test/system/event_join_test.rb index 2fc5f4942..5d9a372ad 100644 --- a/test/features/event_join_test.rb +++ b/test/system/event_join_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EventJoinTest < FeatureTest +class EventJoinTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last @@ -47,11 +47,11 @@ class EventJoinTest < FeatureTest visit cfp_events_join_path(token: @event.invite_token, conference_acronym: @conference.acronym) select 'speaker' click_on('Join event') - + assert_content page, 'deadline for submitting events is over' assert_equal @event.speakers.count, 1 end - + test 'can join an event as assistant after hard deadline' do join_user = create(:cfp_user) sign_in_user(join_user) @@ -61,7 +61,7 @@ class EventJoinTest < FeatureTest visit cfp_events_join_path(token: @event.invite_token, conference_acronym: @conference.acronym) select 'assistant' click_on('Join event') - + assert_content page, 'added to this event' assert @event.people.include?(join_user.person) end diff --git a/test/features/export_profile_test.rb b/test/system/export_profile_test.rb similarity index 71% rename from test/features/export_profile_test.rb rename to test/system/export_profile_test.rb index 0a70c9a46..a4c92c63a 100644 --- a/test/features/export_profile_test.rb +++ b/test/system/export_profile_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class ExportProfileTest < FeatureTest +class ExportProfileTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @event = @conference.events.last @@ -16,6 +16,7 @@ class ExportProfileTest < FeatureTest test 'export profile' do click_on 'Account' click_on 'Export profile' - assert_content page, 'Export profile' + assert_content page, 'Export Profile' + assert_content page, 'Profile data' end end diff --git a/test/features/filter_and_send_mail_test.rb b/test/system/filter_and_send_mail_test.rb similarity index 83% rename from test/features/filter_and_send_mail_test.rb rename to test/system/filter_and_send_mail_test.rb index d82447356..01ec40949 100644 --- a/test/features/filter_and_send_mail_test.rb +++ b/test/system/filter_and_send_mail_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class FilterAndSendMailTest < FeatureTest +class FilterAndSendMailTest < ApplicationSystemTestCase BCC_ADDRESS = "jimmy@example.com" setup do ActionMailer::Base.deliveries = [] @@ -10,9 +10,9 @@ class FilterAndSendMailTest < FeatureTest @admin = create(:admin_user) end - it 'can create a template and use it for filter and send', js: true do + test 'can create a template and use it for filter and send' do sign_in_user(@admin) - + # Add mail template visit "/#{@conference.acronym}/mail_templates/new" fill_in 'Name', with: 'template1' @@ -34,17 +34,19 @@ class FilterAndSendMailTest < FeatureTest refute_content page, e.title end end - + # and Send click_on 'Send mail to all these people' select 'template1', from: "template_name" - find('input', id: 'bulk_email').trigger('click') - + accept_alert do + find('input', id: 'bulk_email').click + end + assert_content page, 'Mails delivered' - - emails = ActionMailer::Base.deliveries - assert emails.count == 1 # without filtering, we would've seen 3 - + + emails = ActionMailer::Base.deliveries + assert emails.count == 1 # without filtering, we would've seen 3 + m = emails.first assert m.to == [ @event.event_people.where(event_role: :speaker).first.person.email ] assert m.subject == "mail regarding #{@event.title}" diff --git a/test/features/filtering_event_list.rb b/test/system/filtering_event_list_test.rb similarity index 84% rename from test/features/filtering_event_list.rb rename to test/system/filtering_event_list_test.rb index 132d0279f..d9f289b5c 100644 --- a/test/features/filtering_event_list.rb +++ b/test/system/filtering_event_list_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class EditingEventRatingTest < FeatureTest +class EditingEventRatingTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_events) @coordinator = create(:conference_coordinator, conference: @conference) @@ -16,10 +16,10 @@ class EditingEventRatingTest < FeatureTest EventRating.create(event: @event2, person: @coordinator.person, rating: 3, comment: "comment1") end - it 'can filter event list by clicking a term', js: true do + test 'can filter event list by clicking a term' do sign_in_user(@user) visit "/#{@conference.acronym}/events/" - + click_on 'Film' assert_content page, '╳ Event type : Film' assert_content page, @event1.title @@ -27,7 +27,7 @@ class EditingEventRatingTest < FeatureTest refute_content page, @event3.title end - it 'can filter event list by clicking a number', js: true do + test 'can filter event list by clicking a number' do sign_in_user(@user) visit "/#{@conference.acronym}/events/ratings" find('a', text: /^1$/).click @@ -37,22 +37,22 @@ class EditingEventRatingTest < FeatureTest refute_content page, @event3.title end - it 'can filter event list by using the multi-filter', js: true do + test 'can filter event list by using the multi-filter' do sign_in_user(@user) visit "/#{@conference.acronym}/events/" - + # click the filter icon next to table header "Type" - find('th', text: 'Type').find('.show_events_modal').trigger('click') + find('th', text: 'Type').find('.show_events_modal').click assert_content page, 'Select filter for' - + check 'Film' check 'dance' - + find('#apply_filter_btn') # TODO - this fails because phantomjs does not support URL.searchParams.set # click_on 'Apply filter' visit "/#{@conference.acronym}/events?event_type=film|dance" - + assert_content page, '╳ Event type : multiple' assert_content page, @event1.title @@ -60,14 +60,14 @@ class EditingEventRatingTest < FeatureTest assert_content page, @event3.title end - it 'can filter event list by using numeric modal', js: true do + test 'can filter event list by using numeric modal' do sign_in_user(@user) visit "/#{@conference.acronym}/events/ratings" - + # click the filter icon next to table header "Event ratings count" - find('th', text: 'Event ratings count').find('.show_events_modal').trigger('click') + find('th', text: 'Event ratings count').find('.show_events_modal').click assert_content page, 'Select filter for Event ratings count:' - + page.find_all(class: "radio", text: "at most").select find("input#filter_form_num").send_keys('0.5') diff --git a/test/features/ldap_test.rb b/test/system/ldap_test.rb similarity index 93% rename from test/features/ldap_test.rb rename to test/system/ldap_test.rb index bcc12d542..90c09735e 100644 --- a/test/features/ldap_test.rb +++ b/test/system/ldap_test.rb @@ -1,9 +1,9 @@ -require 'test_helper' +require 'application_system_test_case' # TODO This test uses a remote service and is flaky. # Fails with: `Authentication failure! ldap_error: Net::LDAP::Error, Connection # timed out - user specified timeout` -class LdapTest < FeatureTest +class LdapTest < ApplicationSystemTestCase LOGIN='tesla' # see https://www.forumsys.com/category/tutorials/integration-how-to/ PASSWORD='password' EMAIL='tesla@ldap.forumsys.com' @@ -26,7 +26,7 @@ def connect_with_ldap(login, pass) assert_content page, 'Successfully authenticated' assert User.where(email: EMAIL).any? - click_on 'Logout' + sign_out end test 'can sign up and sign in with LDAP' do diff --git a/test/features/orga_adds_conference_user_test.rb b/test/system/orga_adds_conference_user_test.rb similarity index 83% rename from test/features/orga_adds_conference_user_test.rb rename to test/system/orga_adds_conference_user_test.rb index c424819e0..61ff750f6 100644 --- a/test/features/orga_adds_conference_user_test.rb +++ b/test/system/orga_adds_conference_user_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class OrgaAddsConferenceUserTest < FeatureTest +class OrgaAddsConferenceUserTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference) @orga = create(:conference_orga, conference: @conference) @@ -8,7 +8,7 @@ class OrgaAddsConferenceUserTest < FeatureTest @person = @crew_user.person end - it 'adds crew user as orga', js: true do + test 'adds crew user as orga' do sign_in_user(@orga.user) visit "/#{@conference.acronym}/people/all" assert_content page, @person.email diff --git a/test/features/sorting_event_list_test.rb b/test/system/sorting_event_list_test.rb similarity index 93% rename from test/features/sorting_event_list_test.rb rename to test/system/sorting_event_list_test.rb index 332c75f0a..52d93e6b9 100644 --- a/test/features/sorting_event_list_test.rb +++ b/test/system/sorting_event_list_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class SortingEventListTest < FeatureTest +class SortingEventListTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference_with_review_metrics_and_events_and_reviews) @conference.events.each do |event| @@ -14,7 +14,7 @@ class SortingEventListTest < FeatureTest @conference.events.first.update( event_attachments_attributes: { 'xx' => { 'title' => 'proposal', 'attachment' => upload } }) end - it 'can sort', js: true do + test 'can sort' do sign_in_user(@coordinator.user) visit "/#{@conference.acronym}/events/" find_all(:css, 'ul.tabs li').map(&:text).each do |tabname| diff --git a/test/features/submit_event_test.rb b/test/system/submit_event_test.rb similarity index 95% rename from test/features/submit_event_test.rb rename to test/system/submit_event_test.rb index 1520b45e5..c77a179bb 100644 --- a/test/features/submit_event_test.rb +++ b/test/system/submit_event_test.rb @@ -1,6 +1,6 @@ -require 'test_helper' +require 'application_system_test_case' -class SubmitEventTest < FeatureTest +class SubmitEventTest < ApplicationSystemTestCase setup do @conference = create(:three_day_conference) create(:call_for_participation, conference: @conference) diff --git a/test/tasks/rake_task_export_attachments_test.rb b/test/tasks/rake_task_export_attachments_test.rb index 8f8653aea..b9c73930a 100644 --- a/test/tasks/rake_task_export_attachments_test.rb +++ b/test/tasks/rake_task_export_attachments_test.rb @@ -1,34 +1,29 @@ require 'test_helper' require 'rake' +# frab:conference_export_attachments class RakeTaskExportAttachmentsTest < ActiveSupport::TestCase + def setup + # Create a conference with an attachment + @conference = create :three_day_conference_with_events + @conference.update(attachment_title_is_freeform: false) - describe 'frab:conference_export_attachments' do + @event = @conference.events.first - def setup - # Create a conference with an attachment - @conference = create :three_day_conference_with_events - @conference.update(attachment_title_is_freeform: false) + upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'textfile.txt'), 'text/plain') + @event.update( event_attachments_attributes: { 'xx' => { 'title' => 'proposal', 'attachment' => upload } }) - @event=@conference.events.first - - upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'textfile.txt'), 'text/plain') - @event.update( event_attachments_attributes: { 'xx' => { 'title' => 'proposal', 'attachment' => upload } }) - - # Run frab:conference_export_attachments - Frab::Application.load_tasks if Rake::Task.tasks.empty? - ENV['CONFERENCE']=@conference.acronym - Rake::Task["frab:conference_export_attachments"].invoke - - end - - def teardown - @conference.destroy - end + # Run frab:conference_export_attachments + Frab::Application.load_tasks if Rake::Task.tasks.empty? + ENV['CONFERENCE'] = @conference.acronym + Rake::Task['frab:conference_export_attachments'].invoke + end - it "should export attachments" do - assert File.file?("tmp/attachments/#{@conference.acronym}/trackless_proposal.tgz") - end + def teardown + @conference.destroy + end + test 'should export attachments' do + assert File.file?("tmp/attachments/#{@conference.acronym}/trackless_proposal.tgz") end end diff --git a/test/tasks/rake_task_export_import_conference_test.rb b/test/tasks/rake_task_export_import_conference_test.rb index 2046d29f5..cb841bb7e 100644 --- a/test/tasks/rake_task_export_import_conference_test.rb +++ b/test/tasks/rake_task_export_import_conference_test.rb @@ -1,67 +1,65 @@ require 'test_helper' require 'rake' +# frab:conference_export_import class RakeTaskExportImportConferenceTest < ActiveSupport::TestCase - describe 'frab:conference_export_import' do + NEW_ACRONYM = 'imported'.freeze - NEW_ACRONYM = 'imported'.freeze + def setup + # Create a conference with an attachment + @conf = create :three_day_conference_with_events - def setup - # Create a conference with an attachment - @conf = create :three_day_conference_with_events + @event = @conf.events.first - @event=@conf.events.first + upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'textfile.txt'), 'text/plain') + @event.update( event_attachments_attributes: { 'xx' => { 'title' => 'proposal', 'attachment' => upload } }) - upload = Rack::Test::UploadedFile.new(Rails.root.join('test', 'fixtures', 'textfile.txt'), 'text/plain') - @event.update( event_attachments_attributes: { 'xx' => { 'title' => 'proposal', 'attachment' => upload } }) + FileUtils.rm_rf('tmp/frab_export') - FileUtils.rm_rf('tmp/frab_export') + # Run frab:conference_export + Frab::Application.load_tasks if Rake::Task.tasks.empty? + ENV['CONFERENCE'] = @conf.acronym + Rake::Task['frab:conference_export'].invoke - # Run frab:conference_export - Frab::Application.load_tasks if Rake::Task.tasks.empty? - ENV['CONFERENCE']=@conf.acronym - Rake::Task["frab:conference_export"].invoke + # Edit the export file to use a different acronym and title + # otherwise it would not import + data = YAML.load_file 'tmp/frab_export/conference.yaml' + data["acronym"] = NEW_ACRONYM + data["title"] = "NewTitle" + File.open("tmp/frab_export/conference.yaml", 'w') { |f| YAML.dump(data, f) } - # Edit the export file to use a different acronym and title - # otherwise it would not import - data = YAML.load_file "tmp/frab_export/conference.yaml" - data["acronym"] = NEW_ACRONYM - data["title"] = "NewTitle" - File.open("tmp/frab_export/conference.yaml", 'w') { |f| YAML.dump(data, f) } - - # Run frab:conference_import - Rake::Task["frab:conference_import"].invoke - end + # Run frab:conference_import + Rake::Task["frab:conference_import"].invoke + end - def teardown - @conf.destroy - @new_conf.destroy - end + def teardown + @conf.destroy + @new_conf.destroy + end - it "should export and import correctly" do - @new_conf = Conference.find_by(acronym: NEW_ACRONYM) - assert @new_conf, "imported successfully" + test 'should export and import correctly' do + @new_conf = Conference.find_by(acronym: NEW_ACRONYM) + assert @new_conf, "imported successfully" - assert @new_conf.events.count == @conf.events.count, "all events restored" + assert @new_conf.events.count == @conf.events.count, "all events restored" - assert( @conf.events.joins(:event_attachments).pluck(:title, :attachment_file_name, :attachment_file_size) == - @new_conf.events.joins(:event_attachments).pluck(:title, :attachment_file_name, :attachment_file_size) , - "all event attachments restored" ) + assert( @conf.events.joins(:event_attachments).pluck(:title, :attachment_file_name, :attachment_file_size) == + @new_conf.events.joins(:event_attachments).pluck(:title, :attachment_file_name, :attachment_file_size) , + 'all event attachments restored' ) - conf_attrs = @conf.attributes - new_conf_attrs = @new_conf.attributes + conf_attrs = @conf.attributes + new_conf_attrs = @new_conf.attributes - attributes_to_compare = conf_attrs.keys - attributes_to_compare -= [ "id" ] # Updated during re-import - attributes_to_compare -= [ "acronym", "title" ] # Updated by this test - attributes_to_compare -= [ "created_at", "updated_at" ] # Modified to import time + attributes_to_compare = conf_attrs.keys + attributes_to_compare -= [ "id" ] # Updated during re-import + attributes_to_compare -= [ "acronym", "title" ] # Updated by this test + attributes_to_compare -= [ "created_at", "updated_at" ] # Modified to import time - attributes_to_compare.each { |attr| - original = conf_attrs[attr] - imported = new_conf_attrs[attr] - assert original == imported, "conference #{attr} should be identical. original is #{original} ; imported is #{imported}" - } - end + attributes_to_compare.each { |attr| + original = conf_attrs[attr] + imported = new_conf_attrs[attr] + assert original == imported, "conference #{attr} should be identical. original is #{original} ; imported is #{imported}" + } end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 11ac2df3f..63c9929b7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,15 +1,14 @@ ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../config/environment', __FILE__) +require_relative '../config/environment' require 'rails/test_help' + require 'minitest/pride' require 'database_cleaner/active_record' require 'sucker_punch/testing/inline' -require 'minitest/rails/capybara' -require 'capybara/poltergeist' - Dir[Rails.root.join('test/support/**/*.rb')].each { |f| require f } +# Unit tests in test/unit class ActiveSupport::TestCase ActiveRecord::Migration.check_pending! include FactoryBot::Syntax::Methods @@ -18,8 +17,6 @@ class ActiveSupport::TestCase # fixtures :all # Add more helper methods to be used by all tests here... - - Capybara.javascript_driver = :poltergeist DatabaseCleaner.strategy = :truncation def setup @@ -32,6 +29,7 @@ def teardown end end +# Controller tests in test/controllers class ActionController::TestCase include Devise::Test::ControllerHelpers @@ -46,15 +44,13 @@ def log_out end end +# Integration tests in test/integration class ActionDispatch::IntegrationTest include Devise::Test::IntegrationHelpers end +# Integration tests in test/integration class PunditControllerTest < ActionDispatch::IntegrationTest include CrewRolesHelper end - -class FeatureTest < Capybara::Rails::TestCase - include CapybaraHelper -end