Rubocop autocorrections

This commit is contained in:
James Mason 2018-11-13 18:01:49 -08:00
parent 299738f58d
commit 43bef689fc
85 changed files with 622 additions and 578 deletions

View file

@ -7,7 +7,7 @@
guard_opts = { guard_opts = {
all_on_start: true, all_on_start: true,
all_after_pass: true, all_after_pass: true,
cmd: 'spring rspec' cmd: 'spring rspec'
} }
def model_specs ; 'spec/models' end def model_specs ; 'spec/models' end

View file

@ -32,7 +32,7 @@ module Admin
def show def show
@event_schedules = @schedule.event_schedules.eager_load( @event_schedules = @schedule.event_schedules.eager_load(
room: :tracks, room: :tracks,
event: [ event: [
:difficulty_level, :difficulty_level,
:track, :track,

View file

@ -57,6 +57,7 @@ module Admin
def sponsorship_level_required def sponsorship_level_required
return unless @conference.sponsorship_levels.empty? return unless @conference.sponsorship_levels.empty?
redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title), redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
alert: 'You need to create atleast one sponsorship level to add a sponsor' alert: 'You need to create atleast one sponsorship level to add a sponsor'
end end

View file

@ -14,6 +14,7 @@ module Admin
@conferences_with_role.uniq! @conferences_with_role.uniq!
return if @conference.blank? return if @conference.blank?
@versions = PaperTrail::Version.where(conference_id: @conference.id).accessible_by(current_ability) @versions = PaperTrail::Version.where(conference_id: @conference.id).accessible_by(current_ability)
end end

View file

@ -12,6 +12,7 @@ class ApplicationController < ActionController::Base
def store_location def store_location
# store last url - this is needed for post-login redirect to whatever the user last visited. # store last url - this is needed for post-login redirect to whatever the user last visited.
return unless request.get? return unless request.get?
if (request.path != '/accounts/sign_in' && if (request.path != '/accounts/sign_in' &&
request.path != '/accounts/sign_up' && request.path != '/accounts/sign_up' &&
request.path != '/accounts/password/new' && request.path != '/accounts/password/new' &&

View file

@ -15,6 +15,7 @@ class PaymentsController < ApplicationController
if @total_amount_to_pay.zero? if @total_amount_to_pay.zero?
raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment)
end end
@unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference)
end end

View file

@ -21,8 +21,8 @@ class PhysicalTicketsController < ApplicationController
format.pdf do format.pdf do
pdf = TicketPdf.new(@conference, @user, @physical_ticket, @ticket_layout, @file_name) pdf = TicketPdf.new(@conference, @user, @physical_ticket, @ticket_layout, @file_name)
send_data pdf.render, send_data pdf.render,
filename: @file_name, filename: @file_name,
type: 'application/pdf', type: 'application/pdf',
disposition: 'attachment' disposition: 'attachment'
end end
end end

View file

@ -99,6 +99,7 @@ module ApplicationHelper
def concurrent_events(event) def concurrent_events(event)
return nil unless event.scheduled? && event.program.selected_event_schedules return nil unless event.scheduled? && event.program.selected_event_schedules
event_schedule = event.program.selected_event_schedules.find { |es| es.event == event } event_schedule = event.program.selected_event_schedules.find { |es| es.event == event }
other_event_schedules = event.program.selected_event_schedules.reject { |other_event_schedule| other_event_schedule == event_schedule } other_event_schedules = event.program.selected_event_schedules.reject { |other_event_schedule| other_event_schedule == event_schedule }
concurrent_events = [] concurrent_events = []
@ -106,6 +107,7 @@ module ApplicationHelper
event_time_range = (event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(event_schedule.end_time.strftime '%Y-%m-%d %H:%M') event_time_range = (event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(event_schedule.end_time.strftime '%Y-%m-%d %H:%M')
other_event_schedules.each do |other_event_schedule| other_event_schedules.each do |other_event_schedule|
next unless other_event_schedule.event.confirmed? next unless other_event_schedule.event.confirmed?
other_event_time_range = (other_event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(other_event_schedule.end_time.strftime '%Y-%m-%d %H:%M') other_event_time_range = (other_event_schedule.start_time.strftime '%Y-%m-%d %H:%M')...(other_event_schedule.end_time.strftime '%Y-%m-%d %H:%M')
if (event_time_range.to_a & other_event_time_range.to_a).present? if (event_time_range.to_a & other_event_time_range.to_a).present?
concurrent_events << other_event_schedule.event concurrent_events << other_event_schedule.event

View file

@ -20,6 +20,7 @@ module DateTimeHelper
# * +String+ -> formated datetime object # * +String+ -> formated datetime object
def format_datetime(obj) def format_datetime(obj)
return unless obj return unless obj
obj.strftime('%Y-%m-%d %H:%M') obj.strftime('%Y-%m-%d %H:%M')
end end

View file

@ -9,6 +9,7 @@ module EventsHelper
# * +String+ -> number of registrations / max allowed registrations # * +String+ -> number of registrations / max allowed registrations
def registered_text(event) def registered_text(event)
return "Registered: #{event.registrations.count}/#{event.max_attendees}" if event.max_attendees return "Registered: #{event.registrations.count}/#{event.max_attendees}" if event.max_attendees
"Registered: #{event.registrations.count}" "Registered: #{event.registrations.count}"
end end
@ -47,8 +48,8 @@ module EventsHelper
def track_selector_input(form) def track_selector_input(form)
if @program.tracks.confirmed.cfp_active.any? if @program.tracks.confirmed.cfp_active.any?
form.input :track_id, as: :select, form.input :track_id, as: :select,
collection: @program.tracks.confirmed.cfp_active.pluck(:name, :id), collection: @program.tracks.confirmed.cfp_active.pluck(:name, :id),
include_blank: '(Please select)' include_blank: '(Please select)'
end end
end end
@ -163,12 +164,12 @@ module EventsHelper
conference_id, conference_id,
event.id, event.id,
event.send(attribute), event.send(attribute),
url: admin_conference_program_event_path( url: admin_conference_program_event_path(
conference_id, conference_id,
event, event,
event: { attribute => nil } event: { attribute => nil }
), ),
class: 'switch-checkbox' class: 'switch-checkbox'
) )
end end

View file

@ -191,9 +191,9 @@ module FormatHelper
return '' if text.nil? return '' if text.nil?
options = { options = {
autolink: true, autolink: true,
space_after_headers: true, space_after_headers: true,
no_intra_emphasis: true no_intra_emphasis: true
} }
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options) markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(escape_html: escape_html), options)
markdown.render(text).html_safe markdown.render(text).html_safe
@ -205,6 +205,7 @@ module FormatHelper
def quantity_left_of(resource) def quantity_left_of(resource)
return '-/-' if resource.quantity.blank? return '-/-' if resource.quantity.blank?
"#{resource.quantity - resource.used}/#{resource.quantity}" "#{resource.quantity - resource.used}/#{resource.quantity}"
end end
end end

View file

@ -13,6 +13,7 @@ module VersionsHelper
org = Organization.find_by(id: organization_id) org = Organization.find_by(id: organization_id)
return current_or_last_object_state('Organization', organization_id).try(:name) unless org return current_or_last_object_state('Organization', organization_id).try(:name) unless org
org.name.to_s org.name.to_s
end end
@ -47,6 +48,7 @@ module VersionsHelper
# Otherwise Returns object state just before deletion # Otherwise Returns object state just before deletion
def current_or_last_object_state(model_name, id) def current_or_last_object_state(model_name, id)
return nil unless id.present? && model_name.present? return nil unless id.present? && model_name.present?
begin begin
object = model_name.constantize.find_by(id: id) object = model_name.constantize.find_by(id: id)
rescue NameError rescue NameError

View file

@ -2,12 +2,12 @@
class Mailbot < ActionMailer::Base class Mailbot < ActionMailer::Base
def registration_mail(conference, user) def registration_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.registration_subject, subject: conference.email_settings.registration_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.registration_body)) conference.email_settings.registration_body))
end end
def ticket_confirmation_mail(ticket_purchase) def ticket_confirmation_mail(ticket_purchase)
@ -20,110 +20,110 @@ class Mailbot < ActionMailer::Base
attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}.pdf"] = pdf.render attachments["ticket_for_#{@conference.short_title}_#{physical_ticket.id}.pdf"] = pdf.render
end end
mail(to: @user.email, mail(to: @user.email,
from: @conference.contact.email, from: @conference.contact.email,
template_name: 'ticket_confirmation_template', template_name: 'ticket_confirmation_template',
subject: "#{@conference.title} | Ticket Confirmation and PDF!") subject: "#{@conference.title} | Ticket Confirmation and PDF!")
end end
def acceptance_mail(event) def acceptance_mail(event)
conference = event.program.conference conference = event.program.conference
mail(to: event.submitter.email, mail(to: event.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.accepted_subject, subject: conference.email_settings.accepted_subject,
body: conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body)) body: conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body))
end end
def submitted_proposal_mail(event) def submitted_proposal_mail(event)
conference = event.program.conference conference = event.program.conference
mail(to: event.submitter.email, mail(to: event.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.submitted_proposal_subject, subject: conference.email_settings.submitted_proposal_subject,
body: conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body)) body: conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body))
end end
def rejection_mail(event) def rejection_mail(event)
conference = event.program.conference conference = event.program.conference
mail(to: event.submitter.email, mail(to: event.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.rejected_subject, subject: conference.email_settings.rejected_subject,
body: conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body)) body: conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body))
end end
def confirm_reminder_mail(event) def confirm_reminder_mail(event)
conference = event.program.conference conference = event.program.conference
mail(to: event.submitter.email, mail(to: event.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.confirmed_without_registration_subject, subject: conference.email_settings.confirmed_without_registration_subject,
body: conference.email_settings.generate_event_mail(event, body: conference.email_settings.generate_event_mail(event,
conference.email_settings.confirmed_without_registration_body)) conference.email_settings.confirmed_without_registration_body))
end end
def conference_date_update_mail(conference, user) def conference_date_update_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.conference_dates_updated_subject, subject: conference.email_settings.conference_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.conference_dates_updated_body)) conference.email_settings.conference_dates_updated_body))
end end
def conference_registration_date_update_mail(conference, user) def conference_registration_date_update_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.conference_registration_dates_updated_subject, subject: conference.email_settings.conference_registration_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.conference_registration_dates_updated_body)) conference.email_settings.conference_registration_dates_updated_body))
end end
def conference_venue_update_mail(conference, user) def conference_venue_update_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.venue_updated_subject, subject: conference.email_settings.venue_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.venue_updated_body)) conference.email_settings.venue_updated_body))
end end
def conference_schedule_update_mail(conference, user) def conference_schedule_update_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.program_schedule_public_subject, subject: conference.email_settings.program_schedule_public_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.program_schedule_public_body)) conference.email_settings.program_schedule_public_body))
end end
def conference_cfp_update_mail(conference, user) def conference_cfp_update_mail(conference, user)
mail(to: user.email, mail(to: user.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.cfp_dates_updated_subject, subject: conference.email_settings.cfp_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference, body: conference.email_settings.generate_email_on_conf_updates(conference,
user, user,
conference.email_settings.cfp_dates_updated_body)) conference.email_settings.cfp_dates_updated_body))
end end
def conference_booths_acceptance_mail(booth) def conference_booths_acceptance_mail(booth)
conference = booth.conference conference = booth.conference
mail(to: booth.submitter.email, mail(to: booth.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.booths_acceptance_subject, subject: conference.email_settings.booths_acceptance_subject,
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body)) body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body))
end end
def conference_booths_rejection_mail(booth) def conference_booths_rejection_mail(booth)
conference = booth.conference conference = booth.conference
mail(to: booth.submitter.email, mail(to: booth.submitter.email,
from: conference.contact.email, from: conference.contact.email,
subject: conference.email_settings.booths_rejection_subject, subject: conference.email_settings.booths_rejection_subject,
body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body)) body: conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body))
end end
def event_comment_mail(comment, user) def event_comment_mail(comment, user)
@ -132,9 +132,9 @@ class Mailbot < ActionMailer::Base
@conference = @event.program.conference @conference = @event.program.conference
@user = user @user = user
mail(to: @user.email, mail(to: @user.email,
from: @conference.contact.email, from: @conference.contact.email,
template_name: 'comment_template', template_name: 'comment_template',
subject: "New comment has been posted for #{@event.title}") subject: "New comment has been posted for #{@event.title}")
end end
end end

View file

@ -150,13 +150,13 @@ class Ability
can :manage, Event, program: { conference_id: conf_ids_for_organizer } can :manage, Event, program: { conference_id: conf_ids_for_organizer }
# To access comment link in menu bar # To access comment link in menu bar
can :index, Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)
end end
if conf_ids_for_cfp if conf_ids_for_cfp
# To access comment link in menu bar # To access comment link in menu bar
can :index, Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
# To access conference/proposals # To access conference/proposals
can :manage, Event, program: { conference_id: conf_ids_for_cfp } can :manage, Event, program: { conference_id: conf_ids_for_cfp }
end end

View file

@ -115,7 +115,7 @@ class AdminAbility
can :manage, Contact, conference_id: conf_ids can :manage, Contact, conference_id: conf_ids
can :manage, EmailSettings, conference_id: conf_ids can :manage, EmailSettings, conference_id: conf_ids
can :manage, Commercial, commercialable_type: 'Conference', can :manage, Commercial, commercialable_type: 'Conference',
commercialable_id: conf_ids commercialable_id: conf_ids
can :manage, Registration, conference_id: conf_ids can :manage, Registration, conference_id: conf_ids
can :manage, RegistrationPeriod do |registration_period| can :manage, RegistrationPeriod do |registration_period|
conference = registration_period.conference conference = registration_period.conference
@ -137,10 +137,10 @@ class AdminAbility
can :manage, Track, program: { conference_id: conf_ids } can :manage, Track, program: { conference_id: conf_ids }
can :manage, DifficultyLevel, program: { conference_id: conf_ids } can :manage, DifficultyLevel, program: { conference_id: conf_ids }
can :manage, Commercial, commercialable_type: 'Event', can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id) commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
can :manage, Venue, conference_id: conf_ids can :manage, Venue, conference_id: conf_ids
can :manage, Commercial, commercialable_type: 'Venue', can :manage, Commercial, commercialable_type: 'Venue',
commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id) commercialable_id: Venue.where(conference_id: conf_ids).pluck(:id)
can :manage, Lodging, conference_id: conf_ids can :manage, Lodging, conference_id: conf_ids
can :manage, Room, venue: { conference_id: conf_ids } can :manage, Room, venue: { conference_id: conf_ids }
can :manage, Sponsor, conference_id: conf_ids can :manage, Sponsor, conference_id: conf_ids
@ -151,7 +151,7 @@ class AdminAbility
conf_ids.include? conf_id conf_ids.include? conf_id
end end
can :index, Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource) # Abilities for Role (Conference resource)
can [:index, :show], Role do |role| can [:index, :show], Role do |role|
@ -188,9 +188,9 @@ class AdminAbility
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp } can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
can :manage, Program, conference_id: conf_ids_for_cfp can :manage, Program, conference_id: conf_ids_for_cfp
can :manage, Commercial, commercialable_type: 'Event', can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) commercialable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
can :index, Comment, commentable_type: 'Event', can :index, Comment, commentable_type: 'Event',
commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id) commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)
# Abilities for Role (Conference resource) # Abilities for Role (Conference resource)
can [:index, :show], Role do |role| can [:index, :show], Role do |role|
@ -306,7 +306,7 @@ class AdminAbility
can :manage, Event, track_id: track_ids_for_track_organizer can :manage, Event, track_id: track_ids_for_track_organizer
can :manage, Commercial, commercialable_type: 'Event', can :manage, Commercial, commercialable_type: 'Event',
commercialable_id: Event.where(track_id: track_ids_for_track_organizer).pluck(:id) commercialable_id: Event.where(track_id: track_ids_for_track_organizer).pluck(:id)
# Show Scheduless in the admin sidebar # Show Scheduless in the admin sidebar
can :update, Schedule do |schedule| can :update, Schedule do |schedule|

