Merge 27fc0acbf8 into 6755328c4c
This commit is contained in:
commit
f86added23
24 changed files with 388 additions and 116 deletions
|
|
@ -121,7 +121,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#conference-reg-start-datepicker").datetimepicker({
|
$("#registration-start-datepicker").datetimepicker({
|
||||||
dateFormat: "yy-mm-dd",
|
dateFormat: "yy-mm-dd",
|
||||||
timeFormat: "HH:mm",
|
timeFormat: "HH:mm",
|
||||||
showSecond: false,
|
showSecond: false,
|
||||||
|
|
@ -131,7 +131,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#conference-reg-end-datepicker").datetimepicker({
|
$("#registration-end-datepicker").datetimepicker({
|
||||||
dateFormat: "yy-mm-dd",
|
dateFormat: "yy-mm-dd",
|
||||||
timeFormat: "HH:mm",
|
timeFormat: "HH:mm",
|
||||||
showSecond: false,
|
showSecond: false,
|
||||||
|
|
|
||||||
46
app/controllers/admin/audiences_controller.rb
Normal file
46
app/controllers/admin/audiences_controller.rb
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
module Admin
|
||||||
|
class AudiencesController < ApplicationController
|
||||||
|
before_action :set_conference, only: [:edit, :update]
|
||||||
|
before_action :set_audience, only: [:edit, :update]
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@audience.assign_attributes(audience_params)
|
||||||
|
|
||||||
|
notify_on_conf_reg_dates_updates = (@audience.registration_start_date_changed? || @audience.registration_end_date_changed?)\
|
||||||
|
&& @conference.email_settings.send_on_updated_conference_registration_dates\
|
||||||
|
&& !@conference.email_settings.updated_conference_registration_dates_subject.blank?\
|
||||||
|
&& @conference.email_settings.updated_conference_registration_dates_template
|
||||||
|
|
||||||
|
if @audience.update(audience_params)
|
||||||
|
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
||||||
|
redirect_to edit_admin_conference_audience_path(@conference.short_title),
|
||||||
|
notice: 'Audience was successfully updated.'
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_conference
|
||||||
|
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
def set_audience
|
||||||
|
@audience = @conference.audience
|
||||||
|
end
|
||||||
|
|
||||||
|
# Only allow a trusted parameter "white list" through.
|
||||||
|
def audience_params
|
||||||
|
# params.require(:audience).permit(:conference_id,
|
||||||
|
# :registration_start_date,
|
||||||
|
# :registration_end_date,
|
||||||
|
# :registration_description)
|
||||||
|
params[:audience]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -100,14 +100,8 @@ module Admin
|
||||||
&& !@conference.email_settings.updated_conference_dates_subject.blank?\
|
&& !@conference.email_settings.updated_conference_dates_subject.blank?\
|
||||||
&& @conference.email_settings.updated_conference_dates_template
|
&& @conference.email_settings.updated_conference_dates_template
|
||||||
|
|
||||||
notify_on_conf_reg_dates_updates = (@conference.registration_start_date_changed? || @conference.registration_end_date_changed?)\
|
|
||||||
&& @conference.email_settings.send_on_updated_conference_registration_dates\
|
|
||||||
&& !@conference.email_settings.updated_conference_registration_dates_subject.blank?\
|
|
||||||
&& @conference.email_settings.updated_conference_registration_dates_template
|
|
||||||
|
|
||||||
if @conference.update_attributes(params[:conference])
|
if @conference.update_attributes(params[:conference])
|
||||||
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
Mailbot.delay.conference_date_update_mail(@conference) if notify_on_conf_dates_updates
|
||||||
Mailbot.delay.conference_registration_date_update_mail(@conference) if notify_on_conf_reg_dates_updates
|
|
||||||
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
redirect_to(edit_admin_conference_path(id: @conference.short_title),
|
||||||
notice: 'Conference was successfully updated.')
|
notice: 'Conference was successfully updated.')
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,8 @@ module Admin
|
||||||
|
|
||||||
@tickets_time = []
|
@tickets_time = []
|
||||||
|
|
||||||
if @conference.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels
|
if @conference.audience.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels
|
||||||
start_date = @conference.registration_start_date
|
start_date = @conference.audience.registration_start_date
|
||||||
end_date = @conference.end_date
|
end_date = @conference.end_date
|
||||||
levels = []
|
levels = []
|
||||||
@conference.supporter_levels.each do |level|
|
@conference.supporter_levels.each do |level|
|
||||||
|
|
@ -154,8 +154,8 @@ module Admin
|
||||||
]
|
]
|
||||||
|
|
||||||
# REGISTRATIONS, registered_time
|
# REGISTRATIONS, registered_time
|
||||||
if @conference.registration_start_date && @conference.end_date && @registered > 0
|
if @conference.audience.registration_start_date && @conference.end_date && @registered > 0
|
||||||
start_date = @conference.registration_start_date
|
start_date = @conference.audience.registration_start_date
|
||||||
end_date = @conference.end_date
|
end_date = @conference.end_date
|
||||||
@registered_time = var_time(start_date, end_date, @registrations, 'created_at')
|
@registered_time = var_time(start_date, end_date, @registrations, 'created_at')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
5
app/models/audience.rb
Normal file
5
app/models/audience.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class Audience < ActiveRecord::Base
|
||||||
|
attr_accessible :registration_description, :registration_start_date, :registration_end_date
|
||||||
|
|
||||||
|
belongs_to :conference
|
||||||
|
end
|
||||||
|
|
@ -9,11 +9,11 @@ class Conference < ActiveRecord::Base
|
||||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
||||||
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
|
:dietary_choices_attributes, :use_dietary_choices, :use_supporter_levels,
|
||||||
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
|
:supporter_levels_attributes, :social_events_attributes, :event_types_attributes,
|
||||||
:registration_start_date, :registration_end_date, :logo, :questions_attributes,
|
:logo, :questions_attributes,
|
||||||
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
|
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
|
||||||
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
|
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
|
||||||
:vpositions_attributes, :use_volunteers, :color,
|
:vpositions_attributes, :use_volunteers, :color,
|
||||||
:description, :registration_description, :ticket_description,
|
:description, :ticket_description,
|
||||||
:sponsorship_levels_attributes, :sponsors_attributes,
|
:sponsorship_levels_attributes, :sponsors_attributes,
|
||||||
:sponsor_description, :sponsor_email, :lodging_description,
|
:sponsor_description, :sponsor_email, :lodging_description,
|
||||||
:include_registrations_in_splash, :include_sponsors_in_splash,
|
:include_registrations_in_splash, :include_sponsors_in_splash,
|
||||||
|
|
@ -28,7 +28,7 @@ class Conference < ActiveRecord::Base
|
||||||
has_and_belongs_to_many :questions
|
has_and_belongs_to_many :questions
|
||||||
|
|
||||||
has_one :contact, dependent: :destroy
|
has_one :contact, dependent: :destroy
|
||||||
|
has_one :audience, dependent: :destroy
|
||||||
has_one :email_settings, dependent: :destroy
|
has_one :email_settings, dependent: :destroy
|
||||||
has_one :call_for_papers, dependent: :destroy
|
has_one :call_for_papers, dependent: :destroy
|
||||||
has_many :social_events, dependent: :destroy
|
has_many :social_events, dependent: :destroy
|
||||||
|
|
@ -95,6 +95,7 @@ class Conference < ActiveRecord::Base
|
||||||
before_create :create_event_types
|
before_create :create_event_types
|
||||||
before_create :create_email_settings
|
before_create :create_email_settings
|
||||||
before_create :add_color
|
before_create :add_color
|
||||||
|
before_create :create_audience
|
||||||
|
|
||||||
##
|
##
|
||||||
# Checks if the user is registered to the conference
|
# Checks if the user is registered to the conference
|
||||||
|
|
@ -125,7 +126,7 @@ class Conference < ActiveRecord::Base
|
||||||
def registration_open?
|
def registration_open?
|
||||||
today = Date.current
|
today = Date.current
|
||||||
if registration_dates_given?
|
if registration_dates_given?
|
||||||
(registration_start_date..registration_end_date).cover?(today)
|
(audience.registration_start_date..audience.registration_end_date).cover?(today)
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
@ -138,7 +139,7 @@ class Conference < ActiveRecord::Base
|
||||||
# * +false+ -> If the conference registration dates are not set
|
# * +false+ -> If the conference registration dates are not set
|
||||||
# * +true+ -> If conference registration dates are set
|
# * +true+ -> If conference registration dates are set
|
||||||
def registration_dates_given?
|
def registration_dates_given?
|
||||||
if registration_start_date.blank? || registration_end_date.blank?
|
if audience.registration_start_date.blank? || audience.registration_end_date.blank?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
|
|
@ -214,8 +215,8 @@ class Conference < ActiveRecord::Base
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
if registrations &&
|
if registrations &&
|
||||||
registration_start_date &&
|
audience.registration_start_date &&
|
||||||
registration_end_date
|
audience.registration_end_date
|
||||||
|
|
||||||
reg = registrations.group(:week).count
|
reg = registrations.group(:week).count
|
||||||
start_week = get_registration_start_week
|
start_week = get_registration_start_week
|
||||||
|
|
@ -233,8 +234,8 @@ class Conference < ActiveRecord::Base
|
||||||
def registration_weeks
|
def registration_weeks
|
||||||
result = 0
|
result = 0
|
||||||
weeks = 0
|
weeks = 0
|
||||||
if registration_start_date && registration_end_date
|
if audience.registration_start_date && audience.registration_end_date
|
||||||
weeks = Date.new(registration_start_date.year, 12, 31).
|
weeks = Date.new(audience.registration_start_date.year, 12, 31).
|
||||||
strftime('%W').to_i
|
strftime('%W').to_i
|
||||||
|
|
||||||
result = get_registration_end_week - get_registration_start_week + 1
|
result = get_registration_end_week - get_registration_start_week + 1
|
||||||
|
|
@ -261,7 +262,7 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +Integer+ -> start week
|
# * +Integer+ -> start week
|
||||||
def get_registration_start_week
|
def get_registration_start_week
|
||||||
registration_start_date.strftime('%W').to_i
|
audience.registration_start_date.strftime('%W').to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -270,7 +271,7 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +Integer+ -> start week
|
# * +Integer+ -> start week
|
||||||
def get_registration_end_week
|
def get_registration_end_week
|
||||||
registration_end_date.strftime('%W').to_i
|
audience.registration_end_date.strftime('%W').to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -426,13 +427,11 @@ class Conference < ActiveRecord::Base
|
||||||
# * +ActiveRecord+
|
# * +ActiveRecord+
|
||||||
def self.get_active_conferences_for_dashboard
|
def self.get_active_conferences_for_dashboard
|
||||||
result = Conference.where('start_date > ?', Time.now).
|
result = Conference.where('start_date > ?', Time.now).
|
||||||
select('id, short_title, color, start_date,
|
select('id, short_title, color, start_date')
|
||||||
registration_end_date, registration_start_date')
|
|
||||||
|
|
||||||
if result.length == 0
|
if result.length == 0
|
||||||
result = Conference.
|
result = Conference.
|
||||||
select('id, short_title, color, start_date, registration_end_date,
|
select('id, short_title, color, start_date').limit(2).
|
||||||
registration_start_date').limit(2).
|
|
||||||
order(start_date: :desc)
|
order(start_date: :desc)
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
|
|
@ -444,8 +443,7 @@ class Conference < ActiveRecord::Base
|
||||||
# ====Returns
|
# ====Returns
|
||||||
# * +ActiveRecord+
|
# * +ActiveRecord+
|
||||||
def self.get_conferences_without_active_for_dashboard(active_conferences)
|
def self.get_conferences_without_active_for_dashboard(active_conferences)
|
||||||
result = Conference.select('id, short_title, color, start_date,
|
result = Conference.select('id, short_title, color, start_date').order(start_date: :desc)
|
||||||
registration_end_date, registration_start_date').order(start_date: :desc)
|
|
||||||
result - active_conferences
|
result - active_conferences
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -707,7 +705,7 @@ class Conference < ActiveRecord::Base
|
||||||
# * +True+ -> If conference has a start and a end date.
|
# * +True+ -> If conference has a start and a end date.
|
||||||
# * +False+ -> If conference has no start or end date.
|
# * +False+ -> If conference has no start or end date.
|
||||||
def registration_date_set?
|
def registration_date_set?
|
||||||
!!registration_start_date && !!registration_end_date
|
!!audience.registration_start_date && !!audience.registration_end_date
|
||||||
end
|
end
|
||||||
|
|
||||||
# Calculates the distribution from events.
|
# Calculates the distribution from events.
|
||||||
|
|
@ -867,6 +865,13 @@ class Conference < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Creates a Audience association proxy. Used as before_create.
|
||||||
|
#
|
||||||
|
def create_audience
|
||||||
|
build_audience
|
||||||
|
true
|
||||||
|
end
|
||||||
##
|
##
|
||||||
# Creates a UID for the conference. Used as before_create.
|
# Creates a UID for the conference. Used as before_create.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ class EmailSettings < ActiveRecord::Base
|
||||||
'conference' => conference.title,
|
'conference' => conference.title,
|
||||||
'conference_start_date' => conference.start_date,
|
'conference_start_date' => conference.start_date,
|
||||||
'conference_end_date' => conference.end_date,
|
'conference_end_date' => conference.end_date,
|
||||||
'registration_start_date' => conference.registration_start_date,
|
'registration_start_date' => conference.audience.registration_start_date,
|
||||||
'registration_end_date' => conference.registration_end_date,
|
'registration_end_date' => conference.audience.registration_end_date,
|
||||||
'venue' => conference.venue.name,
|
'venue' => conference.venue.name,
|
||||||
'venue_address' => conference.venue.address,
|
'venue_address' => conference.venue.address,
|
||||||
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(
|
'registrationlink' => Rails.application.routes.url_helpers.register_conference_url(
|
||||||
|
|
|
||||||
4
app/views/admin/audiences/_form.html.haml
Normal file
4
app/views/admin/audiences/_form.html.haml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
= f.input :registration_start_date, as: :string, input_html: { id: 'registration-start-datepicker', readonly: 'readonly' }
|
||||||
|
= f.input :registration_end_date, as: :string, input_html: { id: 'registration-end-datepicker', readonly: 'readonly' }
|
||||||
|
= f.input :registration_description, hint: markdown_hint('This will appear in the Tickets segment of the splash.'), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
||||||
|
= f.submit 'Save Audience', class: 'btn btn-primary'
|
||||||
5
app/views/admin/audiences/edit.html.haml
Normal file
5
app/views/admin/audiences/edit.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
%h1 Audience
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
= semantic_form_for(@audience, url: admin_conference_audience_path(@conference.short_title)) do |f|
|
||||||
|
= render 'form', f: f
|
||||||
|
|
@ -20,9 +20,6 @@
|
||||||
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
|
= f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" }
|
||||||
= f.inputs name: 'Registration' do
|
= f.inputs name: 'Registration' do
|
||||||
= f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page'
|
= f.input :include_registrations_in_splash, hint: 'On setting this true you will enable the registrations to be displayed on the splash page'
|
||||||
= f.input :registration_start_date, :as => :string, :input_html => { :id => "conference-reg-start-datepicker", :readonly => "readonly" }
|
|
||||||
= f.input :registration_end_date, :as => :string, :input_html => { :id => "conference-reg-end-datepicker", :readonly => "readonly" }
|
|
||||||
= f.input :registration_description, hint: markdown_hint("This description will appear in registration segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
|
||||||
= f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
= f.input :ticket_description, hint: markdown_hint("This will appear in the Tickets segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
||||||
= f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
= f.input :sponsor_description, hint: markdown_hint("This will appear in the sponsor segment of the splash."), input_html: { rows: 5, data: { provide: "markdown-editable" } }
|
||||||
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'
|
= f.input :sponsor_email, hint: 'This will appear in the sponsor segment of the splash for the sponsors to contact to the organizers'
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,14 @@
|
||||||
%div.container.text-center
|
%div.container.text-center
|
||||||
%div.row
|
%div.row
|
||||||
%h1 Registration
|
%h1 Registration
|
||||||
- if !@conference.registration_description.blank?
|
- if !@conference.audience.registration_description.blank?
|
||||||
.lead
|
.lead
|
||||||
= markdown(@conference.registration_description)
|
= markdown(@conference.audience.registration_description)
|
||||||
- if @conference.registration_dates_given?
|
- if @conference.registration_dates_given?
|
||||||
-if @conference.registration_end_date >= Date.today
|
-if @conference.audience.registration_end_date >= Date.today
|
||||||
%h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
%h4 Registration period #{ date_string(@conference.audience.registration_start_date, @conference.audience.registration_end_date) }
|
||||||
-else
|
-else
|
||||||
%h4 Registration is Closed, it was from #{ date_string(@conference.registration_start_date, @conference.registration_end_date) }
|
%h4 Registration is Closed, it was from #{ date_string(@conference.audience.registration_start_date, @conference.audience.registration_end_date) }
|
||||||
- if @conference.registration_open?
|
- if @conference.registration_open?
|
||||||
= link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
= link_to "Register for #{@conference.short_title}", register_conference_path(@conference.short_title), :class =>"btn btn-success btn-lg", target: '_blank'
|
||||||
- if @conference.use_supporter_levels?
|
- if @conference.use_supporter_levels?
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
%span.glyphicon.glyphicon-plus
|
%span.glyphicon.glyphicon-plus
|
||||||
New Conference
|
New Conference
|
||||||
%hr
|
%hr
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"}
|
%li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))}"}
|
||||||
= link_to(admin_conference_path(@conference.short_title)) do
|
= link_to(admin_conference_path(@conference.short_title)) do
|
||||||
%span.fa.fa-tachometer
|
%span.fa.fa-tachometer
|
||||||
Dashboard
|
Dashboard
|
||||||
|
|
@ -41,6 +41,11 @@
|
||||||
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
= link_to(admin_conference_photos_path(@conference.short_title)) do
|
||||||
%span.fa.fa-picture-o
|
%span.fa.fa-picture-o
|
||||||
Photos
|
Photos
|
||||||
|
%li{:class=> active_nav_li(edit_admin_conference_audience_path(@conference.short_title))}
|
||||||
|
= link_to(edit_admin_conference_audience_path(@conference.short_title)) do
|
||||||
|
%span.fa.fa-male
|
||||||
|
Audience
|
||||||
|
%hr
|
||||||
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))}
|
||||||
= link_to(admin_conference_events_path(@conference.short_title)) do
|
= link_to(admin_conference_events_path(@conference.short_title)) do
|
||||||
%span.glyphicon.glyphicon-comment
|
%span.glyphicon.glyphicon-comment
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ Osem::Application.routes.draw do
|
||||||
patch '/registrations/change_field' => 'registrations#change_field'
|
patch '/registrations/change_field' => 'registrations#change_field'
|
||||||
resources :registrations
|
resources :registrations
|
||||||
|
|
||||||
|
resource :audience, only: [:update, :edit]
|
||||||
|
|
||||||
resources :difficulty_levels, only: [:show, :update, :index]
|
resources :difficulty_levels, only: [:show, :update, :index]
|
||||||
|
|
||||||
resources :rooms, only: [:show, :update, :index]
|
resources :rooms, only: [:show, :update, :index]
|
||||||
|
|
|
||||||
12
db/migrate/20140804185823_create_audiences.rb
Normal file
12
db/migrate/20140804185823_create_audiences.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CreateAudiences < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :audiences do |t|
|
||||||
|
t.integer :conference_id
|
||||||
|
t.date :registration_start_date
|
||||||
|
t.date :registration_end_date
|
||||||
|
t.text :registration_description
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
class MoveConferenceRegistrationDataToAudience < ActiveRecord::Migration
|
||||||
|
class TempConference < ActiveRecord::Base
|
||||||
|
self.table_name = 'conferences'
|
||||||
|
end
|
||||||
|
|
||||||
|
class TempAudience < ActiveRecord::Base
|
||||||
|
self.table_name = 'audiences'
|
||||||
|
attr_accessible :conference_id, :registration_start_date, :registration_end_date, :registration_description
|
||||||
|
end
|
||||||
|
|
||||||
|
def change
|
||||||
|
# Move all the settings to the new object
|
||||||
|
TempConference.all.each do |conference|
|
||||||
|
unless TempAudience.exists?(conference_id: conference.id)
|
||||||
|
TempAudience.create(conference_id: conference.id,
|
||||||
|
registration_start_date: conference.registration_start_date,
|
||||||
|
registration_end_date: conference.registration_end_date,
|
||||||
|
registration_description: conference.registration_description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove Columns
|
||||||
|
remove_column :conferences, :registration_start_date
|
||||||
|
remove_column :conferences, :registration_end_date
|
||||||
|
remove_column :conferences, :registration_description
|
||||||
|
end
|
||||||
|
end
|
||||||
14
db/schema.rb
14
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20140801170430) do
|
ActiveRecord::Schema.define(version: 20140812065531) do
|
||||||
|
|
||||||
create_table "ahoy_events", force: true do |t|
|
create_table "ahoy_events", force: true do |t|
|
||||||
t.uuid "visit_id"
|
t.uuid "visit_id"
|
||||||
|
|
@ -31,6 +31,15 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "audiences", force: true do |t|
|
||||||
|
t.integer "conference_id"
|
||||||
|
t.date "registration_start_date"
|
||||||
|
t.date "registration_end_date"
|
||||||
|
t.text "registration_description"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "call_for_papers", force: true do |t|
|
create_table "call_for_papers", force: true do |t|
|
||||||
t.date "start_date", null: false
|
t.date "start_date", null: false
|
||||||
t.date "end_date", null: false
|
t.date "end_date", null: false
|
||||||
|
|
@ -94,8 +103,6 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
||||||
t.integer "venue_id"
|
t.integer "venue_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.date "registration_start_date"
|
|
||||||
t.date "registration_end_date"
|
|
||||||
t.string "logo_file_name"
|
t.string "logo_file_name"
|
||||||
t.string "logo_content_type"
|
t.string "logo_content_type"
|
||||||
t.integer "logo_file_size"
|
t.integer "logo_file_size"
|
||||||
|
|
@ -109,7 +116,6 @@ ActiveRecord::Schema.define(version: 20140801170430) do
|
||||||
t.boolean "use_volunteers"
|
t.boolean "use_volunteers"
|
||||||
t.string "color"
|
t.string "color"
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.text "registration_description"
|
|
||||||
t.text "ticket_description"
|
t.text "ticket_description"
|
||||||
t.text "sponsor_description"
|
t.text "sponsor_description"
|
||||||
t.string "sponsor_email"
|
t.string "sponsor_email"
|
||||||
|
|
|
||||||
97
spec/controllers/admin/audiences_controller_spec.rb
Normal file
97
spec/controllers/admin/audiences_controller_spec.rb
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Admin::AudiencesController do
|
||||||
|
|
||||||
|
# It is necessary to use bang version of let to build roles before user
|
||||||
|
let!(:organizer_role) { create(:organizer_role) }
|
||||||
|
let!(:participant_role) { create(:participant_role) }
|
||||||
|
let!(:admin_role) { create(:admin_role) }
|
||||||
|
|
||||||
|
let(:conference) { create(:conference) }
|
||||||
|
let(:admin) { create(:admin) }
|
||||||
|
let(:organizer) { create(:organizer) }
|
||||||
|
let(:participant) { create(:participant) }
|
||||||
|
|
||||||
|
shared_examples 'access as administration or organizer' do
|
||||||
|
|
||||||
|
before do
|
||||||
|
conference.audience = create(:audience)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'PATCH #update' do
|
||||||
|
|
||||||
|
context 'valid attributes' do
|
||||||
|
|
||||||
|
it 'locates the requested audience object' do
|
||||||
|
patch :update, conference_id: conference.short_title, conference: attributes_for(:audience)
|
||||||
|
expect(assigns(:audience)).to eq(conference.audience)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'changes audience attributes' do
|
||||||
|
patch :update, conference_id: conference.short_title, audience:
|
||||||
|
attributes_for(:audience,
|
||||||
|
registration_description: 'Test')
|
||||||
|
|
||||||
|
conference.reload
|
||||||
|
expect(conference.audience.registration_description).to eq('Test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirects to the updated conference' do
|
||||||
|
patch :update, conference_id: conference.short_title, audience:
|
||||||
|
attributes_for(:audience)
|
||||||
|
conference.reload
|
||||||
|
expect(response).to redirect_to edit_admin_conference_audience_path(
|
||||||
|
conference.short_title)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sends email notification on conference registration date update' do
|
||||||
|
mailer = double
|
||||||
|
allow(mailer).to receive(:deliver)
|
||||||
|
conference.email_settings = create(:email_settings)
|
||||||
|
conference.audience = create(:audience,
|
||||||
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 2.days)
|
||||||
|
|
||||||
|
patch :update, conference_id: conference.short_title, audience:
|
||||||
|
attributes_for(:audience,
|
||||||
|
registration_start_date: Date.today + 2.days,
|
||||||
|
registration_end_date: Date.today + 4.days)
|
||||||
|
conference.reload
|
||||||
|
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'GET #edit' do
|
||||||
|
it 'assigns the requested conference to conference' do
|
||||||
|
get :edit, conference_id: conference.short_title
|
||||||
|
expect(assigns(:audience)).to eq conference.audience
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'renders the show template' do
|
||||||
|
get :edit, conference_id: conference.short_title
|
||||||
|
expect(response).to render_template :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'administrator access' do
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in(admin)
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'access as administration or organizer'
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'organizer access' do
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
sign_in(organizer)
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'access as administration or organizer'
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -50,16 +50,6 @@ describe Admin::ConferenceController do
|
||||||
conference.reload
|
conference.reload
|
||||||
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends email notification on conference registration date update' do
|
|
||||||
mailer = double
|
|
||||||
allow(mailer).to receive(:deliver)
|
|
||||||
conference.email_settings = create(:email_settings)
|
|
||||||
patch :update, id: conference.short_title, conference:
|
|
||||||
attributes_for(:conference, registration_start_date: Date.today + 2.days, registration_end_date: Date.today + 4.days)
|
|
||||||
conference.reload
|
|
||||||
allow(Mailbot).to receive(:conference_registration_date_update_mail).and_return(mailer)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'invalid attributes' do
|
context 'invalid attributes' do
|
||||||
|
|
@ -143,13 +133,13 @@ describe Admin::ConferenceController do
|
||||||
|
|
||||||
describe 'GET #edit' do
|
describe 'GET #edit' do
|
||||||
it 'assigns the requested conference to conference' do
|
it 'assigns the requested conference to conference' do
|
||||||
get :show, id: conference.short_title
|
get :edit, id: conference.short_title
|
||||||
expect(assigns(:conference)).to eq conference
|
expect(assigns(:conference)).to eq conference
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders the show template' do
|
it 'renders the show template' do
|
||||||
get :show, id: conference.short_title
|
get :edit, id: conference.short_title
|
||||||
expect(response).to render_template :show
|
expect(response).to render_template :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
9
spec/factories/audiences.rb
Normal file
9
spec/factories/audiences.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||||
|
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :audience do
|
||||||
|
registration_start_date { 3.days.from_now }
|
||||||
|
registration_end_date { 5.days.from_now }
|
||||||
|
registration_description 'Lorem ipsum dolorem ...'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -7,8 +7,6 @@ FactoryGirl.define do
|
||||||
timezone 'Amsterdam'
|
timezone 'Amsterdam'
|
||||||
start_date { Date.today }
|
start_date { Date.today }
|
||||||
end_date { 6.days.from_now }
|
end_date { 6.days.from_now }
|
||||||
registration_start_date { 3.days.from_now }
|
|
||||||
registration_end_date { 5.days.from_now }
|
|
||||||
make_conference_public true
|
make_conference_public true
|
||||||
venue
|
venue
|
||||||
end
|
end
|
||||||
|
|
|
||||||
46
spec/features/audience_spec.rb
Normal file
46
spec/features/audience_spec.rb
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
feature Audience do
|
||||||
|
|
||||||
|
# It is necessary to use bang version of let to build roles before user
|
||||||
|
let!(:organizer_role) { create(:organizer_role) }
|
||||||
|
let!(:participant_role) { create(:participant_role) }
|
||||||
|
let!(:admin_role) { create(:admin_role) }
|
||||||
|
|
||||||
|
shared_examples 'audience' do |user|
|
||||||
|
scenario 'updates audience', js: true do
|
||||||
|
conference = create(:conference)
|
||||||
|
audience = create(:audience)
|
||||||
|
conference.audience = audience
|
||||||
|
|
||||||
|
sign_in create(user)
|
||||||
|
visit edit_admin_conference_audience_path(
|
||||||
|
conference_id: conference.short_title)
|
||||||
|
|
||||||
|
page.
|
||||||
|
execute_script("$('#registration-start-datepicker').val('" +
|
||||||
|
"#{Date.today.strftime('%d/%m/%Y')}')")
|
||||||
|
page.
|
||||||
|
execute_script("$('#registration-end-datepicker').val('" +
|
||||||
|
"#{(Date.today + 7).strftime('%d/%m/%Y')}')")
|
||||||
|
fill_in 'audience_registration_description', with: 'audience registration description'
|
||||||
|
|
||||||
|
click_button 'Save Audience'
|
||||||
|
|
||||||
|
expect(flash).to eq('Audience was successfully updated.')
|
||||||
|
|
||||||
|
audience.reload
|
||||||
|
expect(audience.registration_start_date).to eq(Date.today)
|
||||||
|
expect(audience.registration_end_date).to eq(Date.today + 7)
|
||||||
|
expect(audience.registration_description).to eq('audience registration description')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'admin' do
|
||||||
|
it_behaves_like 'audience', :admin
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'organizer' do
|
||||||
|
it_behaves_like 'audience', :organizer
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -966,8 +966,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for new conference' do
|
it 'calculates correct for new conference' do
|
||||||
subject.registration_start_date = nil
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = nil
|
registration_start_date: nil,
|
||||||
|
registration_end_date: nil)
|
||||||
subject.call_for_papers = nil
|
subject.call_for_papers = nil
|
||||||
subject.venue = nil
|
subject.venue = nil
|
||||||
subject.rooms = []
|
subject.rooms = []
|
||||||
|
|
@ -980,8 +981,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with registration' do
|
it 'calculates correct for conference with registration' do
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = nil
|
subject.call_for_papers = nil
|
||||||
subject.rooms = []
|
subject.rooms = []
|
||||||
subject.tracks = []
|
subject.tracks = []
|
||||||
|
|
@ -996,8 +998,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp' do
|
it 'calculates correct for conference with registration, cfp' do
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.rooms = []
|
subject.rooms = []
|
||||||
subject.tracks = []
|
subject.tracks = []
|
||||||
|
|
@ -1013,8 +1016,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp, venue' do
|
it 'calculates correct for conference with registration, cfp, venue' do
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
subject.rooms = []
|
subject.rooms = []
|
||||||
|
|
@ -1033,8 +1037,9 @@ describe Conference do
|
||||||
|
|
||||||
it 'calculates correct for conference with registration, cfp, venue, rooms' do
|
it 'calculates correct for conference with registration, cfp, venue, rooms' do
|
||||||
subject.rooms = [create(:room)]
|
subject.rooms = [create(:room)]
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
subject.tracks = []
|
subject.tracks = []
|
||||||
|
|
@ -1054,8 +1059,9 @@ describe Conference do
|
||||||
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
|
it 'calculates correct for conference with registration, cfp, venue, rooms, tracks' do
|
||||||
subject.rooms = [create(:room)]
|
subject.rooms = [create(:room)]
|
||||||
subject.tracks = [create(:track)]
|
subject.tracks = [create(:track)]
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
subject.event_types = []
|
subject.event_types = []
|
||||||
|
|
@ -1077,8 +1083,9 @@ describe Conference do
|
||||||
subject.rooms = [create(:room)]
|
subject.rooms = [create(:room)]
|
||||||
subject.tracks = [create(:track)]
|
subject.tracks = [create(:track)]
|
||||||
subject.event_types = [create(:event_type)]
|
subject.event_types = [create(:event_type)]
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
subject.difficulty_levels = []
|
subject.difficulty_levels = []
|
||||||
|
|
@ -1100,8 +1107,9 @@ describe Conference do
|
||||||
subject.tracks = [create(:track)]
|
subject.tracks = [create(:track)]
|
||||||
subject.event_types = [create(:event_type)]
|
subject.event_types = [create(:event_type)]
|
||||||
subject.difficulty_levels = [create(:difficulty_level)]
|
subject.difficulty_levels = [create(:difficulty_level)]
|
||||||
subject.registration_start_date = Date.today
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 14
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.today + 14)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
subject.call_for_papers = create(:call_for_papers)
|
subject.call_for_papers = create(:call_for_papers)
|
||||||
subject.venue = create(:venue)
|
subject.venue = create(:venue)
|
||||||
|
|
@ -1114,26 +1122,30 @@ describe Conference do
|
||||||
describe '#registration_weeks' do
|
describe '#registration_weeks' do
|
||||||
|
|
||||||
it 'calculates new year' do
|
it 'calculates new year' do
|
||||||
subject.registration_start_date = Date.new(2013, 12, 31)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2013, 12, 30) + 6
|
registration_start_date: Date.new(2013, 12, 31),
|
||||||
|
registration_end_date: Date.new(2013, 12, 30) + 6)
|
||||||
expect(subject.registration_weeks).to eq(1)
|
expect(subject.registration_weeks).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is one if start and end are 6 days apart' do
|
it 'is one if start and end are 6 days apart' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 6
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 6)
|
||||||
expect(subject.registration_weeks).to eq(1)
|
expect(subject.registration_weeks).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is one if start and end date are the same' do
|
it 'is one if start and end date are the same' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26)
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26))
|
||||||
expect(subject.registration_weeks).to eq(1)
|
expect(subject.registration_weeks).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is two if start and end are 10 days apart' do
|
it 'is two if start and end are 10 days apart' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 10
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 10)
|
||||||
expect(subject.registration_weeks).to eq(2)
|
expect(subject.registration_weeks).to eq(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1265,15 +1277,17 @@ describe Conference do
|
||||||
describe '#get_registrations_per_week' do
|
describe '#get_registrations_per_week' do
|
||||||
|
|
||||||
it 'pads with zeros if there are no registrations' do
|
it 'pads with zeros if there are no registrations' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 21
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 21)
|
||||||
|
|
||||||
expect(subject.get_registrations_per_week).to eq([0, 0, 0, 0])
|
expect(subject.get_registrations_per_week).to eq([0, 0, 0, 0])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'summarized correct if there are no registrations in one week' do
|
it 'summarized correct if there are no registrations in one week' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 28
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 28)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26) + 7)
|
created_at: Date.new(2014, 05, 26) + 7)
|
||||||
|
|
@ -1286,8 +1300,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns [1] if there is one registration on the first day' do
|
it 'returns [1] if there is one registration on the first day' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 7
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 7)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26))
|
created_at: Date.new(2014, 05, 26))
|
||||||
|
|
@ -1295,8 +1310,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'summarized correct if there are registrations every week' do
|
it 'summarized correct if there are registrations every week' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 21
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 21)
|
||||||
|
|
||||||
create(:registration, conference: subject, created_at: Date.new(2014, 05, 26))
|
create(:registration, conference: subject, created_at: Date.new(2014, 05, 26))
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
|
|
@ -1308,8 +1324,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'summarized correct if there are registrations every week except the first' do
|
it 'summarized correct if there are registrations every week except the first' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 28
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 28)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26) + 7)
|
created_at: Date.new(2014, 05, 26) + 7)
|
||||||
|
|
@ -1322,8 +1339,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pads left' do
|
it 'pads left' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 35
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 35)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26) + 21)
|
created_at: Date.new(2014, 05, 26) + 21)
|
||||||
|
|
@ -1336,8 +1354,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pads middle' do
|
it 'pads middle' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 35
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 35)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26))
|
created_at: Date.new(2014, 05, 26))
|
||||||
|
|
@ -1348,8 +1367,9 @@ describe Conference do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'pads right' do
|
it 'pads right' do
|
||||||
subject.registration_start_date = Date.new(2014, 05, 26)
|
subject.audience = create(:audience,
|
||||||
subject.registration_end_date = Date.new(2014, 05, 26) + 35
|
registration_start_date: Date.new(2014, 05, 26),
|
||||||
|
registration_end_date: Date.new(2014, 05, 26) + 35)
|
||||||
|
|
||||||
create(:registration, conference: subject,
|
create(:registration, conference: subject,
|
||||||
created_at: Date.new(2014, 05, 26))
|
created_at: Date.new(2014, 05, 26))
|
||||||
|
|
@ -1391,8 +1411,10 @@ describe Conference do
|
||||||
context 'open registration' do
|
context 'open registration' do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.registration_start_date = Date.today - 1
|
audience = create(:audience,
|
||||||
subject.registration_end_date = Date.today + 7
|
registration_start_date: Date.today - 1,
|
||||||
|
registration_end_date: Date.today + 7)
|
||||||
|
subject.audience = audience
|
||||||
end
|
end
|
||||||
|
|
||||||
it '#registration_open? is true' do
|
it '#registration_open? is true' do
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,26 @@ require 'spec_helper'
|
||||||
describe 'conference/show.html.haml' do
|
describe 'conference/show.html.haml' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
|
allow(view).to receive(:date_string).and_return("January 17 - 21 2014")
|
||||||
@conference = create(:conference, registration_description: 'Lorem Ipsum Dolor',
|
@conference = create(:conference,
|
||||||
registration_start_date: Date.today,
|
description: 'Lorem Ipsum',
|
||||||
registration_end_date: Date.tomorrow,
|
sponsor_description: 'Lorem Ipsum Dolor',
|
||||||
description: 'Lorem Ipsum',
|
sponsor_email: 'example@example.com',
|
||||||
sponsor_description: 'Lorem Ipsum Dolor',
|
include_registrations_in_splash: true,
|
||||||
sponsor_email: 'example@example.com',
|
include_program_in_splash: true,
|
||||||
include_registrations_in_splash: true,
|
include_sponsors_in_splash: true,
|
||||||
include_program_in_splash: true,
|
include_tracks_in_splash: true,
|
||||||
include_sponsors_in_splash: true,
|
include_tickets_in_splash: true,
|
||||||
include_tracks_in_splash: true,
|
include_banner_in_splash: true)
|
||||||
include_tickets_in_splash: true,
|
|
||||||
include_banner_in_splash: true)
|
|
||||||
@conference.contact.update(facebook: 'http://www.fbexample.com',
|
@conference.contact.update(facebook: 'http://www.fbexample.com',
|
||||||
googleplus: 'http://www.google-example.com',
|
googleplus: 'http://www.google-example.com',
|
||||||
instagram: 'http://instagram.com',
|
instagram: 'http://instagram.com',
|
||||||
twitter: 'http://twitter.com',
|
twitter: 'http://twitter.com',
|
||||||
public: true
|
public: true
|
||||||
)
|
)
|
||||||
|
@conference.audience = create(:audience,
|
||||||
|
registration_description: 'Lorem Ipsum Dolor',
|
||||||
|
registration_start_date: Date.today,
|
||||||
|
registration_end_date: Date.tomorrow)
|
||||||
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
|
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
|
||||||
include_cfp_in_splash: true)
|
include_cfp_in_splash: true)
|
||||||
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
|
@conference.call_for_papers = create(:call_for_papers, conference: @conference,
|
||||||
|
|
@ -45,7 +47,7 @@ describe 'conference/show.html.haml' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders registration partial' do
|
it 'renders registration partial' do
|
||||||
expect(view.content_for(:splash)).to include("#{@conference.registration_description}")
|
expect(view.content_for(:splash)).to include("#{@conference.audience.registration_description}")
|
||||||
expect(view).to render_template(partial: 'conference/_registration')
|
expect(view).to render_template(partial: 'conference/_registration')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue