From f75c7db1fe7a4fbbe3e84ab62691b13c80792251 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Jul 2011 19:11:57 -0400 Subject: [PATCH 01/14] Fix out-of-date seeds --- db/seeds.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 73bfd7c..57da3e9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,12 +6,17 @@ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Daley', :city => cities.first) # -# +# # -Match.create(:winner => "Adam", :loser => "Bob") -Match.create(:winner => "Bob", :loser => "Carol") -Match.create(:winner => "Carol", :loser => "Dave") -Match.create(:winner => "Dave", :loser => "Ed") -Match.create(:winner => "Adam", :loser => "Carol") -Match.create(:winner => "Adam", :loser => "Dave") -Match.create(:winner => "Adam", :loser => "Ed") +adam = Player.create(name: "Adam") +bob = Player.create(name: "Bob") +carol = Player.create(name: "Carol") +dave = Player.create(name: "Dave") +ed = Player.create(name: "Ed") +Match.create(winner: adam, loser: bob) +Match.create(winner: bob, loser: carol) +Match.create(winner: carol, loser: dave) +Match.create(winner: dave, loser: ed) +Match.create(winner: adam, loser: carol) +Match.create(winner: adam, loser: dave) +Match.create(winner: adam, loser: ed) From 091a43e93776bb274041185a10ab9fa97df7c97c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Jul 2011 19:20:44 -0400 Subject: [PATCH 02/14] Remove old HAML interpolation syntax --- app/views/layouts/application.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 9deb204..d68bcfd 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ %html %head - %title== Pivot Pong - #{location} + %title Pivot Pong - #{location} = stylesheet_link_tag 'reset', 'pong', 'jquery.autocomplete' = javascript_include_tag :defaults = javascript_include_tag 'jquery.autocomplete' @@ -13,7 +13,7 @@ %body #page #content - %h1== pivot pong #{location.downcase} + %h1 pivot pong #{location.downcase} = render 'shared/flash_messages' = yield = link_to "source code", "https://github.com/seanmoon/pivot-pong", class: "source" From fb92007503a52c47d2fe5db6a558475e3f5c8cb4 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Jul 2011 19:27:00 -0400 Subject: [PATCH 03/14] Better page titles --- app/views/layouts/application.html.haml | 2 +- app/views/matches/index.html.haml | 2 ++ app/views/matches/rankings.html.haml | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index d68bcfd..43add31 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ %html %head - %title Pivot Pong - #{location} + %title Pivot Pong #{location} — #{yield :title} = stylesheet_link_tag 'reset', 'pong', 'jquery.autocomplete' = javascript_include_tag :defaults = javascript_include_tag 'jquery.autocomplete' diff --git a/app/views/matches/index.html.haml b/app/views/matches/index.html.haml index 71b6db3..999f3a1 100644 --- a/app/views/matches/index.html.haml +++ b/app/views/matches/index.html.haml @@ -1,3 +1,5 @@ +- content_for :title, "Matches" + %h2 Add a match %nav diff --git a/app/views/matches/rankings.html.haml b/app/views/matches/rankings.html.haml index a0b139f..016d56e 100644 --- a/app/views/matches/rankings.html.haml +++ b/app/views/matches/rankings.html.haml @@ -1,3 +1,5 @@ +- content_for :title, "Rankings" + %h2 Rankings %nav From 3cc0a81f18d941a58a68856d96e92b9ca10bd4bd Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 21 Jul 2011 22:32:15 -0400 Subject: [PATCH 04/14] Use HAML syntax for HTML5 doctype --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 43add31..aadf192 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,4 +1,4 @@ - +!!! 5 %html %head %title Pivot Pong #{location} — #{yield :title} From 48fac70349e2a9fa094a5f2b2d13d5b139d507fb Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 23 Jul 2011 14:31:38 -0400 Subject: [PATCH 05/14] More semantic DOM --- app/views/matches/rankings.html.haml | 6 +++--- public/stylesheets/pong.css | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/matches/rankings.html.haml b/app/views/matches/rankings.html.haml index 016d56e..71dafeb 100644 --- a/app/views/matches/rankings.html.haml +++ b/app/views/matches/rankings.html.haml @@ -5,17 +5,17 @@ %nav = link_to "Matches", matches_path -%h1 All time +%h3 All time %ol.rankings - @rankings.each do |player| %li{class: cycle("even", "odd")}= player.display_name -%h1 Last 30 days +%h3 Last 30 days %ol.rankings - @last_30_days_rankings.each do |player| %li{class: cycle("even", "odd")}= player -%h1 Last 90 days +%h3 Last 90 days %ol.rankings - @last_90_days_rankings.each do |player| %li{class: cycle("even", "odd")}= player diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index 7e89a71..14c29c9 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -2,7 +2,7 @@ body { font-family: "coolvetica-1", "coolvetica-2", Helvetica, Arial, sans-serif; } -body h1 { +body h1, body h3 { font-size: 36px; margin: 10px 0; } From 9bbb1e7e1dec22e699c9d42f1a1d7a27bcab27e2 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 23 Jul 2011 14:31:51 -0400 Subject: [PATCH 06/14] Simpler HAML --- app/views/shared/_flash_messages.html.haml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/shared/_flash_messages.html.haml b/app/views/shared/_flash_messages.html.haml index 08bf193..567faf0 100644 --- a/app/views/shared/_flash_messages.html.haml +++ b/app/views/shared/_flash_messages.html.haml @@ -1,8 +1,6 @@ - if notice || alert .flash - if notice - .notice - = notice + .notice= notice - if alert - .alert - = alert \ No newline at end of file + .alert= alert From c3dac0599c76627852fab6adbf452f417488acf1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 23 Jul 2011 14:59:26 -0400 Subject: [PATCH 07/14] Remove unnecessary specificity on selectors --- public/stylesheets/pong.css | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index 14c29c9..973c96d 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -2,12 +2,12 @@ body { font-family: "coolvetica-1", "coolvetica-2", Helvetica, Arial, sans-serif; } -body h1, body h3 { +h1, h3 { font-size: 36px; margin: 10px 0; } -body a { +a { text-decoration: none; color: #cc5500; } @@ -17,53 +17,53 @@ nav a { margin-top: 20px; } -body ol { +ol { font-size: 48px; margin: 20px auto; width: 550px; } -body li { +li { padding: 5px 25px; width: 500px; list-style-position: inside; } -body li, body td { +li, td { white-space: nowrap; text-overflow: ellipsis; } -body table { +table { table-layout: fixed; margin: 10px 0px; width: 550px; } -body tr { +tr { height: 20px; } -body th, body td { +th, td { padding: 2px 5px; vertical-align: middle; } -body th { +th { background-color: #333; color: white; overflow: hidden; } -body td { +td { width: 200px; } -body form { +form { margin: 10px 0; } -body input[type='text'] { +input[type='text'] { font-size: 24px; display: block; width: 100%; From e623ac5e2a80b46e6790a95271ab18d1d1e3cb79 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 23 Jul 2011 15:04:35 -0400 Subject: [PATCH 08/14] Remove superfluous div#page; use box-sizing to fix broken box model --- app/views/layouts/application.html.haml | 11 +++++------ public/stylesheets/pong.css | 16 ++++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index aadf192..a439681 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,9 +11,8 @@ = csrf_meta_tag %body - #page - #content - %h1 pivot pong #{location.downcase} - = render 'shared/flash_messages' - = yield - = link_to "source code", "https://github.com/seanmoon/pivot-pong", class: "source" + #content + %h1 pivot pong #{location.downcase} + = render 'shared/flash_messages' + = yield + = link_to "source code", "https://github.com/seanmoon/pivot-pong", class: "source" diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index 973c96d..6107aac 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -2,6 +2,13 @@ body { font-family: "coolvetica-1", "coolvetica-2", Helvetica, Arial, sans-serif; } +body > * { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; +} + h1, h3 { font-size: 36px; margin: 10px 0; @@ -19,8 +26,8 @@ nav a { ol { font-size: 48px; - margin: 20px auto; - width: 550px; + margin-top: 20px; + margin-bottom: 20px; } li { @@ -80,15 +87,12 @@ td.action, th.action { text-align: center; } -#page { +#content { margin-left: auto; margin-right: auto; border-left: 1px solid #999; border-right: 1px solid #999; width: 600px; -} - -#content { padding: 25px; background-color: #DEDEDE; } From 217db414a6e75ae34539cb1d76ce96d50f56102a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 01:48:35 -0400 Subject: [PATCH 09/14] Lowercase hex colors --- public/stylesheets/pong.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index 6107aac..fa22094 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -16,7 +16,7 @@ h1, h3 { a { text-decoration: none; - color: #cc5500; + color: #c50; } nav a { @@ -94,15 +94,15 @@ td.action, th.action { border-right: 1px solid #999; width: 600px; padding: 25px; - background-color: #DEDEDE; + background-color: #dedede; } .even { - background-color: #F0F0F0; + background-color: #f0f0f0; } .odd { - background-color: #E7E7E7; + background-color: #e7e7e7; } a.source { From fd103224c969a8f54d882bd6c0146b072a14eee0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 01:52:44 -0400 Subject: [PATCH 10/14] Clean up DOM a bit - #content --> #page - Bottom nav --> #footer --- app/views/layouts/application.html.haml | 5 +++-- public/stylesheets/pong.css | 16 +++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a439681..0172793 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -11,8 +11,9 @@ = csrf_meta_tag %body - #content + #page %h1 pivot pong #{location.downcase} = render 'shared/flash_messages' = yield - = link_to "source code", "https://github.com/seanmoon/pivot-pong", class: "source" + %footer + = link_to "source code", "https://github.com/seanmoon/pivot-pong" diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index fa22094..bc41374 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -19,9 +19,12 @@ a { color: #c50; } -nav a { - display: block; - margin-top: 20px; +footer { + font-size: 12px; +} + +footer a { + float: right; } ol { @@ -87,7 +90,7 @@ td.action, th.action { text-align: center; } -#content { +#page { margin-left: auto; margin-right: auto; border-left: 1px solid #999; @@ -105,11 +108,6 @@ td.action, th.action { background-color: #e7e7e7; } -a.source { - font-size: 12px; - float: right; -} - .flash { margin-bottom: 10px; } From 49fc50e7f3f66efb871b35124ae0c8228401f777 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 01:33:12 -0400 Subject: [PATCH 11/14] Tabs for rankings page --- app/views/layouts/application.html.haml | 2 +- app/views/matches/index.html.haml | 7 +---- app/views/matches/rankings.html.haml | 35 ++++++++++++++----------- public/javascripts/application.js | 3 ++- public/javascripts/jquery.tabs.js | 33 +++++++++++++++++++++++ public/stylesheets/pong.css | 21 ++++++++++++++- 6 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 public/javascripts/jquery.tabs.js diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0172793..352e506 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -4,7 +4,7 @@ %title Pivot Pong #{location} — #{yield :title} = stylesheet_link_tag 'reset', 'pong', 'jquery.autocomplete' = javascript_include_tag :defaults - = javascript_include_tag 'jquery.autocomplete' + = javascript_include_tag 'jquery.autocomplete', 'jquery.tabs' = javascript_include_tag "http://use.typekit.com/rol0dzy.js" = javascript_tag "try{Typekit.load();}catch(e){}" = favicon_link_tag diff --git a/app/views/matches/index.html.haml b/app/views/matches/index.html.haml index 999f3a1..5b7fd32 100644 --- a/app/views/matches/index.html.haml +++ b/app/views/matches/index.html.haml @@ -1,9 +1,8 @@ - content_for :title, "Matches" -%h2 Add a match - %nav = link_to "Rankings", root_path + = link_to "Matches", matches_path, class: "current" = form_for(@match) do |f| = label_tag :winner_name @@ -28,7 +27,3 @@ %td= m.winner.display_name %td= m.loser.display_name %td.action= link_to "delete", match_path(m), method: :delete - - -%nav - = link_to "Rankings", root_path diff --git a/app/views/matches/rankings.html.haml b/app/views/matches/rankings.html.haml index 71dafeb..987742c 100644 --- a/app/views/matches/rankings.html.haml +++ b/app/views/matches/rankings.html.haml @@ -1,24 +1,27 @@ - content_for :title, "Rankings" -%h2 Rankings - %nav + = link_to "Rankings", root_path, class: "current" = link_to "Matches", matches_path -%h3 All time -%ol.rankings - - @rankings.each do |player| - %li{class: cycle("even", "odd")}= player.display_name +.tabs + %ul.tab-bar + %li= link_to "All time", "#all-time" + %li= link_to "Last 30 days", "#30-days" + %li= link_to "Last 90 days", "#90-days" -%h3 Last 30 days -%ol.rankings - - @last_30_days_rankings.each do |player| - %li{class: cycle("even", "odd")}= player + %ol#all-time.rankings + - @rankings.each do |player| + %li{class: cycle("even", "odd")}= player.display_name -%h3 Last 90 days -%ol.rankings - - @last_90_days_rankings.each do |player| - %li{class: cycle("even", "odd")}= player + - reset_cycle -%nav - = link_to "Matches", matches_path + %ol#30-days.rankings + - @last_30_days_rankings.each do |player| + %li{class: cycle("even", "odd")}= player + + - reset_cycle + + %ol#90-days.rankings + - @last_90_days_rankings.each do |player| + %li{class: cycle("even", "odd")}= player diff --git a/public/javascripts/application.js b/public/javascripts/application.js index c351eea..ac14b4a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1,3 +1,4 @@ $(document).ready( function(){ $('#new_match input[type=text]').autocomplete('/matches/players'); -}); \ No newline at end of file + $('.tab-bar').tabs(); +}); diff --git a/public/javascripts/jquery.tabs.js b/public/javascripts/jquery.tabs.js new file mode 100644 index 0000000..837fd45 --- /dev/null +++ b/public/javascripts/jquery.tabs.js @@ -0,0 +1,33 @@ +(function($) { + $.fn.tabs = function() { + var $this = $(this); + var tabs = []; + $this.data("currentTab", $("