View file

@ -16,7 +16,7 @@ class Booth < ApplicationRecord
validates :title, validates :title,
uniqueness: { case_sensitive: false }, uniqueness: { case_sensitive: false },
presence: true presence: true
validates :description, validates :description,
:reasoning, :reasoning,

View file

@ -13,12 +13,12 @@ class Cfp < ApplicationRecord
validate :before_end_of_conference validate :before_end_of_conference
validate :start_after_end_date validate :start_after_end_date
validates :cfp_type, validates :cfp_type,
presence: true, presence: true,
inclusion: { inclusion: {
in: TYPES in: TYPES
}, },
uniqueness: { uniqueness: {
scope: :program, scope: :program,
case_sensitive: false case_sensitive: false
} }

View file

@ -23,8 +23,8 @@ class Comment < ApplicationRecord
def self.build_from(obj, user_id, comment) def self.build_from(obj, user_id, comment)
new \ new \
commentable: obj, commentable: obj,
body: comment, body: comment,
user_id: user_id user_id: user_id
end end
#helper method to check if a comment has children #helper method to check if a comment has children

View file

@ -344,18 +344,18 @@ class Conference < ApplicationRecord
# * +hash+ -> true -> filled / false -> missing # * +hash+ -> true -> filled / false -> missing
def get_status def get_status
result = { result = {
registration: registration_date_set?, registration: registration_date_set?,
cfp: cfp_set?, cfp: cfp_set?,
venue: venue_set?, venue: venue_set?,
rooms: rooms_set?, rooms: rooms_set?,
tracks: tracks_set?, tracks: tracks_set?,
event_types: event_types_set?, event_types: event_types_set?,
difficulty_levels: difficulty_levels_set?, difficulty_levels: difficulty_levels_set?,
splashpage: splashpage&.public? splashpage: splashpage&.public?
} }
result.update( result.update(
process: calculate_setup_progress(result), process: calculate_setup_progress(result),
short_title: short_title short_title: short_title
).with_indifferent_access ).with_indifferent_access
end end
@ -670,6 +670,7 @@ class Conference < ApplicationRecord
return false unless email_settings.send_on_conference_dates_updated return false unless email_settings.send_on_conference_dates_updated
# do not notify unless one of the dates changed # do not notify unless one of the dates changed
return false unless start_date_changed? || end_date_changed? return false unless start_date_changed? || end_date_changed?
# do not notify unless the mail content is set up # do not notify unless the mail content is set up
(email_settings.conference_dates_updated_subject.present? && email_settings.conference_dates_updated_body.present?) (email_settings.conference_dates_updated_subject.present? && email_settings.conference_dates_updated_body.present?)
end end
@ -686,6 +687,7 @@ class Conference < ApplicationRecord
return false unless registration_period return false unless registration_period
# do not notify unless one of the dates changed # do not notify unless one of the dates changed
return false unless registration_period.start_date_changed? || registration_period.end_date_changed? return false unless registration_period.start_date_changed? || registration_period.end_date_changed?
# do not notify unless the mail content is set up # do not notify unless the mail content is set up
(email_settings.conference_registration_dates_updated_subject.present? && email_settings.conference_registration_dates_updated_body.present?) (email_settings.conference_registration_dates_updated_subject.present? && email_settings.conference_registration_dates_updated_body.present?)
end end
@ -710,7 +712,7 @@ class Conference < ApplicationRecord
start_index = { start_index = {
tracks: (program.tracks.count + 1), tracks: (program.tracks.count + 1),
levels: (program.difficulty_levels.count + 51), levels: (program.difficulty_levels.count + 51),
types: (program.event_types.count + 101) types: (program.event_types.count + 101)
} }
next_color(start_index[collection]) next_color(start_index[collection])
end end
@ -842,8 +844,8 @@ class Conference < ApplicationRecord
# * +Hash+ -> e.g. 'Confirmed' => { 3 => 5, 4 => 6 } # * +Hash+ -> e.g. 'Confirmed' => { 3 => 5, 4 => 6 }
def get_events_per_week_by_state def get_events_per_week_by_state
result = { result = {
'Submitted' => {}, 'Submitted' => {},
'Confirmed' => {}, 'Confirmed' => {},
'Unconfirmed' => {} 'Unconfirmed' => {}
} }

View file

@ -12,6 +12,7 @@ class Contact < ApplicationRecord
def has_social_media? def has_social_media?
return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || mastodon.present? || email.present? return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || mastodon.present? || email.present?
false false
end end
end end

View file

@ -7,17 +7,17 @@ class EmailSettings < ApplicationRecord
def get_values(conference, user, event = nil, booth = nil) def get_values(conference, user, event = nil, booth = nil)
h = { h = {
'email' => user.email, 'email' => user.email,
'name' => user.name, 'name' => user.name,
'conference' => conference.title, 'conference' => conference.title,
'conference_start_date' => conference.start_date, 'conference_start_date' => conference.start_date,
'conference_end_date' => conference.end_date, 'conference_end_date' => conference.end_date,
'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url( 'registrationlink' => Rails.application.routes.url_helpers.conference_conference_registration_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
'conference_splash_link' => Rails.application.routes.url_helpers.conference_url( 'conference_splash_link' => Rails.application.routes.url_helpers.conference_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')), conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')),
'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url( 'schedule_link' => Rails.application.routes.url_helpers.conference_schedule_url(
conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000')) conference.short_title, host: (ENV['OSEM_HOSTNAME'] || 'localhost:3000'))
} }

View file

@ -94,6 +94,7 @@ class Event < ApplicationRecord
def registration_possible? def registration_possible?
return false unless require_registration && state == 'confirmed' return false unless require_registration && state == 'confirmed'
return true if max_attendees.nil? return true if max_attendees.nil?
registrations.count < max_attendees registrations.count < max_attendees
end end
@ -228,14 +229,14 @@ class Event < ApplicationRecord
# Returns +Hash+ # Returns +Hash+
def progress_status def progress_status
{ {
registered: speakers.all? { |speaker| program.conference.user_registered? speaker }, registered: speakers.all? { |speaker| program.conference.user_registered? speaker },
commercials: commercials.any?, commercials: commercials.any?,
biographies: speakers.all? { |speaker| !speaker.biography.blank? }, biographies: speakers.all? { |speaker| !speaker.biography.blank? },
subtitle: !subtitle.blank?, subtitle: !subtitle.blank?,
track: (!track.blank? unless program.tracks.empty?), track: (!track.blank? unless program.tracks.empty?),
difficulty_level: !difficulty_level.blank?, difficulty_level: !difficulty_level.blank?,
title: true, title: true,
abstract: true abstract: true
}.with_indifferent_access }.with_indifferent_access
end end
@ -278,6 +279,7 @@ class Event < ApplicationRecord
def ended? def ended?
event_schedule = event_schedules.find_by(schedule_id: selected_schedule_id) event_schedule = event_schedules.find_by(schedule_id: selected_schedule_id)
return false unless event_schedule return false unless event_schedule
event_schedule.end_time < Time.current event_schedule.end_time < Time.current
end end
@ -291,12 +293,14 @@ class Event < ApplicationRecord
# Do not allow, for the event, more attendees than the size of the room # Do not allow, for the event, more attendees than the size of the room
def max_attendees_no_more_than_room_size def max_attendees_no_more_than_room_size
return unless room && max_attendees_changed? return unless room && max_attendees_changed?
errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size) errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size)
end end
def abstract_limit def abstract_limit
# If we don't have an event type, there is no need to count anything # If we don't have an event type, there is no need to count anything
return unless event_type && abstract return unless event_type && abstract
len = abstract.split.size len = abstract.split.size
max_words = event_type.maximum_abstract_length max_words = event_type.maximum_abstract_length
min_words = event_type.minimum_abstract_length min_words = event_type.minimum_abstract_length
@ -335,6 +339,7 @@ class Event < ApplicationRecord
# #
def valid_track def valid_track
return unless track&.program && program return unless track&.program && program
errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program errors.add(:track, 'is invalid') unless track.confirmed? && track.program == program
end end

View file

@ -56,6 +56,7 @@ class EventSchedule < ApplicationRecord
def replacement?(event_schedule_source = nil) def replacement?(event_schedule_source = nil)
return false unless event.state == 'confirmed' return false unless event.state == 'confirmed'
return replaced_event_schedules.exists? unless event_schedule_source return replaced_event_schedules.exists? unless event_schedule_source
event_schedule_source.any? { |event_schedule| intersects_with?(event_schedule) } event_schedule_source.any? { |event_schedule| intersects_with?(event_schedule) }
end end
@ -82,11 +83,13 @@ class EventSchedule < ApplicationRecord
def start_after_end_hour def start_after_end_hour
return unless event && start_time && event.program && event.program.conference && event.program.conference.end_hour return unless event && start_time && event.program && event.program.conference && event.program.conference.end_hour
errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour
end end
def start_before_start_hour def start_before_start_hour
return unless event && start_time && event.program && event.program.conference && event.program.conference.start_hour return unless event && start_time && event.program && event.program.conference && event.program.conference.start_hour
errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour
end end
@ -99,6 +102,7 @@ class EventSchedule < ApplicationRecord
# #
def same_room_as_track def same_room_as_track
return unless event.try(:track).try(:room) return unless event.try(:track).try(:room)
errors.add(:room, "must be the same as the track's room (#{event.track.room.name})") unless event.track.room == room errors.add(:room, "must be the same as the track's room (#{event.track.room.name})") unless event.track.room == room
end end
@ -122,6 +126,7 @@ class EventSchedule < ApplicationRecord
# #
def valid_schedule def valid_schedule
return unless event.try(:track).try(:self_organized?) && schedule return unless event.try(:track).try(:self_organized?) && schedule
errors.add(:schedule, "must be one of #{event.track.name} track's schedules") unless event.track.schedules.include?(schedule) errors.add(:schedule, "must be one of #{event.track.name} track's schedules") unless event.track.schedules.include?(schedule)
end end
end end

View file

@ -4,7 +4,7 @@ class EventType < ApplicationRecord
belongs_to :program, touch: true belongs_to :program, touch: true
has_many :events, dependent: :restrict_with_error has_many :events, dependent: :restrict_with_error
has_paper_trail meta: { conference_id: :conference_id }, has_paper_trail meta: { conference_id: :conference_id },
ignore: %i[updated_at] ignore: %i[updated_at]
validates :title, presence: true validates :title, presence: true

View file

@ -13,7 +13,7 @@ class Organization < ApplicationRecord
uniqueness: { uniqueness: {
case_sensitive: false case_sensitive: false
}, },
presence: true presence: true
mount_uploader :picture, PictureUploader, mount_on: :picture mount_uploader :picture, PictureUploader, mount_on: :picture

View file

@ -13,7 +13,7 @@ class Payment < ApplicationRecord
validates :conference_id, presence: true validates :conference_id, presence: true
enum status: { enum status: {
unpaid: 0, unpaid: 0,
success: 1, success: 1,
failure: 2 failure: 2
} }
@ -23,11 +23,11 @@ class Payment < ApplicationRecord
end end
def purchase def purchase
gateway_response = Stripe::Charge.create source: stripe_customer_token, gateway_response = Stripe::Charge.create source: stripe_customer_token,
receipt_email: stripe_customer_email, receipt_email: stripe_customer_email,
description: "ticket purchases(#{user.username})", description: "ticket purchases(#{user.username})",
amount: amount_to_pay, amount: amount_to_pay,
currency: conference.tickets.first.price_currency currency: conference.tickets.first.price_currency
self.amount = gateway_response[:amount] self.amount = gateway_response[:amount]
self.last4 = gateway_response[:source][:last4] self.last4 = gateway_response[:source][:last4]

View file

@ -82,6 +82,7 @@ class Program < ApplicationRecord
event_schedules = selected_schedule.event_schedules.includes(*includes).order(start_time: :asc) if selected_schedule event_schedules = selected_schedule.event_schedules.includes(*includes).order(start_time: :asc) if selected_schedule
tracks.self_organized.confirmed.includes(selected_schedule: { event_schedules: includes }).order(start_date: :asc).each do |track| tracks.self_organized.confirmed.includes(selected_schedule: { event_schedules: includes }).order(start_date: :asc).each do |track|
next unless track.selected_schedule next unless track.selected_schedule
event_schedules += track.selected_schedule.event_schedules event_schedules += track.selected_schedule.event_schedules
end end
event_schedules.sort_by(&:start_time) event_schedules.sort_by(&:start_time)
@ -157,6 +158,7 @@ class Program < ApplicationRecord
return false unless conference.email_settings.send_on_program_schedule_public return false unless conference.email_settings.send_on_program_schedule_public
# do not notify if the schedule is not public # do not notify if the schedule is not public
return false unless schedule_public return false unless schedule_public
# do not notify unless the mail content is set up # do not notify unless the mail content is set up
(!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?) (!conference.email_settings.program_schedule_public_subject.blank? && !conference.email_settings.program_schedule_public_body.blank?)
end end
@ -173,6 +175,7 @@ class Program < ApplicationRecord
# * +False+ -> If there is not any event for the given date # * +False+ -> If there is not any event for the given date
def any_event_for_this_date?(date) def any_event_for_this_date?(date)
return false unless selected_schedule.present? return false unless selected_schedule.present?
parsed_date = DateTime.parse("#{date} 00:00").utc parsed_date = DateTime.parse("#{date} 00:00").utc
range = parsed_date..(parsed_date + 1.day) range = parsed_date..(parsed_date + 1.day)
selected_schedule.event_schedules.any? { |es| range.cover?(es.start_time) } selected_schedule.event_schedules.any? { |es| range.cover?(es.start_time) }
@ -185,6 +188,7 @@ class Program < ApplicationRecord
# * +ActiveRecord+ -> The program's cfp with cfp_type == 'events' # * +ActiveRecord+ -> The program's cfp with cfp_type == 'events'
def cfp def cfp
return nil if cfps.for_events.blank? return nil if cfps.for_events.blank?
cfps.for_events cfps.for_events
end end
@ -231,6 +235,7 @@ class Program < ApplicationRecord
# #
def check_languages_format def check_languages_format
return unless languages.present? return unless languages.present?
# All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved # All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
self.languages = languages.delete(' ').downcase self.languages = languages.delete(' ').downcase
errors.add(:languages, 'must be two letters separated by commas') && return unless errors.add(:languages, 'must be two letters separated by commas') && return unless

View file

@ -19,6 +19,7 @@ class Survey < ActiveRecord::Base
# * +false+ -> If the survey is closed # * +false+ -> If the survey is closed
def active? def active?
return true unless start_date || end_date return true unless start_date || end_date
# Find timezone of conference (survyeable is Conference or Event) # Find timezone of conference (survyeable is Conference or Event)
timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.timezone timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.timezone
now = Time.current.in_time_zone(timezone) now = Time.current.in_time_zone(timezone)

View file

@ -5,7 +5,7 @@ class Ticket < ApplicationRecord
has_many :ticket_purchases, dependent: :destroy has_many :ticket_purchases, dependent: :destroy
has_many :buyers, -> { distinct }, through: :ticket_purchases, source: :user has_many :buyers, -> { distinct }, through: :ticket_purchases, source: :user
has_paper_trail meta: { conference_id: :conference_id }, has_paper_trail meta: { conference_id: :conference_id },
ignore: %i[updated_at] ignore: %i[updated_at]
monetize :price_cents, with_model_currency: :price_currency monetize :price_cents, with_model_currency: :price_currency
@ -66,6 +66,7 @@ class Ticket < ApplicationRecord
def tickets_turnover_total(id) def tickets_turnover_total(id)
ticket = Ticket.find(id) ticket = Ticket.find(id)
return Money.new(0, 'USD') unless ticket return Money.new(0, 'USD') unless ticket
sum = ticket.ticket_purchases.paid.total sum = ticket.ticket_purchases.paid.total
Money.new(sum, ticket.price_currency) Money.new(sum, ticket.price_currency)
end end
@ -79,6 +80,7 @@ class Ticket < ApplicationRecord
def tickets_of_conference_have_same_currency def tickets_of_conference_have_same_currency
tickets = Ticket.where(conference_id: conference_id) tickets = Ticket.where(conference_id: conference_id)
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first) return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
unless tickets.all?{|t| t.price_currency == price_currency } unless tickets.all?{|t| t.price_currency == price_currency }
errors.add(:price_currency, 'is different from the existing tickets of this conference.') errors.add(:price_currency, 'is different from the existing tickets of this conference.')
end end

View file

@ -51,21 +51,21 @@ class TicketPurchase < ApplicationRecord
def self.purchase_ticket(conference, quantity, ticket, user) def self.purchase_ticket(conference, quantity, ticket, user)
if quantity > 0 if quantity > 0
purchase = new(ticket_id: ticket.id, purchase = new(ticket_id: ticket.id,
conference_id: conference.id, conference_id: conference.id,
user_id: user.id, user_id: user.id,
quantity: quantity, quantity: quantity,
amount_paid: ticket.price) amount_paid: ticket.price)
purchase.pay(nil) if ticket.price_cents.zero? purchase.pay(nil) if ticket.price_cents.zero?
end end
purchase purchase
end end
def self.update_quantity(conference, quantity, ticket, user) def self.update_quantity(conference, quantity, ticket, user)
purchase = TicketPurchase.where(ticket_id: ticket.id, purchase = TicketPurchase.where(ticket_id: ticket.id,
conference_id: conference.id, conference_id: conference.id,
user_id: user.id, user_id: user.id,
paid: false).first paid: false).first
purchase.quantity = quantity if quantity > 0 purchase.quantity = quantity if quantity > 0
purchase purchase

View file

@ -19,13 +19,13 @@ class Track < ApplicationRecord
validates :name, presence: true validates :name, presence: true
validates :color, format: /\A#[0-9A-F]{6}\z/ validates :color, format: /\A#[0-9A-F]{6}\z/
validates :short_name, validates :short_name,
presence: true, presence: true,
format: /\A[a-zA-Z0-9_-]*\z/, format: /\A[a-zA-Z0-9_-]*\z/,
uniqueness: { uniqueness: {
scope: :program scope: :program
} }
validates :state, validates :state,
presence: true, presence: true,
inclusion: { in: %w(new to_accept accepted confirmed to_reject rejected canceled withdrawn) } inclusion: { in: %w(new to_accept accepted confirmed to_reject rejected canceled withdrawn) }
validates :cfp_active, inclusion: { in: [true, false] } validates :cfp_active, inclusion: { in: [true, false] }
validates :start_date, presence: true, if: :self_organized_and_accepted_or_confirmed? validates :start_date, presence: true, if: :self_organized_and_accepted_or_confirmed?
@ -92,6 +92,7 @@ class Track < ApplicationRecord
# * +false+ -> if the track doesn't have a submitter # * +false+ -> if the track doesn't have a submitter
def self_organized? def self_organized?
return true if submitter return true if submitter
false false
end end
@ -200,6 +201,7 @@ class Track < ApplicationRecord
# #
def dates_within_conference_dates def dates_within_conference_dates
return unless start_date && end_date && program.try(:conference).try(:start_date) && program.try(:conference).try(:end_date) return unless start_date && end_date && program.try(:conference).try(:start_date) && program.try(:conference).try(:end_date)
errors.add(:start_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(start_date) errors.add(:start_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(start_date)
errors.add(:end_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(end_date) errors.add(:end_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(end_date)
end end
@ -209,6 +211,7 @@ class Track < ApplicationRecord
# #
def start_date_before_end_date def start_date_before_end_date
return unless start_date && end_date return unless start_date && end_date
errors.add(:start_date, 'can\'t be after the end date') if start_date > end_date errors.add(:start_date, 'can\'t be after the end date') if start_date > end_date
end end
@ -217,6 +220,7 @@ class Track < ApplicationRecord
# #
def valid_room def valid_room
return unless room.try(:venue).try(:conference) && program.try(:conference) return unless room.try(:venue).try(:conference) && program.try(:conference)
errors.add(:room, "must be a room of #{program.conference.venue.name}") unless room.venue.conference == program.conference errors.add(:room, "must be a room of #{program.conference.venue.name}") unless room.venue.conference == program.conference
end end
@ -225,8 +229,10 @@ class Track < ApplicationRecord
# #
def overlapping def overlapping
return unless start_date && end_date && room && program.try(:tracks) return unless start_date && end_date && room && program.try(:tracks)
(program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track| (program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track|
next unless existing_track.room == room && existing_track.start_date && existing_track.end_date next unless existing_track.room == room && existing_track.start_date && existing_track.end_date
if start_date >= existing_track.start_date && start_date <= existing_track.end_date || if start_date >= existing_track.start_date && start_date <= existing_track.end_date ||
end_date >= existing_track.start_date && end_date <= existing_track.end_date || end_date >= existing_track.start_date && end_date <= existing_track.end_date ||
start_date <= existing_track.start_date && end_date >= existing_track.end_date start_date <= existing_track.start_date && end_date >= existing_track.end_date

View file

@ -87,7 +87,7 @@ class User < ApplicationRecord
uniqueness: { uniqueness: {
case_sensitive: false case_sensitive: false
}, },
presence: true presence: true
validate :biography_limit validate :biography_limit
@ -103,6 +103,7 @@ class User < ApplicationRecord
event_registration = event.events_registrations.find_by(registration: registrations) event_registration = event.events_registrations.find_by(registration: registrations)
return false unless event_registration.present? return false unless event_registration.present?
event_registration.attended event_registration.attended
end end
@ -138,8 +139,8 @@ class User < ApplicationRecord
raise UserDisabled if user&.is_disabled raise UserDisabled if user&.is_disabled
if user if user
user.update_attributes(email: attributes[:email], user.update_attributes(email: attributes[:email],
last_sign_in_at: user.current_sign_in_at, last_sign_in_at: user.current_sign_in_at,
current_sign_in_at: Time.current) current_sign_in_at: Time.current)
else else
begin begin

View file

@ -38,6 +38,7 @@ class Venue < ApplicationRecord
return false unless conference.try(:email_settings).try(:send_on_venue_updated) return false unless conference.try(:email_settings).try(:send_on_venue_updated)
# do not notify unless the address changed # do not notify unless the address changed
return false unless name_changed? || street_changed? || city_changed? || country_changed? return false unless name_changed? || street_changed? || city_changed? || country_changed?
# do not notify unless the mail content is set up # do not notify unless the mail content is set up
(!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?) (!conference.email_settings.venue_updated_subject.blank? && !conference.email_settings.venue_updated_body.blank?)
end end

View file

@ -7,17 +7,17 @@ class ConferenceSerializer < ActiveModel::Serializer
:date_range, :revision :date_range, :revision
def difficulty_levels def difficulty_levels
object.program.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id, object.program.difficulty_levels.map do |difficulty_level| { id: difficulty_level.id,
title: difficulty_level.title, title: difficulty_level.title,
description: difficulty_level.description description: difficulty_level.description
} }
end end
end end
def event_types def event_types
object.program.event_types.map do |event_type| { id: event_type.id, object.program.event_types.map do |event_type| { id: event_type.id,
title: event_type.title, title: event_type.title,
length: event_type.length, length: event_type.length,
description: event_type.description description: event_type.description
} }
end end
@ -25,20 +25,20 @@ class ConferenceSerializer < ActiveModel::Serializer
def rooms def rooms
if object.venue if object.venue
object.venue.rooms.map do |room| { id: room.id, object.venue.rooms.map do |room| { id: room.id,
size: room.size, size: room.size,
events: room.event_schedules.map do |event_schedule| { guid: event_schedule.event.title, events: room.event_schedules.map do |event_schedule| { guid: event_schedule.event.title,
title: event_schedule.event.title, title: event_schedule.event.title,
subtitle: event_schedule.event.subtitle, subtitle: event_schedule.event.subtitle,
abstract: event_schedule.event.abstract, abstract: event_schedule.event.abstract,
description: event_schedule.event.description, description: event_schedule.event.description,
is_highlight: event_schedule.event.is_highlight, is_highlight: event_schedule.event.is_highlight,
require_registration: event_schedule.event.require_registration, require_registration: event_schedule.event.require_registration,
start_time: event_schedule.start_time, start_time: event_schedule.start_time,
event_type_id: event_schedule.event.event_type.id, event_type_id: event_schedule.event.event_type.id,
difficulty_level_id: event_schedule.event.difficulty_level_id, difficulty_level_id: event_schedule.event.difficulty_level_id,
track_id: event_schedule.event.track_id, track_id: event_schedule.event.track_id,
speaker_names: event_schedule.event.speaker_names speaker_names: event_schedule.event.speaker_names
} }
end end
} }
@ -49,8 +49,8 @@ class ConferenceSerializer < ActiveModel::Serializer
end end
def tracks def tracks
object.program.tracks.map do |track| { 'id' => track.id, object.program.tracks.map do |track| { 'id' => track.id,
'name' => track.name, 'name' => track.name,
'description' => track.description 'description' => track.description
} }
end end

View file

@ -53,60 +53,60 @@ Osem::Application.configure do
OmniAuth.config.mock_auth[:facebook] = OmniAuth.config.mock_auth[:facebook] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'facebook', provider: 'facebook',
uid: 'facebook-test-uid-1', uid: 'facebook-test-uid-1',
info: { info: {
name: 'facebook user', name: 'facebook user',
email: 'user-facebook@example.com', email: 'user-facebook@example.com',
username: 'user_facebook' username: 'user_facebook'
}, },
credentials: { credentials: {
token: 'fb_mock_token', token: 'fb_mock_token',
secret: 'fb_mock_secret' secret: 'fb_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:google] = OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-1', uid: 'google-test-uid-1',
info: { info: {
name: 'google user', name: 'google user',
email: 'user-google@example.com', email: 'user-google@example.com',
username: 'user_google' username: 'user_google'
}, },
credentials: { credentials: {
token: 'google_mock_token', token: 'google_mock_token',
secret: 'google_mock_secret' secret: 'google_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:suse] = OmniAuth.config.mock_auth[:suse] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'suse', provider: 'suse',
uid: 'suse-test-uid-1', uid: 'suse-test-uid-1',
info: { info: {
name: 'suse user', name: 'suse user',
email: 'user-suse@example.com', email: 'user-suse@example.com',
username: 'user_suse' username: 'user_suse'
}, },
credentials: { credentials: {
token: 'suse_mock_token', token: 'suse_mock_token',
secret: 'suse_mock_secret' secret: 'suse_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:github] = OmniAuth.config.mock_auth[:github] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'github', provider: 'github',
uid: 'github-test-uid-1', uid: 'github-test-uid-1',
info: { info: {
name: 'github user', name: 'github user',
email: 'user-github@example.com', email: 'user-github@example.com',
username: 'user_github' username: 'user_github'
}, },
credentials: { credentials: {
token: 'github_mock_token', token: 'github_mock_token',
secret: 'github_mock_secret' secret: 'github_mock_secret'
} }
) )

View file

@ -8,7 +8,7 @@ Devise.setup do |config|
config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user' config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user'
config.omniauth :google_oauth2, (ENV['OSEM_GOOGLE_KEY'] || Rails.application.secrets.google_key), (ENV['OSEM_GOOGLE_SECRET'] || Rails.application.secrets.google_secret), config.omniauth :google_oauth2, (ENV['OSEM_GOOGLE_KEY'] || Rails.application.secrets.google_key), (ENV['OSEM_GOOGLE_SECRET'] || Rails.application.secrets.google_secret),
name: 'google', name: 'google',
scope: 'email' scope: 'email'
config.omniauth :facebook, (ENV['OSEM_FACEBOOK_KEY'] || Rails.application.secrets.facebook_key), (ENV['OSEM_FACEBOOK_SECRET'] || Rails.application.secrets.facebook_secret) config.omniauth :facebook, (ENV['OSEM_FACEBOOK_KEY'] || Rails.application.secrets.facebook_key), (ENV['OSEM_FACEBOOK_SECRET'] || Rails.application.secrets.facebook_secret)
config.omniauth :github, (ENV['OSEM_GITHUB_KEY'] || Rails.application.secrets.github_key), (ENV['OSEM_GITHUB_SECRET'] || Rails.application.secrets.github_secret) config.omniauth :github, (ENV['OSEM_GITHUB_KEY'] || Rails.application.secrets.github_key), (ENV['OSEM_GITHUB_SECRET'] || Rails.application.secrets.github_secret)

View file

@ -11,7 +11,7 @@ Osem::Application.routes.draw do
controllers: { controllers: {
registrations: :registrations, confirmations: :confirmations, registrations: :registrations, confirmations: :confirmations,
omniauth_callbacks: 'users/omniauth_callbacks' }, omniauth_callbacks: 'users/omniauth_callbacks' },
path: 'accounts' path: 'accounts'
end end
# Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant) # Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant)

View file

@ -13,6 +13,7 @@ class MigrateDataPersonToUser < ActiveRecord::Migration
TempPerson.all.each do |p| TempPerson.all.each do |p|
user = TempUser.find_by(id: p.user_id) user = TempUser.find_by(id: p.user_id)
next unless user next unless user
if p.public_name.empty? if p.public_name.empty?
user.name = p.email user.name = p.email
else else

View file

@ -27,12 +27,12 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration
week = event_version.created_at.end_of_week week = event_version.created_at.end_of_week
no_events = { no_events = {
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
unconfirmed: 0, unconfirmed: 0,
confirmed: 0, confirmed: 0,
canceled: 0, canceled: 0,
rejected: 0, rejected: 0,
} }
if !conference.events_per_week if !conference.events_per_week

View file

@ -13,13 +13,13 @@ class MoveConferenceContactDetailsToContact < ActiveRecord::Migration
# Move all the settings to the new object # Move all the settings to the new object
TempConference.all.each do |conference| TempConference.all.each do |conference|
unless TempContact.exists?(conference_id: conference.id) unless TempContact.exists?(conference_id: conference.id)
TempContact.create(social_tag: conference.social_tag, TempContact.create(social_tag: conference.social_tag,
email: conference.contact_email, email: conference.contact_email,
facebook: conference.facebook_url, facebook: conference.facebook_url,
googleplus: conference.google_url, googleplus: conference.google_url,
twitter: conference.twitter_url, twitter: conference.twitter_url,
instagram: conference.instagram_url, instagram: conference.instagram_url,
public: conference.include_social_media_in_splash, public: conference.include_social_media_in_splash,
conference_id: conference.id) conference_id: conference.id)
end end
end end

View file

@ -14,9 +14,9 @@ class MoveConferenceMediaToCommercial < ActiveRecord::Migration
TempConference.all.each do |conference| TempConference.all.each do |conference|
unless TempCommercial.exists?(commercialable_id: conference.id, commercialable_id: 'Conference') unless TempCommercial.exists?(commercialable_id: conference.id, commercialable_id: 'Conference')
unless conference.media_id.blank? || conference.media_type.blank? unless conference.media_id.blank? || conference.media_type.blank?
TempCommercial.create(commercial_id: conference.media_id, TempCommercial.create(commercial_id: conference.media_id,
commercial_type: conference.media_type, commercial_type: conference.media_type,
commercialable_id: conference.id, commercialable_id: conference.id,
commercialable_type: 'Conference') commercialable_type: 'Conference')
end end
end end

View file

@ -14,9 +14,9 @@ class MoveEventMediaToCommercial < ActiveRecord::Migration
TempEvent.all.each do |event| TempEvent.all.each do |event|
unless TempCommercial.exists?(commercialable_id: event.id, commercialable_id: 'Conference') unless TempCommercial.exists?(commercialable_id: event.id, commercialable_id: 'Conference')
unless event.media_id.blank? || event.media_type.blank? unless event.media_id.blank? || event.media_type.blank?
TempCommercial.create(commercial_id: event.media_id, TempCommercial.create(commercial_id: event.media_id,
commercial_type: event.media_type, commercial_type: event.media_type,
commercialable_id: event.id, commercialable_id: event.id,
commercialable_type: 'Event') commercialable_type: 'Event')
end end
end end

View file

@ -14,9 +14,9 @@ class MoveConferenceRegistrationDataToRegistrationPeriods < ActiveRecord::Migrat
TempConference.all.each do |conference| TempConference.all.each do |conference|
unless TempRegistrationPeriod.exists?(conference_id: conference.id) unless TempRegistrationPeriod.exists?(conference_id: conference.id)
TempRegistrationPeriod.create(conference_id: conference.id, TempRegistrationPeriod.create(conference_id: conference.id,
start_date: conference.registration_start_date, start_date: conference.registration_start_date,
end_date: conference.registration_end_date, end_date: conference.registration_end_date,
description: conference.registration_description) description: conference.registration_description)
end end
end end

View file

@ -41,8 +41,8 @@ class MigratingSupporterRegistrationsToTicketUsers < ActiveRecord::Migration
# Sum up if a user has bought more than one ticket # Sum up if a user has bought more than one ticket
TempSupporterRegistrations.all.each do |s| TempSupporterRegistrations.all.each do |s|
sup_reg = TempSupporterRegistrations.where( sup_reg = TempSupporterRegistrations.where(
ticket_id: s.ticket_id, ticket_id: s.ticket_id,
user_id: s.user_id, user_id: s.user_id,
conference_id: s.conference_id) conference_id: s.conference_id)
quantity = sup_reg.count quantity = sup_reg.count

View file

@ -25,22 +25,22 @@ class MoveSplashpageAttributesFromConferenceToSplashpage < ActiveRecord::Migrati
# Copy values to splashpage # Copy values to splashpage
TempConference.all.each do |conference| TempConference.all.each do |conference|
unless TempSplashpage.exists?(conference_id: conference.id) unless TempSplashpage.exists?(conference_id: conference.id)
splash = TempSplashpage.create(conference_id: conference.id, splash = TempSplashpage.create(conference_id: conference.id,
public: conference.make_conference_public, public: conference.make_conference_public,
include_registrations: conference.include_registrations_in_splash, include_registrations: conference.include_registrations_in_splash,
include_tracks: conference.include_tracks_in_splash, include_tracks: conference.include_tracks_in_splash,
include_program: conference.include_program_in_splash, include_program: conference.include_program_in_splash,
include_banner: conference.include_banner_in_splash, include_banner: conference.include_banner_in_splash,
include_tickets: conference.include_tickets_in_splash, include_tickets: conference.include_tickets_in_splash,
ticket_description: conference.ticket_description, ticket_description: conference.ticket_description,
include_sponsors: conference.include_sponsors_in_splash, include_sponsors: conference.include_sponsors_in_splash,
sponsor_description: conference.sponsor_description, sponsor_description: conference.sponsor_description,
lodging_description: conference.lodging_description, lodging_description: conference.lodging_description,
banner_description: conference.description, banner_description: conference.description,
banner_photo_file_name: conference.banner_photo_file_name, banner_photo_file_name: conference.banner_photo_file_name,
banner_photo_content_type: conference.banner_photo_content_type, banner_photo_content_type: conference.banner_photo_content_type,
banner_photo_file_size: conference.banner_photo_file_size, banner_photo_file_size: conference.banner_photo_file_size,
banner_photo_updated_at: conference.banner_photo_updated_at) banner_photo_updated_at: conference.banner_photo_updated_at)
contact = TempContact.find_by(conference_id: conference.id) contact = TempContact.find_by(conference_id: conference.id)
if contact if contact

View file

@ -18,7 +18,7 @@ class MoveSponsorEmailToContact < ActiveRecord::Migration
contact.sponsor_email = conference.sponsor_email contact.sponsor_email = conference.sponsor_email
contact.save contact.save
else else
Contact.create(conference_id: conference.id, Contact.create(conference_id: conference.id,
sponsors_email: conference.sponsor_email) sponsors_email: conference.sponsor_email)
end end
end end

View file

@ -58,9 +58,9 @@ class AddRequireHandicappedAccessToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No') answer_no = TempAnswer.find_or_create_by!(title: 'No')
# Find existing question or initialize it # Find existing question or initialize it
q = TempQuestion.find_or_initialize_by(title: 'Do you need handicapped access?', q = TempQuestion.find_or_initialize_by(title: 'Do you need handicapped access?',
question_type_id: qtype.id, question_type_id: qtype.id,
global: true) global: true)
# Save question # Save question
q.save! q.save!

View file

@ -58,9 +58,9 @@ class AddAttendingWithPartnerToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No') answer_no = TempAnswer.find_or_create_by!(title: 'No')
# Find existing question or initialize it # Find existing question or initialize it
q = TempQuestion.find_or_initialize_by(title: 'Will you attend with a partner?', q = TempQuestion.find_or_initialize_by(title: 'Will you attend with a partner?',
question_type_id: qtype.id, question_type_id: qtype.id,
global: true) global: true)
# Save question # Save question
q.save! q.save!

View file

@ -58,9 +58,9 @@ class AddStayingAtSuggestedHotelToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No') answer_no = TempAnswer.find_or_create_by!(title: 'No')
# Find existing question or initialize it # Find existing question or initialize it
q = TempQuestion.find_or_initialize_by(title: 'Will you stay at one of the suggested hotels?', q = TempQuestion.find_or_initialize_by(title: 'Will you stay at one of the suggested hotels?',
question_type_id: qtype.id, question_type_id: qtype.id,
global: true) global: true)
# Save question # Save question
q.save! q.save!

View file

@ -58,9 +58,9 @@ class AddAttendingSocialEventsToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No') answer_no = TempAnswer.find_or_create_by!(title: 'No')
# Find existing question or initialize it # Find existing question or initialize it
q = TempQuestion.find_or_initialize_by(title: 'Will you attend the social event(s)?', q = TempQuestion.find_or_initialize_by(title: 'Will you attend the social event(s)?',
question_type_id: qtype.id, question_type_id: qtype.id,
global: true) global: true)
# Save question # Save question
q.save! q.save!

View file

@ -74,27 +74,27 @@ class RemoveSocialEventsTable < ActiveRecord::Migration
TempConference.all.each do |conference| TempConference.all.each do |conference|
if TempSocialEvent.where(conference_id: conference.id).any? if TempSocialEvent.where(conference_id: conference.id).any?
# Find existing question or initialize it # Find existing question or initialize it
question = TempQuestion.find_or_initialize_by(title: 'Which of the following social events are you going to attend?', question = TempQuestion.find_or_initialize_by(title: 'Which of the following social events are you going to attend?',
conference_id: conference.id, conference_id: conference.id,
question_type_id: qtype.id) question_type_id: qtype.id)
question.save! question.save!
# Enable the question for the conference # Enable the question for the conference
TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, TempConferencesQuestions.find_or_create_by!(conference_id: conference.id,
question_id: question.id) question_id: question.id)
end end
TempSocialEvent.where(conference_id: conference.id).each do |social_event| TempSocialEvent.where(conference_id: conference.id).each do |social_event|
answer = TempAnswer.find_or_create_by!(title: social_event.title) answer = TempAnswer.find_or_create_by!(title: social_event.title)
# Associate answer with the question # Associate answer with the question
qa = TempQanswer.find_or_initialize_by(question_id: question.id, qa = TempQanswer.find_or_initialize_by(question_id: question.id,
answer_id: answer.id) answer_id: answer.id)
qa.save! qa.save!
# Associate appropriate answer with registration # Associate appropriate answer with registration
TempRegistrationsSocialEvent.where(social_event_id: social_event.id).each do |registration_social_event| TempRegistrationsSocialEvent.where(social_event_id: social_event.id).each do |registration_social_event|
registration = TempRegistration.find(registration_social_event.registration_id) registration = TempRegistration.find(registration_social_event.registration_id)
TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, TempQanswerRegistration.find_or_create_by!(registration_id: registration.id,
qanswer_id: qa.id) qanswer_id: qa.id)
end end
end end
end end
@ -124,7 +124,7 @@ class RemoveSocialEventsTable < ActiveRecord::Migration
TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration|
answer = TempAnswer.find(qa.answer_id) answer = TempAnswer.find(qa.answer_id)
registration = TempRegistration.find(qa_registration.registration_id) registration = TempRegistration.find(qa_registration.registration_id)
social_event = TempSocialEvent.find_or_create_by!(title: answer.title, social_event = TempSocialEvent.find_or_create_by!(title: answer.title,
conference_id: conference.id) conference_id: conference.id)
TempRegistrationsSocialEvent.find_or_create_by!(registration_id: registration.id, TempRegistrationsSocialEvent.find_or_create_by!(registration_id: registration.id,
social_event_id: social_event.id) social_event_id: social_event.id)

View file

@ -67,25 +67,25 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration
TempConference.all.each do |conference| TempConference.all.each do |conference|
if TempDietaryChoice.where(conference_id: conference.id).any? if TempDietaryChoice.where(conference_id: conference.id).any?
# Find existing question or initialize it # Find existing question or initialize it
question = TempQuestion.find_or_initialize_by(title: 'Which is your dietary choice?', question = TempQuestion.find_or_initialize_by(title: 'Which is your dietary choice?',
conference_id: conference.id, conference_id: conference.id,
question_type_id: qtype.id) question_type_id: qtype.id)
question.save! question.save!
# Enable the question for the conference # Enable the question for the conference
TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, TempConferencesQuestions.find_or_create_by!(conference_id: conference.id,
question_id: question.id) question_id: question.id)
TempDietaryChoice.where(conference_id: conference.id).each do |dietary_choice| TempDietaryChoice.where(conference_id: conference.id).each do |dietary_choice|
answer = TempAnswer.find_or_create_by!(title: dietary_choice.title) answer = TempAnswer.find_or_create_by!(title: dietary_choice.title)
# Associate answer with the question # Associate answer with the question
qa = TempQanswer.find_or_initialize_by(question_id: question.id, qa = TempQanswer.find_or_initialize_by(question_id: question.id,
answer_id: answer.id) answer_id: answer.id)
qa.save! qa.save!
# Associate appropriate answer with registration # Associate appropriate answer with registration
TempRegistration.where(dietary_choice_id: dietary_choice.id).each do |registration| TempRegistration.where(dietary_choice_id: dietary_choice.id).each do |registration|
TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, TempQanswerRegistration.find_or_create_by!(registration_id: registration.id,
qanswer_id: qa.id) qanswer_id: qa.id)
end end
end end
end end
@ -96,26 +96,26 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration
if registration.other_dietary_choice.present? if registration.other_dietary_choice.present?
conference = TempConference.find(registration.conference_id) conference = TempConference.find(registration.conference_id)
qtype = TempQuestionType.find_or_create_by!(title: 'Yes/No') qtype = TempQuestionType.find_or_create_by!(title: 'Yes/No')
question = TempQuestion.find_or_initialize_by(title: 'Do you have another dietary choice?', question = TempQuestion.find_or_initialize_by(title: 'Do you have another dietary choice?',
conference_id: conference.id, conference_id: conference.id,
question_type_id: qtype.id) question_type_id: qtype.id)
question.save! question.save!
# Enable the question for the conference # Enable the question for the conference
TempConferencesQuestions.find_or_create_by!(conference_id: conference.id, TempConferencesQuestions.find_or_create_by!(conference_id: conference.id,
question_id: question.id) question_id: question.id)
# Create 'Yes' answer # Create 'Yes' answer
answer_yes = TempAnswer.find_or_create_by!(title: 'Yes') answer_yes = TempAnswer.find_or_create_by!(title: 'Yes')
# Associate answer with the question # Associate answer with the question
qa = TempQanswer.find_or_initialize_by(question_id: question.id, qa = TempQanswer.find_or_initialize_by(question_id: question.id,
answer_id: answer_yes.id) answer_id: answer_yes.id)
qa.save! qa.save!
# Associate appropriate answer with registration # Associate appropriate answer with registration
TempQanswerRegistration.find_or_create_by!(registration_id: registration.id, TempQanswerRegistration.find_or_create_by!(registration_id: registration.id,
qanswer_id: qa.id) qanswer_id: qa.id)
# Move data from other_dietary_choice to other_special_needs # Move data from other_dietary_choice to other_special_needs
registration.other_special_needs << "Other dietary choice: #{registration.other_dietary_choice}." registration.other_special_needs << "Other dietary choice: #{registration.other_dietary_choice}."
@ -148,7 +148,7 @@ class RemoveDietaryChoicesTable < ActiveRecord::Migration
TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration| TempQanswerRegistration.where(qanswer_id: qa.id).each do |qa_registration|
answer = TempAnswer.find(qa.answer_id) answer = TempAnswer.find(qa.answer_id)
registration = TempRegistration.find(qa_registration.registration_id) registration = TempRegistration.find(qa_registration.registration_id)
dietary_choice = TempDietaryChoice.find_or_create_by!(title: answer.title, dietary_choice = TempDietaryChoice.find_or_create_by!(title: answer.title,
conference_id: conference.id) conference_id: conference.id)
registration.dietary_choice_id = dietary_choice.id registration.dietary_choice_id = dietary_choice.id
registration.save! registration.save!

View file

@ -11,10 +11,10 @@ namespace :data do
program.events.each do |event| program.events.each do |event|
unless event.start_time.nil? && event.room_id.nil? unless event.start_time.nil? && event.room_id.nil?
# we can not use .room as this relation has been removed # we can not use .room as this relation has been removed
EventSchedule.create(event: event, EventSchedule.create(event: event,
schedule: schedule, schedule: schedule,
start_time: event.start_time, start_time: event.start_time,
room_id: event.room_id) room_id: event.room_id)
event.start_time = nil event.start_time = nil
event.room_id = nil event.room_id = nil
event.save event.save

View file

@ -24,7 +24,7 @@ describe Admin::ConferencesController do
it 'changes conference attributes' do it 'changes conference attributes' do
patch :update, id: conference.short_title, conference: patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con', attributes_for(:conference, title: 'Example Con',
short_title: 'ExCon') short_title: 'ExCon')
conference.reload conference.reload
expect(conference.title).to eq('Example Con') expect(conference.title).to eq('Example Con')
@ -52,7 +52,7 @@ describe Admin::ConferencesController do
context 'invalid attributes' do context 'invalid attributes' do
it 'does not change conference attributes' do it 'does not change conference attributes' do
patch :update, id: conference.short_title, conference: patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con', attributes_for(:conference, title: 'Example Con',
short_title: nil) short_title: nil)
conference.reload conference.reload
@ -64,7 +64,7 @@ describe Admin::ConferencesController do
it 're-renders the #show template' do it 're-renders the #show template' do
patch :update, id: conference.short_title, conference: patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con', attributes_for(:conference, title: 'Example Con',
short_title: nil) short_title: nil)
expect(flash[:error]) expect(flash[:error])
@ -181,9 +181,9 @@ describe Admin::ConferencesController do
conference conference
date = Date.new(2014, 05, 26) date = Date.new(2014, 05, 26)
create(:cfp, create(:cfp,
program: conference.program, program: conference.program,
start_date: date, start_date: date,
end_date: date + 14) end_date: date + 14)
get :index get :index
expect(assigns(:cfp_weeks)).to match_array([1, 2, 3]) expect(assigns(:cfp_weeks)).to match_array([1, 2, 3])
end end
@ -214,14 +214,14 @@ describe Admin::ConferencesController do
it 'saves the conference to the database' do it 'saves the conference to the database' do
expected = expect do expected = expect do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
end end
expected.to change { Conference.count }.by 1 expected.to change { Conference.count }.by 1
end end
it 'redirects to conference#show' do it 'redirects to conference#show' do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id) attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
expect(response).to redirect_to admin_conference_path( expect(response).to redirect_to admin_conference_path(
assigns[:conference].short_title) assigns[:conference].short_title)
@ -233,7 +233,7 @@ describe Admin::ConferencesController do
volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference) volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference)
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: 'dps15') attributes_for(:conference, short_title: 'dps15')
expect(conference.roles.count).to eq 4 expect(conference.roles.count).to eq 4
@ -245,14 +245,14 @@ describe Admin::ConferencesController do
it 'does not save the conference to the database' do it 'does not save the conference to the database' do
expected = expect do expected = expect do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: nil, organization_id: organization.id) attributes_for(:conference, short_title: nil, organization_id: organization.id)
end end
expected.to_not change { Conference.count } expected.to_not change { Conference.count }
end end
it 're-renders the new template' do it 're-renders the new template' do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: nil, organization_id: organization.id) attributes_for(:conference, short_title: nil, organization_id: organization.id)
expect(response).to be_success expect(response).to be_success
end end
end end
@ -262,7 +262,7 @@ describe Admin::ConferencesController do
conference conference
expected = expect do expected = expect do
post :create, conference: post :create, conference:
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id) attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
end end
expected.to_not change { Conference.count } expected.to_not change { Conference.count }
end end
@ -352,7 +352,7 @@ describe Admin::ConferencesController do
describe 'PATCH #update' do describe 'PATCH #update' do
it 'requires organizer privileges' do it 'requires organizer privileges' do
patch :update, id: conference.short_title, patch :update, id: conference.short_title,
conference: attributes_for(:conference, conference: attributes_for(:conference,
short_title: 'ExCon') short_title: 'ExCon')
expect(response).to redirect_to(send(path)) expect(response).to redirect_to(send(path))

View file

@ -23,9 +23,9 @@ describe Admin::EventSchedulesController do
post :create, conference_id: conference.short_title, event_schedule: post :create, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule, attributes_for(:event_schedule,
schedule_id: schedule.id, schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id, event_id: create(:event, program: conference.program).id,
room_id: create(:room, venue: venue).id, room_id: create(:room, venue: venue).id,
start_time: conference.start_date + conference.start_hour.hours) start_time: conference.start_date + conference.start_hour.hours)
end end
it 'saves the event schedule to the database' do it 'saves the event schedule to the database' do
@ -44,9 +44,9 @@ describe Admin::EventSchedulesController do
post :create, conference_id: conference.short_title, event_schedule: post :create, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule, attributes_for(:event_schedule,
schedule_id: schedule.id, schedule_id: schedule.id,
event_id: nil, event_id: nil,
room_id: nil, room_id: nil,
start_time: nil) start_time: nil)
end end
it 'does not save the event schedule to the database' do it 'does not save the event schedule to the database' do
@ -66,9 +66,9 @@ describe Admin::EventSchedulesController do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule: patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule, attributes_for(:event_schedule,
schedule_id: schedule.id, schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id, event_id: create(:event, program: conference.program).id,
room_id: room.id, room_id: room.id,
start_time: conference.start_date + conference.start_hour.hours) start_time: conference.start_date + conference.start_hour.hours)
event_schedule.reload event_schedule.reload
end end
@ -90,9 +90,9 @@ describe Admin::EventSchedulesController do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule: patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule, attributes_for(:event_schedule,
schedule_id: schedule.id, schedule_id: schedule.id,
event_id: nil, event_id: nil,
room_id: nil, room_id: nil,
start_time: nil) start_time: nil)
end end
it 'does not save the event schedule to the database' do it 'does not save the event schedule to the database' do
expect{ update_action }.to_not change { event_schedule } expect{ update_action }.to_not change { event_schedule }

View file

@ -174,7 +174,7 @@ describe Admin::OrganizationsController do
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) } let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
before do before do
post :assign_org_admins, id: organization.id, post :assign_org_admins, id: organization.id,
user: { email: user.email } user: { email: user.email }
end end
@ -188,7 +188,7 @@ describe Admin::OrganizationsController do
let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) } let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) }
before do before do
delete :unassign_org_admins, id: organization.id, delete :unassign_org_admins, id: organization.id,
user: { email: org_admin_user.email } user: { email: org_admin_user.email }
end end

View file

@ -50,12 +50,12 @@ describe Admin::RegistrationPeriodsController do
conference.email_settings = create(:email_settings) conference.email_settings = create(:email_settings)
conference.registration_period = create(:registration_period, conference.registration_period = create(:registration_period,
start_date: Date.today, start_date: Date.today,
end_date: Date.today + 2.days) end_date: Date.today + 2.days)
patch :update, conference_id: conference.short_title, registration_period: patch :update, conference_id: conference.short_title, registration_period:
attributes_for(:registration_period, attributes_for(:registration_period,
start_date: Date.today + 2.days, start_date: Date.today + 2.days,
end_date: Date.today + 4.days) end_date: Date.today + 4.days)
conference.reload conference.reload
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer) allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
end end
@ -67,7 +67,7 @@ describe Admin::RegistrationPeriodsController do
it 'saves the registration period to the database' do it 'saves the registration period to the database' do
expected = expect do expected = expect do
post :create, post :create,
conference_id: conference.short_title, conference_id: conference.short_title,
registration_period: attributes_for(:registration_period) registration_period: attributes_for(:registration_period)
end end
expected.to change { RegistrationPeriod.count }.by 1 expected.to change { RegistrationPeriod.count }.by 1
@ -75,7 +75,7 @@ describe Admin::RegistrationPeriodsController do
it 'redirects to registration_periods#show' do it 'redirects to registration_periods#show' do
post :create, post :create,
conference_id: conference.short_title, conference_id: conference.short_title,
registration_period: attributes_for(:registration_period) registration_period: attributes_for(:registration_period)
expect(response).to redirect_to admin_conference_registration_period_path( expect(response).to redirect_to admin_conference_registration_period_path(
@ -87,20 +87,20 @@ describe Admin::RegistrationPeriodsController do
it 'does not save the registration period to the database' do it 'does not save the registration period to the database' do
expected = expect do expected = expect do
post :create, post :create,
conference_id: conference.short_title, conference_id: conference.short_title,
registration_period: attributes_for(:registration_period, registration_period: attributes_for(:registration_period,
start_date: nil, start_date: nil,
end_date: nil) end_date: nil)
end end
expected.to_not change { Conference.count } expected.to_not change { Conference.count }
end end
it 're-renders the new template' do it 're-renders the new template' do
post :create, post :create,
conference_id: conference.short_title, conference_id: conference.short_title,
registration_period: attributes_for(:registration_period, registration_period: attributes_for(:registration_period,
start_date: nil, start_date: nil,
end_date: nil) end_date: nil)
expect(response).to be_success expect(response).to be_success
end end
end end

View file

@ -30,7 +30,7 @@ describe Admin::RolesController do
before :each do before :each do
sign_in(admin) sign_in(admin)
xhr :get, :show, conference_id: conference.short_title, xhr :get, :show, conference_id: conference.short_title,
id: 'organizer' id: 'organizer'
end end
it 'assigns correct value to selection variable' do it 'assigns correct value to selection variable' do
@ -46,8 +46,8 @@ describe Admin::RolesController do
before :each do before :each do
sign_in admin sign_in admin
patch :update, conference_id: conference.short_title, patch :update, conference_id: conference.short_title,
id: 'cfp', id: 'cfp',
role: { description: 'New description for cfp role!' } role: { description: 'New description for cfp role!' }
end end
it 'changes the description of the role' do it 'changes the description of the role' do
@ -59,8 +59,8 @@ describe Admin::RolesController do
before :each do before :each do
sign_in admin sign_in admin
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' }, user: { email: 'user1@osem.io' },
id: 'cfp' id: 'cfp'
end end
context 'assigns correct values to variables' do context 'assigns correct values to variables' do
@ -80,16 +80,16 @@ describe Admin::RolesController do
context 'adds role to user' do context 'adds role to user' do
it 'adds second user' do it 'adds second user' do
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user2@osem.io' }, user: { email: 'user2@osem.io' },
id: 'cfp' id: 'cfp'
expect(user2.roles).to eq [cfp_role] expect(user2.roles).to eq [cfp_role]
end end
it 'assigns second role to user' do it 'assigns second role to user' do
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' }, user: { email: 'user1@osem.io' },
id: 'organizer' id: 'organizer'
expect(user1.roles).to eq [organizer_role, cfp_role] expect(user1.roles).to eq [organizer_role, cfp_role]
end end
@ -98,22 +98,22 @@ describe Admin::RolesController do
context 'removes role from user' do context 'removes role from user' do
it 'removes role from user' do it 'removes role from user' do
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' }, user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp' id: 'cfp'
expect(user1.roles).to eq [] expect(user1.roles).to eq []
end end
it 'removes second role from user' do it 'removes second role from user' do
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io' }, user: { email: 'user1@osem.io' },
id: 'organizer' id: 'organizer'
expect(user1.roles).to eq [organizer_role, cfp_role] expect(user1.roles).to eq [organizer_role, cfp_role]
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' }, user: { email: 'user1@osem.io', state: 'false' },
id: 'cfp' id: 'cfp'
user1.reload user1.reload
expect(user1.roles).to eq [organizer_role] expect(user1.roles).to eq [organizer_role]
@ -123,14 +123,14 @@ describe Admin::RolesController do
it 'does not remove role if user is the last organizer' do it 'does not remove role if user is the last organizer' do
# Add role organizer # Add role organizer
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'true' }, user: { email: 'user1@osem.io', state: 'true' },
id: 'organizer' id: 'organizer'
expect(organizer_role.users).to eq [user1] expect(organizer_role.users).to eq [user1]
# Try to remove role organizer, when there is only 1 user as organizer # Try to remove role organizer, when there is only 1 user as organizer
post :toggle_user, conference_id: conference.short_title, post :toggle_user, conference_id: conference.short_title,
user: { email: 'user1@osem.io', state: 'false' }, user: { email: 'user1@osem.io', state: 'false' },
id: 'organizer' id: 'organizer'
expect(organizer_role.users).to eq [user1] expect(organizer_role.users).to eq [user1]
end end
end end

View file

@ -91,9 +91,9 @@ describe Admin::RoomsController do
describe 'PATCH #update' do describe 'PATCH #update' do
context 'updates successfully' do context 'updates successfully' do
before do before do
patch :update, room: attributes_for(:room, size: 2), patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title, conference_id: conference.short_title,
id: room.id id: room.id
end end
it 'redirects to admin room index path' do it 'redirects to admin room index path' do
@ -113,9 +113,9 @@ describe Admin::RoomsController do
context 'update fails' do context 'update fails' do
before do before do
allow_any_instance_of(Room).to receive(:save).and_return(false) allow_any_instance_of(Room).to receive(:save).and_return(false)
patch :update, room: attributes_for(:room, size: 2), patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title, conference_id: conference.short_title,
id: room.id id: room.id
end end
it 'renders edit template' do it 'renders edit template' do

View file

@ -51,7 +51,7 @@ describe Admin::SponsorshipLevelsController do
context 'saves successfuly' do context 'saves successfuly' do
before(:each, run: true) do before(:each, run: true) do
post :create, sponsorship_level: attributes_for(:sponsorship_level), post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title conference_id: conference.short_title
end end
it 'redirects to admin sponsorship_level index path', run: true do it 'redirects to admin sponsorship_level index path', run: true do
@ -65,7 +65,7 @@ describe Admin::SponsorshipLevelsController do
it 'creates new sponsorship_level' do it 'creates new sponsorship_level' do
expect do expect do
post :create, sponsorship_level: attributes_for(:sponsorship_level), post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title conference_id: conference.short_title
end.to change{ conference.sponsorship_levels.count }.from(0).to(1) end.to change{ conference.sponsorship_levels.count }.from(0).to(1)
end end
end end
@ -74,7 +74,7 @@ describe Admin::SponsorshipLevelsController do
before do before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false) allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
post :create, sponsorship_level: attributes_for(:sponsorship_level), post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title conference_id: conference.short_title
end end
it 'renders new template' do it 'renders new template' do
@ -95,8 +95,8 @@ describe Admin::SponsorshipLevelsController do
context 'updates successfully' do context 'updates successfully' do
before do before do
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: sponsorship_level.id id: sponsorship_level.id
end end
it 'redirects to admin sponsorship_level index path' do it 'redirects to admin sponsorship_level index path' do
@ -117,8 +117,8 @@ describe Admin::SponsorshipLevelsController do
before do before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false) allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'), patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: sponsorship_level.id id: sponsorship_level.id
end end
it 'renders edit template' do it 'renders edit template' do

