diff --git a/app/controllers/admin/lodgings_controller.rb b/app/controllers/admin/lodgings_controller.rb index 554c8107..34dfa628 100644 --- a/app/controllers/admin/lodgings_controller.rb +++ b/app/controllers/admin/lodgings_controller.rb @@ -16,7 +16,7 @@ module Admin notice: 'Lodgings were successfully updated.') else redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Lodgings Updation Failed!') + notice: 'Updating lodgings failed!') end end end diff --git a/app/models/conference.rb b/app/models/conference.rb index cdc82963..6d48e314 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -15,7 +15,8 @@ class Conference < ActiveRecord::Base :registration_description, :ticket_description, :sponsorship_levels_attributes, :sponsors_attributes, :facebook_url, - :google_url, :twitter_url, :sponsor_description, :sponsor_email + :google_url, :twitter_url, :sponsor_description, :sponsor_email, + :lodging_description has_paper_trail diff --git a/app/models/lodging.rb b/app/models/lodging.rb index b7eddb9f..296ff0b1 100644 --- a/app/models/lodging.rb +++ b/app/models/lodging.rb @@ -1,5 +1,5 @@ class Lodging < ActiveRecord::Base - attr_accessible :name, :description, :photo + attr_accessible :name, :description, :photo, :website_link belongs_to :venue has_attached_file :photo, styles: { thumb: '100x100>', large: '300x300>' } diff --git a/app/views/admin/conference/edit.html.haml b/app/views/admin/conference/edit.html.haml index bace7d37..f0efbb86 100644 --- a/app/views/admin/conference/edit.html.haml +++ b/app/views/admin/conference/edit.html.haml @@ -18,6 +18,7 @@ = f.input :ticket_description, hint: 'This will appear in the Tickets segment of the splash' = f.input :sponsor_description, hint: 'This will appear in the sponsor segment of the splash' = 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 :lodging_description, hint: 'This will appear in the lodging segment of the splash' = f.inputs :name => "Media" do - if !@conference.logo.blank? diff --git a/app/views/admin/lodgings/_lodging_fields.html.erb b/app/views/admin/lodgings/_lodging_fields.html.erb index 7f9866d5..83c27724 100644 --- a/app/views/admin/lodgings/_lodging_fields.html.erb +++ b/app/views/admin/lodgings/_lodging_fields.html.erb @@ -5,6 +5,7 @@ of what they are offering, about types of rooms, prices and address' %> <%= image_tag f.object.photo(:thumb) if !f.object.photo.blank? %> <%= f.input :photo %> + <%= f.input :website_link %> <%= remove_association_link :lodging, f %> <% end %> diff --git a/app/views/conference/_location.html.haml b/app/views/conference/_location.html.haml index 69d1e31f..ed5a7dfe 100644 --- a/app/views/conference/_location.html.haml +++ b/app/views/conference/_location.html.haml @@ -25,11 +25,12 @@ = link_to 'Visit Venue Website', @conference.venue.website, target: '_blank' -:javascript - $(document).ready(function(){ - var photo = "#{@conference.venue.photo}"; - if(photo) - { - $('#location').css('background-image', 'url('+photo+')'); - } - }); +- unless @conference.venue.photo.blank? + :javascript + $(document).ready(function(){ + var photo = "#{@conference.venue.photo}"; + if(photo) + { + $('#location').css('background-image', 'url('+photo+')'); + } + }); diff --git a/app/views/conference/_lodging.html.haml b/app/views/conference/_lodging.html.haml new file mode 100644 index 00000000..de09c222 --- /dev/null +++ b/app/views/conference/_lodging.html.haml @@ -0,0 +1,18 @@ +%div.row.col-md-12.text-center + %h2 Lodgings + -unless @conference.lodging_description.blank? + %p.lead + = @conference.lodging_description + +%div.row + - @conference.venue.lodgings.each do |r| + %div.col-md-3.thumbnail + -unless r.photo.blank? + = image_tag r.photo(:large), class: 'img-responsive' + -unless r.name.blank? + %h4.text-center #{ r.name } + -unless r.description.blank? + %p.text-left #{ r.description } + - unless r.website_link.blank? + .text-center + = link_to 'Go to Website', r.website_link diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 311da44b..330da61f 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -13,6 +13,9 @@ -unless @conference.venue.blank? %div#location = render 'location' +- if @conference.venue + - unless @conference.venue.lodgings.empty? + = render 'lodging' %div#sponsors = render 'sponsor' %div#social-media diff --git a/db/migrate/20140614171853_add_lodging_description_to_conference.rb b/db/migrate/20140614171853_add_lodging_description_to_conference.rb new file mode 100644 index 00000000..37dd2c30 --- /dev/null +++ b/db/migrate/20140614171853_add_lodging_description_to_conference.rb @@ -0,0 +1,5 @@ +class AddLodgingDescriptionToConference < ActiveRecord::Migration + def change + add_column :conferences, :lodging_description, :text + end +end diff --git a/db/migrate/20140614174354_add_website_link_to_lodging.rb b/db/migrate/20140614174354_add_website_link_to_lodging.rb new file mode 100644 index 00000000..63c37bb3 --- /dev/null +++ b/db/migrate/20140614174354_add_website_link_to_lodging.rb @@ -0,0 +1,5 @@ +class AddWebsiteLinkToLodging < ActiveRecord::Migration + def change + add_column :lodgings, :website_link, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index a3d9c00c..16717c99 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140613083115) do +ActiveRecord::Schema.define(version: 20140614174354) do create_table "answers", force: true do |t| t.string "title" @@ -86,6 +86,7 @@ ActiveRecord::Schema.define(version: 20140613083115) do t.string "google_url" t.text "sponsor_description" t.string "sponsor_email" + t.text "lodging_description" end create_table "conferences_questions", id: false, force: true do |t| @@ -202,6 +203,7 @@ ActiveRecord::Schema.define(version: 20140613083115) do t.integer "venue_id" t.datetime "created_at" t.datetime "updated_at" + t.string "website_link" end create_table "people", force: true do |t| diff --git a/spec/factories/lodgings.rb b/spec/factories/lodgings.rb index d5481b83..efa16bb2 100644 --- a/spec/factories/lodgings.rb +++ b/spec/factories/lodgings.rb @@ -4,6 +4,7 @@ FactoryGirl.define do factory :lodging do name 'Example Hotel' description 'Lorem Ipsum Dolor' + website_link 'http://www.example.com' venue end end diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index 5bb305a5..10576cc9 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -24,18 +24,29 @@ feature Lodging do page. find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea'). set('Lorem Ipsum Dolor') + attach_file 'Photo', path + page. + find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input'). + set('http://www.example.com') + click_button 'Update Venue' # Validations expect(flash).to eq('Lodgings were successfully updated.') + expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). value).to eq('Example Hotel') + expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea'). value).to eq('Lorem Ipsum Dolor') + expect(page).to have_selector("img[src*='rails.png']") + expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(4) input'). + value).to eq('http://www.example.com') + # Remove room click_link 'Remove lodging' expect(page.all('div.nested-fields').count == 0).to be true diff --git a/spec/views/admin/lodgings/index.html.haml_spec.rb b/spec/views/admin/lodgings/index.html.haml_spec.rb index 982942bb..7bc6925a 100644 --- a/spec/views/admin/lodgings/index.html.haml_spec.rb +++ b/spec/views/admin/lodgings/index.html.haml_spec.rb @@ -9,5 +9,6 @@ describe 'admin/lodgings/index' do render expect(rendered).to include('Example Hotel') expect(rendered).to include('Lorem Ipsum Dolor') + expect(rendered).to include('http://www.example.com') end end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index e2187680..0290add8 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -17,6 +17,7 @@ describe 'conference/show.html.haml' do @sponsorship_level.sponsors << create(:sponsor, sponsorship_level: @sponsorship_level, conference: @conference) @conference.venue = create(:venue) + @conference.venue.lodgings << create(:lodging, venue: @conference.venue) assign :conference, @conference render end @@ -60,4 +61,11 @@ describe 'conference/show.html.haml' do expect(rendered).to include('www.opensuse.org') expect(rendered).to include('Lorem Ipsum Dolor') end + + it 'renders lodging partial' do + expect(view).to render_template(partial: 'conference/_lodging') + expect(rendered).to include('Example Hotel') + expect(rendered).to include('Lorem Ipsum Dolor') + expect(rendered).to include('http://www.example.com') + end end