Merge branch 'master' of https://github.com/CactusPuppy/snapcon into 176895512-automatically-redirect-to-registration-after-buying-a-ticket

This commit is contained in:
Jimmy 2021-03-10 14:58:01 -08:00
commit 85c7b31a77
85 changed files with 740 additions and 509 deletions

View file

@ -1,5 +1,3 @@
require 'pry'
# frozen_string_literal: true
require 'spec_helper'

View file

@ -8,10 +8,10 @@ describe Admin::UsersController do
sign_in(admin)
end
describe 'GET #index' do
it 'sets up users array with existing users records' do
xit 'sets up users array with existing users records' do
user1 = create(:user, email: 'user1@email.osem')
user2 = create(:user, email: 'user2@email.osem')
user_deleted = User.find_by(name: 'User deleted')
user_deleted = User.find_by!(username: 'deleted_user')
get :index
expect(assigns(:users)).to match_array([user_deleted, user, admin, user1, user2])
end
@ -103,4 +103,21 @@ describe Admin::UsersController do
end
end
end
describe 'DELETE #destroy' do
before do
delete :destroy, params: { id: user.id }
end
it 'redirects to admin users index path' do
expect(response).to redirect_to admin_users_path
end
it 'shows success message in flash notice' do
expect(flash[:notice]).to match("User #{user.id} (#{user.email}) deleted.")
end
it 'deletes the user' do
expect { user.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

View file

@ -8,7 +8,7 @@ describe UserDatatable do
end
let(:data_cols) do
[:id, :confirmed_at, :email, :name, :username, :attended, :roles, :view_url, :edit_url, :DT_RowId]
[:id, :confirmed_at, :email, :name, :username, :attended, :roles, :view_url, :edit_url, :DT_RowId, :confirmed]
end
let(:view) do
view = double(
@ -126,7 +126,6 @@ describe UserDatatable do
end
it 'confirmed_at' do
expect(Date.parse(user_data[:confirmed_at])).to eq(user.confirmed_at.to_date)
end

View file

@ -10,6 +10,7 @@
# length :integer default(30)
# maximum_abstract_length :integer default(500)
# minimum_abstract_length :integer default(0)
# submission_instructions :text
# title :string not null
# created_at :datetime
# updated_at :datetime
@ -22,6 +23,8 @@ FactoryBot.define do
length { 30 }
minimum_abstract_length { 0 }
maximum_abstract_length { 500 }
description { 'Example Event Description' }
submission_instructions { 'Example Event Instructions' }
color { '#ffffff' }
program
end

View file

@ -7,6 +7,7 @@
# id :bigint not null, primary key
# abstract :text
# comments_count :integer default(0), not null
# committee_review :text
# description :text
# guid :string not null
# is_highlight :boolean default(FALSE)
@ -18,6 +19,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer

View file

@ -13,6 +13,10 @@ feature 'BaseController' do
describe 'GET #verify_user_admin' do
context 'when user is a guest' do
before(:each) do
sign_out
end
it 'redirects to sign in page' do
visit admin_conferences_path
expect(current_path).to eq new_user_session_path
@ -30,31 +34,31 @@ feature 'BaseController' do
expect(flash).to eq 'You are not authorized to access this page.'
end
it 'an admin he can access the admin area' do
it 'an admin they can access the admin area' do
user.is_admin = true
visit admin_conferences_path
expect(current_path).to eq admin_conferences_path
end
it 'an organizer he can access the admin area' do
it 'an organizer they can access the admin area' do
user.role_ids = organizer_role.id
visit admin_conferences_path
expect(current_path).to eq admin_conferences_path
end
it 'a volunteers_coordinator he can access the admin area' do
it 'a volunteers_coordinator they can access the admin area' do
user.role_ids = volunteers_coordinator_role.id
visit admin_conferences_path
expect(current_path).to eq admin_conferences_path
end
it 'a cfp he can access the admin area' do
it 'a cfp they can access the admin area' do
user.role_ids = cfp_role.id
visit admin_conferences_path
expect(current_path).to eq admin_conferences_path
end
it 'an info_desk he can access the admin area' do
it 'an info_desk they can access the admin area' do
user.role_ids = info_desk_role.id
visit admin_conferences_path
expect(current_path).to eq admin_conferences_path

View file

@ -22,6 +22,8 @@ feature EventType do
fill_in 'event_type_title', with: 'Party'
fill_in 'event_type_length', with: '240'
fill_in 'event_type_description', with: '**Description**'
fill_in 'event_type_submission_instructions', with: '**Instructions**'
fill_in 'event_type_minimum_abstract_length', with: '0'
fill_in 'event_type_maximum_abstract_length', with: '13042'
page.find('#event_type_color').set('#e4e4e4')
@ -29,11 +31,14 @@ feature EventType do
click_button 'Create Event type'
page.find('#flash')
# Validations
# binding.pry
expect(flash).to eq('Event type successfully created.')
within('table#event_types') do
expect(page.has_content?('Party')).to be true
expect(page.has_content?('13042')).to be true
expect(page.has_content?('#E4E4E4')).to be true
expect(page.has_content?('Description')).to be true
expect(page.has_content?('Instructions')).to be true
expect(page.assert_selector('tr', count: 3)).to be true
end

View file

@ -27,6 +27,21 @@ feature Event do
sign_in organizer
end
scenario 'can preview a proposal if it is public', feature: true, js: true do
visit admin_conference_program_event_path(conference.short_title, @event)
expect(page).to have_selector(:link_or_button, 'Preview')
click_link 'Preview'
expect(current_path).to eq(conference_program_proposal_path(conference.short_title, @event.id))
end
scenario 'cannot preview a proposal if it is not public', feature: true, js: true do
event = create(:event, program: conference.program, title: 'Example Proposal')
event.public = false
event.save!
visit admin_conference_program_event_path(conference.short_title, event)
expect(page).to_not have_selector(:link_or_button, 'Preview')
end
scenario 'rejects a proposal', feature: true, js: true do
visit admin_conference_program_events_path(conference.short_title)
expect(page).to have_content 'Example Proposal'
@ -82,6 +97,7 @@ feature Event do
fill_in 'event_title', with: 'Example Proposal'
select('Example Event Type', from: 'event[event_type_id]')
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
fill_in 'event_submission_text', with: 'Lorem ipsum submission'
click_button 'Submit Proposal'
page.find('#flash')
@ -91,6 +107,17 @@ feature Event do
expect(User.count).to eq(expected_count_user)
end
scenario 'edit proposal without cfp' do
conference = create(:conference)
proposal = create(:event, program: conference.program)
sign_in proposal.submitter
visit edit_conference_program_proposal_path(proposal.program.conference.short_title, proposal)
expect(page).to have_content 'Proposal Information'
end
scenario 'update a proposal' do
conference = create(:conference)
create(:cfp, program: conference.program)
@ -120,9 +147,15 @@ feature Event do
select('Example Event Type', from: 'event[event_type_id]')
expect(page).to have_selector(".in[id='#{find_field('event[event_type_id]').value}-help']") # End of animation
expect(page).to have_text('Example Event Description')
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
expect(page).to have_text('You have used 3 words')
fill_in 'event_submission_text', with: 'Lorem ipsum submission_text'
expect(page).to have_text('Submission text')
# Submission Instructions content
expect(page).to have_text('Example Event Instructions')
click_link 'Do you require something special?'
fill_in 'event_description', with: 'Lorem ipsum description'
@ -158,5 +191,24 @@ feature Event do
@event.reload
expect(@event.state).to eq('withdrawn')
end
scenario 'can reset to text template', feature: true, js: true do
event_type = conference.program.event_types[-1]
event_type.description = 'Example event description'
event_type.save!
sign_in participant
visit new_conference_program_proposal_path(conference.short_title)
fill_in 'event_title', with: 'Example Proposal'
select(event_type.title, from: 'event[event_type_id]')
fill_in 'event_submission_text', with: 'Lorem ipsum example submission text'
accept_confirm do
click_button 'Reset to Template'
end
expect(page.find('#event_submission_text').value).to eq(event_type.description)
end
end
end

View file

@ -11,6 +11,25 @@ feature Registration, feature: true, js: true do
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket, third_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) }
let!(:participant) { create(:user) }
def make_stripe_purchase(card_number='4242424242424242')
find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
sleep(5)
Capybara.within_frame stripe_iframe do
expect(page).to have_content("#{ENV['OSEM_NAME']} tickets")
fill_in 'Card number', with: card_number
fill_in 'Expiry', with: '08/22'
fill_in 'CVC', with: '123'
click_button '$20.00'
sleep(20)
end
end
def make_failed_stripe_purchase
make_stripe_purchase('4000000000000341')
end
context 'as a participant' do
before(:each) do
sign_in participant
@ -22,7 +41,7 @@ feature Registration, feature: true, js: true do
context 'who is not registered' do
scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do
scenario 'purchases and pays for a ticket succcessfully' do
visit root_path
click_link 'Register'
@ -39,22 +58,11 @@ feature Registration, feature: true, js: true do
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
if Rails.application.secrets.stripe_publishable_key
find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
sleep(5)
Capybara.within_frame stripe_iframe do
expect(page).to have_content('book your tickets')
page.execute_script(%{ $('input#card_number').val('4242424242424242'); })
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
page.execute_script(%{ $('input#cc-csc').val('123'); })
page.execute_script(%{ $('#submitButton').click(); })
sleep(20)
end
expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true
if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key
make_stripe_purchase
# expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(current_path).to eq(conference_physical_tickets_path(conference.short_title))
expect(page).to have_content 'Your ticket is booked successfully.'
end
end
@ -75,19 +83,8 @@ feature Registration, feature: true, js: true do
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
if Rails.application.secrets.stripe_publishable_key
find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
sleep(5)
Capybara.within_frame stripe_iframe do
expect(page).to have_content('book your tickets')
page.execute_script(%{ $('input#card_number').val('4000000000000341'); })
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
page.execute_script(%{ $('input#cc-csc').val('123'); })
page.execute_script(%{ $('#submitButton').click(); })
sleep(20)
end
if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key
make_failed_stripe_purchase
page.find('#flash')
expect(current_path).to eq(conference_payments_path(conference.short_title))
expect(flash).to eq('Your card was declined. Please try again with correct credentials.')
@ -203,6 +200,7 @@ feature Registration, feature: true, js: true do
context 'who is registered' do
scenario 'unregisters from conference, but ticket purchases dont delete' do
pending('SNAPCON: Investigate failure on the unregister button')
visit root_path
click_link 'Register'
@ -219,22 +217,11 @@ feature Registration, feature: true, js: true do
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
if Rails.application.secrets.stripe_publishable_key
find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last
sleep(5)
Capybara.within_frame stripe_iframe do
expect(page).to have_content('book your tickets')
page.execute_script(%{ $('input#card_number').val('4242424242424242'); })
page.execute_script(%{ $('input#cc-exp').val('08/22'); })
page.execute_script(%{ $('input#cc-csc').val('123'); })
page.execute_script(%{ $('#submitButton').click(); })
sleep(20)
end
expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true
if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key
make_stripe_purchase
# expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(current_path).to eq(conference_physical_tickets_path(conference.short_title))
expect(page).to have_content 'Your ticket is booked successfully.'
click_button 'Unregister'
end