View file

@ -134,9 +134,9 @@ describe Admin::TracksController do
describe 'PATCH #update' do describe 'PATCH #update' do
context 'updates successfully' do context 'updates successfully' do
before :each do before :each do
patch :update, track: attributes_for(:track, color: '#FF0000'), patch :update, track: attributes_for(:track, color: '#FF0000'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: track.short_name id: track.short_name
end end
it 'assigns the correct track' do it 'assigns the correct track' do
@ -160,9 +160,9 @@ describe Admin::TracksController do
context 'update fails' do context 'update fails' do
before :each do before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false) allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :update, track: attributes_for(:track, color: '#FF0000'), patch :update, track: attributes_for(:track, color: '#FF0000'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: track.short_name id: track.short_name
end end
it 'assigns the correct track' do it 'assigns the correct track' do

View file

@ -248,8 +248,8 @@ describe ConferenceRegistrationsController, type: :controller do
before do before do
@ticket = create(:ticket, conference: conference) @ticket = create(:ticket, conference: conference)
@purchased_ticket = create(:ticket_purchase, conference: conference, @purchased_ticket = create(:ticket_purchase, conference: conference,
user: user, user: user,
ticket: @ticket) ticket: @ticket)
get :show, conference_id: conference.short_title get :show, conference_id: conference.short_title
end end
@ -290,13 +290,13 @@ describe ConferenceRegistrationsController, type: :controller do
before do before do
@registration = create(:registration, @registration = create(:registration,
conference: conference, conference: conference,
user: user, user: user,
arrival: Date.new(2014, 04, 25)) arrival: Date.new(2014, 04, 25))
end end
context 'updates successfully' do context 'updates successfully' do
before do before do
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)), patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 29)),
conference_id: conference.short_title conference_id: conference.short_title
end end
@ -317,7 +317,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'update fails' do context 'update fails' do
before do before do
allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false) allow_any_instance_of(Registration).to receive(:update_attributes).and_return(false)
patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)), patch :update, registration: attributes_for(:registration, arrival: Date.new(2014, 04, 27)),
conference_id: conference.short_title conference_id: conference.short_title
end end

View file

@ -31,9 +31,9 @@ describe ProposalsController do
before { create(:cfp, program: conference.program) } before { create(:cfp, program: conference.program) }
it 'assigns url variables' do it 'assigns url variables' do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end end
@ -41,9 +41,9 @@ describe ProposalsController do
describe 'user related actions' do describe 'user related actions' do
before do before do
@new_user = attributes_for(:user) @new_user = attributes_for(:user)
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: @new_user user: @new_user
end end
it 'creates new user' do it 'creates new user' do
@ -58,9 +58,9 @@ describe ProposalsController do
context 'creates proposal successfully' do context 'creates proposal successfully' do
before(:each, run: true) do before(:each, run: true) do
@new_user = attributes_for(:user) @new_user = attributes_for(:user)
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: @new_user user: @new_user
end end
it 'assigns event variable', run: true do it 'assigns event variable', run: true do
@ -86,9 +86,9 @@ describe ProposalsController do
it 'creates new event' do it 'creates new event' do
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end.to change{ Event.count }.by 1 end.to change{ Event.count }.by 1
end end
end end
@ -96,9 +96,9 @@ describe ProposalsController do
context 'proposal save fails' do context 'proposal save fails' do
before(:each, run: true) do before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false) allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end end
it 'renders new template', run: true do it 'renders new template', run: true do
@ -112,9 +112,9 @@ describe ProposalsController do
it 'does not create new proposal' do it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false) allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end.not_to change{ Event.count } end.not_to change{ Event.count }
end end
end end
@ -125,25 +125,25 @@ describe ProposalsController do
it 'does not create new user' do it 'does not create new user' do
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end.not_to change { User.count } end.not_to change { User.count }
end end
it 'does not create new event' do it 'does not create new event' do
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end.not_to change { Event.count } end.not_to change { Event.count }
end end
describe 'response' do describe 'response' do
before do before do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
user: attributes_for(:user) user: attributes_for(:user)
end end
it 'renders new template' do it 'renders new template' do
@ -228,14 +228,14 @@ describe ProposalsController do
before { create(:cfp, program: conference.program) } before { create(:cfp, program: conference.program) }
it 'assigns url variables' do it 'assigns url variables' do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title conference_id: conference.short_title
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals' expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end end
context 'creates proposal successfully' do context 'creates proposal successfully' do
before(:each, run: true) do before(:each, run: true) do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title conference_id: conference.short_title
end end
@ -262,7 +262,7 @@ describe ProposalsController do
it 'creates new event' do it 'creates new event' do
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title conference_id: conference.short_title
end.to change{ Event.count }.by 1 end.to change{ Event.count }.by 1
end end
@ -271,7 +271,7 @@ describe ProposalsController do
context 'proposal save fails' do context 'proposal save fails' do
before(:each, run: true) do before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false) allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title conference_id: conference.short_title
end end
@ -286,7 +286,7 @@ describe ProposalsController do
it 'does not create new proposal' do it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false) allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do expect do
post :create, event: attributes_for(:event, event_type_id: event_type.id), post :create, event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title conference_id: conference.short_title
end.not_to change{ Event.count } end.not_to change{ Event.count }
end end
@ -296,17 +296,17 @@ describe ProposalsController do
describe 'PATCH #update' do describe 'PATCH #update' do
it 'assigns url variable' do it 'assigns url variable' do
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
id: event.id id: event.id
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}" expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end end
context 'updates successfully' do context 'updates successfully' do
before do before do
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
id: event.id id: event.id
end end
it 'updates the proposal' do it 'updates the proposal' do
@ -326,9 +326,9 @@ describe ProposalsController do
context 'update fails' do context 'update fails' do
before do before do
allow_any_instance_of(Event).to receive(:save).and_return(false) allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id), patch :update, event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title, conference_id: conference.short_title,
id: event.id id: event.id
end end
it 'does not update the proposal' do it 'does not update the proposal' do

View file

@ -128,9 +128,9 @@ describe TracksController do
describe 'PATCH #update' do describe 'PATCH #update' do
context 'updates successfully' do context 'updates successfully' do
before :each do before :each do
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: self_organized_track.short_name id: self_organized_track.short_name
end end
it 'assigns the correct track' do it 'assigns the correct track' do
@ -154,9 +154,9 @@ describe TracksController do
context 'update fails' do context 'update fails' do
before :each do before :each do
allow_any_instance_of(Track).to receive(:save).and_return(false) allow_any_instance_of(Track).to receive(:save).and_return(false)
patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'), patch :update, track: attributes_for(:track, :self_organized, color: '#FF0000'),
conference_id: conference.short_title, conference_id: conference.short_title,
id: self_organized_track.short_name id: self_organized_track.short_name
end end
it 'assigns the correct track' do it 'assigns the correct track' do

View file

@ -16,15 +16,15 @@ end
def stub_env_for_omniauth def stub_env_for_omniauth
request.env['devise.mapping'] = Devise.mappings[:user] request.env['devise.mapping'] = Devise.mappings[:user]
env = OmniAuth::AuthHash.new( env = OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-1', uid: 'google-test-uid-1',
info: { info: {
name: 'google user', name: 'google user',
email: nil, email: nil,
username: 'user_google' username: 'user_google'
}, },
credentials: { credentials: {
token: 'google_mock_token', token: 'google_mock_token',
secret: 'google_mock_secret' secret: 'google_mock_secret'
} }
) )

View file

@ -66,11 +66,11 @@ describe UserDatatable do
'search' => { 'value' => '', 'regex' => 'false' } 'search' => { 'value' => '', 'regex' => 'false' }
} }
}, },
'order' => { '0' => { 'column' => '0', 'dir' => 'asc' } }, 'order' => { '0' => { 'column' => '0', 'dir' => 'asc' } },
'start' => '0', 'start' => '0',
'length' => '10', 'length' => '10',
'search' => { 'value' => '', 'regex' => 'false' }, 'search' => { 'value' => '', 'regex' => 'false' },
'_' => '1532637360488' '_' => '1532637360488'
}.with_indifferent_access }.with_indifferent_access
) )
allow(view).to receive(:admin_user_path) do |arg| allow(view).to receive(:admin_user_path) do |arg|

View file

@ -4,9 +4,11 @@
FactoryBot.define do FactoryBot.define do
factory :splashpage do factory :splashpage do
public { false } public { false }
factory :full_splashpage do factory :full_splashpage do
public { true } public { true }
include_tracks { true } include_tracks { true }

View file

@ -46,8 +46,8 @@ feature Commercial do
before(:each) do before(:each) do
event.event_users = [create(:event_user, event.event_users = [create(:event_user,
user_id: participant.id, user_id: participant.id,
event_id: event.id, event_id: event.id,
event_role: 'submitter')] event_role: 'submitter')]
sign_in participant sign_in participant
end end
@ -85,7 +85,7 @@ feature Commercial do
scenario 'updates a commercial of an event', feature: true, versioning: true, js: true do scenario 'updates a commercial of an event', feature: true, versioning: true, js: true do
commercial = create(:commercial, commercial = create(:commercial,
commercialable_id: event.id, commercialable_id: event.id,
commercialable_type: 'Event') commercialable_type: 'Event')
visit edit_conference_program_proposal_path(conference.short_title, event.id) visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials' click_link 'Commercials'
@ -99,9 +99,9 @@ feature Commercial do
scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true, js: true do scenario 'does not update a commercial of an event with invalid data', feature: true, versioning: true, js: true do
commercial = create(:commercial, commercial = create(:commercial,
commercialable_id: event.id, commercialable_id: event.id,
commercialable_type: 'Event', commercialable_type: 'Event',
url: 'https://www.youtube.com/watch?v=BTTygyxuGj8') url: 'https://www.youtube.com/watch?v=BTTygyxuGj8')
visit edit_conference_program_proposal_path(conference.short_title, event.id) visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials' click_link 'Commercials'
fill_in "commercial_url_#{commercial.id}", with: 'invalid_commercial_url' fill_in "commercial_url_#{commercial.id}", with: 'invalid_commercial_url'
@ -114,7 +114,7 @@ feature Commercial do
scenario 'deletes a commercial of an event', feature: true, versioning: true, js: true do scenario 'deletes a commercial of an event', feature: true, versioning: true, js: true do
create(:commercial, create(:commercial,
commercialable_id: event.id, commercialable_id: event.id,
commercialable_type: 'Event') commercialable_type: 'Event')
visit edit_conference_program_proposal_path(conference.short_title, event.id) visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials' click_link 'Commercials'

View file

@ -41,7 +41,7 @@ describe Mailbot do
before do before do
conference.email_settings.update_attributes(send_on_accepted: true, conference.email_settings.update_attributes(send_on_accepted: true,
accepted_subject: 'Lorem Ipsum Dolsum', accepted_subject: 'Lorem Ipsum Dolsum',
accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit') accepted_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end end
include_examples 'mailer actions' do include_examples 'mailer actions' do
@ -53,7 +53,7 @@ describe Mailbot do
before do before do
conference.email_settings.update_attributes(send_on_rejected: true, conference.email_settings.update_attributes(send_on_rejected: true,
rejected_subject: 'Lorem Ipsum Dolsum', rejected_subject: 'Lorem Ipsum Dolsum',
rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit') rejected_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end end
include_examples 'mailer actions' do include_examples 'mailer actions' do
@ -65,7 +65,7 @@ describe Mailbot do
before do before do
conference.email_settings.update_attributes(send_on_confirmed_without_registration: true, conference.email_settings.update_attributes(send_on_confirmed_without_registration: true,
confirmed_without_registration_subject: 'Lorem Ipsum Dolsum', confirmed_without_registration_subject: 'Lorem Ipsum Dolsum',
confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit') confirmed_without_registration_body: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
end end
include_examples 'mailer actions' do include_examples 'mailer actions' do

View file

@ -38,13 +38,13 @@ describe Booth do
states = [:new, :withdrawn, :to_accept, :accepted, :to_reject, :rejected, :canceled, :confirmed] states = [:new, :withdrawn, :to_accept, :accepted, :to_reject, :rejected, :canceled, :confirmed]
transitions = [:restart, :withdraw, :accept, :reject, :to_accept, :to_reject, :cancel] transitions = [:restart, :withdraw, :accept, :reject, :to_accept, :to_reject, :cancel]
states_transitions = { new: { restart: false, withdraw: true, accept: true, to_accept: true, to_reject: true, reject: true, cancel: false, confirm: false }, states_transitions = { new: { restart: false, withdraw: true, accept: true, to_accept: true, to_reject: true, reject: true, cancel: false, confirm: false },
withdrawn: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false }, withdrawn: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false },
to_accept: { restart: false, withdraw: true, accept: true, to_accept: false, to_reject: true, reject: false, cancel: true, confirm: false }, to_accept: { restart: false, withdraw: true, accept: true, to_accept: false, to_reject: true, reject: false, cancel: true, confirm: false },
to_reject: { restart: false, withdraw: true, accept: false, to_accept: true, to_reject: false, reject: true, cancel: true, confirm: false }, to_reject: { restart: false, withdraw: true, accept: false, to_accept: true, to_reject: false, reject: true, cancel: true, confirm: false },
accepted: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: true }, accepted: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: true },
rejected: { restart: true, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false }, rejected: { restart: true, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false },
canceled: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false }, canceled: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false },
confirmed: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false } } confirmed: { restart: false, withdraw: true, accept: false, to_accept: false, to_reject: false, reject: false, cancel: true, confirm: false } }
states.each do |state| states.each do |state|

