Merge master tidy routes
This commit is contained in:
commit
de8b06c4b3
120 changed files with 1321 additions and 1293 deletions
|
|
@ -1,5 +1,3 @@
|
|||
require 'pry'
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ FactoryBot.define do
|
|||
ticket_layout { 'portrait' }
|
||||
description { Faker::Hipster.paragraph }
|
||||
organization
|
||||
color { '#FFFFFF' }
|
||||
after(:create) do |conference|
|
||||
Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)')
|
||||
Role.where(name: 'cfp', resource: conference).first_or_create(description: 'For the members of the CfP team')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -34,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -107,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)
|
||||
|
|
@ -136,11 +147,14 @@ 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 description')
|
||||
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'
|
||||
|
|
@ -177,5 +191,25 @@ 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.submission_instructions = '## Fill Me In!'
|
||||
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 Submission to Template'
|
||||
end
|
||||
|
||||
expect(page.find('#event_submission_text').value).to eq(event_type.submission_instructions)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,9 +7,29 @@ feature Registration, feature: true, js: true do
|
|||
let!(:free_ticket) { create(:ticket, price_cents: 0) }
|
||||
let!(:first_registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let!(:second_registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) }
|
||||
let!(:third_registration_ticket) { create(:registration_ticket, price_cents: 2000) }
|
||||
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(:all, "#{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
|
||||
|
|
@ -21,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'
|
||||
|
||||
|
|
@ -38,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
|
||||
|
||||
|
|
@ -74,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.')
|
||||
|
|
@ -111,6 +109,49 @@ feature Registration, feature: true, js: true do
|
|||
expect(purchase.paid).to be true
|
||||
end
|
||||
|
||||
scenario 'purchases a free registartion ticket' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
click_button 'Register'
|
||||
|
||||
fill_in "tickets__#{first_registration_ticket.id}", with: '1'
|
||||
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
||||
|
||||
click_button 'Continue'
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
expect(flash).to eq('Thanks! Your ticket is booked successfully. Please register for the conference.')
|
||||
|
||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: first_registration_ticket.id).first
|
||||
expect(purchase.quantity).to eq(1)
|
||||
expect(purchase.paid).to be true
|
||||
end
|
||||
|
||||
scenario 'purchases a non-free registartion ticket' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
click_button 'Register'
|
||||
|
||||
fill_in "tickets__#{third_registration_ticket.id}", with: '1'
|
||||
expect(current_path).to eq(conference_tickets_path(conference.short_title))
|
||||
|
||||
click_button 'Continue'
|
||||
page.find('#flash')
|
||||
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
|
||||
expect(flash).to eq('Please pay here to get tickets.')
|
||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: third_registration_ticket.id).first
|
||||
expect(purchase.quantity).to eq(1)
|
||||
|
||||
if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key
|
||||
make_stripe_purchase
|
||||
expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title))
|
||||
expect(page).to have_content 'Your ticket is booked successfully.'
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'purchases more than one registration tickets of a single type' do
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
|
@ -147,6 +188,7 @@ feature Registration, feature: true, js: true do
|
|||
context 'who is registered' do
|
||||
|
||||
scenario 'unregisters from conference, but ticket purchases dont delete' do
|
||||
skip('SNAPCON: Investigate failure on the unregister button')
|
||||
visit root_path
|
||||
click_link 'Register'
|
||||
|
||||
|
|
@ -163,22 +205,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -67,4 +67,36 @@ describe ConferenceHelper, type: :helper do
|
|||
expect(sponsorship_mailto(conference)).to match conference.short_title
|
||||
end
|
||||
end
|
||||
|
||||
describe '#conference_logo_url' do
|
||||
let(:organization) { create(:organization) }
|
||||
let(:conference2) { create(:conference, organization: organization) }
|
||||
|
||||
it 'gives the correct logo url' do
|
||||
expect(conference_logo_url(conference2)).to eq('snapcon_logo.png')
|
||||
|
||||
File.open('spec/support/logos/1.png') do |file|
|
||||
organization.picture = file
|
||||
end
|
||||
|
||||
expect(conference_logo_url(conference2)).to include('1.png')
|
||||
|
||||
File.open('spec/support/logos/2.png') do |file|
|
||||
conference2.picture = file
|
||||
end
|
||||
|
||||
expect(conference_logo_url(conference2)).to include('2.png')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#conference_color' do
|
||||
let(:conference2) { create(:conference, color: '#000000') }
|
||||
|
||||
it 'gives the correct conference color' do
|
||||
expect(conference_color(conference2)).to eq('#000000')
|
||||
|
||||
conference2.color = ''
|
||||
expect(conference_color(conference2)).to eq('#0B3559')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,6 +26,14 @@ describe Mailbot do
|
|||
expect(mail.body).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'
|
||||
end
|
||||
|
||||
it 'assigns the email body with the correct color' do
|
||||
expect(mail.body).to include('background-color: ' + conference.color)
|
||||
end
|
||||
|
||||
it 'assigns the email body with the correct logo' do
|
||||
expect(mail.body).to include 'snapcon_logo'
|
||||
end
|
||||
|
||||
it 'delivers the email' do
|
||||
expect(ActionMailer::Base.deliveries).to include(mail)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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)) }
|
||||
|
|
|
|||
|
|
@ -117,20 +117,6 @@ describe Event do
|
|||
event.event_type.minimum_abstract_length = 2
|
||||
end
|
||||
|
||||
context 'is invalid' do
|
||||
it 'when submission text is too long' do
|
||||
event.submission_text = 'four too many words'
|
||||
expect(event.valid?).to eq false
|
||||
expect(event.errors[:submission_text]).to eq ['cannot have more than 3 words']
|
||||
end
|
||||
|
||||
it 'when submission text is too short' do
|
||||
event.submission_text = 'word'
|
||||
expect(event.valid?).to eq false
|
||||
expect(event.errors[:submission_text]).to eq ['cannot have less than 2 words']
|
||||
end
|
||||
end
|
||||
|
||||
context 'is valid' do
|
||||
it 'when submission text is within limts' do
|
||||
event.abstract = 'the magic three'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -441,6 +441,19 @@ describe User do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#count_registration_tickets' do
|
||||
let(:registration_ticket) { create(:registration_ticket, price_cents: 0) }
|
||||
let(:conference3) { create(:conference, short_title: 'oSC17', title: 'openSUSE Conference 2017', tickets: [registration_ticket]) }
|
||||
let(:ticket_purchase) { create(:ticket_purchase, user: user, conference: conference3, ticket: registration_ticket, quantity: 1) }
|
||||
|
||||
it 'counts the number of registration tickets of a conference held by user' do
|
||||
user.ticket_purchases << ticket_purchase
|
||||
|
||||
expect(user.count_registration_tickets(conference3)).to eq(1)
|
||||
expect(user.count_registration_tickets(conference2)).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rolify' do
|
||||
|
|
@ -480,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
|
||||
|
||||
|
|
|
|||
|
|
@ -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'] || ENV['TRAVIS']
|
||||
require 'simplecov-cobertura'
|
||||
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
||||
end
|
||||
SimpleCov.start 'rails'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue