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 = {
all_on_start: true,
all_after_pass: true,
cmd: 'spring rspec'
cmd: 'spring rspec'
}
def model_specs ; 'spec/models' end

View File

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

View File

@@ -57,6 +57,7 @@ module Admin
def sponsorship_level_required
return unless @conference.sponsorship_levels.empty?
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'
end

View File

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

View File

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

View File

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

View File

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

View File

@@ -99,6 +99,7 @@ module ApplicationHelper
def concurrent_events(event)
return nil unless event.scheduled? && event.program.selected_event_schedules
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 }
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')
other_event_schedules.each do |other_event_schedule|
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')
if (event_time_range.to_a & other_event_time_range.to_a).present?
concurrent_events << other_event_schedule.event

View File

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

View File

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

View File

@@ -191,9 +191,9 @@ module FormatHelper
return '' if text.nil?
options = {
autolink: true,
autolink: 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.render(text).html_safe
@@ -205,6 +205,7 @@ module FormatHelper
def quantity_left_of(resource)
return '-/-' if resource.quantity.blank?
"#{resource.quantity - resource.used}/#{resource.quantity}"
end
end

View File

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

View File

@@ -2,12 +2,12 @@
class Mailbot < ActionMailer::Base
def registration_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.registration_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.registration_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.registration_body))
end
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
end
mail(to: @user.email,
from: @conference.contact.email,
mail(to: @user.email,
from: @conference.contact.email,
template_name: 'ticket_confirmation_template',
subject: "#{@conference.title} | Ticket Confirmation and PDF!")
subject: "#{@conference.title} | Ticket Confirmation and PDF!")
end
def acceptance_mail(event)
conference = event.program.conference
mail(to: event.submitter.email,
from: conference.contact.email,
mail(to: event.submitter.email,
from: conference.contact.email,
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
def submitted_proposal_mail(event)
conference = event.program.conference
mail(to: event.submitter.email,
from: conference.contact.email,
mail(to: event.submitter.email,
from: conference.contact.email,
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
def rejection_mail(event)
conference = event.program.conference
mail(to: event.submitter.email,
from: conference.contact.email,
mail(to: event.submitter.email,
from: conference.contact.email,
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
def confirm_reminder_mail(event)
conference = event.program.conference
mail(to: event.submitter.email,
from: conference.contact.email,
mail(to: event.submitter.email,
from: conference.contact.email,
subject: conference.email_settings.confirmed_without_registration_subject,
body: conference.email_settings.generate_event_mail(event,
conference.email_settings.confirmed_without_registration_body))
body: conference.email_settings.generate_event_mail(event,
conference.email_settings.confirmed_without_registration_body))
end
def conference_date_update_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.conference_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.conference_dates_updated_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.conference_dates_updated_body))
end
def conference_registration_date_update_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.conference_registration_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.conference_registration_dates_updated_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.conference_registration_dates_updated_body))
end
def conference_venue_update_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.venue_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.venue_updated_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.venue_updated_body))
end
def conference_schedule_update_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.program_schedule_public_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.program_schedule_public_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.program_schedule_public_body))
end
def conference_cfp_update_mail(conference, user)
mail(to: user.email,
from: conference.contact.email,
mail(to: user.email,
from: conference.contact.email,
subject: conference.email_settings.cfp_dates_updated_subject,
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.cfp_dates_updated_body))
body: conference.email_settings.generate_email_on_conf_updates(conference,
user,
conference.email_settings.cfp_dates_updated_body))
end
def conference_booths_acceptance_mail(booth)
conference = booth.conference
mail(to: booth.submitter.email,
from: conference.contact.email,
mail(to: booth.submitter.email,
from: conference.contact.email,
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
def conference_booths_rejection_mail(booth)
conference = booth.conference
mail(to: booth.submitter.email,
from: conference.contact.email,
mail(to: booth.submitter.email,
from: conference.contact.email,
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
def event_comment_mail(comment, user)
@@ -132,9 +132,9 @@ class Mailbot < ActionMailer::Base
@conference = @event.program.conference
@user = user
mail(to: @user.email,
from: @conference.contact.email,
mail(to: @user.email,
from: @conference.contact.email,
template_name: 'comment_template',
subject: "New comment has been posted for #{@event.title}")
subject: "New comment has been posted for #{@event.title}")
end
end

View File

@@ -150,13 +150,13 @@ class Ability
can :manage, Event, program: { conference_id: conf_ids_for_organizer }
# To access comment link in menu bar
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
if conf_ids_for_cfp
# To access comment link in menu bar
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
can :manage, Event, program: { conference_id: conf_ids_for_cfp }
end

View File

@@ -115,7 +115,7 @@ class AdminAbility
can :manage, Contact, conference_id: conf_ids
can :manage, EmailSettings, conference_id: conf_ids
can :manage, Commercial, commercialable_type: 'Conference',
commercialable_id: conf_ids
commercialable_id: conf_ids
can :manage, Registration, conference_id: conf_ids
can :manage, RegistrationPeriod do |registration_period|
conference = registration_period.conference
@@ -137,10 +137,10 @@ class AdminAbility
can :manage, Track, program: { conference_id: conf_ids }
can :manage, DifficultyLevel, program: { conference_id: conf_ids }
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, 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, Room, venue: { conference_id: conf_ids }
can :manage, Sponsor, conference_id: conf_ids
@@ -151,7 +151,7 @@ class AdminAbility
conf_ids.include? conf_id
end
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)
can [:index, :show], Role do |role|
@@ -188,9 +188,9 @@ class AdminAbility
can :manage, Cfp, program: { conference_id: conf_ids_for_cfp }
can :manage, Program, conference_id: conf_ids_for_cfp
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',
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)
can [:index, :show], Role do |role|
@@ -306,7 +306,7 @@ class AdminAbility
can :manage, Event, track_id: track_ids_for_track_organizer
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
can :update, Schedule do |schedule|

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -56,6 +56,7 @@ class EventSchedule < ApplicationRecord
def replacement?(event_schedule_source = nil)
return false unless event.state == 'confirmed'
return replaced_event_schedules.exists? unless event_schedule_source
event_schedule_source.any? { |event_schedule| intersects_with?(event_schedule) }
end
@@ -82,11 +83,13 @@ class EventSchedule < ApplicationRecord
def start_after_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
end
def start_before_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
end
@@ -99,6 +102,7 @@ class EventSchedule < ApplicationRecord
#
def same_room_as_track
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
end
@@ -122,6 +126,7 @@ class EventSchedule < ApplicationRecord
#
def valid_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)
end
end

View File

@@ -4,7 +4,7 @@ class EventType < ApplicationRecord
belongs_to :program, touch: true
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]
validates :title, presence: true

View File

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

View File

@@ -13,7 +13,7 @@ class Payment < ApplicationRecord
validates :conference_id, presence: true
enum status: {
unpaid: 0,
unpaid: 0,
success: 1,
failure: 2
}
@@ -23,11 +23,11 @@ class Payment < ApplicationRecord
end
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,
description: "ticket purchases(#{user.username})",
amount: amount_to_pay,
currency: conference.tickets.first.price_currency
description: "ticket purchases(#{user.username})",
amount: amount_to_pay,
currency: conference.tickets.first.price_currency
self.amount = gateway_response[:amount]
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
tracks.self_organized.confirmed.includes(selected_schedule: { event_schedules: includes }).order(start_date: :asc).each do |track|
next unless track.selected_schedule
event_schedules += track.selected_schedule.event_schedules
end
event_schedules.sort_by(&:start_time)
@@ -157,6 +158,7 @@ class Program < ApplicationRecord
return false unless conference.email_settings.send_on_program_schedule_public
# do not notify if the schedule is not public
return false unless schedule_public
# 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?)
end
@@ -173,6 +175,7 @@ class Program < ApplicationRecord
# * +False+ -> If there is not any event for the given date
def any_event_for_this_date?(date)
return false unless selected_schedule.present?
parsed_date = DateTime.parse("#{date} 00:00").utc
range = parsed_date..(parsed_date + 1.day)
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'
def cfp
return nil if cfps.for_events.blank?
cfps.for_events
end
@@ -231,6 +235,7 @@ class Program < ApplicationRecord
#
def check_languages_format
return unless languages.present?
# 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
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
def active?
return true unless start_date || end_date
# Find timezone of conference (survyeable is Conference or Event)
timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.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 :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]
monetize :price_cents, with_model_currency: :price_currency
@@ -66,6 +66,7 @@ class Ticket < ApplicationRecord
def tickets_turnover_total(id)
ticket = Ticket.find(id)
return Money.new(0, 'USD') unless ticket
sum = ticket.ticket_purchases.paid.total
Money.new(sum, ticket.price_currency)
end
@@ -79,6 +80,7 @@ class Ticket < ApplicationRecord
def tickets_of_conference_have_same_currency
tickets = Ticket.where(conference_id: conference_id)
return if tickets.count.zero? || (tickets.count == 1 && self == tickets.first)
unless tickets.all?{|t| t.price_currency == price_currency }
errors.add(:price_currency, 'is different from the existing tickets of this conference.')
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,7 +11,7 @@ Osem::Application.routes.draw do
controllers: {
registrations: :registrations, confirmations: :confirmations,
omniauth_callbacks: 'users/omniauth_callbacks' },
path: 'accounts'
path: 'accounts'
end
# 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|
user = TempUser.find_by(id: p.user_id)
next unless user
if p.public_name.empty?
user.name = p.email
else

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -58,9 +58,9 @@ class AddRequireHandicappedAccessToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No')
# 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,
global: true)
global: true)
# Save question
q.save!

