From 7a5f47257ad145bb05496d1e66c4b143666a1892 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Mon, 19 May 2014 21:21:06 +0530 Subject: [PATCH 1/2] Create view for splash page from existing routes --- app/controllers/conference_controller.rb | 5 +++++ app/views/conference/show.html.haml | 3 +++ app/views/home/_conference_details.html.haml | 2 ++ app/views/layouts/_navigation.html.haml | 2 ++ config/routes.rb | 4 +++- spec/controllers/conference_controller_spec.rb | 12 ++++++++++++ spec/spec_helper.rb | 2 ++ spec/views/conference/show.html.haml_spec.rb | 10 ++++++++++ 8 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/controllers/conference_controller.rb create mode 100644 app/views/conference/show.html.haml create mode 100644 spec/controllers/conference_controller_spec.rb create mode 100644 spec/views/conference/show.html.haml_spec.rb diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb new file mode 100644 index 00000000..7a872c26 --- /dev/null +++ b/app/controllers/conference_controller.rb @@ -0,0 +1,5 @@ +class ConferenceController < ApplicationController + def show + @conference = Conference.find_by_short_title(params[:id]) + end +end diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml new file mode 100644 index 00000000..021d213f --- /dev/null +++ b/app/views/conference/show.html.haml @@ -0,0 +1,3 @@ += content_for :splash_logo do + = link_to @conference.title, "#", :class => 'navbar-brand' += render :partial => "home/conference_details", :locals => {:conference => @conference} \ No newline at end of file diff --git a/app/views/home/_conference_details.html.haml b/app/views/home/_conference_details.html.haml index 1653b3d8..335b25ed 100644 --- a/app/views/home/_conference_details.html.haml +++ b/app/views/home/_conference_details.html.haml @@ -20,6 +20,8 @@ = simple_format(conference.venue.description, class: 'lead') .col-md-2 .btn-group-vertical + - if !@conference || @conference != conference + = link_to "View Conference", conference_path(conference.short_title), :class =>"btn btn-default" - if conference.registration_open? - if conference.user_registered?(current_user) = link_to "Modify Registration", register_conference_path(conference.short_title), :class =>"btn btn-default" diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index a260104c..b6c4853f 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -7,8 +7,10 @@ %span.icon-bar %span.icon-bar %span.icon-bar + = yield(:splash_logo) = link_to CONFIG['name'], root_path, :class => 'navbar-brand', :title => "Open Source Event Manager" .collapse.navbar-collapse + = yield(:splash_header) - if @conference && !@conference.short_title.nil? %p.navbar-text = @conference.short_title diff --git a/config/routes.rb b/config/routes.rb index 78e9d930..45626f94 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Osem::Application.routes.draw do + get 'conference/show' + devise_for :users, :controllers => { :registrations => :registrations }, :path => 'accounts' namespace :admin do @@ -66,7 +68,7 @@ Osem::Application.routes.draw do end end - resources :conference, :only => [] do + resources :conference, only: [:show] do resources :proposal do resources :event_attachment, :controller => "event_attachments" patch "/confirm" => "proposal#confirm" diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb new file mode 100644 index 00000000..1efd6b3c --- /dev/null +++ b/spec/controllers/conference_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe ConferenceController do + + describe "GET 'show'" do + it "returns http success" do + get :show, id: 'sample' + expect(response).to be_success + end + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index acfed143..de5a2666 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -44,6 +44,8 @@ RSpec.configure do |config| # Enables devise sign_in function config.include Devise::TestHelpers, type: :controller + config.include Devise::TestHelpers, type: :view + # Use capybara-webkit as default javascript driver Capybara.javascript_driver = :webkit diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb new file mode 100644 index 00000000..5426c6d1 --- /dev/null +++ b/spec/views/conference/show.html.haml_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe "conference/show.html.haml" do + it 'renders conference details' do + @conference = create(:conference) + assign :conference, @conference + render + expect(render).to include("#{@conference.title}") + end +end From 03138fd40d32473da9d43175adeccdd5b571d051 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Mon, 19 May 2014 21:25:42 +0530 Subject: [PATCH 2/2] fixes by houndci --- spec/controllers/conference_controller_spec.rb | 5 ++--- spec/spec_helper.rb | 1 - spec/views/conference/show.html.haml_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb index 1efd6b3c..464288cd 100644 --- a/spec/controllers/conference_controller_spec.rb +++ b/spec/controllers/conference_controller_spec.rb @@ -1,9 +1,8 @@ require 'spec_helper' describe ConferenceController do - - describe "GET 'show'" do - it "returns http success" do + describe 'GET #show' do + it 'returns http success' do get :show, id: 'sample' expect(response).to be_success end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index de5a2666..027c7a9e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -45,7 +45,6 @@ RSpec.configure do |config| config.include Devise::TestHelpers, type: :controller config.include Devise::TestHelpers, type: :view - # Use capybara-webkit as default javascript driver Capybara.javascript_driver = :webkit diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 5426c6d1..b822a73e 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' - -describe "conference/show.html.haml" do +describe 'conference/show.html.haml' do it 'renders conference details' do @conference = create(:conference) assign :conference, @conference render expect(render).to include("#{@conference.title}") end + end