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/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/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 a522dd50..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: 20140614171853) do +ActiveRecord::Schema.define(version: 20140614174354) do create_table "answers", force: true do |t| t.string "title" @@ -203,6 +203,7 @@ ActiveRecord::Schema.define(version: 20140614171853) 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