View file

@ -12,21 +12,21 @@ describe Conference do
it 'updates pending conferences' do it 'updates pending conferences' do
create(:conference, create(:conference,
start_date: Date.today - 2.weeks, start_date: Date.today - 2.weeks,
end_date: Date.today - 1.weeks) end_date: Date.today - 1.weeks)
subject.start_date = Date.today + 1.weeks subject.start_date = Date.today + 1.weeks
subject.end_date = Date.today + 2.weeks subject.end_date = Date.today + 2.weeks
result = { result = {
DateTime.now.end_of_week => DateTime.now.end_of_week =>
{ {
confirmed: 0, confirmed: 0,
unconfirmed: 0, unconfirmed: 0,
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
} }
Conference.write_event_distribution_to_db Conference.write_event_distribution_to_db
@ -37,7 +37,7 @@ describe Conference do
it 'does not update past conferences' do it 'does not update past conferences' do
old_conference = create(:conference, old_conference = create(:conference,
start_date: Date.today - 2.weeks, start_date: Date.today - 2.weeks,
end_date: Date.today - 1.weeks) end_date: Date.today - 1.weeks)
Conference.write_event_distribution_to_db Conference.write_event_distribution_to_db
old_conference.reload old_conference.reload
@ -76,14 +76,14 @@ describe Conference do
result = { result = {
DateTime.now.end_of_week => DateTime.now.end_of_week =>
{ {
confirmed: 1, confirmed: 1,
unconfirmed: 1, unconfirmed: 1,
new: 1, new: 1,
withdrawn: 1, withdrawn: 1,
canceled: 1, canceled: 1,
rejected: 1 rejected: 1
}, },
} }
subject.reload subject.reload
@ -96,23 +96,23 @@ describe Conference do
subject.end_date = Date.today + 7.weeks subject.end_date = Date.today + 7.weeks
db_data = { db_data = {
DateTime.now.end_of_week - 2.weeks => DateTime.now.end_of_week - 2.weeks =>
{ {
confirmed: 1, confirmed: 1,
unconfirmed: 2, unconfirmed: 2,
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
DateTime.now.end_of_week - 1.weeks => DateTime.now.end_of_week - 1.weeks =>
{ {
confirmed: 3, confirmed: 3,
unconfirmed: 4, unconfirmed: 4,
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
} }
subject.events_per_week = db_data subject.events_per_week = db_data
subject.save subject.save
@ -131,32 +131,32 @@ describe Conference do
result = { result = {
DateTime.now.end_of_week - 2.weeks => DateTime.now.end_of_week - 2.weeks =>
{ {
confirmed: 1, confirmed: 1,
unconfirmed: 2, unconfirmed: 2,
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
DateTime.now.end_of_week - 1.weeks => DateTime.now.end_of_week - 1.weeks =>
{ {
confirmed: 3, confirmed: 3,
unconfirmed: 4, unconfirmed: 4,
new: 0, new: 0,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
DateTime.now.end_of_week => DateTime.now.end_of_week =>
{ {
confirmed: 1, confirmed: 1,
unconfirmed: 1, unconfirmed: 1,
new: 1, new: 1,
withdrawn: 0, withdrawn: 0,
canceled: 0, canceled: 0,
rejected: 0 rejected: 0
}, },
} }
subject.reload subject.reload
@ -176,11 +176,11 @@ describe Conference do
# Inject last two weeks to database # Inject last two weeks to database
db_data = { db_data = {
Date.today.end_of_week - 2.weeks => { Date.today.end_of_week - 2.weeks => {
confirmed: 1, confirmed: 1,
unconfirmed: 2, unconfirmed: 2,
}, },
Date.today.end_of_week - 1.weeks => { Date.today.end_of_week - 1.weeks => {
confirmed: 3, confirmed: 3,
unconfirmed: 4, unconfirmed: 4,
} }
} }
@ -192,10 +192,10 @@ describe Conference do
create(:event, program: subject.program, created_at: Date.today - 2.weeks) create(:event, program: subject.program, created_at: Date.today - 2.weeks)
result = { result = {
'Submitted' => [1, 1, 1], 'Submitted' => [1, 1, 1],
'Confirmed' => [1, 3, 0], 'Confirmed' => [1, 3, 0],
'Unconfirmed' => [2, 4, 0], 'Unconfirmed' => [2, 4, 0],
'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
} }
expect(subject.get_submissions_data).to eq(result) expect(subject.get_submissions_data).to eq(result)
end end
@ -208,10 +208,10 @@ describe Conference do
create(:event, program: subject.program) create(:event, program: subject.program)
result = { result = {
'Submitted' => [1], 'Submitted' => [1],
'Confirmed' => [0], 'Confirmed' => [0],
'Unconfirmed' => [0], 'Unconfirmed' => [0],
'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8] 'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8]
} }
expect(subject.get_submissions_data).to eq(result) expect(subject.get_submissions_data).to eq(result)
end end
@ -233,10 +233,10 @@ describe Conference do
confirmed.confirm! confirmed.confirm!
result = { result = {
'Submitted' => [0, 0, 3], 'Submitted' => [0, 0, 3],
'Confirmed' => [0, 0, 1], 'Confirmed' => [0, 0, 1],
'Unconfirmed' => [0, 0, 1], 'Unconfirmed' => [0, 0, 1],
'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
} }
expect(subject.get_submissions_data).to eq(result) expect(subject.get_submissions_data).to eq(result)
end end
@ -248,11 +248,11 @@ describe Conference do
# Inject last two weeks to database # Inject last two weeks to database
db_data = { db_data = {
Date.today.end_of_week - 3.weeks => { Date.today.end_of_week - 3.weeks => {
confirmed: 1, confirmed: 1,
unconfirmed: 2, unconfirmed: 2,
}, },
Date.today.end_of_week - 1.weeks => { Date.today.end_of_week - 1.weeks => {
confirmed: 3, confirmed: 3,
unconfirmed: 4, unconfirmed: 4,
} }
} }
@ -264,10 +264,10 @@ describe Conference do
create(:event, program: subject.program, created_at: Date.today - 3.weeks) create(:event, program: subject.program, created_at: Date.today - 3.weeks)
result = { result = {
'Submitted' => [1, 1, 1, 1], 'Submitted' => [1, 1, 1, 1],
'Confirmed' => [1, 0, 3, 0], 'Confirmed' => [1, 0, 3, 0],
'Unconfirmed' => [2, 0, 4, 0], 'Unconfirmed' => [2, 0, 4, 0],
'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] 'Weeks' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
} }
expect(subject.get_submissions_data).to eq(result) expect(subject.get_submissions_data).to eq(result)
end end
@ -1083,7 +1083,7 @@ describe Conference do
it 'calculates new year' do it 'calculates new year' do
subject.registration_period = create(:registration_period, subject.registration_period = create(:registration_period,
start_date: Date.new(2013, 12, 31), start_date: Date.new(2013, 12, 31),
end_date: Date.new(2013, 12, 30) + 6) end_date: Date.new(2013, 12, 30) + 6)
expect(subject.registration_weeks).to eq(1) expect(subject.registration_weeks).to eq(1)
end end

View file

@ -8,18 +8,18 @@ describe EmailSettings do
let(:event) { create(:event, program: conference.program, title: 'Talk about talks', submitter: user) } let(:event) { create(:event, program: conference.program, title: 'Talk about talks', submitter: user) }
let(:expected_hash) do let(:expected_hash) do
{ {
'email' => 'john@doe.com', 'email' => 'john@doe.com',
'name' => 'John Doe', 'name' => 'John Doe',
'conference' => conference.title, 'conference' => conference.title,
'conference_start_date' => Date.new(2014, 05, 01), 'conference_start_date' => Date.new(2014, 05, 01),
'conference_end_date' => Date.new(2014, 05, 06), 'conference_end_date' => Date.new(2014, 05, 06),
'registrationlink' => 'http://localhost:3000/conferences/goto/register', 'registrationlink' => 'http://localhost:3000/conferences/goto/register',
'conference_splash_link' => 'http://localhost:3000/conferences/goto', 'conference_splash_link' => 'http://localhost:3000/conferences/goto',
'schedule_link' => 'http://localhost:3000/conferences/goto/schedule', 'schedule_link' => 'http://localhost:3000/conferences/goto/schedule',
'cfp_end_date' => 'Unknown', 'cfp_end_date' => 'Unknown',
'cfp_start_date' => 'Unknown', 'cfp_start_date' => 'Unknown',
'venue' => 'Unknown', 'venue' => 'Unknown',
'venue_address' => 'Unknown' 'venue_address' => 'Unknown'
} }
end end
@ -50,8 +50,8 @@ describe EmailSettings do
before do before do
create(:cfp, create(:cfp,
start_date: Date.new(2014, 04, 29), start_date: Date.new(2014, 04, 29),
end_date: Date.new(2014, 05, 06), end_date: Date.new(2014, 05, 06),
program: conference.program) program: conference.program)
cfp_dates_hash = { 'cfp_start_date' => Date.new(2014, 04, 29), 'cfp_end_date' => Date.new(2014, 05, 06) } cfp_dates_hash = { 'cfp_start_date' => Date.new(2014, 04, 29), 'cfp_end_date' => Date.new(2014, 05, 06) }
expected_hash.merge!(cfp_dates_hash) expected_hash.merge!(cfp_dates_hash)
end end
@ -77,7 +77,7 @@ describe EmailSettings do
before do before do
conference.update_attributes(registration_period: create(:registration_period, conference.update_attributes(registration_period: create(:registration_period,
start_date: Date.new(2014, 05, 03), start_date: Date.new(2014, 05, 03),
end_date: Date.new(2014, 05, 05))) end_date: Date.new(2014, 05, 05)))
registration_period_hash = { 'registration_start_date' => Date.new(2014, 05, 03), 'registration_end_date' => Date.new(2014, 05, 05) } registration_period_hash = { 'registration_start_date' => Date.new(2014, 05, 03), 'registration_end_date' => Date.new(2014, 05, 05) }
expected_hash.merge!(registration_period_hash) expected_hash.merge!(registration_period_hash)
end end

View file

@ -320,12 +320,12 @@ describe Event do
states = [:new, :withdrawn, :unconfirmed, :confirmed, :canceled, :rejected] states = [:new, :withdrawn, :unconfirmed, :confirmed, :canceled, :rejected]
transitions = [:restart, :withdraw, :accept, :confirm, :cancel, :reject] transitions = [:restart, :withdraw, :accept, :confirm, :cancel, :reject]
states_transitions = { new: { restart: false, withdraw: true, accept: true, confirm: false, cancel: false, reject: true}, states_transitions = { new: { restart: false, withdraw: true, accept: true, confirm: false, cancel: false, reject: true},
withdrawn: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false}, withdrawn: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false},
unconfirmed: { restart: false, withdraw: true, accept: false, confirm: true, cancel: true, reject: false}, unconfirmed: { restart: false, withdraw: true, accept: false, confirm: true, cancel: true, reject: false},
confirmed: { restart: false, withdraw: true, accept: false, confirm: false, cancel: true, reject: false}, confirmed: { restart: false, withdraw: true, accept: false, confirm: false, cancel: true, reject: false},
canceled: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false}, canceled: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false},
rejected: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false} rejected: { restart: true, withdraw: false, accept: false, confirm: false, cancel: false, reject: false}
} }
states.each do |state| states.each do |state|

View file

@ -65,8 +65,8 @@ describe TicketPurchase do
tickets = { free_ticket.id.to_s => '10' } tickets = { free_ticket.id.to_s => '10' }
message = TicketPurchase.purchase(conference, participant, tickets) message = TicketPurchase.purchase(conference, participant, tickets)
purchase = TicketPurchase.where(conference_id: conference.id, purchase = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id, user_id: participant.id,
ticket_id: free_ticket.id).first ticket_id: free_ticket.id).first
expect(TicketPurchase.count).to eq(1) expect(TicketPurchase.count).to eq(1)
expect(purchase.quantity).to eq(10) expect(purchase.quantity).to eq(10)
@ -77,8 +77,8 @@ describe TicketPurchase do
tickets = { ticket_1.id.to_s => '1' } tickets = { ticket_1.id.to_s => '1' }
message = TicketPurchase.purchase(conference, participant, tickets) message = TicketPurchase.purchase(conference, participant, tickets)
purchase = TicketPurchase.where(conference_id: conference.id, purchase = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id, user_id: participant.id,
ticket_id: ticket_1.id).first ticket_id: ticket_1.id).first
expect(TicketPurchase.count).to eq(1) expect(TicketPurchase.count).to eq(1)
expect(purchase.quantity).to eq(1) expect(purchase.quantity).to eq(1)
@ -89,12 +89,12 @@ describe TicketPurchase do
tickets = { ticket_1.id.to_s => '1', ticket_2.id.to_s => '1' } tickets = { ticket_1.id.to_s => '1', ticket_2.id.to_s => '1' }
message = TicketPurchase.purchase(conference, participant, tickets) message = TicketPurchase.purchase(conference, participant, tickets)
purchase_1 = TicketPurchase.where(conference_id: conference.id, purchase_1 = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id, user_id: participant.id,
ticket_id: ticket_1.id).first ticket_id: ticket_1.id).first
purchase_2 = TicketPurchase.where(conference_id: conference.id, purchase_2 = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id, user_id: participant.id,
ticket_id: ticket_2.id).first ticket_id: ticket_2.id).first
expect(TicketPurchase.count).to eq(2) expect(TicketPurchase.count).to eq(2)
expect(purchase_1.quantity).to eq(1) expect(purchase_1.quantity).to eq(1)
@ -119,9 +119,9 @@ describe TicketPurchase do
it 'updates the quantity if the user already bought this ticket' do it 'updates the quantity if the user already bought this ticket' do
purchase = create(:ticket_purchase, purchase = create(:ticket_purchase,
conference: conference, conference: conference,
user: participant, user: participant,
ticket: ticket_1, ticket: ticket_1,
quantity: 5) quantity: 5)
tickets = { ticket_1.id.to_s => '10' } tickets = { ticket_1.id.to_s => '10' }
message = TicketPurchase.purchase(conference, participant, tickets) message = TicketPurchase.purchase(conference, participant, tickets)