View file

@ -232,7 +232,7 @@ feature 'Version' do
end
# TODO-SNAPCON: Figure out why this is failing!!
skip 'display changes in splashpages', feature: true, versioning: true, js: true do
xscenario 'display changes in splashpages', feature: true, versioning: true, js: true do
visit admin_conference_splashpage_path(conference.short_title)
click_link 'Create Splashpage'
click_button 'Save Changes'
@ -247,15 +247,15 @@ feature 'Version' do
uncheck('Display social media links')
check('Make splash page public?')
click_button 'Save Changes'
splashpage_id = conference.splashpage.id
click_link 'Delete'
page.accept_alert
expect(page).to have_text('Splashpage was successfully destroyed')
visit admin_revision_history_path
expect(page).to have_text("#{organizer.name} created new splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} updated public, include program, include cfp, include venue, include tickets, include lodgings, include sponsors and include social media of splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} deleted splashpage with ID #{splashpage_id} in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} created new splashpage in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} updated public, include program, include cfp, include venue, include tickets, include lodgings, include sponsors and include social media of splashpage in conference #{conference.short_title}")
expect(page).to have_text("#{organizer.name} deleted splashpage in conference #{conference.short_title}")
end
scenario 'displays users subscribe/unsubscribe to conferences', feature: true, versioning: true, js: true do

