Merge pull request #328 from hennevogel/master

Various small fixes
This commit is contained in:
Henne Vogelsang 2014-07-16 19:44:09 +02:00
commit 2068d25d84
6 changed files with 55 additions and 30 deletions

View file

@ -4,8 +4,8 @@ html {
}
body {
/* Margin bottom by footer height */
margin-bottom: 60px;
/* Margin bottom by 2 times the footer height */
margin-bottom: 120px;
/* Margin bottom by navbar height */
padding-top: 60px;
}

View file

@ -91,6 +91,7 @@ class Conference < ActiveRecord::Base
validates_format_of :short_title, :with => /\A[a-zA-Z0-9_-]*\z/
before_create :generate_guid
before_create :create_venue
before_create :create_event_types
before_create :create_email_settings
before_create :add_color
@ -696,13 +697,26 @@ class Conference < ActiveRecord::Base
end
##
# Creates a venue and sets self.venue_id to it's id. Used as before_create.
# Creates a Venue for this Conference. Used as before_create.
#
def create_venue
self.venue_id = Venue.create.id
true
end
##
# Creates default EventTypes for this Conference. Used as before_create.
#
def create_event_types
event_types << EventType.create(title: 'Talk', length: 30, color: '#FF0000',
minimum_abstract_length: 0,
maximum_abstract_length: 500)
event_types << EventType.create(title: 'Workshop', length: 60, color: '#0000FF',
minimum_abstract_length: 0,
maximum_abstract_length: 500)
true
end
##
# Creates a EmailSettings association proxy. Used as before_create.
#

View file

@ -33,7 +33,8 @@ class Event < ActiveRecord::Base
validate :biography_exists
validates :title, presence: true
validates :abstract, presence: true
validates :media_type, allow_nil: true, inclusion: { in: Conference.media_types.values }
validates :event_type, presence: true
validates :media_type, inclusion: { in: Conference.media_types.values }, allow_blank: true
scope :confirmed, -> { where(state: 'confirmed') }
@ -181,15 +182,14 @@ class Event < ActiveRecord::Base
private
def abstract_limit
# If we don't have an event type, there is no need to count anything
return unless event_type
len = abstract.split.size
max = event_type.maximum_abstract_length
min = event_type.minimum_abstract_length
max_words = event_type.maximum_abstract_length
min_words = event_type.minimum_abstract_length
if len < min
errors.add(:abstract, "cannot have less than #{min} words")
end
errors.add(:abstract, "cannot have more than #{max} words") if len > max
errors.add(:abstract, "cannot have less than #{min_words} words") if len < min_words
errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words
end
def biography_exists

View file

@ -3,7 +3,10 @@ class EventType < ActiveRecord::Base
belongs_to :conference
validates :title, presence: true
validates :length, :numericality => {:greater_than => 0}
validates :minimum_abstract_length, presence: true
validates :maximum_abstract_length, presence: true
alias_attribute :name, :title
end

View file

@ -45,12 +45,17 @@
= form_tag user_session_path do
= text_field_tag 'user[email]', nil, id: 'user_email_dd'
= password_field_tag 'user[password]', nil, id: 'user_password_dd'
%label.checkbox
= check_box_tag 'user[remember_me]'
Remember me
%button.btn.btn-block Sign in
%br
= link_to "Forgot your password?", new_password_path('user')
= link_to 'Sign in with openID', new_user_session_path
%p.text-right
%small
Remember me
= check_box_tag 'user[remember_me]'
%button.btn.btn-success.btn-block Sign in
%p
%small
%ul.list-unstyled
%li
= link_to "Forgot your password?", new_password_path('user')
%li
= link_to 'Sign in with openID', new_user_session_path
%li.hidden-lg
= link_to('Sign In', new_user_session_path)

View file

@ -13,42 +13,45 @@ feature EventType do
visit admin_conference_eventtypes_path(
conference_id: conference.short_title)
expect(page.all('div.nested-fields').count == 2).to be true
# Add event type
click_link 'Add event_type'
expect(page.all('div.nested-fields').count == 1).to be true
expect(page.all('div.nested-fields').count == 3).to be true
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
find('div.nested-fields:nth-of-type(3) div:nth-of-type(1) input').
set('Example event type')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
find('div.nested-fields:nth-of-type(3) div:nth-of-type(2) input').
set('60')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) input').
find('div.nested-fields:nth-of-type(3) div:nth-of-type(3) input').
set('0')
page.
find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
find('div.nested-fields:nth-of-type(3) div:nth-of-type(4) input').
set('300')
click_button 'Update Conference'
# Validations
expect(flash).to eq('Event types were successfully updated.')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input').
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(1) input').
value).to eq('Example event type')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input').
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(2) input').
value).to eq('60')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(3) input').
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(3) input').
value).to eq('0')
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input').
expect(find('div.nested-fields:nth-of-type(3) div:nth-of-type(4) input').
value).to eq('300')
# Remove event type
click_link 'Remove event_type'
expect(page.all('div.nested-fields').count == 0).to be true
within("div.nested-fields:nth-of-type(3)") do
click_link 'Remove event_type'
end
expect(page.all('div.nested-fields').count == 2).to be true
click_button 'Update Conference'
expect(flash).to eq('Event types were successfully updated.')
expect(page.all('div.nested-fields').count == 0).to be true
expect(page.all('div.nested-fields').count == 2).to be true
end
end