punchcard 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- punchcard (0.1.4)
4
+ punchcard (0.2.4)
5
5
  activerecord (~> 3.0.0)
6
6
  bson_ext
7
7
  gravtastic
@@ -42,6 +42,7 @@ GEM
42
42
  sqlite3 (0.1.1)
43
43
  ffi (>= 0.6.3)
44
44
  tilt (1.1)
45
+ timecop (0.3.5)
45
46
  tzinfo (0.3.23)
46
47
 
47
48
  PLATFORMS
@@ -58,3 +59,4 @@ DEPENDENCIES
58
59
  shoulda (= 2.10.3)
59
60
  sinatra (>= 1.0.0)
60
61
  sqlite3
62
+ timecop
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ begin
19
19
  gem.add_development_dependency "shoulda", "2.10.3"
20
20
  gem.add_development_dependency "rack-test", ">= 0.5.6"
21
21
  gem.add_development_dependency 'sqlite3', '>= 0'
22
+ gem.add_development_dependency 'timecop', '>= 0'
22
23
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
24
  end
24
25
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
@@ -18,7 +18,7 @@ class Person < ActiveRecord::Base
18
18
  if punch = pending?
19
19
  punch.punch_out!
20
20
  else
21
- if recently_finished = punches.recently_finished.first
21
+ if recently_finished = punches.finished.first and recently_finished.checked_out_at > 30.minutes.ago
22
22
  recently_finished.reopen!
23
23
  else
24
24
  punches.create!
@@ -5,7 +5,6 @@ class Punch < ActiveRecord::Base
5
5
 
6
6
  scope :pending, where("checked_out_at IS NULL").order("checked_in_at ASC")
7
7
  scope :finished, where("checked_in_at IS NOT NULL AND checked_out_at IS NOT NULL").order('checked_out_at DESC')
8
- scope :recently_finished, where("checked_out_at > ?", 30.minutes.ago).order('checked_out_at DESC')
9
8
 
10
9
  before_validation do |p|
11
10
  p.checked_in_at ||= Time.now
@@ -15,9 +15,7 @@
15
15
  <li id="${_id}">
16
16
  <img src="${gravatar_url}" title="${name}" class="gravatar {{if pending == true}}pending{{/if}} ${pending}"/>
17
17
  <div class="person">${name}</div>
18
- {{if checked_in_at}}
19
- <abbr class="timeago" title="${checked_in_at}"></abbr>
20
- {{/if}}
18
+ <abbr class="timeago" title="{{if checked_in_at}}${checked_in_at}{{/if}}">&nbsp;</abbr>
21
19
  </li>
22
20
  </script>
23
21
 
@@ -14,6 +14,7 @@ $yellow: #fc0
14
14
  background: #eadab6
15
15
  border-top: 10px solid #f8bba6
16
16
  -moz-box-shadow: 3px 3px 0px #d2bd8e
17
+ -moz-border-radius: 20px
17
18
 
18
19
  .clear
19
20
  clear: both
data/punchcard.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{punchcard}
8
- s.version = "0.2.4"
8
+ s.version = "0.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christoph Olszowka"]
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
69
69
  s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
70
70
  s.add_development_dependency(%q<rack-test>, [">= 0.5.6"])
71
71
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
72
+ s.add_development_dependency(%q<timecop>, [">= 0"])
72
73
  else
73
74
  s.add_dependency(%q<sinatra>, [">= 1.0.0"])
74
75
  s.add_dependency(%q<bson_ext>, [">= 0"])
@@ -79,6 +80,7 @@ Gem::Specification.new do |s|
79
80
  s.add_dependency(%q<shoulda>, ["= 2.10.3"])
80
81
  s.add_dependency(%q<rack-test>, [">= 0.5.6"])
81
82
  s.add_dependency(%q<sqlite3>, [">= 0"])
83
+ s.add_dependency(%q<timecop>, [">= 0"])
82
84
  end
83
85
  else