View File

@@ -58,9 +58,9 @@ class AddAttendingWithPartnerToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No')
# 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,
global: true)
global: true)
# Save question
q.save!

View File

@@ -58,9 +58,9 @@ class AddStayingAtSuggestedHotelToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No')
# 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,
global: true)
global: true)
# Save question
q.save!

View File

@@ -58,9 +58,9 @@ class AddAttendingSocialEventsToQuestions < ActiveRecord::Migration
answer_no = TempAnswer.find_or_create_by!(title: 'No')
# 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,
global: true)
global: true)
# Save question
q.save!

View File

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

View File

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

View File

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

View File

@@ -24,7 +24,7 @@ describe Admin::ConferencesController do
it 'changes conference attributes' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: 'ExCon')
conference.reload
expect(conference.title).to eq('Example Con')
@@ -52,7 +52,7 @@ describe Admin::ConferencesController do
context 'invalid attributes' do
it 'does not change conference attributes' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: nil)
conference.reload
@@ -64,7 +64,7 @@ describe Admin::ConferencesController do
it 're-renders the #show template' do
patch :update, id: conference.short_title, conference:
attributes_for(:conference, title: 'Example Con',
attributes_for(:conference, title: 'Example Con',
short_title: nil)
expect(flash[:error])
@@ -181,9 +181,9 @@ describe Admin::ConferencesController do
conference
date = Date.new(2014, 05, 26)
create(:cfp,
program: conference.program,
program: conference.program,
start_date: date,
end_date: date + 14)
end_date: date + 14)
get :index
expect(assigns(:cfp_weeks)).to match_array([1, 2, 3])
end
@@ -214,14 +214,14 @@ describe Admin::ConferencesController do
it 'saves the conference to the database' do
expected = expect do
post :create, conference:
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
end
expected.to change { Conference.count }.by 1
end
it 'redirects to conference#show' do
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(
assigns[:conference].short_title)
@@ -233,7 +233,7 @@ describe Admin::ConferencesController do
volunteers_coordinator_role = Role.find_by(name: 'volunteers_coordinator', resource: conference)
post :create, conference:
attributes_for(:conference, short_title: 'dps15')
attributes_for(:conference, short_title: 'dps15')
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
expected = expect do
post :create, conference:
attributes_for(:conference, short_title: nil, organization_id: organization.id)
attributes_for(:conference, short_title: nil, organization_id: organization.id)
end
expected.to_not change { Conference.count }
end
it 're-renders the new template' do
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
end
end
@@ -262,7 +262,7 @@ describe Admin::ConferencesController do
conference
expected = expect do
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
expected.to_not change { Conference.count }
end
@@ -352,7 +352,7 @@ describe Admin::ConferencesController do
describe 'PATCH #update' do
it 'requires organizer privileges' do
patch :update, id: conference.short_title,
patch :update, id: conference.short_title,
conference: attributes_for(:conference,
short_title: 'ExCon')
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:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id,
room_id: create(:room, venue: venue).id,
start_time: conference.start_date + conference.start_hour.hours)
event_id: create(:event, program: conference.program).id,
room_id: create(:room, venue: venue).id,
start_time: conference.start_date + conference.start_hour.hours)
end
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:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: nil,
room_id: nil,
start_time: nil)
event_id: nil,
room_id: nil,
start_time: nil)
end
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:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: create(:event, program: conference.program).id,
room_id: room.id,
start_time: conference.start_date + conference.start_hour.hours)
event_id: create(:event, program: conference.program).id,
room_id: room.id,
start_time: conference.start_date + conference.start_hour.hours)
event_schedule.reload
end
@@ -90,9 +90,9 @@ describe Admin::EventSchedulesController do
patch :update, id: event_schedule.id, conference_id: conference.short_title, event_schedule:
attributes_for(:event_schedule,
schedule_id: schedule.id,
event_id: nil,
room_id: nil,
start_time: nil)
event_id: nil,
room_id: nil,
start_time: nil)
end
it 'does not save the event schedule to the database' do
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) }
before do
post :assign_org_admins, id: organization.id,
post :assign_org_admins, id: organization.id,
user: { email: user.email }
end
@@ -188,7 +188,7 @@ describe Admin::OrganizationsController do
let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) }
before do
delete :unassign_org_admins, id: organization.id,
delete :unassign_org_admins, id: organization.id,
user: { email: org_admin_user.email }
end

View File

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

View File

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

View File

@@ -91,9 +91,9 @@ describe Admin::RoomsController do
describe 'PATCH #update' do
context 'updates successfully' do
before do
patch :update, room: attributes_for(:room, size: 2),
patch :update, room: attributes_for(:room, size: 2),
conference_id: conference.short_title,
id: room.id
id: room.id
end
it 'redirects to admin room index path' do
@@ -113,9 +113,9 @@ describe Admin::RoomsController do
context 'update fails' do
before do
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,
id: room.id
id: room.id
end
it 'renders edit template' do

View File

@@ -51,7 +51,7 @@ describe Admin::SponsorshipLevelsController do
context 'saves successfuly' do
before(:each, run: true) do
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
conference_id: conference.short_title
end
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
expect do
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
end
@@ -74,7 +74,7 @@ describe Admin::SponsorshipLevelsController do
before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
post :create, sponsorship_level: attributes_for(:sponsorship_level),
conference_id: conference.short_title
conference_id: conference.short_title
end
it 'renders new template' do
@@ -95,8 +95,8 @@ describe Admin::SponsorshipLevelsController do
context 'updates successfully' do
before do
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title,
id: sponsorship_level.id
conference_id: conference.short_title,
id: sponsorship_level.id
end
it 'redirects to admin sponsorship_level index path' do
@@ -117,8 +117,8 @@ describe Admin::SponsorshipLevelsController do
before do
allow_any_instance_of(SponsorshipLevel).to receive(:save).and_return(false)
patch :update, sponsorship_level: attributes_for(:sponsorship_level, title: 'Gold'),
conference_id: conference.short_title,
id: sponsorship_level.id
conference_id: conference.short_title,
id: sponsorship_level.id
end
it 'renders edit template' do