View file

@ -39,7 +39,7 @@ describe Ticket do
it 'is not valid if tickets of conference do not have same currency' do it 'is not valid if tickets of conference do not have same currency' do
conflicting_currency_ticket = build(:ticket, conflicting_currency_ticket = build(:ticket,
conference: ticket.conference, conference: ticket.conference,
price_currency: 'INR') price_currency: 'INR')
expected_error_message = 'Price currency is different from the existing tickets of this conference.' expected_error_message = 'Price currency is different from the existing tickets of this conference.'
@ -57,7 +57,7 @@ describe Ticket do
describe '#bought?' do describe '#bought?' do
it 'returns true if the user has bought this ticket' do it 'returns true if the user has bought this ticket' do
create(:ticket_purchase, create(:ticket_purchase,
user: user, user: user,
ticket: ticket) ticket: ticket)
expect(ticket.bought?(user)).to eq(true) expect(ticket.bought?(user)).to eq(true)
end end
@ -112,8 +112,8 @@ describe Ticket do
context 'user has not paid' do context 'user has not paid' do
it 'returns the correct value if the user has bought this ticket' do it 'returns the correct value if the user has bought this ticket' do
create(:ticket_purchase, create(:ticket_purchase,
user: user, user: user,
ticket: ticket, ticket: ticket,
quantity: 20) quantity: 20)
expect(ticket.quantity_bought_by(user, paid: false)).to eq(20) expect(ticket.quantity_bought_by(user, paid: false)).to eq(20)
end end
@ -137,8 +137,8 @@ describe Ticket do
context 'user has not paid' do context 'user has not paid' do
it 'returns the correct value if the user has bought this ticket' do it 'returns the correct value if the user has bought this ticket' do
create(:ticket_purchase, create(:ticket_purchase,
user: user, user: user,
ticket: ticket, ticket: ticket,
quantity: 20) quantity: 20)
expect(ticket.total_price(user, paid: false)).to eq(Money.new(100000, 'USD')) expect(ticket.total_price(user, paid: false)).to eq(Money.new(100000, 'USD'))
end end

View file

@ -326,13 +326,13 @@ describe Track do
states = [:new, :to_accept, :accepted, :confirmed, :to_reject, :rejected, :canceled, :withdrawn] states = [:new, :to_accept, :accepted, :confirmed, :to_reject, :rejected, :canceled, :withdrawn]
transitions = [:restart, :to_accept, :accept, :confirm, :to_reject, :reject, :cancel, :withdraw] transitions = [:restart, :to_accept, :accept, :confirm, :to_reject, :reject, :cancel, :withdraw]
states_transitions = { new: { restart: false, to_accept: true, accept: true, confirm: false, to_reject: true, reject: true, cancel: false, withdraw: true }, states_transitions = { new: { restart: false, to_accept: true, accept: true, confirm: false, to_reject: true, reject: true, cancel: false, withdraw: true },
to_accept: { restart: false, to_accept: false, accept: true, confirm: false, to_reject: true, reject: false, cancel: true, withdraw: true }, to_accept: { restart: false, to_accept: false, accept: true, confirm: false, to_reject: true, reject: false, cancel: true, withdraw: true },
accepted: { restart: false, to_accept: false, accept: false, confirm: true, to_reject: false, reject: false, cancel: true, withdraw: true }, accepted: { restart: false, to_accept: false, accept: false, confirm: true, to_reject: false, reject: false, cancel: true, withdraw: true },
confirmed: { restart: false, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: true, withdraw: true }, confirmed: { restart: false, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: true, withdraw: true },
to_reject: { restart: false, to_accept: true, accept: false, confirm: false, to_reject: false, reject: true, cancel: true, withdraw: true }, to_reject: { restart: false, to_accept: true, accept: false, confirm: false, to_reject: false, reject: true, cancel: true, withdraw: true },
rejected: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false }, rejected: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false },
canceled: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false }, canceled: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false },
withdrawn: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false } } withdrawn: { restart: true, to_accept: false, accept: false, confirm: false, to_reject: false, reject: false, cancel: false, withdraw: false } }
states.each do |state| states.each do |state|

View file

@ -234,15 +234,15 @@ describe User do
describe '.find_for_auth' do describe '.find_for_auth' do
let(:auth) do let(:auth) do
OmniAuth::AuthHash.new(provider: 'google', OmniAuth::AuthHash.new(provider: 'google',
uid: 'google-test-uid-1', uid: 'google-test-uid-1',
info: { info: {
name: 'new user name', name: 'new user name',
email: 'test-1@gmail.com', email: 'test-1@gmail.com',
username: 'newuser' username: 'newuser'
}, },
credentials: { credentials: {
token: 'mock_token', token: 'mock_token',
secret: 'mock_secret' secret: 'mock_secret'
} }
) )
@ -285,7 +285,7 @@ describe User do
it 'returns hash of role and conference' do it 'returns hash of role and conference' do
expected_hash = { expected_hash = {
'organizer' => %w[oSC16 oSC15], 'organizer' => %w[oSC16 oSC15],
'cfp' => ['oSC16'] 'cfp' => ['oSC16']
} }
expect(user.get_roles).to eq expected_hash expect(user.get_roles).to eq expected_hash

View file

@ -6,8 +6,8 @@ describe ConferenceSerializer, type: :serializer do
let(:conference) do let(:conference) do
create(:conference, short_title: 'goto', create(:conference, short_title: 'goto',
description: 'Lorem ipsum dolor sit', description: 'Lorem ipsum dolor sit',
start_date: Date.new(2014, 03, 04), start_date: Date.new(2014, 03, 04),
end_date: Date.new(2014, 03, 10)) end_date: Date.new(2014, 03, 10))
end end
let(:serializer) { ConferenceSerializer.new(conference) } let(:serializer) { ConferenceSerializer.new(conference) }

View file

@ -9,16 +9,16 @@ describe EventSerializer, type: :serializer do
it 'sets guid, title, length, abstract and type' do it 'sets guid, title, length, abstract and type' do
expected_json = { expected_json = {
event: { event: {
guid: event.guid, guid: event.guid,
title: 'Some Talk', title: 'Some Talk',
length: 30, length: 30,
scheduled_date: '', scheduled_date: '',
language: nil, language: nil,
abstract: 'Lorem ipsum dolor sit amet', abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: event.speaker_ids, speaker_ids: event.speaker_ids,
type: 'Example Event Type', type: 'Example Event Type',
room: nil, room: nil,
track: nil track: nil
} }
}.to_json }.to_json
@ -41,16 +41,16 @@ describe EventSerializer, type: :serializer do
it 'sets guid, title, length, abstract, type, date, language, speakers, room and track' do it 'sets guid, title, length, abstract, type, date, language, speakers, room and track' do
expected_json = { expected_json = {
event: { event: {
guid: event.guid, guid: event.guid,
title: 'Some Talk', title: 'Some Talk',
length: 30, length: 30,
scheduled_date: ' 2014-03-04T09:00:00+0000 ', scheduled_date: ' 2014-03-04T09:00:00+0000 ',
language: 'English', language: 'English',
abstract: 'Lorem ipsum dolor sit amet', abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: [speaker.id], speaker_ids: [speaker.id],
type: 'Example Event Type', type: 'Example Event Type',
room: room.guid, room: room.guid,
track: track.guid track: track.guid
} }
}.to_json }.to_json

View file

@ -8,8 +8,8 @@ describe RoomSerializer, type: :serializer do
it 'set guid, name and description' do it 'set guid, name and description' do
expected_json = { expected_json = {
room: { room: {
guid: room.guid, guid: room.guid,
name: room.name, name: room.name,
description: '' description: ''
} }
}.to_json }.to_json

View file

@ -9,9 +9,9 @@ describe SpeakerSerializer, type: :serializer do
it 'sets name and affiliation' do it 'sets name and affiliation' do
expected_json = { expected_json = {
speaker: { speaker: {
name: 'John Doe', name: 'John Doe',
affiliation: 'JohnDoesInc', affiliation: 'JohnDoesInc',
biography: nil biography: nil
} }
}.to_json }.to_json
@ -25,9 +25,9 @@ describe SpeakerSerializer, type: :serializer do
it 'sets name, affiliation and biography' do it 'sets name, affiliation and biography' do
expected_json = { expected_json = {
speaker: { speaker: {
name: 'John Doe', name: 'John Doe',
affiliation: 'JohnDoesInc', affiliation: 'JohnDoesInc',
biography: 'Doest of all Jon Does' biography: 'Doest of all Jon Does'
} }
}.to_json }.to_json

View file

@ -9,8 +9,8 @@ describe TrackSerializer, type: :serializer do
it 'sets guild, name, color' do it 'sets guild, name, color' do
expected_json = { expected_json = {
track: { track: {
guid: track.guid, guid: track.guid,
name: track.name, name: track.name,
color: track.color color: track.color
} }
}.to_json }.to_json

View file

@ -12,19 +12,19 @@ end
def mock_commercial_request def mock_commercial_request
response = { response = {
author_name: 'Confreaks', author_name: 'Confreaks',
html: '<iframe width="560" height="315" frameborder="0" allowfullscreen></iframe>', html: '<iframe width="560" height="315" frameborder="0" allowfullscreen></iframe>',
thumbnail_width: 480, thumbnail_width: 480,
thumbnail_url: '/images/rails.png', thumbnail_url: '/images/rails.png',
provider_name: 'YouTube', provider_name: 'YouTube',
width: 459, width: 459,
type: 'video', type: 'video',
provider_url: 'http://www.youtube.com/', provider_url: 'http://www.youtube.com/',
version: '1.0', version: '1.0',
thumbnail_height: 360, thumbnail_height: 360,
title: 'RailsConf 2014 - Closing Keynote by Aaron Patterson', title: 'RailsConf 2014 - Closing Keynote by Aaron Patterson',
author_url: 'https://www.youtube.com/user/Confreaks', author_url: 'https://www.youtube.com/user/Confreaks',
height: 344 height: 344
} }
WebMock.stub_request(:get, /.*youtube.*/) WebMock.stub_request(:get, /.*youtube.*/)
.to_return(status: 200, body: response.to_json, headers: {}) .to_return(status: 200, body: response.to_json, headers: {})

View file

@ -6,6 +6,7 @@ module Flash
if results.empty? if results.empty?
return 'none' return 'none'
end end
if results.count > 1 if results.count > 1
texts = results.map { |r| r.text } texts = results.map { |r| r.text }
fail "One flash expected, but we had #{texts.inspect}" fail "One flash expected, but we had #{texts.inspect}"

View file

@ -16,14 +16,14 @@ module OmniauthMacros
def mock_auth_new_user def mock_auth_new_user
OmniAuth.config.mock_auth[:google] = OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-1', uid: 'google-test-uid-1',
info: { info: {
name: 'new user name', name: 'new user name',
email: 'test-1@example.com' email: 'test-1@example.com'
}, },
credentials: { credentials: {
token: 'mock_token', token: 'mock_token',
secret: 'mock_secret' secret: 'mock_secret'
} }
) )
@ -32,14 +32,14 @@ module OmniauthMacros
def mock_auth_new_user_fb def mock_auth_new_user_fb
OmniAuth.config.mock_auth[:facebook] = OmniAuth.config.mock_auth[:facebook] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'facebook', provider: 'facebook',
uid: 'facebook-test-uid-1', uid: 'facebook-test-uid-1',
info: { info: {
name: 'new user fb name', name: 'new user fb name',
email: 'test-1@example.com' email: 'test-1@example.com'
}, },
credentials: { credentials: {
token: 'mock_token', token: 'mock_token',
secret: 'mock_secret' secret: 'mock_secret'
} }
) )
@ -50,14 +50,14 @@ module OmniauthMacros
# authentication hashes to return during integration testing. # authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:google] = OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-participant-1', uid: 'google-test-uid-participant-1',
info: { info: {
name: 'existing user participant name', name: 'existing user participant name',
email: 'test-participant-1@example.com' email: 'test-participant-1@example.com'
}, },
credentials: { credentials: {
token: 'mock_token', token: 'mock_token',
secret: 'mock_secret' secret: 'mock_secret'
} }
) )
@ -68,14 +68,14 @@ module OmniauthMacros
# authentication hashes to return during integration testing. # authentication hashes to return during integration testing.
OmniAuth.config.mock_auth[:google] = OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-admin-1', uid: 'google-test-uid-admin-1',
info: { info: {
name: 'existing user admin name', name: 'existing user admin name',
email: 'test-admin-1@example.com' email: 'test-admin-1@example.com'
}, },
credentials: { credentials: {
token: 'mock_token', token: 'mock_token',
secret: 'mock_secret' secret: 'mock_secret'
} }
) )
@ -89,60 +89,60 @@ module OmniauthMacros
def mock_auth_accounts def mock_auth_accounts
OmniAuth.config.mock_auth[:facebook] = OmniAuth.config.mock_auth[:facebook] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'facebook', provider: 'facebook',
uid: 'facebook-test-uid-1', uid: 'facebook-test-uid-1',
info: { info: {
name: 'facebook user', name: 'facebook user',
email: 'user-facebook@example.com', email: 'user-facebook@example.com',
username: 'user_facebook' username: 'user_facebook'
}, },
credentials: { credentials: {
token: 'fb_mock_token', token: 'fb_mock_token',
secret: 'fb_mock_secret' secret: 'fb_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:google] = OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'google', provider: 'google',
uid: 'google-test-uid-1', uid: 'google-test-uid-1',
info: { info: {
name: 'google user', name: 'google user',
email: 'user-google@example.com', email: 'user-google@example.com',
username: 'user_google' username: 'user_google'
}, },
credentials: { credentials: {
token: 'google_mock_token', token: 'google_mock_token',
secret: 'google_mock_secret' secret: 'google_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:suse] = OmniAuth.config.mock_auth[:suse] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'suse', provider: 'suse',
uid: 'suse-test-uid-1', uid: 'suse-test-uid-1',
info: { info: {
name: 'suse user', name: 'suse user',
email: 'user-suse@example.com', email: 'user-suse@example.com',
username: 'user_suse' username: 'user_suse'
}, },
credentials: { credentials: {
token: 'suse_mock_token', token: 'suse_mock_token',
secret: 'suse_mock_secret' secret: 'suse_mock_secret'
} }
) )
OmniAuth.config.mock_auth[:github] = OmniAuth.config.mock_auth[:github] =
OmniAuth::AuthHash.new( OmniAuth::AuthHash.new(
provider: 'github', provider: 'github',
uid: 'github-test-uid-1', uid: 'github-test-uid-1',
info: { info: {
name: 'github user', name: 'github user',
email: 'user-github@example.com', email: 'user-github@example.com',
username: 'user_github' username: 'user_github'
}, },
credentials: { credentials: {
token: 'github_mock_token', token: 'github_mock_token',
secret: 'github_mock_secret' secret: 'github_mock_secret'
} }
) )