diff --git a/app/controllers/admin/lodgings_controller.rb b/app/controllers/admin/lodgings_controller.rb index 34dfa628..3b5b8834 100644 --- a/app/controllers/admin/lodgings_controller.rb +++ b/app/controllers/admin/lodgings_controller.rb @@ -1,23 +1,57 @@ module Admin class LodgingsController < ApplicationController before_filter :verify_organizer + before_action :set_lodging, only: [:edit, :update, :destroy] + before_action :set_venue, only: [:index] def index - @venue = @conference.venue end - def show + def new + @lodging = @conference.venue.lodgings.build + end + + def edit + end + + def create + @lodging = @conference.venue.lodgings.build(lodging_params) + + if @lodging.save + redirect_to admin_conference_lodgings_path(@conference.short_title), notice: 'Lodging was successfully created.' + else + flash[:alert] = "A error prohibited this Lodging from being saved: #{@lodging.errors.full_messages.join('. ')}." + render :new + end end def update - @venue = @conference.venue - if @venue.update_attributes(params[:venue]) + if @lodging.update_attributes(lodging_params) redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Lodgings were successfully updated.') + notice: 'Lodging was successfully updated.') else - redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Updating lodgings failed!') + flash[:alert] = "A error prohibited this Lodging from being saved: #{@venue.errors.full_messages.join('. ')}." + render :edit end end + + def destroy + @lodging.destroy + redirect_to admin_conference_lodgings_path, notice: 'Lodging was successfully destroyed.' + end + + private + + def set_lodging + @lodging = Lodging.find(params[:id]) + end + + def set_venue + @venue = @conference.venue + end + + def lodging_params + params[:lodging] + end end end diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index 00342258..362af28c 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -1,19 +1,54 @@ class Admin::RoomsController < ApplicationController - before_filter :verify_organizer + before_action :set_room, only: [:edit, :update, :destroy] + before_action :set_conference - def show - render :rooms_list + def index + @rooms = @conference.rooms + end + + def new + @room = @conference.rooms.build + end + + def edit + end + + def create + @room = @conference.rooms.build(room_params) + + if @room.save + redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully created.' + else + flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}." + render :new + end end def update - if @conference.update_attributes(params[:conference]) - redirect_to(admin_conference_rooms_path( - conference_id: @conference.short_title), - notice: 'Rooms were successfully updated.') + if @room.update(room_params) + redirect_to admin_conference_rooms_path(@conference.short_title), notice: 'Room was successfully updated.' else - redirect_to(admin_conference_rooms_path( - conference_id: @conference.short_title), - notice: 'Room update failed.') + flash[:alert] = "A error prohibited this Rooms from being saved: #{@room.errors.full_messages.join('. ')}." + render :edit end end + + def destroy + @room.destroy + redirect_to admin_conference_rooms_path, notice: 'Room was successfully destroyed.' + end + + private + + def set_conference + @conference = Conference.find_by(short_title: params[:conference_id]) + end + + def set_room + @room = Room.find(params[:id]) + end + + def room_params + params[:room] + end end diff --git a/app/controllers/admin/venue_controller.rb b/app/controllers/admin/venues_controller.rb similarity index 56% rename from app/controllers/admin/venue_controller.rb rename to app/controllers/admin/venues_controller.rb index 583e3c5f..760ae34d 100644 --- a/app/controllers/admin/venue_controller.rb +++ b/app/controllers/admin/venues_controller.rb @@ -1,30 +1,34 @@ -class Admin::VenueController < ApplicationController +class Admin::VenuesController < ApplicationController before_filter :verify_organizer - - def index - end + before_action :set_venue, only: [:update, :edit] def update - @venue = @conference.venue - @venue.assign_attributes(params[:venue]) + @venue.assign_attributes(venue_params) venue_notify = (@venue.name_changed? || @venue.address_changed?) && (!@venue.name.blank? && !@venue.address.blank?) && (@conference.email_settings.send_on_venue_update && !@conference.email_settings.venue_update_subject.blank? && @conference.email_settings.venue_update_template) - if @venue.update_attributes(params[:venue]) + if @venue.save Mailbot.delay.send_email_on_venue_update(@conference) if venue_notify - redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title), - notice: 'Venue was successfully updated.') + redirect_to(:back, notice: 'Venue was successfully updated.') else - redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title), + redirect_to(:back, notice: 'Venue Updation Failed!') end end - def show + def edit + end + + private + + def venue_params + params[:venue] + end + + def set_venue @venue = @conference.venue - render :venue_info end end diff --git a/app/views/admin/conference/_todo_list.html.haml b/app/views/admin/conference/_todo_list.html.haml index 3f87ecbd..4e388ea2 100644 --- a/app/views/admin/conference/_todo_list.html.haml +++ b/app/views/admin/conference/_todo_list.html.haml @@ -14,7 +14,7 @@ = link_to 'Set up call for papers', admin_conference_callforpapers_path(conference_progress['short_title']) %li{'class'=>class_for_todo(conference_progress['venue'])} %span{'class'=>icon_for_todo(conference_progress['venue'])} - = link_to 'Add venue', admin_conference_venue_info_path(conference_progress['short_title']) + = link_to 'Add venues', edit_admin_conference_venue_path(conference_progress['short_title']) %li{'class'=>class_for_todo(conference_progress['rooms'])} %span{'class'=>icon_for_todo(conference_progress['rooms'])} = link_to 'Add rooms', admin_conference_rooms_path(conference_progress['short_title']) diff --git a/app/views/admin/lodgings/_form.html.haml b/app/views/admin/lodgings/_form.html.haml new file mode 100644 index 00000000..cc7f727b --- /dev/null +++ b/app/views/admin/lodgings/_form.html.haml @@ -0,0 +1,8 @@ += f.inputs do + = f.input :name + = f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint("Write about the hotel/place, 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 + .actions + = f.button 'Save Lodging', class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/admin/lodgings/_lodging_fields.html.erb b/app/views/admin/lodgings/_lodging_fields.html.erb deleted file mode 100644 index 11e74a18..00000000 --- a/app/views/admin/lodgings/_lodging_fields.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
- <%= f.inputs do %> - <%= f.input :name %> - <%= f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint("Write about the hotel/place, 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/admin/lodgings/edit.html.haml b/app/views/admin/lodgings/edit.html.haml new file mode 100644 index 00000000..4b9bf0ca --- /dev/null +++ b/app/views/admin/lodgings/edit.html.haml @@ -0,0 +1,6 @@ +%h1 Editing Lodging + += semantic_form_for @lodging, url: admin_conference_lodging_path(conference_id: @conference.short_title, id: @lodging.id) do |f| + = render 'form', f: f + += link_to 'Back', admin_conference_lodgings_path diff --git a/app/views/admin/lodgings/index.html.haml b/app/views/admin/lodgings/index.html.haml index 2141ff2d..c0fc8555 100644 --- a/app/views/admin/lodgings/index.html.haml +++ b/app/views/admin/lodgings/index.html.haml @@ -1,6 +1,37 @@ .row .col-md-8 - = semantic_form_for(@venue, :url => admin_conference_lodging_path(@conference.short_title, @conference.venue.lodgings), :html => {:multipart => true}) do |f| + = semantic_form_for(@venue, :url => admin_conference_venue_path(@conference.short_title, @conference.venue)) do |f| = f.input :include_lodgings_in_splash, hint: 'On setting this true you will enable the lodgings to be displayed on the splash page' - = dynamic_association :lodgings, "Lodgings", f = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} +%hr + +- @venue.lodgings.each_slice(3) do |slice| + .row.row-flex.row-flex-wrap + - slice.each do |lodging| + .col-md-4 + .thumbnail.flex-col + %h3.text-center + = lodging.name + - unless lodging.photo.blank? + = image_tag(lodging.photo(:large), class: 'img-responsive') + -else + %h4.text-center + Not set! + .caption.flex-grow + .caption + %p + %dl.dl-horizontal + %dt + Description + %dd + = markdown(lodging.description) unless lodging.description.blank? + %dt + Website + %dd + = lodging.website_link + %p + = link_to 'Edit', edit_admin_conference_lodging_path(@conference.short_title, lodging.id), class: 'btn btn-primary' + = link_to 'Delete', admin_conference_lodging_path(@conference.short_title, lodging.id), + method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' + += link_to 'New Lodging', new_admin_conference_lodging_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/lodgings/new.html.haml b/app/views/admin/lodgings/new.html.haml new file mode 100644 index 00000000..61d3e49c --- /dev/null +++ b/app/views/admin/lodgings/new.html.haml @@ -0,0 +1,6 @@ +%h1 New Lodging + += semantic_form_for @lodging, url: admin_conference_lodgings_path(conference_id: @conference.short_title) do |f| + = render 'form', f: f + += link_to 'Back', admin_conference_lodgings_path diff --git a/app/views/admin/rooms/_form.html.haml b/app/views/admin/rooms/_form.html.haml new file mode 100644 index 00000000..a12701d6 --- /dev/null +++ b/app/views/admin/rooms/_form.html.haml @@ -0,0 +1,6 @@ += f.inputs do + = f.input :name + = f.input :size, input_html: { size: 5 } + = f.input :public, as: :boolean + .actions + = f.button 'Save Room', class: 'btn btn-primary' \ No newline at end of file diff --git a/app/views/admin/rooms/_room_fields.html.erb b/app/views/admin/rooms/_room_fields.html.erb deleted file mode 100644 index 203176e8..00000000 --- a/app/views/admin/rooms/_room_fields.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -
- <%= f.inputs do %> - <%= f.input :name %> - <%= f.input :size, :input_html => {:size => 5} %> - <%= f.input :public, :as => :boolean %> - <%= remove_association_link :room, f %> - <% end %> -
diff --git a/app/views/admin/rooms/edit.html.haml b/app/views/admin/rooms/edit.html.haml new file mode 100644 index 00000000..0337f8b3 --- /dev/null +++ b/app/views/admin/rooms/edit.html.haml @@ -0,0 +1,6 @@ +%h1 Editing Room + += semantic_form_for @room, url: admin_conference_room_path(conference_id: @conference.short_title, id: @room.id) do |f| + = render 'form', f: f + += link_to 'Back', admin_conference_rooms_path diff --git a/app/views/admin/rooms/index.html.haml b/app/views/admin/rooms/index.html.haml index dfb23884..47384a3e 100644 --- a/app/views/admin/rooms/index.html.haml +++ b/app/views/admin/rooms/index.html.haml @@ -1,5 +1,23 @@ -.row - .col-md-8 - = semantic_form_for(@conference, :url => admin_conference_room_path(@conference.short_title, @conference.rooms)) do |f| - = dynamic_association :rooms, "Rooms", f - = f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"} +%h1 Rooms + +%table.table + %thead + %tr + %th Name + %th Size + %th Public + %th Delete + + - @rooms.each do |room| + %tr + %td= link_to room.name, edit_admin_conference_room_path(@conference.short_title, room.id) + %td= room.size + %td + - if room.public + %span.fa.fa-check{'style'=>'color: green;'} + -else + %span.fa.fa-times{'style'=>'color: red;'} + %td= link_to 'Delete', admin_conference_room_path(@conference.short_title, room.id), + method: :delete, data: { confirm: 'Are you sure?' } + += link_to 'New Room', new_admin_conference_room_path(@conference.short_title), class: 'btn btn-primary' diff --git a/app/views/admin/rooms/new.html.haml b/app/views/admin/rooms/new.html.haml new file mode 100644 index 00000000..5090f1dd --- /dev/null +++ b/app/views/admin/rooms/new.html.haml @@ -0,0 +1,6 @@ +%h1 New Room + += semantic_form_for @room, url: admin_conference_rooms_path(conference_id: @conference.short_title) do |f| + = render 'form', f: f + += link_to 'Back', admin_conference_rooms_path diff --git a/app/views/admin/venue/venue_info.html.haml b/app/views/admin/venues/_edit.html.haml similarity index 81% rename from app/views/admin/venue/venue_info.html.haml rename to app/views/admin/venues/_edit.html.haml index f747bad6..6c93e887 100644 --- a/app/views/admin/venue/venue_info.html.haml +++ b/app/views/admin/venues/_edit.html.haml @@ -1,6 +1,6 @@ .row .col-md-8 - = semantic_form_for(@venue, :url => admin_conference_venue_update_path(@conference.short_title),:html => {:multipart => true}) do |f| + = semantic_form_for(@venue, :url => admin_conference_venue_path(@conference.short_title),:html => {:multipart => true}) do |f| = f.input :include_venue_in_splash, hint: 'On setting this true you will enable the venue to be displayed on the splash page' = f.input :name, :input_html => {:rows => 1} = f.input :address, :input_html => {:rows => 1} diff --git a/app/views/admin/venues/_show.html.haml b/app/views/admin/venues/_show.html.haml new file mode 100644 index 00000000..26f3f3bc --- /dev/null +++ b/app/views/admin/venues/_show.html.haml @@ -0,0 +1,44 @@ +%dl.dl-horizontal + %dt + Name + %dd + - unless @conference.venue.name.blank? + = @conference.venue.name + - else + Not set! + %dt + Address + %dd + - unless @conference.venue.name.blank? + = @conference.venue.address + - else + Not set! + %dt + Website + %dd + - unless @conference.venue.name.blank? + = @conference.venue.website + - else + Not set! + %dt + Description + %dd + - unless @conference.venue.name.blank? + = markdown(@conference.venue.description) + - else + Not set! +.thumbnail + %h3.text-center + Venue Photo + - if @conference.venue.photo? + = image_tag(@conference.venue.photo(:large), class: 'img-responsive') + .caption + %p + %dl.dl-horizontal + %dt + Filename + %dd + = @conference.venue.photo_file_name + -else + %h4.text-center + Not set! diff --git a/app/views/admin/venues/edit.html.haml b/app/views/admin/venues/edit.html.haml new file mode 100644 index 00000000..2c5d4a39 --- /dev/null +++ b/app/views/admin/venues/edit.html.haml @@ -0,0 +1,16 @@ +.row + .col-md-12 + %ul.nav.nav-tabs{'role'=>'tablist'} + %li.active + %a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'} + Show + %li + %a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'} + Edit +.row + .col-md-12 + .tab-content + .tab-pane.active#show + = render partial: 'show' + .tab-pane#edit + = render partial: 'edit' diff --git a/app/views/layouts/_admin_sidebar.html.haml b/app/views/layouts/_admin_sidebar.html.haml index f9eddd03..012d0e0c 100644 --- a/app/views/layouts/_admin_sidebar.html.haml +++ b/app/views/layouts/_admin_sidebar.html.haml @@ -22,8 +22,22 @@ %hr %li{:class=> "#{active_nav_li(admin_conference_path(@conference.short_title))} nav-header nav-header-bigger"} = link_to(admin_conference_path(@conference.short_title)) do - %span.glyphicon.glyphicon-dashboard - Manage + %span.fa.fa-tachometer + Dashboard + %li{ class: active_nav_li(edit_admin_conference_venue_path(@conference.short_title)) } + = link_to(edit_admin_conference_venue_path(@conference.short_title)) do + %span.fa.fa-building + Venue + %ul + %li{ class: active_nav_li(admin_conference_rooms_path(@conference.short_title)) } + = link_to(admin_conference_rooms_path(@conference.short_title)) do + %span.fa.fa-flag + Rooms + %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } + = link_to(admin_conference_lodgings_path(@conference.short_title)) do + %span.fa.fa-institution + Lodgings + %hr %li{:class=> active_nav_li(admin_conference_events_path(@conference.short_title))} = link_to(admin_conference_events_path(@conference.short_title)) do %span.glyphicon.glyphicon-comment @@ -49,16 +63,6 @@ = link_to(admin_conference_targets_path(@conference.short_title)) do %span.glyphicon.glyphicon-flag Targets - %li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))} myAccordion"} - = link_to(admin_conference_venue_info_path(@conference.short_title)) do - %span.glyphicon.glyphicon-road - Venue - %span.small.glyphicon.glyphicon-chevron-right - %ul.nav.nav-stacked.nav-pills.small.collapse.subNav - %li{:class=> active_nav_li(admin_conference_rooms_path(@conference.short_title))} - = link_to 'Rooms', admin_conference_rooms_path(@conference.short_title) - %li{ class: active_nav_li(admin_conference_lodgings_path(@conference.short_title)) } - = link_to 'Lodgings', admin_conference_lodgings_path(@conference.short_title) %li{:class=> "#{active_nav_li(admin_conference_sponsorship_levels_path(@conference.short_title))} myAccordion" } = link_to(admin_conference_sponsorship_levels_path(@conference.short_title)) do %span.glyphicon.glyphicon-star diff --git a/config/routes.rb b/config/routes.rb index 20c43a75..3fe89fdc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,9 +9,8 @@ Osem::Application.routes.draw do resources :people resources :conference do resource :schedule, only: [:show, :update] + resource :venue, only: [:edit, :update] get '/stats' => 'stats#index' - get '/venue' => 'venue#show', as: 'venue_info' - patch '/venue' => 'venue#update', as: 'venue_update' get '/dietary_choices' => 'dietchoices#show', as: 'dietary_list' patch '/dietary_choices' => 'dietchoices#update', as: 'dietary_update' get '/volunteers_list' => 'volunteers#show' @@ -23,7 +22,7 @@ Osem::Application.routes.draw do resources :difficulty_levels, only: [:show, :update, :index] - resources :rooms, only: [:show, :update, :index] + resources :rooms, except: [:show] resources :tracks, only: [:show, :update, :index] @@ -31,7 +30,7 @@ Osem::Application.routes.draw do resources :sponsors, only: [:show, :update, :index] - resources :lodgings, only: [:show, :update, :index] + resources :lodgings, except: [:show] resources :targets, only: [:update, :index] diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index 10576cc9..39eb6a63 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -8,51 +8,58 @@ feature Lodging do shared_examples 'lodgings' do |user| scenario 'adds and updates lodgings', feature: true, js: true do - path = "#{Rails.root}/app/assets/images/rails.png" + expected_count = Lodging.count + 1 conference = create(:conference) conference.venue = create(:venue) sign_in create(user) + visit admin_conference_lodgings_path( conference_id: conference.short_title) + # Add lodging - click_link 'Add lodging' - expect(page.all('div.nested-fields').count == 1).to be true - page. - find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). - set('Example Hotel') - - 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' + click_link 'New Lodging' + fill_in 'lodging_name', with: 'Lodging1000' + fill_in 'lodging_description', with: 'Lorem ipsum dolorem' + attach_file('lodging_photo', Rails.root + 'spec/fixtures/suse.jpg') + fill_in 'lodging_website_link', with: 'http://www.suse.com' + click_button 'Save Lodging' # Validations - expect(flash).to eq('Lodgings were successfully updated.') + expect(Lodging.count).to eq(expected_count) + expect(flash).to eq('Lodging was successfully created.') + expect(page.has_content?('Lodging1000')).to be true + expect(page.has_content?('Lorem ipsum dolorem')).to be true + expect(page.has_content?('http://www.suse.com')).to be true - expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). - value).to eq('Example Hotel') + # Update room + click_link 'Edit' + fill_in 'lodging_name', with: 'Lodging2000' + fill_in 'lodging_description', with: 'Lorem ipsum dolorem...' + attach_file('lodging_photo', Rails.root + 'spec/fixtures/suse_pinguin.png') + fill_in 'lodging_website_link', with: 'http://www.opensuse.com' + click_button 'Save Lodging' - 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') + # Validations + expect(Lodging.count).to eq(expected_count) + expect(flash).to eq('Lodging was successfully updated.') + expect(page.has_content?('Lodging2000')).to be true + expect(page.has_content?('Lorem ipsum dolorem...')).to be true + expect(page.has_content?('http://www.opensuse.com')).to be true # Remove room - click_link 'Remove lodging' - expect(page.all('div.nested-fields').count == 0).to be true + click_link 'Delete' + + # Validations + expect(Lodging.count).to eq(expected_count - 1) + expect(flash).to eq('Lodging was successfully destroyed.') + expect(page.has_content?('Lodging2000')).to be false + expect(page.has_content?('Lorem ipsum dolorem...')).to be false + expect(page.has_content?('http://www.opensuse.com')).to be false + + # Enable lodgings for splash page + check('venue_include_lodgings_in_splash') click_button 'Update Venue' - expect(flash).to eq('Lodgings were successfully updated.') - expect(page.all('div.nested-fields').count == 0).to be true + expect(flash).to eq('Venue was successfully updated.') end end diff --git a/spec/features/rooms_spec.rb b/spec/features/rooms_spec.rb index dc88f9bd..91d2996b 100644 --- a/spec/features/rooms_spec.rb +++ b/spec/features/rooms_spec.rb @@ -9,37 +9,45 @@ feature Room do shared_examples 'rooms' do |user| scenario 'adds and updates rooms', feature: true, js: true do conference = create(:conference) + expected_count = Room.count + 1 sign_in create(user) visit admin_conference_rooms_path( conference_id: conference.short_title) # Add room - click_link 'Add room' - expect(page.all('div.nested-fields').count == 1).to be true - - page. - find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). - set('Example room') - - page. - find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input'). - set('100') - - click_button 'Update Conference' + click_link 'New Room' + fill_in 'room_name', with: 'Room1000' + fill_in 'room_size', with: '500' + check('room_public') + click_button 'Save Room' # Validations - expect(flash).to eq('Rooms were successfully updated.') - expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(1) input'). - value).to eq('Example room') - expect(find('div.nested-fields:nth-of-type(1) div:nth-of-type(2) input'). - value).to eq('100') + expect(Room.count).to eq(expected_count) + expect(flash).to eq('Room was successfully created.') + expect(page.has_content?('Room1000')).to be true + expect(page.has_content?('500')).to be true + + # Update room + click_link 'Room1000' + fill_in 'room_name', with: 'Room2000' + fill_in 'room_size', with: '600' + check('room_public') + click_button 'Save Room' + + # Validations + expect(Room.count).to eq(expected_count) + expect(flash).to eq('Room was successfully updated.') + expect(page.has_content?('Room2000')).to be true + expect(page.has_content?('600')).to be true # Remove room - click_link 'Remove room' - expect(page.all('div.nested-fields').count == 0).to be true - click_button 'Update Conference' - expect(flash).to eq('Rooms were successfully updated.') - expect(page.all('div.nested-fields').count == 0).to be true + click_link 'Delete' + + # Validations + expect(Room.count).to eq(expected_count - 1) + expect(flash).to eq('Room was successfully destroyed.') + expect(page.has_content?('Room2000')).to be false + expect(page.has_content?('600')).to be false end end diff --git a/spec/features/venue_spec.rb b/spec/features/venue_spec.rb index 7f2e82a3..0164fea7 100644 --- a/spec/features/venue_spec.rb +++ b/spec/features/venue_spec.rb @@ -12,12 +12,14 @@ feature Conference do conference = create(:conference) sign_in create(user) - visit admin_conference_venue_info_path( + visit edit_admin_conference_venue_path( conference_id: conference.short_title) expect(page.find("//*[@id='venue_submit_action']"). text).to eq('Update Venue') + click_link 'Edit' + fill_in 'venue_name', with: 'Example University' fill_in 'venue_address', with: 'Example Street 42 \n' + '12345 Example City \n Germany' diff --git a/spec/fixtures/suse.jpg b/spec/fixtures/suse.jpg new file mode 100644 index 00000000..62cb4a73 Binary files /dev/null and b/spec/fixtures/suse.jpg differ diff --git a/spec/fixtures/suse_pinguin.png b/spec/fixtures/suse_pinguin.png new file mode 100644 index 00000000..a7676194 Binary files /dev/null and b/spec/fixtures/suse_pinguin.png differ diff --git a/spec/views/admin/rooms/index.html.haml_spec.rb b/spec/views/admin/rooms/index.html.haml_spec.rb index 71caf7f4..edc5655d 100644 --- a/spec/views/admin/rooms/index.html.haml_spec.rb +++ b/spec/views/admin/rooms/index.html.haml_spec.rb @@ -3,6 +3,7 @@ describe 'admin/rooms/index' do it 'renders rooms list' do @room = create(:room) + assign :rooms, [@room] assign :conference, @room.conference render expect(rendered).to include('Example Room') diff --git a/spec/views/admin/venue/venue_info.html.haml_spec.rb b/spec/views/admin/venues/edit.html.haml_spec.rb similarity index 78% rename from spec/views/admin/venue/venue_info.html.haml_spec.rb rename to spec/views/admin/venues/edit.html.haml_spec.rb index dd9f1922..5613c674 100644 --- a/spec/views/admin/venue/venue_info.html.haml_spec.rb +++ b/spec/views/admin/venues/edit.html.haml_spec.rb @@ -1,15 +1,14 @@ require 'spec_helper' -describe 'admin/venue/venue_info' do +describe 'admin/venues/edit' do - it 'renders venue#show' do + it 'renders venue#edit' do @conference = create(:conference) @venue = @conference.venue @venue.name = 'Croatia' @venue.description = 'Lorem ipsum dolsum' @venue.save! assign :conference, @conference - assign :venue, @venue render expect(rendered).to include('Croatia') expect(rendered).to include('Lorem ipsum dolsum')