")); + + var switchToTab = function(elem) { + console.log(elem); + $elem = $(elem); + current = $this.data("currentTab"); + $(current).hide(); + $("a[href='" + current + "']").removeClass("current"); + $elem.show(); + $("a[href='" + elem + "']").addClass("current"); + $this.data("currentTab", elem); + } + + $this.children().each(function() { + var link = $(this).find("a").first(); + var id = link.attr("href"); + tabs.push(id); + $(id).hide(); + link.click(function(e) { + e.preventDefault(); + switchToTab(id); + }); + }); + + switchToTab(tabs[0]); + + return this; + } +})(jQuery); diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index bc41374..deb337a 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -19,6 +19,13 @@ a { color: #c50; } +a.current { + color: #eee; + background-color: #c50; + padding-left: 3px; + padding-right: 3px; +} + footer { font-size: 12px; } @@ -29,7 +36,7 @@ footer a { ol { font-size: 48px; - margin-top: 20px; + margin-top: 10px; margin-bottom: 20px; } @@ -108,6 +115,18 @@ td.action, th.action { background-color: #e7e7e7; } +.tabs { + margin-top: 20px; +} + +.tab-bar { + list-style-type: none; +} + +.tab-bar li { + display: inline; +} + .flash { margin-bottom: 10px; } From 0981770748499263b321be5dafcc3e5c77b4f731 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 22:25:49 -0400 Subject: [PATCH 12/14] Turn on RSpec color --- spec/spec_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b8b02c..bb38a51 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,4 +24,6 @@ # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true + + config.color_enabled = true end From 92e3887d7203f2b54753b90fa6e3ee68d3cc3106 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 22:28:56 -0400 Subject: [PATCH 13/14] Simplify ApplicationHelper spec --- spec/helpers/application_helper_spec.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index b89957e..0f115bd 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -2,20 +2,18 @@ describe ApplicationHelper do describe "#location" do + subject { helper.location } + context "when no location is configured" do - it "returns nyc" do - helper.location.should == "NYC" - end + it { should == "NYC" } end - + context "when a location is configured" do before do ENV["PIVOT_PONG_LOCATION"] = "Starbase Alpha" end - - it "returns that location" do - helper.location.should == "Starbase Alpha" - end + + it { should == "Starbase Alpha" } end end end From 01f669612b5546d7b5d32f27a00552a29739ae1d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 26 Jul 2011 22:29:16 -0400 Subject: [PATCH 14/14] Move navigation links into header --- app/helpers/application_helper.rb | 5 +++++ app/views/layouts/application.html.haml | 7 ++++++- app/views/matches/index.html.haml | 4 ---- app/views/matches/rankings.html.haml | 4 ---- public/stylesheets/pong.css | 17 +++++++++++++++++ spec/helpers/application_helper_spec.rb | 18 ++++++++++++++++++ spec/views/matches/index.html.haml_spec.rb | 1 - spec/views/matches/rankings.html.haml_spec.rb | 1 - 8 files changed, 46 insertions(+), 11 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1426787..c89f12c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,9 @@ module ApplicationHelper + def link_to_with_current(name, url) + options = (current_page? url) ? { class: "current" } : {} + link_to name, url, options + end + def location ENV["PIVOT_PONG_LOCATION"] || "NYC" end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 352e506..4b4cd14 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -12,7 +12,12 @@ %body #page - %h1 pivot pong #{location.downcase} + %header + %h1 pivot pong #{location.downcase} + %nav + = link_to_with_current "Rankings", root_path + = link_to_with_current "Matches", matches_path + = render 'shared/flash_messages' = yield %footer diff --git a/app/views/matches/index.html.haml b/app/views/matches/index.html.haml index 5b7fd32..6bb0202 100644 --- a/app/views/matches/index.html.haml +++ b/app/views/matches/index.html.haml @@ -1,9 +1,5 @@ - content_for :title, "Matches" -%nav - = link_to "Rankings", root_path - = link_to "Matches", matches_path, class: "current" - = form_for(@match) do |f| = label_tag :winner_name = text_field_tag :winner_name, "", autocomplete: "off" diff --git a/app/views/matches/rankings.html.haml b/app/views/matches/rankings.html.haml index 987742c..78bce63 100644 --- a/app/views/matches/rankings.html.haml +++ b/app/views/matches/rankings.html.haml @@ -1,9 +1,5 @@ - content_for :title, "Rankings" -%nav - = link_to "Rankings", root_path, class: "current" - = link_to "Matches", matches_path - .tabs %ul.tab-bar %li= link_to "All time", "#all-time" diff --git a/public/stylesheets/pong.css b/public/stylesheets/pong.css index deb337a..810292f 100644 --- a/public/stylesheets/pong.css +++ b/public/stylesheets/pong.css @@ -26,6 +26,23 @@ a.current { padding-right: 3px; } +header { + margin-bottom: 20px; +} + +header > * { + display: inline; +} + +header nav { + margin-left: 10px; + vertical-align: 4px; +} + +header nav a + a { + margin-left: 10px; +} + footer { font-size: 12px; } diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0f115bd..77e0a7a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,6 +1,24 @@ require 'spec_helper' describe ApplicationHelper do + describe "#link_to_with_current" do + let(:name) { "My Link" } + let(:url) { "/the/url" } + subject { helper.link_to_with_current(name, url) } + + context "when the URL is the current page" do + before { view.stub(:current_page?) { true } } + + it { should include('class="current"') } + end + + context "when the URL is not the current page" do + before { view.stub(:current_page?) { false } } + + it { should_not include('class="current"') } + end + end + describe "#location" do subject { helper.location } diff --git a/spec/views/matches/index.html.haml_spec.rb b/spec/views/matches/index.html.haml_spec.rb index 5c15550..c77423f 100644 --- a/spec/views/matches/index.html.haml_spec.rb +++ b/spec/views/matches/index.html.haml_spec.rb @@ -11,6 +11,5 @@ it { should include("Cl") } it { should include("Minzy") } it { should include(occured_at.strftime("%Y-%m-%d")) } - it { should include(link_to "Rankings", "/") } it { should include(link_to "delete", match_path(match), method: :delete) } end diff --git a/spec/views/matches/rankings.html.haml_spec.rb b/spec/views/matches/rankings.html.haml_spec.rb index 1f1af33..89e47d6 100644 --- a/spec/views/matches/rankings.html.haml_spec.rb +++ b/spec/views/matches/rankings.html.haml_spec.rb @@ -15,5 +15,4 @@ it { should include("two") } it { should include("meow") } it { should include("woof") } - it { should include(link_to "Matches", matches_path) } end