View File

@@ -134,9 +134,9 @@ describe Admin::TracksController do
describe 'PATCH #update' do
context 'updates successfully' 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,
id: track.short_name
id: track.short_name
end
it 'assigns the correct track' do
@@ -160,9 +160,9 @@ describe Admin::TracksController do
context 'update fails' do
before :each do
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,
id: track.short_name
id: track.short_name
end
it 'assigns the correct track' do

View File

@@ -248,8 +248,8 @@ describe ConferenceRegistrationsController, type: :controller do
before do
@ticket = create(:ticket, conference: conference)
@purchased_ticket = create(:ticket_purchase, conference: conference,
user: user,
ticket: @ticket)
user: user,
ticket: @ticket)
get :show, conference_id: conference.short_title
end
@@ -290,13 +290,13 @@ describe ConferenceRegistrationsController, type: :controller do
before do
@registration = create(:registration,
conference: conference,
user: user,
arrival: Date.new(2014, 04, 25))
user: user,
arrival: Date.new(2014, 04, 25))
end
context 'updates successfully' 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
end
@@ -317,7 +317,7 @@ describe ConferenceRegistrationsController, type: :controller do
context 'update fails' do
before do
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
end

View File

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

View File

@@ -128,9 +128,9 @@ describe TracksController do
describe 'PATCH #update' do
context 'updates successfully' 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,
id: self_organized_track.short_name
id: self_organized_track.short_name
end
it 'assigns the correct track' do
@@ -154,9 +154,9 @@ describe TracksController do
context 'update fails' do
before :each do
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,
id: self_organized_track.short_name
id: self_organized_track.short_name
end
it 'assigns the correct track' do

View File

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

View File

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

View File

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

View File

@@ -46,8 +46,8 @@ feature Commercial do
before(:each) do
event.event_users = [create(:event_user,
user_id: participant.id,
event_id: event.id,
user_id: participant.id,
event_id: event.id,
event_role: 'submitter')]
sign_in participant
end
@@ -85,7 +85,7 @@ feature Commercial do
scenario 'updates a commercial of an event', feature: true, versioning: true, js: true do
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_id: event.id,
commercialable_type: 'Event')
visit edit_conference_program_proposal_path(conference.short_title, event.id)
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
commercial = create(:commercial,
commercialable_id: event.id,
commercialable_id: event.id,
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)
click_link 'Commercials'
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
create(:commercial,
commercialable_id: event.id,
commercialable_id: event.id,
commercialable_type: 'Event')
visit edit_conference_program_proposal_path(conference.short_title, event.id)
click_link 'Commercials'

View File

@@ -41,7 +41,7 @@ describe Mailbot do
before do
conference.email_settings.update_attributes(send_on_accepted: true,
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
include_examples 'mailer actions' do
@@ -53,7 +53,7 @@ describe Mailbot do
before do
conference.email_settings.update_attributes(send_on_rejected: true,
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
include_examples 'mailer actions' do
@@ -65,7 +65,7 @@ describe Mailbot do
before do
conference.email_settings.update_attributes(send_on_confirmed_without_registration: true,
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
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]
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 },
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 },
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 },
canceled: { restart: true, withdraw: false, accept: false, to_accept: false, to_reject: false, reject: false, cancel: false, confirm: false },
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 },
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 } }
states.each do |state|

View File

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

View File

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

View File

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

View File