View file

@ -5,6 +5,7 @@ require 'spec_helper'
describe EventsHelper, type: :helper do
let(:conference) { create(:conference) }
let(:event) { create(:event_full, program: conference.program) }
let(:event_schedule) { create(:event_schedule) }
let(:my_vote) { 3 }
let(:max_rating) { 5 }
let(:fraction) { my_vote.to_s + '/' + max_rating.to_s }
@ -28,6 +29,27 @@ describe EventsHelper, type: :helper do
end
end
describe '#canceled_replacement_event_label' do
describe 'returns nothing' do
it "when the event isn't cancelled and is not a replacement" do
event.state = 'confirmed'
expect(canceled_replacement_event_label(event, nil, 'text-class')).to eq nil
end
it 'when the event is canceled' do
event.state = 'canceled'
expect(canceled_replacement_event_label(event, nil, 'test-class')).to eq '<span class="label label-danger test-class">CANCELED</span>'
end
it 'when the event is a replacement but is not canceled' do
event.state = 'confirmed'
allow(event_schedule).to receive(:replacement?) { true }
expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq '<span class="label label-info tent-class">REPLACEMENT</span>'
end
end
end
describe '#rating_tooltip' do
let(:vote_count) { pluralize(event.voters.length, 'vote') }

View file

