From abfb0884a11900042c22ffa6340c58f5ee38299f Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Wed, 28 May 2014 18:12:45 +0530 Subject: [PATCH] Added registration segment to display description, period Controller test for Conference#show houndci fixes Rebased with single entry for navigation branding Conditional rendering of splash navbar --- app/models/conference.rb | 4 ++-- app/views/admin/conference/edit.html.haml | 1 + app/views/conference/_registration.html.haml | 12 ++++++++++++ app/views/conference/show.html.haml | 3 +++ ...842_add_registration_description_to_conference.rb | 5 +++++ spec/views/conference/show.html.haml_spec.rb | 11 +++++++++++ 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/views/conference/_registration.html.haml create mode 100644 db/migrate/20140528115842_add_registration_description_to_conference.rb diff --git a/app/models/conference.rb b/app/models/conference.rb index fb3e14ae..bc67ffc8 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -9,7 +9,7 @@ class Conference < ActiveRecord::Base :questions_attributes, :question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes, :use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes, :vpositions_attributes, :use_volunteers, - :media_id, :media_type, :color, :description + :media_id, :media_type, :color, :description, :registration_description has_paper_trail @@ -74,7 +74,7 @@ class Conference < ActiveRecord::Base # Checks if the user is registered to the conference # # ====Args - # * +user+ -> The user we check for + # * +user+ -> The user we check for # ====Returns # * +nil+ -> If the user doesn't exist # * +false+ -> If the user is registered diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index 8ad5d0a3..300eefce 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -14,6 +14,7 @@ = f.input :end_date, :as => :string, :input_html => { :id => "conference-end-datepicker", :readonly => "readonly" } = 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: 'This description will appear in registration segment of the splash' = f.inputs :name => "Media" do - if !@conference.logo.blank? diff --git a/app/views/conference/_registration.html.haml b/app/views/conference/_registration.html.haml new file mode 100644 index 00000000..5a0ba8e3 --- /dev/null +++ b/app/views/conference/_registration.html.haml @@ -0,0 +1,12 @@ += content_for :splash_nav do + %li + %a{ href: '#registration' } Registration +%div.container.text-center + %div.row + %h2 Registration + - if !@conference.registration_description.blank? + %p + = @conference.registration_description + %h4 Registration period #{ date_string(@conference.registration_start_date, @conference.registration_end_date) } + - 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' diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 319cb460..7489d2a9 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -2,3 +2,6 @@ = link_to @conference.title, conference_url(@conference.short_title), class: 'navbar-brand' %div#program = render 'program' +%div#registration + = render 'registration' + diff --git a/db/migrate/20140528115842_add_registration_description_to_conference.rb b/db/migrate/20140528115842_add_registration_description_to_conference.rb new file mode 100644 index 00000000..b893de72 --- /dev/null +++ b/db/migrate/20140528115842_add_registration_description_to_conference.rb @@ -0,0 +1,5 @@ +class AddRegistrationDescriptionToConference < ActiveRecord::Migration + def change + add_column :conferences, :registration_description, :text + end +end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index d72a3070..7af548ce 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -7,4 +7,15 @@ describe 'conference/show.html.haml' do expect(render).to include("#{@conference.description}") expect(view).to render_template(partial: 'conference/_program') end + + it 'renders registration partial' do + @conference = create(:conference, registration_description: 'Lorem Ipsum Dolor', + registration_start_date: Date.today, + registration_end_date: Date.tomorrow) + assign :conference, @conference + render + expect(rendered).to include("#{@conference.registration_description}") + expect(rendered).to include("Register for #{@conference.short_title}") + expect(view).to render_template(partial: 'conference/_registration') + end end