1
Gemfile
1
Gemfile
@@ -74,6 +74,7 @@ group :test do
|
||||
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
||||
gem "capybara"
|
||||
gem "selenium-webdriver"
|
||||
gem "so_many_devices"
|
||||
end
|
||||
|
||||
gem "pundit", "~> 2.5"
|
||||
|
||||
@@ -365,6 +365,8 @@ GEM
|
||||
slim (5.2.1)
|
||||
temple (~> 0.10.0)
|
||||
tilt (>= 2.1.0)
|
||||
so_many_devices (1.0.0)
|
||||
capybara (>= 3.0)
|
||||
solid_cable (3.0.12)
|
||||
actioncable (>= 7.2)
|
||||
activejob (>= 7.2)
|
||||
@@ -465,6 +467,7 @@ DEPENDENCIES
|
||||
rubocop-rails-omakase
|
||||
selenium-webdriver
|
||||
slim
|
||||
so_many_devices
|
||||
solid_cable
|
||||
solid_cache
|
||||
solid_queue
|
||||
|
||||
29
spec/factories/contestant.rb
Normal file
29
spec/factories/contestant.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: contestants
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# display_time :string
|
||||
# email :string
|
||||
# name :string
|
||||
# projected_time :string
|
||||
# qrcode :string
|
||||
# time_seconds :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_contestants_on_contest_id (contest_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# contest_id (contest_id => contests.id)
|
||||
#
|
||||
FactoryBot.define do
|
||||
factory :contestant do
|
||||
name { Faker::Name.name }
|
||||
email { Faker::Internet.unique.email }
|
||||
end
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: categories
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_categories_on_contest_id (contest_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# contest_id (contest_id => contests.id)
|
||||
#
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Category, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: csv_imports
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# content :string not null
|
||||
# separator :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CsvImport, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,26 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: messages
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# author :string
|
||||
# display_time :string
|
||||
# text :string not null
|
||||
# time_seconds :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# contest_id :integer not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_messages_on_contest_id (contest_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# contest_id (contest_id => contests.id)
|
||||
#
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Message, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: offlines
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# completed :boolean
|
||||
# end_time :datetime
|
||||
# missing_pieces :integer
|
||||
# name :string not null
|
||||
# remaining_pieces :integer
|
||||
# start_time :datetime not null
|
||||
# submitted :boolean
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# completion_id :integer
|
||||
# contest_id :integer not null
|
||||
# contestant_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_offlines_on_completion_id (completion_id)
|
||||
# index_offlines_on_contest_id (contest_id)
|
||||
# index_offlines_on_contestant_id (contestant_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# completion_id (completion_id => completions.id)
|
||||
# contest_id (contest_id => contests.id)
|
||||
# contestant_id (contestant_id => contestants.id)
|
||||
#
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Offline, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -67,4 +67,6 @@ RSpec.configure do |config|
|
||||
config.filter_rails_from_backtrace!
|
||||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
|
||||
config.include SoManyDevices::DownloadsHelper, type: :system
|
||||
end
|
||||
|
||||
38
spec/system/export_spec.rb
Normal file
38
spec/system/export_spec.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Exports", type: :system do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
driven_by :selenium_chrome_with_download_headless
|
||||
end
|
||||
|
||||
after do
|
||||
clear_downloads
|
||||
end
|
||||
|
||||
context "when in a contest with at least one contestant" do
|
||||
let!(:contest) { create(:contest, user: user) }
|
||||
let!(:first_contestant) { create(:contestant, contest: contest) }
|
||||
let!(:second_contestant) { create(:contestant, contest: contest) }
|
||||
|
||||
it "should be possible to export the list of contestants", :with_downloads do
|
||||
login(user)
|
||||
|
||||
sleep 0.5
|
||||
|
||||
visit contest_contestants_path(contest)
|
||||
|
||||
click_link I18n.t("helpers.buttons.export")
|
||||
|
||||
wait_for_download
|
||||
|
||||
expect(downloads.length).to eq(1)
|
||||
expect(last_download).to include("#{contest.friendly_id}_results.csv")
|
||||
|
||||
results_csv = File.read(last_download)
|
||||
expect(results_csv).to include(first_contestant.name)
|
||||
expect(results_csv).to include(second_contestant.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user