@ -39,6 +39,34 @@
# !/bin/env ruby
require 'spec_helper'
context 'Delegation' do
subject do
FactoryBot.create(:conference, start_date: 1.month.from_now, end_date: 2.month.from_now)
end
context 'Venue' do
context 'when venue has not been set' do
it 'the accessors should be nil' do
expect(subject.city).to eq(nil)
expect(subject.country_name).to eq(nil)
expect(subject.venue_name).to eq(nil)
expect(subject.venue_street).to eq(nil)
end
end
context 'when venue has been set' do
it 'should delegate to venue' do
venue = FactoryBot.create(:venue)
subject.update(venue: venue)
expect(subject.city).to eq(venue.city)
expect(subject.country_name).to eq(venue.country_name)
expect(subject.venue_name).to eq(venue.name)
expect(subject.venue_street).to eq(venue.street)
end
end
end
end
describe Conference do
let(:subject) { create(:conference, start_date: Date.new(2014, 06, 30), end_date: Date.new(2014, 06, 30)) }

View file

@ -7,6 +7,7 @@
# id :bigint not null, primary key
# abstract :text
# comments_count :integer default(0), not null
# committee_review :text
# description :text
# guid :string not null
# is_highlight :boolean default(FALSE)
@ -18,6 +19,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer
@ -109,6 +111,21 @@ describe Event do
end
end
describe '#submission_limit' do
before :each do
event.event_type.maximum_abstract_length = 3
event.event_type.minimum_abstract_length = 2
end
context 'is valid' do
it 'when submission text is within limts' do
event.abstract = 'the magic three'
expect(event.valid?).to eq true
expect(event.errors.size).to eq 0
end
end
end
describe '#before_end_of_conference' do
context 'is invalid' do
it 'when event is created after the conference end_date, and returns an error message' do

View file

@ -10,6 +10,7 @@
# length :integer default(30)
# maximum_abstract_length :integer default(500)
# minimum_abstract_length :integer default(0)
# submission_instructions :text
# title :string not null
# created_at :datetime
# updated_at :datetime

View file

@ -493,7 +493,7 @@ describe User do
end
describe 'assigns admin attribute' do
it 'to second user when first user is deleted_user' do
xit 'to second user when first user is deleted_user' do
deleted_user = User.find_by(email: 'deleted@localhost.osem')
expect(deleted_user.is_admin).to be false

View file

@ -7,6 +7,7 @@
# id :bigint not null, primary key
# abstract :text
# comments_count :integer default(0), not null
# committee_review :text
# description :text
# guid :string not null
# is_highlight :boolean default(FALSE)
@ -18,6 +19,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer

View file

@ -3,9 +3,9 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'simplecov'
if ENV['TRAVIS']
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
if ENV['GITHUB_ACTIONS']
require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
end
SimpleCov.start 'rails'