@@ -65,8 +65,8 @@ describe TicketPurchase do
tickets = { free_ticket.id.to_s => '10' }
message = TicketPurchase.purchase(conference, participant, tickets)
purchase = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id,
ticket_id: free_ticket.id).first
user_id: participant.id,
ticket_id: free_ticket.id).first
expect(TicketPurchase.count).to eq(1)
expect(purchase.quantity).to eq(10)
@@ -77,8 +77,8 @@ describe TicketPurchase do
tickets = { ticket_1.id.to_s => '1' }
message = TicketPurchase.purchase(conference, participant, tickets)
purchase = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id,
ticket_id: ticket_1.id).first
user_id: participant.id,
ticket_id: ticket_1.id).first
expect(TicketPurchase.count).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' }
message = TicketPurchase.purchase(conference, participant, tickets)
purchase_1 = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id,
ticket_id: ticket_1.id).first
user_id: participant.id,
ticket_id: ticket_1.id).first
purchase_2 = TicketPurchase.where(conference_id: conference.id,
user_id: participant.id,
ticket_id: ticket_2.id).first
user_id: participant.id,
ticket_id: ticket_2.id).first
expect(TicketPurchase.count).to eq(2)
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
purchase = create(:ticket_purchase,
conference: conference,
user: participant,
ticket: ticket_1,
quantity: 5)
user: participant,
ticket: ticket_1,
quantity: 5)
tickets = { ticket_1.id.to_s => '10' }
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
conflicting_currency_ticket = build(:ticket,
conference: ticket.conference,
conference: ticket.conference,
price_currency: 'INR')
expected_error_message = 'Price currency is different from the existing tickets of this conference.'
@@ -57,7 +57,7 @@ describe Ticket do
describe '#bought?' do
it 'returns true if the user has bought this ticket' do
create(:ticket_purchase,
user: user,
user: user,
ticket: ticket)
expect(ticket.bought?(user)).to eq(true)
end
@@ -112,8 +112,8 @@ describe Ticket do
context 'user has not paid' do
it 'returns the correct value if the user has bought this ticket' do
create(:ticket_purchase,
user: user,
ticket: ticket,
user: user,
ticket: ticket,
quantity: 20)
expect(ticket.quantity_bought_by(user, paid: false)).to eq(20)
end
@@ -137,8 +137,8 @@ describe Ticket do
context 'user has not paid' do
it 'returns the correct value if the user has bought this ticket' do
create(:ticket_purchase,
user: user,
ticket: ticket,
user: user,
ticket: ticket,
quantity: 20)
expect(ticket.total_price(user, paid: false)).to eq(Money.new(100000, 'USD'))
end

View File

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

View File

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

View File

@@ -6,8 +6,8 @@ describe ConferenceSerializer, type: :serializer do
let(:conference) do
create(:conference, short_title: 'goto',
description: 'Lorem ipsum dolor sit',
start_date: Date.new(2014, 03, 04),
end_date: Date.new(2014, 03, 10))
start_date: Date.new(2014, 03, 04),
end_date: Date.new(2014, 03, 10))
end
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
expected_json = {
event: {
guid: event.guid,
title: 'Some Talk',
length: 30,
guid: event.guid,
title: 'Some Talk',
length: 30,
scheduled_date: '',
language: nil,
abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: event.speaker_ids,
type: 'Example Event Type',
room: nil,
track: nil
language: nil,
abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: event.speaker_ids,
type: 'Example Event Type',
room: nil,
track: nil
}
}.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
expected_json = {
event: {
guid: event.guid,
title: 'Some Talk',
length: 30,
guid: event.guid,
title: 'Some Talk',
length: 30,
scheduled_date: ' 2014-03-04T09:00:00+0000 ',
language: 'English',
abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: [speaker.id],
type: 'Example Event Type',
room: room.guid,
track: track.guid
language: 'English',
abstract: 'Lorem ipsum dolor sit amet',
speaker_ids: [speaker.id],
type: 'Example Event Type',
room: room.guid,
track: track.guid
}
}.to_json

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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