Make open source
This commit is contained in:
6
test/application_system_test_case.rb
Normal file
6
test/application_system_test_case.rb
Normal file
@ -0,0 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
# driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||
driven_by :rack_test
|
||||
end
|
0
test/controllers/.keep
Normal file
0
test/controllers/.keep
Normal file
23
test/controllers/guests_controller_test.rb
Normal file
23
test/controllers/guests_controller_test.rb
Normal file
@ -0,0 +1,23 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GuestsControllerTest < ActionDispatch::IntegrationTest
|
||||
test 'checks for duplicates on email update' do
|
||||
guest_one = guests(:one)
|
||||
guest_two = guests(:two)
|
||||
|
||||
patch guest_path(guest_one), params: {
|
||||
guest: { email: guest_two.email }
|
||||
}
|
||||
|
||||
assert_select 'li', 'Email has already been taken'
|
||||
end
|
||||
|
||||
test 'records confirmed_at time' do
|
||||
guest_one = guests(:one)
|
||||
|
||||
patch complete_guest_path(guest_one), params: { guest: { notes: '' } }
|
||||
|
||||
guest_one.reload
|
||||
assert guest_one.confirmed_at
|
||||
end
|
||||
end
|
7
test/controllers/plus_ones_controller_test.rb
Normal file
7
test/controllers/plus_ones_controller_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PlusOnesControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
8
test/controllers/welcome_controller_test.rb
Normal file
8
test/controllers/welcome_controller_test.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require 'test_helper'
|
||||
|
||||
class WelcomeControllerTest < ActionDispatch::IntegrationTest
|
||||
test 'should get index' do
|
||||
get welcome_index_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
0
test/fixtures/.keep
vendored
Normal file
0
test/fixtures/.keep
vendored
Normal file
11
test/fixtures/admin_users.yml
vendored
Normal file
11
test/fixtures/admin_users.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one:
|
||||
email: admin1@example.com
|
||||
|
||||
two:
|
||||
email: admin2@example.com
|
0
test/fixtures/files/.keep
vendored
Normal file
0
test/fixtures/files/.keep
vendored
Normal file
13
test/fixtures/guests.yml
vendored
Normal file
13
test/fixtures/guests.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
token: abcdefghijkmnopqrstuv
|
||||
email: one@example.com
|
||||
first_name: Guest
|
||||
last_name: One
|
||||
|
||||
two:
|
||||
token: vutsrqponmkjihgfedcba
|
||||
email: two@example.com
|
||||
first_name: Guest
|
||||
last_name: Two
|
15
test/fixtures/plus_ones.yml
vendored
Normal file
15
test/fixtures/plus_ones.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
guest: one
|
||||
first_name: Plus
|
||||
last_name: One
|
||||
diet: Level 1 Vegan
|
||||
child: false
|
||||
|
||||
two:
|
||||
guest: one
|
||||
first_name: Plus
|
||||
last_name: Two
|
||||
diet: Level 2 Vegan
|
||||
child: false
|
0
test/helpers/.keep
Normal file
0
test/helpers/.keep
Normal file
0
test/integration/.keep
Normal file
0
test/integration/.keep
Normal file
0
test/mailers/.keep
Normal file
0
test/mailers/.keep
Normal file
7
test/mailers/guest_mailer_test.rb
Normal file
7
test/mailers/guest_mailer_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GuestMailerTest < ActionMailer::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
28
test/mailers/previews/guest_mailer_preview.rb
Normal file
28
test/mailers/previews/guest_mailer_preview.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# Preview all emails at http://localhost:3000/rails/mailers/guest_mailer
|
||||
class GuestMailerPreview < ActionMailer::Preview
|
||||
def confirmation_email_attending
|
||||
GuestMailer.confirmation_email(
|
||||
Guest.new(
|
||||
id: 123,
|
||||
first_name: 'John',
|
||||
last_name: 'Doe',
|
||||
email: 'john.doe@example.com',
|
||||
token: 'abcdefghiklmnop',
|
||||
attending: true
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def confirmation_email_attending_not_attending
|
||||
GuestMailer.confirmation_email(
|
||||
Guest.new(
|
||||
id: 123,
|
||||
first_name: 'John',
|
||||
last_name: 'Doe',
|
||||
email: 'john.doe@example.com',
|
||||
token: 'abcdefghiklmnop',
|
||||
attending: false
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
0
test/models/.keep
Normal file
0
test/models/.keep
Normal file
7
test/models/admin_user_test.rb
Normal file
7
test/models/admin_user_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AdminUserTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/models/attendee_test.rb
Normal file
7
test/models/attendee_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AttendeeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
12
test/models/guest_test.rb
Normal file
12
test/models/guest_test.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'test_helper'
|
||||
|
||||
class GuestTest < ActiveSupport::TestCase
|
||||
test 'email_safe_salutation' do
|
||||
guest = guests(:one)
|
||||
assert_equal 'Dear Guest,', guest.email_safe_salutation
|
||||
guest.first_name = 'Visit spam.com'
|
||||
assert_equal 'Hello,', guest.email_safe_salutation
|
||||
guest.first_name = 'Visit spam dot com for free stuff' # too long
|
||||
assert_equal 'Hello,', guest.email_safe_salutation
|
||||
end
|
||||
end
|
7
test/models/plus_one_test.rb
Normal file
7
test/models/plus_one_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PlusOneTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
0
test/system/.keep
Normal file
0
test/system/.keep
Normal file
125
test/system/rsvp_happy_path_test.rb
Normal file
125
test/system/rsvp_happy_path_test.rb
Normal file
@ -0,0 +1,125 @@
|
||||
require 'application_system_test_case'
|
||||
|
||||
class RsvpHappyPathTest < ApplicationSystemTestCase
|
||||
test 'RSVP attending' do
|
||||
visit root_url
|
||||
click_link 'RSVP TODAY!', match: :first
|
||||
|
||||
fill_in 'Email', with: 'test@example.com'
|
||||
click_on 'Continue'
|
||||
|
||||
#
|
||||
# About You
|
||||
#
|
||||
fill_in 'First Name', with: 'Test'
|
||||
fill_in 'Last Name', with: 'User'
|
||||
choose 'Yes'
|
||||
fill_in 'Dietary Preferences', with: 'Level 5 Vegan'
|
||||
fill_in 'Song Suggestions', with: 'Mozart'
|
||||
click_on 'Continue'
|
||||
|
||||
#
|
||||
# Plus Ones
|
||||
#
|
||||
click_on 'Add Plus One'
|
||||
|
||||
fill_in 'First Name', with: 'Test Plus'
|
||||
fill_in 'Last Name', with: 'One Name'
|
||||
fill_in 'Dietary Preferences', with: 'Vegetarian'
|
||||
check 'Child'
|
||||
click_on 'Add Plus One'
|
||||
|
||||
assert page.has_content? 'Test Plus One Name'
|
||||
|
||||
click_on 'Add Plus One'
|
||||
|
||||
fill_in 'First Name', with: 'Test Plus'
|
||||
fill_in 'Last Name', with: 'Two Name'
|
||||
fill_in 'Dietary Preferences', with: 'Pescatarian'
|
||||
check 'Child'
|
||||
click_on 'Add Plus One'
|
||||
|
||||
assert page.has_content? 'Test Plus One Name'
|
||||
assert page.has_content? 'Test Plus Two Name'
|
||||
|
||||
click_on 'Continue'
|
||||
|
||||
#
|
||||
# Confirm
|
||||
#
|
||||
|
||||
assert page.has_content? 'Test User'
|
||||
assert page.has_content? 'Level 5 Vegan'
|
||||
assert page.has_content? 'Mozart'
|
||||
assert page.has_content? 'Test Plus One Name'
|
||||
assert page.has_content? 'Vegetarian'
|
||||
assert page.has_content? 'Test Plus Two Name'
|
||||
assert page.has_content? 'Pescatarian'
|
||||
|
||||
fill_in 'guest[notes]', with: 'I hope there is cake!'
|
||||
|
||||
click_on 'Complete RSVP'
|
||||
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
assert_equal 'test@example.com', email.to[0]
|
||||
end
|
||||
|
||||
test 'RSVP not attending' do
|
||||
visit root_url
|
||||
click_link 'RSVP TODAY!', match: :first
|
||||
|
||||
fill_in 'Email', with: 'test@example.com'
|
||||
click_on 'Continue'
|
||||
|
||||
#
|
||||
# About You
|
||||
#
|
||||
fill_in 'First Name', with: 'Test'
|
||||
fill_in 'Last Name', with: 'User'
|
||||
choose 'No'
|
||||
|
||||
click_on 'Continue'
|
||||
|
||||
#
|
||||
# Skip to Confirm
|
||||
#
|
||||
assert page.has_content? 'Test User'
|
||||
assert page.has_content? 'Sorry to hear'
|
||||
|
||||
click_on 'Complete RSVP'
|
||||
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
assert_equal 'test@example.com', email.to[0]
|
||||
end
|
||||
|
||||
test 'Sends RSVP update email' do
|
||||
visit root_url
|
||||
click_link 'RSVP TODAY!', match: :first
|
||||
|
||||
fill_in 'Email', with: 'test@example.com'
|
||||
click_on 'Continue'
|
||||
|
||||
fill_in 'First Name', with: 'Test'
|
||||
fill_in 'Last Name', with: 'User'
|
||||
|
||||
click_on 'Continue'
|
||||
click_on 'Continue' # No plus ones
|
||||
click_on 'Complete RSVP'
|
||||
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
|
||||
visit root_url
|
||||
click_link 'RSVP TODAY!', match: :first
|
||||
|
||||
fill_in 'Email', with: 'test@example.com'
|
||||
click_on 'Continue'
|
||||
|
||||
assert page.has_content? 'Welcome Back'
|
||||
|
||||
assert_equal 2, ActionMailer::Base.deliveries.size
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
assert_equal 'test@example.com', email.to[0]
|
||||
end
|
||||
end
|
10
test/test_helper.rb
Normal file
10
test/test_helper.rb
Normal file
@ -0,0 +1,10 @@
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../config/environment', __dir__)
|
||||
require 'rails/test_help'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
fixtures :all
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
end
|
Reference in New Issue
Block a user