Adds website link to lodging
This commit is contained in:
parent
feabc3b954
commit
01bd45a045
7 changed files with 22 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
class Lodging < ActiveRecord::Base
|
class Lodging < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :photo
|
attr_accessible :name, :description, :photo, :website_link
|
||||||
belongs_to :venue
|
belongs_to :venue
|
||||||
has_attached_file :photo,
|
has_attached_file :photo,
|
||||||
styles: { thumb: '100x100>', large: '300x300>' }
|
styles: { thumb: '100x100>', large: '300x300>' }
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
of what they are offering, about types of rooms, prices and address' %>
|
of what they are offering, about types of rooms, prices and address' %>
|
||||||
<%= image_tag f.object.photo(:thumb) if !f.object.photo.blank? %>
|
<%= image_tag f.object.photo(:thumb) if !f.object.photo.blank? %>
|
||||||
<%= f.input :photo %>
|
<%= f.input :photo %>
|
||||||
|
<%= f.input :website_link %>
|
||||||
<%= remove_association_link :lodging, f %>
|
<%= remove_association_link :lodging, f %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
5
db/migrate/20140614174354_add_website_link_to_lodging.rb
Normal file
5
db/migrate/20140614174354_add_website_link_to_lodging.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddWebsiteLinkToLodging < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :lodgings, :website_link, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -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: 20140614171853) do
|
ActiveRecord::Schema.define(version: 20140614174354) do
|
||||||
|
|
||||||
create_table "answers", force: true do |t|
|
create_table "answers", force: true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
|
|
@ -203,6 +203,7 @@ ActiveRecord::Schema.define(version: 20140614171853) 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.string "website_link"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "people", force: true do |t|
|
create_table "people", force: true do |t|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ FactoryGirl.define do
|
||||||
factory :lodging do
|
factory :lodging do
|
||||||
name 'Example Hotel'
|
name 'Example Hotel'
|
||||||
description 'Lorem Ipsum Dolor'
|
description 'Lorem Ipsum Dolor'
|
||||||
|
website_link 'http://www.example.com'
|
||||||
venue
|
venue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,18 +24,29 @@ feature Lodging do
|
||||||
page.
|
page.
|
||||||
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
||||||
set('Lorem Ipsum Dolor')
|
set('Lorem Ipsum Dolor')
|
||||||
|
|
||||||
attach_file 'Photo', path
|
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'
|
click_button 'Update Venue'
|
||||||
|
|
||||||
# Validations
|
# Validations
|
||||||
expect(flash).to eq('Lodgings were successfully updated.')
|
expect(flash).to eq('Lodgings 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(1) div:nth-of-type(1) input').
|
||||||
value).to eq('Example Hotel')
|
value).to eq('Example Hotel')
|
||||||
|
|
||||||
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) textarea').
|
||||||
value).to eq('Lorem Ipsum Dolor')
|
value).to eq('Lorem Ipsum Dolor')
|
||||||
|
|
||||||
expect(page).to have_selector("img[src*='rails.png']")
|
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
|
# Remove room
|
||||||
click_link 'Remove lodging'
|
click_link 'Remove lodging'
|
||||||
expect(page.all('div.nested-fields').count == 0).to be true
|
expect(page.all('div.nested-fields').count == 0).to be true
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,6 @@ describe 'admin/lodgings/index' do
|
||||||
render
|
render
|
||||||
expect(rendered).to include('Example Hotel')
|
expect(rendered).to include('Example Hotel')
|
||||||
expect(rendered).to include('Lorem Ipsum Dolor')
|
expect(rendered).to include('Lorem Ipsum Dolor')
|
||||||
|
expect(rendered).to include('http://www.example.com')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue