From 3d3e9ab6e1b60f17754016106366019452bca7c5 Mon Sep 17 00:00:00 2001 From: Kirill Pimenov Date: Mon, 30 Mar 2015 20:32:46 +0200 Subject: [PATCH] Fixed RSS error for :all episodes Closes #126 But I really don't like duplication between `ApplicationController#set_episode` and `ProjectsController#load_episode` --- app/controllers/application_controller.rb | 2 +- app/views/layouts/_header.html.haml | 4 ++-- app/views/projects/newest.rss.haml | 2 +- spec/controllers/projects_controller_spec.rb | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b68a1007..b350fb68 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -62,7 +62,7 @@ def set_episode @episode = Episode.active else if params[:episode] == 'all' - @episode = 'all' + @episode = :all else @episode = Episode.find_by(id: params[:episode]) end diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 98edeee8..30357ba9 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -10,7 +10,7 @@ %ul.nav.navbar-nav.hidden-xs %li.dropdown = link_to(projects_path(@episode), {class: "navbar-brand"}) do - - if @episode == 'all' + - if @episode == :all = "All Hackweeks" - else = @episode.name if @episode @@ -18,7 +18,7 @@ %i.fa.fa-caret-square-o-down %ul.dropdown-menu{:role => "menu"} %li{:role => "presentation"} - = link_to(projects_path('all'), {title: "Projects for all hackweeks"}) do + = link_to(projects_path(:all), {title: "Projects for all hackweeks"}) do All Hackweeks - Episode.all.reverse.each do |episode| %li{:role => "presentation"} diff --git a/app/views/projects/newest.rss.haml b/app/views/projects/newest.rss.haml index ebfad362..8accacbd 100644 --- a/app/views/projects/newest.rss.haml +++ b/app/views/projects/newest.rss.haml @@ -8,7 +8,7 @@ rel="self" type="application/rss+xml") - -if @episode + -if @episode.is_a? Episode %title Newest #{ @episode.name } projects %description These are the newest projects for the #{ @episode.name } -else diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 9ff8dc56..4172314a 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -360,6 +360,10 @@ expect(xml.xpath('//item').count).to eq 10 expect(xml.xpath('//item/title').first.text).to eq project.title end + + it 'works for :all episodes' do + expect {get :newest, episode: :all, format: :rss}.not_to raise_error + end end end end