Skip to content

Commit

Permalink
Change Time.now to Time.current, upgrade gems.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalermo committed Aug 24, 2014
1 parent dea778b commit 7bc603e
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
10 changes: 6 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ GEM
less-rails (2.2.6)
actionpack (>= 3.1)
less (~> 2.2.0)
libv8 (3.3.10.4)
libv8 (3.16.14.3)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -118,9 +118,10 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.4)
rake (10.3.2)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
Expand All @@ -144,8 +145,9 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
subexec (0.2.2)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.18.1)
tilt (1.4.1)
tinymce-rails (3.5.8)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update
winner, loser = params.values_at(:winner_name, :loser_name).map { |name|
Player.find_or_create_by_name name.strip.downcase
}
occured_at = params[:match].present? ? params[:match][:occured_at] : Time.now
occured_at = params[:match].present? ? params[:match][:occured_at] : Time.current
if @match.update_attributes winner: winner, loser: loser, occured_at: occured_at
flash.notice = "Match successfully updated"
redirect_to admin_matches_path
Expand All @@ -33,7 +33,7 @@ def create
Player.find_or_create_by_name name.strip.downcase
}

occured_at = params[:match].present? ? params[:match][:occured_at] : Time.now
occured_at = params[:match].present? ? params[:match][:occured_at] : Time.current
match = Match.new winner: winner, loser: loser, occured_at: occured_at

unless [winner, loser].all?(&:valid?) && match.save
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def create
Player.find_or_create_by_name name.strip.downcase
}

occured_at = params[:match].present? ? params[:match][:occured_at] : Time.now
occured_at = params[:match].present? ? params[:match][:occured_at] : Time.current
match = Match.new winner: winner, loser: loser, occured_at: occured_at

unless [winner, loser].all?(&:valid?) && match.save
Expand Down
2 changes: 1 addition & 1 deletion app/models/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Log < ActiveRecord::Base

def check_for_occured_at
if self.occured_at.blank?
self.occured_at = Time.now
self.occured_at = Time.current
end
end
end
2 changes: 1 addition & 1 deletion app/models/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Match < ActiveRecord::Base
private

def set_default_occured_at_date
self.occured_at ||= Time.now
self.occured_at ||= Time.current
end

def daily_limit
Expand Down
2 changes: 1 addition & 1 deletion app/models/working_hard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def badge
end

def eligible?(player)
player.matches.occurred_today(Time.now).size > 5
player.matches.occurred_today(Time.current).size > 5
end
end
end
2 changes: 1 addition & 1 deletion app/views/admin/matches/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
= label_tag :loser_name
= text_field_tag :loser_name, @match ? @match.loser.display_name : '', autocomplete: "off"
= f.label :occured_at
= f.text_field :occured_at, value: @match.occured_at || Time.now.strftime("%Y-%m-%d %H:%M:%S")
= f.text_field :occured_at, value: @match.occured_at || Time.current.strftime("%Y-%m-%d %H:%M:%S")
%br/
%p
= link_to "Cancel", admin_players_path
Expand Down
2 changes: 1 addition & 1 deletion app/views/matches/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
= label_tag :loser_name
= text_field_tag :loser_name, "", autocomplete: "off"
= f.label :occured_at
= f.text_field :occured_at, value: Time.now.strftime("%Y-%m-%d %H:%M:%S")
= f.text_field :occured_at
= submit_tag "Add match", disable_with: "Working..."

= render partial: 'shared/match_history', locals: {matches: @matches}
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/matches_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
subject { response }

describe "GET #index" do
let(:occured_at) { Time.now }
let(:occured_at) { Time.current }
let(:me) { Player.create(name: "me") }
let(:you) { Player.create(name: "you") }
let!(:newer_match) { Match.create(winner: me, loser: you, occured_at: occured_at) }
Expand All @@ -25,7 +25,7 @@
end

describe "GET #show" do
let(:occured_at) { Time.now }
let(:occured_at) { Time.current }
let(:me) { Player.create(name: "me") }
let(:you) { Player.create(name: "you") }
let!(:match) { Match.create(winner: me, loser: you, occured_at: occured_at) }
Expand Down Expand Up @@ -96,7 +96,7 @@
let(:you) { Player.create(name: "you") }
let(:us) { Player.create(name: "us") }
let(:them) { Player.create(name: "them")}
let(:occured_at) { Time.now }
let(:occured_at) { Time.current }

it "returns the correctly ranked players" do
Match.create(winner: Player.create(name: "one"),
Expand Down
2 changes: 1 addition & 1 deletion spec/models/match_observer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:me) { Player.create(name: 'me') }
let(:you) { Player.create(name: 'you') }
let(:observer) { MatchObserver.instance }
let(:match) { mock_model(Match, winner: you, loser: me, occured_at: Time.now) }
let(:match) { mock_model(Match, winner: you, loser: me, occured_at: Time.current) }

describe "#after_save" do
it "should make the appropriate method calls" do
Expand Down

0 comments on commit 7bc603e

Please sign in to comment.