Skip to content

Commit

Permalink
Merge pull request #873 from frab/switch-to-rails-system-tests
Browse files Browse the repository at this point in the history
Switch to Rails system tests
  • Loading branch information
manno committed Nov 30, 2021
2 parents 82a8383 + b42a3d4 commit 78f88d0
Show file tree
Hide file tree
Showing 35 changed files with 323 additions and 281 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7
Exclude:
- bin/**/*
- contrib/**/*
Expand Down Expand Up @@ -94,3 +94,9 @@ Layout/MultilineMethodCallIndentation:
# Load order is important
Bundler/OrderedGems:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Layout/EmptyLineAfterGuardClause:
Enabled: false
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 26 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -232,30 +233,17 @@ 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)
mime-types-data (3.2021.0704)
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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -389,20 +373,22 @@ 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)
rqrcode_core (~> 0.2)
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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -485,6 +479,7 @@ DEPENDENCIES
capistrano-rails
capistrano-rvm
capistrano3-puma
capybara (>= 3.26)
cocoon
coffee-rails
dalli
Expand All @@ -508,15 +503,13 @@ DEPENDENCIES
letter_opener
listen
localized_language_select!
minitest-rails-capybara
mysql2
nokogiri
omniauth-google-oauth2
omniauth-rails_csrf_protection
omniauth_openid_connect
paper_trail
pg
poltergeist
prawn (< 1.0)
prawn_rails
pry-byebug
Expand All @@ -535,11 +528,13 @@ DEPENDENCIES
rqrcode
sass-rails (< 6)
scanf
selenium-webdriver
simple_form
sqlite3
sucker_punch
transitions
uglifier
webdrivers
will_paginate
yard

Expand Down
14 changes: 7 additions & 7 deletions app/helpers/events_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
/^(?<op>[≤≥=]?)(?<val>.*)$/ =~ str
return op, val
Expand Down
12 changes: 7 additions & 5 deletions app/lib/import_export_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run_import(export_dir = EXPORT_DIR)
unpack_paperclip_files
restore_all_data
end

enable_callbacks
end

Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -397,15 +399,15 @@ 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)
Availability.set_callback(:save, :after, :update_event_conflicts)
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')
Expand Down
11 changes: 7 additions & 4 deletions app/lib/static_schedule/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 0 additions & 13 deletions test/features/can_access_home_test.rb

This file was deleted.

0 comments on commit 78f88d0

Please sign in to comment.