Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for hours worked

  • Loading branch information...
commit ffc033844d7b92307f79c162f460dc70d36acefd 1 parent 87a0125
Bernardo de Pádua bernardo authored
13 .idea/ponto_ra.iml
View
@@ -17,12 +17,12 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack-cache (v1.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.0.3, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bcrypt-ruby (v3.0.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="rack-cache (v1.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sprockets (v2.1.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activeresource (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="uglifier (v1.1.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.1.3, Ruby SDK 1.9.2-p180) [gem]" level="application" />
@@ -32,16 +32,17 @@
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.6.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="thor (v0.14.6, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="test-unit (v2.4.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="arel (v2.2.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.2.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="rdoc (v3.11, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v0.3.31, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v3.11, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="hike (v1.2.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="tilt (v1.3.3, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="builder (v3.0.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="rack (v1.3.5, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v0.9.2.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="rack (v1.3.5, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.0.21, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-rails (v3.1.1, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
@@ -54,11 +55,11 @@
<orderEntry type="library" scope="PROVIDED" name="polyglot (v0.3.3, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mime-types (v1.17.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bourbon (v1.1.0, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="will_paginate (v3.0.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="will_paginate (v3.0.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.3.10, Ruby SDK 1.9.2-p180) [gem]" level="application" />
- <orderEntry type="library" scope="PROVIDED" name="sass (v3.1.10, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v1.0.17, Ruby SDK 1.9.2-p180) [gem]" level="application" />
+ <orderEntry type="library" scope="PROVIDED" name="sass (v3.1.10, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="treetop (v1.4.10, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.3.4, Ruby SDK 1.9.2-p180) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v3.1.2, Ruby SDK 1.9.2-p180) [gem]" level="application" />
269 .idea/workspace.xml
View
@@ -2,9 +2,18 @@
<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$/app/controllers/stats_controller.rb" afterPath="$PROJECT_DIR$/app/controllers/stats_controller.rb" />
+ <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" />
<ignored path=".idea/workspace.xml" />
@@ -31,10 +40,37 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="stats_controller.rb" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/app/controllers/stats_controller.rb">
+ <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="108" column="67" selection-start="3092" selection-end="3092" vertical-scroll-proportion="0.4003407">
+ <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>
@@ -54,25 +90,32 @@
<component name="IdeDocumentHistory">
<option name="changedFiles">
<list>
- <option value="$PROJECT_DIR$/app/views/layouts/application.html.erb" />
- <option value="$PROJECT_DIR$/app/views/punches/_form.html.erb" />
- <option value="$PROJECT_DIR$/app/assets/stylesheets/general.css.scss" />
- <option value="$PROJECT_DIR$/app/assets/stylesheets/application.css.scss" />
<option value="$PROJECT_DIR$/app/views/users/index.html.erb" />
<option value="$PROJECT_DIR$/config/locales/models.yml" />
- <option value="$PROJECT_DIR$/Gemfile" />
<option value="$PROJECT_DIR$/app/views/users/show.html.erb" />
<option value="$PROJECT_DIR$/app/controllers/users_controller.rb" />
<option value="$PROJECT_DIR$/config/locales/will_paginate.yml" />
<option value="$PROJECT_DIR$/db/migrate/20111119190729_add_indexes.rb" />
<option value="$PROJECT_DIR$/config/routes.rb" />
- <option value="$PROJECT_DIR$/app/models/user.rb" />
<option value="$PROJECT_DIR$/app/views/application/_user_stats.html.erb" />
<option value="$PROJECT_DIR$/app/views/stats/gecko_latest_punches.xml.erb" />
<option value="$PROJECT_DIR$/app/controllers/stats_controller.rb" />
+ <option value="$PROJECT_DIR$/test/test_helper.rb" />
+ <option value="$PROJECT_DIR$/Gemfile" />
+ <option value="$PROJECT_DIR$/app/models/punch.rb" />
+ <option value="$PROJECT_DIR$/test/unit/punch_test.rb" />
+ <option value="$PROJECT_DIR$/app/models/user.rb" />
+ <option value="$PROJECT_DIR$/test/unit/user_test.rb" />
</list>
</option>
</component>
+ <component name="LogFilters">
+ <option name="FILTER_ERRORS" value="false" />
+ <option name="FILTER_WARNINGS" value="false" />
+ <option name="FILTER_INFO" value="true" />
+ <option name="FILTER_DEBUG" value="true" />
+ <option name="CUSTOM_FILTER" />
+ </component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
@@ -99,24 +142,25 @@
<sortByType />
</navigator>
<panes>
+ <pane id="Scope" />
<pane id="Favorites" />
- <pane id="RailsProjectView">
+ <pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="ponto_ra" />
- <option name="myItemType" value="org.jetbrains.plugins.ruby.rails.projectView.v2.nodes.RailsProjectNode" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
- </subPane>
- </pane>
- <pane id="ProjectPane">
- <subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="ponto_ra" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -127,6 +171,42 @@
<option name="myItemId" value="ponto_ra" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="test" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="test" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="unit" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="app" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -141,6 +221,10 @@
<option name="myItemId" value="app" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="models" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
@@ -162,7 +246,16 @@
</PATH>
</subPane>
</pane>
- <pane id="Scope" />
+ <pane id="RailsProjectView">
+ <subPane>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="ponto_ra" />
+ <option name="myItemType" value="org.jetbrains.plugins.ruby.rails.projectView.v2.nodes.RailsProjectNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ </subPane>
+ </pane>
</panes>
</component>
<component name="PropertiesComponent">
@@ -174,7 +267,67 @@
<property name="options.splitter.details.proportions" value="0.2" />
<property name="GoToClass.includeJavaFiles" value="false" />
</component>
- <component name="RunManager" selected="Rails.Development: ponto_ra">
+ <component name="RunManager" selected="Test::Unit/Shoulda.UserTest">
+ <configuration default="false" name="UserTest" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda" temporary="true">
+ <predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
+ <module name="ponto_ra" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$PROJECT_DIR$" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
+ <envs>
+ <env name="RAILS_ENV" value="test" />
+ <env name="JRUBY_OPTS" value="-X+O" />
+ </envs>
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov">
+ <COVERAGE_PATTERN ENABLED="true">
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
+ </COVERAGE_PATTERN>
+ </EXTENSION>
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$PROJECT_DIR$/test/unit/user_test.rb" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
+ <RunnerSettings RunnerId="RubyRunner" />
+ <ConfigurationWrapper RunnerId="RubyRunner" />
+ <method />
+ </configuration>
+ <configuration default="false" name="test_punches_caso_normal" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda" temporary="true">
+ <predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
+ <module name="ponto_ra" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) -Itest" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$PROJECT_DIR$" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
+ <envs>
+ <env name="RAILS_ENV" value="test" />
+ <env name="JRUBY_OPTS" value="-X+O" />
+ </envs>
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" track_test_folders="true" runner="rcov">
+ <COVERAGE_PATTERN ENABLED="true">
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
+ </COVERAGE_PATTERN>
+ </EXTENSION>
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$PROJECT_DIR$/test/unit/user_test.rb" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_CLASS_NAME" VALUE="UserTest" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="test_punches_caso_normal" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_METHOD" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="INHERITANCE_CHECK_DISABLED" VALUE="false" />
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
+ <RunnerSettings RunnerId="RubyRunner" />
+ <ConfigurationWrapper RunnerId="RubyRunner" />
+ <method />
+ </configuration>
<configuration default="true" type="RakeRunConfigurationType" factoryName="Rake">
<module name="" />
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
@@ -423,11 +576,13 @@
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
<method />
</configuration>
- <list size="4">
+ <list size="6">
<item index="0" class="java.lang.String" itemvalue="Rails.Development: ponto_ra" />
<item index="1" class="java.lang.String" itemvalue="Rails.Production: ponto_ra" />
<item index="2" class="java.lang.String" itemvalue="Rake.spec" />
<item index="3" class="java.lang.String" itemvalue="Rake.test" />
+ <item index="4" class="java.lang.String" itemvalue="Test::Unit/Shoulda.UserTest" />
+ <item index="5" class="java.lang.String" itemvalue="Test::Unit/Shoulda.test_punches_caso_normal" />
</list>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
@@ -478,7 +633,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
- <frame x="37" y="64" width="1654" height="723" extended-state="0" />
+ <frame x="0" y="22" width="1920" height="979" extended-state="0" />
<editor active="true" />
<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" />
@@ -486,9 +641,9 @@
<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.3233645" sideWeight="0.67" order="0" 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="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="false" weight="0.32907802" 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="true" 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" />
@@ -543,21 +698,6 @@
<breakpoint-manager />
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/app/views/punches/_form.html.erb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="30" column="10" selection-start="855" selection-end="855" vertical-scroll-proportion="-0.051446944" />
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/app/views/punches/index.html.erb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="30" column="8" selection-start="888" selection-end="888" vertical-scroll-proportion="0.7717042" />
- </provider>
- </entry>
- <entry file="file://$PROJECT_DIR$/config/locales/will_paginate.yml">
- <provider selected="true" editor-type-id="text-editor">
- <state line="3" column="33" selection-start="98" selection-end="98" vertical-scroll-proportion="0.07272727" />
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/config/locales/models.yml">
<provider selected="true" editor-type-id="text-editor">
<state line="2" column="3" selection-start="57" selection-end="66" vertical-scroll-proportion="0.048484847" />
@@ -573,11 +713,6 @@
<state line="23" column="21" selection-start="540" selection-end="540" vertical-scroll-proportion="0.2590909" />
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/Gemfile">
- <provider selected="true" editor-type-id="text-editor">
- <state line="16" column="3" selection-start="361" selection-end="361" vertical-scroll-proportion="0.38787878" />
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/db/migrate/20111119190729_add_indexes.rb">
<provider selected="true" editor-type-id="text-editor">
<state line="13" column="0" selection-start="295" selection-end="295" vertical-scroll-proportion="0.3151515" />
@@ -588,11 +723,6 @@
<state line="5" column="74" selection-start="332" selection-end="332" vertical-scroll-proportion="0.096969694" />
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/app/models/user.rb">
- <provider selected="true" editor-type-id="text-editor">
- <state line="27" column="5" selection-start="586" selection-end="586" vertical-scroll-proportion="0.33173844" />
- </provider>
- </entry>
<entry file="file://$PROJECT_DIR$/app/views/application/_user_stats.html.erb">
<provider selected="true" editor-type-id="text-editor">
<state line="4" column="24" selection-start="170" selection-end="170" vertical-scroll-proportion="0.10631229" />
@@ -608,19 +738,54 @@
<state line="7" column="21" selection-start="324" selection-end="324" vertical-scroll-proportion="0.17310664" />
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/config/routes.rb">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="13" column="61" selection-start="599" selection-end="599" vertical-scroll-proportion="0.32148376" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/app/controllers/stats_controller.rb">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="108" column="67" selection-start="3092" selection-end="3092" vertical-scroll-proportion="0.4003407" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/test/test_helper.rb">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="9" column="0" selection-start="373" selection-end="373" vertical-scroll-proportion="0.1682243">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/Gemfile">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="41" column="6" selection-start="774" selection-end="774" vertical-scroll-proportion="0.8017699">
+ <folding />
+ </state>
+ </provider>
+ </entry>
<entry file="file://$PROJECT_DIR$/app/models/punch.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="0" column="0" selection-start="0" selection-end="0" 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$/config/routes.rb">
+ <entry file="file://$PROJECT_DIR$/test/unit/punch_test.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="13" column="61" selection-start="599" selection-end="599" vertical-scroll-proportion="0.32148376" />
+ <state line="1" column="0" selection-start="18" selection-end="18" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/app/controllers/stats_controller.rb">
+ <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>
+ <entry file="file://$PROJECT_DIR$/app/models/user.rb">
<provider selected="true" editor-type-id="text-editor">
- <state line="108" column="67" selection-start="3092" selection-end="3092" vertical-scroll-proportion="0.4003407">
+ <state line="45" column="45" selection-start="1315" selection-end="1315" vertical-scroll-proportion="0.5797101">
<folding />
</state>
</provider>
1  Gemfile
View
@@ -39,4 +39,5 @@ end
group :test do
# Pretty printed test output
gem 'turn', :require => false
+ gem 'test-unit'
end
2  Gemfile.lock
View
@@ -97,6 +97,7 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.4)
+ test-unit (2.4.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -122,6 +123,7 @@ DEPENDENCIES
rails (= 3.1.2)
sass-rails (~> 3.1.4)
sqlite3
+ test-unit
turn
uglifier (>= 1.0.3)
will_paginate
4 app/models/punch.rb
View
@@ -5,8 +5,8 @@ class Punch < ActiveRecord::Base
validates_presence_of :user
- before_validation(:on => :create) do
- self.punched_at = Time.now
+ before_validation do
+ self.punched_at ||= Time.now
end
before_save do
25 app/models/user.rb
View
@@ -31,17 +31,28 @@ def hours_worked(datetime_range)
punches_in_range = self.punches.where('punched_at >= ? and punched_at <= ?', datetime_range.begin, datetime_range.end).order('punched_at ASC').all
return 0 if punches_in_range.empty?
-
+
+ fixed_punches_in_range = []
+
+ #adds punches that may be missing in the middle
+ punches_in_range.each_with_index do |p, i|
+ fixed_punches_in_range << p
+ next_punch = punches_in_range[i+1]
+ if next_punch and next_punch.entrance == p.entrance #next punch is not right, add one in between
+ fixed_punches_in_range << Punch.new(:punched_at => next_punch.punched_at, :entrance => !next_punch.entrance?)
+ end
+ end
+
#add punches to the edges, if appropriate
- if not punches_in_range.first.entrance?
- punches_in_range.unshift self.punches.new(:punched_at => datetime_range.begin)
+ if not fixed_punches_in_range.first.entrance?
+ fixed_punches_in_range.unshift Punch.new(:punched_at => datetime_range.begin)
end
- if punches_in_range.last.entrance?
- punches_in_range << self.punches.new(:punched_at => datetime_range.end)
+ if fixed_punches_in_range.last.entrance?
+ fixed_punches_in_range << Punch.new(:punched_at => datetime_range.end)
end
-
+
time_worked = 0
- punches_in_range.each_cons(2) do |pair|
+ fixed_punches_in_range.each_slice(2) do |pair|
time_worked += pair.last.punched_at - pair.first.punched_at
end
0  test/fixtures/.gitkeep
View
No changes.
7 test/fixtures/punches.yml
View
@@ -1,7 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
- user_id: 1
-
-two:
- user_id: 1
9 test/fixtures/users.yml
View
@@ -1,9 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
- name: MyString
- password_digest: MyString
-
-two:
- name: MyString
- password_digest: MyString
2  test/test_helper.rb
View
@@ -7,7 +7,7 @@ class ActiveSupport::TestCase
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
- fixtures :all
+ #fixtures :all
# Add more helper methods to be used by all tests here...
end
2  test/unit/punch_test.rb
View
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
require 'test_helper'
class PunchTest < ActiveSupport::TestCase
65 test/unit/user_test.rb
View
@@ -1,7 +1,66 @@
+# encoding: utf-8
+
require 'test_helper'
class UserTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+
+ def setup
+ @user = User.create(:name => "Joao Cohones", :password => "abc123")
+ end
+
+ test "hours_worked caso normal" do
+ #entrou 1:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 1.hour))
+ #saiu 5:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours))
+ #entrou 10:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours))
+ #saiu 15:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 15.hours))
+
+ assert_equal 9, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ end
+
+ test "hours_worked punches falta fim" do
+ #entrou 1:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 1.hour))
+ #saiu 5:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours))
+ #entrou 10:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours))
+
+ #18 horas, até o fim do período
+ assert_equal 18, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ end
+
+ test "hours_worked punches falta início" do
+ #saiu 5:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 5.hours))
+ #entrou 10:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 10.hours))
+ #saiu 17:00
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 17.hours))
+
+ #12 horas, desde o início do dia
+ assert_equal 12, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ 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
+ @punches = @user.punches.create(:punched_at => (Time.now.beginning_of_day + 20.hours))
+
+ #9 horas
+ assert_equal 9, @user.hours_worked(Time.now.beginning_of_day..Time.now.end_of_day)
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.