84
86
  s.add_dependency(%q<sinatra>, [">= 1.0.0"])
@@ -90,6 +92,7 @@ Gem::Specification.new do |s|
90
92
  s.add_dependency(%q<shoulda>, ["= 2.10.3"])
91
93
  s.add_dependency(%q<rack-test>, [">= 0.5.6"])
92
94
  s.add_dependency(%q<sqlite3>, [">= 0"])
95
+ s.add_dependency(%q<timecop>, [">= 0"])
93
96
  end
94
97
  end
95
98
 
data/test/helper.rb CHANGED
@@ -5,6 +5,7 @@ Bundler.require
5
5
  require 'test/unit'
6
6
  require 'shoulda'
7
7
  require 'rack/test'
8
+ require 'timecop'
8
9
 
9
10
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
11
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -23,10 +23,12 @@ class TestDatabase < Test::Unit::TestCase
23
23
 
24
24
  context "that got punched 2 hours ago" do
25
25
  setup do
26
- assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
27
- punch = @person.pending?
28
- punch.checked_in_at = 2.hours.ago
29
- punch.save!
26
+ Timecop.freeze(2.hours.ago) do
27
+ assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
28
+ punch = @person.pending?
29
+ punch.checked_in_at = 2.hours.ago
30
+ punch.save!
31
+ end
30
32
  end
31
33
 
32
34
  should "have one pending punch" do
@@ -41,13 +43,15 @@ class TestDatabase < Test::Unit::TestCase
41
43
  end
42
44
  end
43
45
 
44
- context "and gets punched again" do
46
+ context "and checked out 25 minutes ago" do
45
47
  setup do
46
- assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
48
+ Timecop.freeze(25.minutes.ago) do
49
+ assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
50
+ end
47
51
  end
48
52
 
49
53
  should "have finished the pending punch" do
50
- assert @person.punches.first.checked_out_at > 5.seconds.ago
54
+ assert @person.punches.first.checked_out_at < 24.minutes.ago and @person.punches.first.checked_out_at > 26.minutes.ago
51
55
  end
52
56
 
53
57
  should "not be pending" do
@@ -60,7 +64,7 @@ class TestDatabase < Test::Unit::TestCase
60
64
  assert_equal 1, @person.punches.finished.count
61
65
  end
62
66
 
63
- context "and gets punched yet again" do
67
+ context "and punches in again now" do
64
68
  setup do
65
69
  assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
66
70
  end
@@ -76,15 +80,12 @@ class TestDatabase < Test::Unit::TestCase
76
80
  end
77
81
  end
78
82
 
79
- context "and gets punched yet again 2 hours later" do
83
+ context "and gets punched yet again 1 hour later" do
80
84
  setup do
81
- # Fake the timestamp so reopening does not get triggered
82
- punch = @person.punches.finished.first
83
- punch.checked_in_at = 3.hours.ago
84
- punch.checked_out_at = 2.hours.ago
85
- punch.save!
86
- assert_nil @person.pending?
87
- assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
85
+ Timecop.freeze(1.hour.from_now) do
86
+ assert_nil @person.pending?
87
+ assert @person.punch!.instance_of?(Punch), "Should have been able to get punched and have returned a Punch"
88
+ end
88
89
  end
89
90
 
90
91
  should "be pending" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 4
9
- version: 0.2.4
8
+ - 5
9
+ version: 0.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Christoph Olszowka
@@ -146,6 +146,19 @@ dependencies:
146
146
  version: "0"
147
147
  type: :development
148
148
  version_requirements: *id009
149
+ - !ruby/object:Gem::Dependency
150
+ name: timecop
151
+ prerelease: false
152
+ requirement: &id010 !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ segments:
158
+ - 0
159
+ version: "0"
160
+ type: :development
161
+ version_requirements: *id010
149
162
  description: Simple sinatra/activerecord based app for tracking time when people have been in the office
150
163
  email: christoph at olszowka de
151
164
  executables: []