Permalink
Browse files

Fixes test, now 100%

  • Loading branch information...
bernardo committed Nov 25, 2011
1 parent ffc0338 commit 0a48f9fd85e3e87381639c588f72cd06322b4745
Showing with 33 additions and 72 deletions.
  1. +11 −59 .idea/workspace.xml
  2. +22 −13 test/unit/user_test.rb
View
@@ -2,17 +2,6 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="188ad806-9dbe-4371-8574-0b8a662aa667" name="Default" comment="">
- <change type="DELETED" beforePath="$PROJECT_DIR$/test/fixtures/.gitkeep" afterPath="" />
- <change type="DELETED" beforePath="$PROJECT_DIR$/test/fixtures/punches.yml" afterPath="" />
- <change type="DELETED" beforePath="$PROJECT_DIR$/test/fixtures/users.yml" afterPath="" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/ponto_ra.iml" afterPath="$PROJECT_DIR$/.idea/ponto_ra.iml" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Gemfile.lock" afterPath="$PROJECT_DIR$/Gemfile.lock" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/Gemfile" afterPath="$PROJECT_DIR$/Gemfile" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/models/punch.rb" afterPath="$PROJECT_DIR$/app/models/punch.rb" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/app/models/user.rb" afterPath="$PROJECT_DIR$/app/models/user.rb" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/test_helper.rb" afterPath="$PROJECT_DIR$/test/test_helper.rb" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/unit/punch_test.rb" afterPath="$PROJECT_DIR$/test/unit/punch_test.rb" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/test/unit/user_test.rb" afterPath="$PROJECT_DIR$/test/unit/user_test.rb" />
</list>
<ignored path="ponto_ra.iws" />
@@ -39,44 +28,7 @@
<favorites_list name="ponto_ra" />
</component>
<component name="FileEditorManager">
- <leaf>
- <file leaf-file-name="user.rb" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/app/models/user.rb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="45" column="45" selection-start="1315" selection-end="1315" vertical-scroll-proportion="0.5797101">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="punch_test.rb" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/test/unit/punch_test.rb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="1" column="0" selection-start="18" selection-end="18" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="punch.rb" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/app/models/punch.rb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="0" column="17" selection-start="0" selection-end="18" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- <file leaf-file-name="user_test.rb" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/test/unit/user_test.rb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="62" column="18" selection-start="2397" selection-end="2397" vertical-scroll-proportion="0.0">
- <folding />
- </state>
- </provider>
- </entry>
- </file>
- </leaf>
+ <leaf />
</component>
<component name="FindManager">
<FindUsagesManager>
@@ -634,16 +586,16 @@
</component>
<component name="ToolWindowManager">
<frame x="0" y="22" width="1920" height="979" extended-state="0" />
- <editor active="true" />
+ <editor active="false" />
<layout>
<window_info id="Data Sources" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32907802" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32907802" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Dependency Viewer" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33244255" sideWeight="0.67118645" order="0" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.33244255" sideWeight="0.67118645" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32881355" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32881355" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
@@ -762,30 +714,30 @@
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/app/models/punch.rb">
+ <entry file="file://$PROJECT_DIR$/test/unit/user_test.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="0" column="17" selection-start="0" selection-end="18" vertical-scroll-proportion="0.0">
+ <state line="69" column="99" selection-start="3285" selection-end="3285" vertical-scroll-proportion="0.660177">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/test/unit/punch_test.rb">
+ <entry file="file://$PROJECT_DIR$/app/models/punch.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="1" column="0" selection-start="18" selection-end="18" vertical-scroll-proportion="0.0">
+ <state line="0" column="17" selection-start="0" selection-end="18" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/test/unit/user_test.rb">
+ <entry file="file://$PROJECT_DIR$/test/unit/punch_test.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="62" column="18" selection-start="2397" selection-end="2397" vertical-scroll-proportion="0.0">
+ <state line="1" column="0" selection-start="18" selection-end="18" vertical-scroll-proportion="0.028318584">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app/models/user.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="45" column="45" selection-start="1315" selection-end="1315" vertical-scroll-proportion="0.5797101">
+ <state line="29" column="17" selection-start="607" selection-end="607" vertical-scroll-proportion="0.11594203">
<folding />
</state>
</provider>
View
@@ -46,21 +46,30 @@ def setup
end
- test "hours_worked ignora faltante um no meio" do
- #entrou 1:00
- @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 1.hours))
- #saiu 5:00
- @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours))
- #saiu 10:00
- @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours))
- @punches.update_attribute(:entrance, false)
- #entrou 15:00
- @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 15.hours))
- #saiu 20:00
+ test "hours_worked ignora entrada faltante no meio" do
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 1.hours)) #entra
+ # 3:00 sai
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours)) #sai
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours)) #entra
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 15.hours)) #sai
+
@punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 20.hours))
+ @punches.update_attribute(:punched_at, (Time.now.beginning_of_day + 3.hours) ) # sai lá atrás
- #9 horas
- assert_equal 9, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ assert_equal 7, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ end
+
+ test "hours_worked ignora saída faltante no meio" do
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 1.hours)) #entra
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours)) #sai
+ # 8 entra
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours))#entra
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 15.hours))#sai
+
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 20.hours))#some
+ @punches.update_attribute(:punched_at, (Time.now.beginning_of_day + 8.hours) ) # entra lá atrás
+
+ assert_equal 11, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
end
end

0 comments on commit 0a48f9f

Please sign in to comment.