Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: DD9/dd9-extranet
base: 3bef213ff3
...
head fork: DD9/dd9-extranet
compare: 35c78d8e04
  • 2 commits
  • 30 files changed
  • 0 commit comments
  • 1 contributor
Showing with 253 additions and 252 deletions.
  1. +1 −1  Gemfile
  2. +86 −86 Gemfile.lock
  3. +15 −15 features/step_definitions/hour_log_steps.rb
  4. +3 −3 features/step_definitions/time_entry_steps.rb
  5. +2 −2 features/step_definitions/user_steps.rb
  6. +2 −2 features/support/env.rb
  7. +5 −5 spec/controllers/companies_controller_spec.rb
  8. +3 −3 spec/controllers/home_controller_spec.rb
  9. +7 −7 spec/controllers/hour_logs_controller_spec.rb
  10. +3 −3 spec/controllers/invoices_controller_spec.rb
  11. +6 −6 spec/controllers/time_entries_controller_spec.rb
  12. +9 −9 spec/controllers/users_controller_spec.rb
  13. +57 −57 spec/factories.rb
  14. +3 −3 spec/models/hour_log_spec.rb
  15. +9 −9 spec/models/time_entry_spec.rb
  16. +1 −0  spec/spec_helper.rb
  17. +2 −2 spec/views/companies/index.html.haml_spec.rb
  18. +3 −3 spec/views/companies/show.html.haml_spec.rb
  19. +4 −4 spec/views/hour_logs/index.html.haml_spec.rb
  20. +7 −7 spec/views/hour_logs/new.html.haml_spec.rb
  21. +7 −7 spec/views/hour_logs/show.html.haml_spec.rb
  22. +3 −3 spec/views/invoices/index.html.haml_spec.rb
  23. +3 −3 spec/views/shared/_navigation_spec.rb
  24. +1 −1  spec/views/shared/_prenav_spec.rb
  25. +2 −2 spec/views/time_entries/index.html.haml_spec.rb
  26. +3 −3 spec/views/time_entries/new.html.haml_spec.rb
  27. +1 −1  spec/views/time_entries/upload.html.haml_spec.rb
  28. +1 −1  spec/views/users/_destroy_confirm.html.haml_spec.rb
  29. +2 −2 spec/views/users/_form.html.haml_spec.rb
  30. +2 −2 spec/views/users/index.html.haml_spec.rb
View
2  Gemfile
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'rails', '3.2.1'
+gem 'rails', '3.2.2'
# local & production web server
gem 'eventmachine', '1.0.0.beta.3'
View
172 Gemfile.lock
@@ -1,12 +1,12 @@
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.1)
- actionpack (= 3.2.1)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
mail (~> 2.4.0)
- actionpack (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
@@ -14,22 +14,22 @@ GEM
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
- activemodel (3.2.1)
- activesupport (= 3.2.1)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
- activerecord (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- arel (~> 3.0.0)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.1)
- activemodel (= 3.2.1)
- activesupport (= 3.2.1)
- activesupport (3.2.1)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.6)
- arel (3.0.0)
+ addressable (2.2.7)
+ arel (3.0.2)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
best_in_place (1.0.6)
@@ -44,10 +44,10 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- capybara-webkit (0.8.0)
+ capybara-webkit (0.11.0)
capybara (>= 1.0.0, < 1.2)
json
- childprocess (0.3.0)
+ childprocess (0.3.1)
ffi (~> 1.0.6)
client_side_validations (3.1.4)
coffee-rails (3.2.2)
@@ -57,55 +57,55 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
- cucumber (1.1.4)
+ cucumber (1.1.9)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
- gherkin (~> 2.7.1)
+ gherkin (~> 2.9.0)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
- cucumber-rails (1.2.1)
+ cucumber-rails (1.3.0)
capybara (>= 1.1.2)
- cucumber (>= 1.1.3)
+ cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
- daemons (1.1.6)
- database_cleaner (0.7.1)
- devise (2.0.0)
+ daemons (1.1.8)
+ database_cleaner (0.7.2)
+ devise (2.0.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
railties (~> 3.1)
- warden (~> 1.1)
+ warden (~> 1.1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0.beta.3)
eventmachine (1.0.0.beta.3-x86-mingw32)
execjs (1.3.0)
multi_json (~> 1.0)
- factory_girl (2.5.0)
- activesupport
- factory_girl_rails (1.6.0)
- factory_girl (~> 2.5.0)
+ factory_girl (3.0.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (3.0.0)
+ factory_girl (~> 3.0.0)
railties (>= 3.0.0)
faker (1.0.1)
i18n (~> 0.4)
ffi (1.0.11)
flutie (1.3.3)
- formtastic (2.0.2)
- rails (~> 3.0)
- gherkin (2.7.6)
+ formtastic (2.1.1)
+ actionpack (~> 3.0)
+ gherkin (2.9.3)
json (>= 1.4.6)
- gherkin (2.7.6-x86-mingw32)
+ gherkin (2.9.3-x86-mingw32)
json (>= 1.4.6)
growl_notify (0.0.3)
rb-appscript
- guard (1.0.0)
+ guard (1.0.1)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-cucumber (0.7.5)
cucumber (>= 0.10)
guard (>= 0.8.3)
- guard-rspec (0.6.0)
+ guard-rspec (0.7.0)
guard (>= 0.10.0)
- guard-spork (0.5.1)
+ guard-spork (0.5.2)
guard (>= 0.10.0)
spork (>= 0.8.4)
haml (3.1.4)
@@ -119,79 +119,79 @@ GEM
multi_json
multi_xml
i18n (0.6.0)
- journey (1.0.1)
- jquery-rails (1.0.19)
- railties (~> 3.0)
+ journey (1.0.3)
+ jquery-rails (2.0.1)
+ railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
- json (1.6.5)
- launchy (2.0.5)
+ json (1.6.6)
+ launchy (2.1.0)
addressable (~> 2.2.6)
- mail (2.4.1)
+ mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- mime-types (1.17.2)
- multi_json (1.0.4)
- multi_xml (0.4.1)
- nokogiri (1.5.0)
- nokogiri (1.5.0-x86-mingw32)
- orm_adapter (0.0.6)
- pg (0.12.2)
- pg (0.12.2-x86-mingw32)
+ mime-types (1.18)
+ multi_json (1.2.0)
+ multi_xml (0.4.2)
+ nokogiri (1.5.2)
+ nokogiri (1.5.2-x86-mingw32)
+ orm_adapter (0.0.7)
+ pg (0.13.2)
+ pg (0.13.2-x86-mingw32)
polyglot (0.3.3)
rack (1.4.1)
- rack-cache (1.1)
+ rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.1)
- actionmailer (= 3.2.1)
- actionpack (= 3.2.1)
- activerecord (= 3.2.1)
- activeresource (= 3.2.1)
- activesupport (= 3.2.1)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
bundler (~> 1.0)
- railties (= 3.2.1)
- railties (3.2.1)
- actionpack (= 3.2.1)
- activesupport (= 3.2.1)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rb-appscript (0.6.1)
- rb-fsevent (0.4.3.1)
+ rb-fsevent (0.9.0)
rdoc (3.12)
json (~> 1.4)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- rspec-rails (2.8.1)
+ rspec (2.9.0)
+ rspec-core (~> 2.9.0)
+ rspec-expectations (~> 2.9.0)
+ rspec-mocks (~> 2.9.0)
+ rspec-core (2.9.0)
+ rspec-expectations (2.9.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.9.0)
+ rspec-rails (2.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.8.0)
- rubyzip (0.9.5)
- sass (3.1.12)
- sass-rails (3.2.4)
+ rspec (~> 2.9.0)
+ rubyzip (0.9.6.1)
+ sass (3.1.15)
+ sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- selenium-webdriver (2.18.0)
+ selenium-webdriver (2.20.0)
childprocess (>= 0.2.5)
- ffi (~> 1.0.9)
- multi_json (~> 1.0.4)
+ ffi (~> 1.0)
+ multi_json (~> 1.0)
rubyzip
- spork (1.0.0rc0)
- spork (1.0.0rc0-x86-mingw32)
+ spork (1.0.0rc2)
+ spork (1.0.0rc2-x86-mingw32)
win32-process
sprockets (2.1.2)
hike (~> 1.2)
@@ -207,11 +207,11 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.31)
- uglifier (1.2.2)
+ tzinfo (0.3.32)
+ uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
- warden (1.1.0)
+ warden (1.1.1)
rack (>= 1.0)
win32-api (1.4.8-x86-mingw32)
win32-process (0.6.5)
@@ -251,7 +251,7 @@ DEPENDENCIES
jquery-rails
launchy (>= 2.0.5)
pg
- rails (= 3.2.1)
+ rails (= 3.2.2)
rb-fsevent
rspec-rails (>= 2.6.1)
sass-rails (~> 3.2.3)
View
30 features/step_definitions/hour_log_steps.rb
@@ -16,18 +16,18 @@ def should_see_time_entries(time_entries)
@time_entries = []
10.times do
- @time_entries << Factory(:time_entry, :company => @user.company, :status => 'approved')
+ @time_entries << create(:time_entry, :company => @user.company, :status => 'approved')
end
2.times do
- @time_entries << Factory(:time_entry, :company => @user.company, :status => 'created')
+ @time_entries << create(:time_entry, :company => @user.company, :status => 'created')
end
3.times do
- @time_entries << Factory(:time_entry, :company => @user.company, :status => 'submitted')
+ @time_entries << create(:time_entry, :company => @user.company, :status => 'submitted')
end
- @time_entries << Factory(:time_entry, :company => @user.company, :status => 'hidden')
+ @time_entries << create(:time_entry, :company => @user.company, :status => 'hidden')
end
Given /^There are some open hour logs$/ do
@@ -35,22 +35,22 @@ def should_see_time_entries(time_entries)
time_entries = []
2.times do
- company = Factory(:company)
+ company = create(:company)
2.times do
- time_entries << Factory(:time_entry, :company => company, :status => 'approved')
+ time_entries << create(:time_entry, :company => company, :status => 'approved')
end
2.times do
- time_entries << Factory(:time_entry, :company => company, :status => 'submitted')
+ time_entries << create(:time_entry, :company => company, :status => 'submitted')
end
2.times do
- time_entries << Factory(:time_entry, :company => company, :status => 'hidden')
+ time_entries << create(:time_entry, :company => company, :status => 'hidden')
end
2.times do
- time_entries << Factory(:time_entry, :company => company, :status => 'created')
+ time_entries << create(:time_entry, :company => company, :status => 'created')
end
@open_hour_log_companies << company
@@ -63,10 +63,10 @@ def should_see_time_entries(time_entries)
@hour_logs = []
20.times do
- hour_log = Factory(:hour_log)
+ hour_log = create(:hour_log)
2.times do
- hour_log.time_entries << Factory(:time_entry, :status => 'approved')
- hour_log.time_entries << Factory(:time_entry, :status => 'hidden')
+ hour_log.time_entries << create(:time_entry, :status => 'approved')
+ hour_log.time_entries << create(:time_entry, :status => 'hidden')
end
@hour_logs << hour_log
@@ -77,10 +77,10 @@ def should_see_time_entries(time_entries)
@hour_logs = []
20.times do
- hour_log = Factory(:hour_log, :company => @user.company)
+ hour_log = create(:hour_log, :company => @user.company)
2.times do
- hour_log.time_entries << Factory(:time_entry, :status => 'approved')
- hour_log.time_entries << Factory(:time_entry, :status => 'hidden')
+ hour_log.time_entries << create(:time_entry, :status => 'approved')
+ hour_log.time_entries << create(:time_entry, :status => 'hidden')
end
@hour_logs << hour_log
View
6 features/step_definitions/time_entry_steps.rb
@@ -2,7 +2,7 @@
entries = []
20.times do
- entries << Factory(:time_entry, :user => @user)
+ entries << create(:time_entry, :user => @user)
end
@new_time_entries = entries.select {|t| t.created? }
@@ -11,7 +11,7 @@
Given /^I have some new time entries$/ do
@new_time_entries = []
10.times do
- @new_time_entries << Factory(:time_entry, :user => @user, :status => 'created')
+ @new_time_entries << create(:time_entry, :user => @user, :status => 'created')
end
end
@@ -47,7 +47,7 @@
end
Given /^I have a new time entry$/ do
- @new_time_entry = Factory(:time_entry,
+ @new_time_entry = create(:time_entry,
:status => 'created',
:user => @user,
:description => 'This is the description for my new time entry.')
View
4 features/step_definitions/user_steps.rb
@@ -13,7 +13,7 @@
end
Given /^I am an? (client|staff|admin)(?: member)? named "([^" ]+) ([^"]+)" with an email "([^"]+)" and password "([^"]+)"/ do |role, first_name, last_name, email, password|
- @user = Factory(:user,
+ @user = create(:user,
:role => role,
:first_name => first_name,
:last_name => last_name,
@@ -23,7 +23,7 @@
end
Given /^There is a client named "([^" ]+) ([^"]+)"$/ do |first_name, last_name|
- @another_user = Factory(:user, :role => 'client', :first_name => first_name, :last_name => last_name)
+ @another_user = create(:user, :role => 'client', :first_name => first_name, :last_name => last_name)
end
Given /^My account is inactive$/ do
View
4 features/support/env.rb
@@ -6,17 +6,17 @@
require 'rubygems'
require 'spork'
-
+
Spork.prefork do
require 'cucumber/rails'
-
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
# order to ease the transition to Capybara we set the default here. If you'd
# prefer to use XPath just remove this line and adjust any selectors in your
# steps to use the XPath syntax.
Capybara.default_selector = :css
+ World FactoryGirl::Syntax::Methods
end
Spork.each_run do
View
10 spec/controllers/companies_controller_spec.rb
@@ -2,7 +2,7 @@
describe CompaniesController do
subject { response }
- let (:company) { Factory.stub(:company) }
+ let (:company) { build_stubbed(:company) }
context 'not logged in' do
describe "GET 'index'" do
@@ -35,7 +35,7 @@
end
context 'as staff' do
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
describe "GET 'index'" do
it "redirects to root" do
@@ -64,7 +64,7 @@
end
context 'as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
describe "GET 'index'" do
it "redirects to root path" do
@@ -92,7 +92,7 @@
end
context 'from that company' do
- let(:user) { Factory.stub(:user, :role => 'client', :company => company) }
+ let(:user) { build_stubbed(:user, :role => 'client', :company => company) }
before do
Company.stub(:find) { company }
@@ -132,7 +132,7 @@
end
describe 'as admin' do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
describe "GET 'index'" do
before do
View
6 spec/controllers/home_controller_spec.rb
@@ -18,19 +18,19 @@
end
context "as client" do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
it { should redirect_to new_hour_log_path }
end
context "as admin" do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
it { should redirect_to hour_logs_path }
end
describe 'as staff' do
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
it { should redirect_to(new_time_entry_path) }
end
View
14 spec/controllers/hour_logs_controller_spec.rb
@@ -47,14 +47,14 @@
end
context 'logged in' do
- let (:company) { Factory.stub :company }
- let (:hour_log) { Factory.stub :hour_log, :company => user.company }
+ let (:company) { build_stubbed(:company) }
+ let (:hour_log) { build_stubbed(:hour_log, :company => user.company) }
let (:approved_time_entries) do
approved = []
10.times do
- approved << Factory.stub(:time_entry, :status => 'approved', :hour_log => nil)
+ approved << build_stubbed(:time_entry, :status => 'approved', :hour_log => nil)
end
approved
@@ -64,7 +64,7 @@
companies = []
5.times do
- companies << Factory.stub(:company)
+ companies << build_stubbed(:company)
end
companies
@@ -77,7 +77,7 @@
end
context 'as staff' do
- let (:user) { Factory.stub :user, :role => 'staff' }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
context "GET" do
['index', 'new'].each do |action|
@@ -120,7 +120,7 @@
end
context 'as client' do
- let (:user) { Factory.stub :user, :role => 'client' }
+ let (:user) { build_stubbed(:user, :role => 'client') }
describe "GET 'index'" do
before do
@@ -178,7 +178,7 @@
end
context 'as admin' do
- let (:user) { Factory.stub :user, :role => 'admin' }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
describe "GET 'index'" do
context 'response' do
View
6 spec/controllers/invoices_controller_spec.rb
@@ -18,7 +18,7 @@
end
context 'as staff' do
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
describe "GET 'index'" do
it "redirects to root" do
@@ -29,7 +29,7 @@
end
context 'as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
describe "GET 'index'" do
before do
@@ -42,7 +42,7 @@
end
describe 'as admin' do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
describe "GET 'index'" do
before do
View
12 spec/controllers/time_entries_controller_spec.rb
@@ -48,7 +48,7 @@
context 'logged in' do
let (:time_entry) do
- time_entry = Factory.stub(:time_entry, :status => 'created', :user => user)
+ time_entry = build_stubbed(:time_entry, :status => 'created', :user => user)
time_entry.stub(:update_attribute)
time_entry.stub(:update_attributes)
time_entry.stub(:destroy)
@@ -61,7 +61,7 @@
end
context 'as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
context "GET" do
['index', 'new'].each do |action|
@@ -106,7 +106,7 @@
['staff', 'admin'].each do |role|
context "as #{role}" do
- let (:user) { Factory.stub(:user, :role => role) }
+ let (:user) { build_stubbed(:user, :role => role) }
describe "GET 'index'" do
before do
@@ -134,7 +134,7 @@
end
describe "POST 'create'" do
- let (:new_time_entry) { Factory.stub(:time_entry) }
+ let (:new_time_entry) { build_stubbed(:time_entry) }
context "with valid form data" do
before do
@@ -284,7 +284,7 @@
end
context "as staff" do
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
context "PUT" do
['approve', 'reject', 'hide'].each do |action|
@@ -299,7 +299,7 @@
end
context "as admin" do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
context "PUT" do
['approve', 'reject', 'hide'].each do |action|
View
18 spec/controllers/users_controller_spec.rb
@@ -19,14 +19,14 @@
['client', 'staff'].each do |role|
describe "as #{role}" do
- let (:user) { Factory.stub(:user, :role => role) }
+ let (:user) { build_stubbed(:user, :role => role) }
it { should redirect_to root_path }
end
end
describe "as admin" do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
it { should be_success }
it { should render_template :index }
@@ -43,7 +43,7 @@
['client', 'staff', 'admin'].each do |role|
describe "as #{role}" do
- let (:user) { Factory.stub(:user, :role => role) }
+ let (:user) { build_stubbed(:user, :role => role) }
it { should be_success }
it { should render_template :edit }
@@ -69,7 +69,7 @@
['client', 'staff', 'admin'].each do |role|
describe "as #{role}" do
let (:user) do
- user = Factory.stub(:user, :role => role)
+ user = build_stubbed(:user, :role => role)
user.stub(:update_attributes).and_return(true)
user
end
@@ -91,7 +91,7 @@
['client', 'staff', 'admin'].each do |role|
describe "as #{role}" do
let (:user) do
- user = Factory.stub(:user, :role => role)
+ user = build_stubbed(:user, :role => role)
user.stub(:update_attributes) { false }
user.stub(:errors) { [true] }
user
@@ -109,7 +109,7 @@
end
context "logged in as admin" do
- let (:admin) { Factory.stub(:user, :role => 'admin') }
+ let (:admin) { build_stubbed(:user, :role => 'admin') }
before do
stub_sign_in admin
@@ -125,7 +125,7 @@
end
context "POST 'create'" do
- let (:new_user) { Factory.stub(:user) }
+ let (:new_user) { build_stubbed(:user) }
context "with valid form data" do
before do
User.stub(:create!) { new_user }
@@ -148,7 +148,7 @@
end
context "#destroy_confirm" do
- let (:user) { Factory.stub(:user) }
+ let (:user) { build_stubbed(:user) }
before do
User.should_receive(:find).and_return(user)
@@ -160,7 +160,7 @@
end
context "#destroy" do
- let (:user) { Factory.stub(:user) }
+ let (:user) { build_stubbed(:user) }
before do
User.stub(:find) { user }
user.should_receive(:destroy).and_return(true)
View
114 spec/factories.rb
@@ -1,58 +1,58 @@
-require 'factory_girl'
-
-Factory.define :user do |u|
- u.first_name { Faker::Name.first_name }
- u.last_name { Faker::Name.last_name }
- u.email { Faker::Internet.email }
- u.password 'please'
- u.role 'client'
- u.association :company
-end
-
-Factory.define :admin, :parent => :user do |u|
- u.role 'admin'
-end
-
-Factory.define :client, :parent => :user do |u|
- u.role 'client'
-end
-
-Factory.define :staff, :parent => :user do |u|
- u.role 'staff'
-end
-
-Factory.define :company do |c|
- c.name { Faker::Company.name }
- c.memo { Faker::Lorem.sentence }
- c.sequence(:qboe_id)
-end
-
-Factory.define :time_entry do |t|
- t.association :user
- t.association :company
-
- t.public_user { |c| c.association(:user) }
- t.public_company { |c| c.association(:company) }
-
- t.date Date.today
- t.description { Faker::Lorem.sentence }
- t.hours { 0.25 * (rand(24) + 1) }
-
- t.public_date Date.today
- t.public_description { Faker::Lorem.sentence }
- t.public_hours { 0.25 * (rand(24) + 1) }
-
- t.status { TimeEntry.statuses.sample }
-end
-
-Factory.define :hour_log do |h|
- h.date Date.today
- h.association :company
- h.title { Faker::Lorem.sentence(2) }
-end
-
-Factory.define :invoice do |i|
- i.date Date.today
- i.total_amount { rand(10000) }
- i.association :company
+FactoryGirl.define do
+ factory :user do |u|
+ u.first_name { Faker::Name.first_name }
+ u.last_name { Faker::Name.last_name }
+ u.email { Faker::Internet.email }
+ u.password 'please'
+ u.role 'client'
+ u.association :company
+ end
+
+ factory :admin, :parent => :user do |u|
+ u.role 'admin'
+ end
+
+ factory :client, :parent => :user do |u|
+ u.role 'client'
+ end
+
+ factory :staff, :parent => :user do |u|
+ u.role 'staff'
+ end
+
+ factory :company do |c|
+ c.name { Faker::Company.name }
+ c.memo { Faker::Lorem.sentence }
+ c.sequence(:qboe_id)
+ end
+
+ factory :time_entry do |t|
+ t.association :user
+ t.association :company
+
+ t.public_user { |c| c.association(:user) }
+ t.public_company { |c| c.association(:company) }
+
+ t.date Date.today
+ t.description { Faker::Lorem.sentence }
+ t.hours { 0.25 * (rand(24) + 1) }
+
+ t.public_date Date.today
+ t.public_description { Faker::Lorem.sentence }
+ t.public_hours { 0.25 * (rand(24) + 1) }
+
+ t.status { TimeEntry.statuses.sample }
+ end
+
+ factory :hour_log do |h|
+ h.date Date.today
+ h.association :company
+ h.title { Faker::Lorem.sentence(2) }
+ end
+
+ factory :invoice do |i|
+ i.date Date.today
+ i.total_amount { rand(10000) }
+ i.association :company
+ end
end
View
6 spec/models/hour_log_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe HourLog do
- let (:company) { Factory(:company) }
- let (:hour_log) { Factory(:hour_log, :company => company) }
+ let (:company) { create(:company) }
+ let (:hour_log) { create(:hour_log, :company => company) }
describe "#newest?" do
it "returns true when newest" do
@@ -10,7 +10,7 @@
end
it "returns false when not newest" do
- other_hour_log = Factory(:hour_log, :company => hour_log.company, :date => hour_log.date + 1.days)
+ other_hour_log = create(:hour_log, :company => hour_log.company, :date => hour_log.date + 1.days)
hour_log.newest?.should == false
end
end
View
18 spec/models/time_entry_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe TimeEntry do
- let (:stub_time_entry) { Factory.stub(:time_entry) }
- let (:time_entry) { Factory(:time_entry) }
+ let (:stub_time_entry) { build_stubbed(:time_entry) }
+ let (:time_entry) { create(:time_entry) }
describe "#can_submit?" do
['created', 'rejected'].each do |status|
@@ -70,7 +70,7 @@
describe "as admin" do
['created', 'rejected'].each do |status|
it "returns true for time entries with status '#{status}'" do
- User.current = Factory(:user, :role => 'admin')
+ User.current = create(:user, :role => 'admin')
stub_time_entry.status = status
stub_time_entry.can_approve?.should be_true
@@ -98,7 +98,7 @@
describe "as admin" do
['created', 'rejected'].each do |status|
it "returns true for time entries with status '#{status}'" do
- User.current = Factory(:user, :role => 'admin')
+ User.current = create(:user, :role => 'admin')
stub_time_entry.status = status
stub_time_entry.can_hide?.should be_true
@@ -118,11 +118,11 @@
end
describe "#save" do
- let (:time_entry) { Factory(:time_entry, :date => '2012-01-01', :user => user, :company => company, :hours => 1.25, :description => 'My original description') }
- let (:company) { Factory(:company) }
- let (:other_company) { Factory(:company) }
- let (:user) { Factory(:user) }
- let (:other_user) { Factory(:user) }
+ let (:time_entry) { create(:time_entry, :date => '2012-01-01', :user => user, :company => company, :hours => 1.25, :description => 'My original description') }
+ let (:company) { create(:company) }
+ let (:other_company) { create(:company) }
+ let (:user) { create(:user) }
+ let (:other_user) { create(:user) }
context "new record" do
it "sets public_user equal to user" do
View
1  spec/spec_helper.rb
@@ -41,6 +41,7 @@
config.include AuthenticationHelpers
config.include RSpec::ViewHelper, :type => :view
+ config.include FactoryGirl::Syntax::Methods
# reset current user for each request
config.before :each do
View
4 spec/views/companies/index.html.haml_spec.rb
@@ -2,12 +2,12 @@
describe "companies/index" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
let (:companies) do
companies = []
2.times do
- companies << Factory.stub(:company)
+ companies << build_stubbed(:company)
end
companies
View
6 spec/views/companies/show.html.haml_spec.rb
@@ -2,9 +2,9 @@
describe "companies/show" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'admin') }
- let (:company) { Factory.stub(:company) }
- let (:users) { 3.times.inject([]) { |array| array << Factory.stub(:user, :company => company) } }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
+ let (:company) { build_stubbed(:company) }
+ let (:users) { 3.times.inject([]) { |array| array << build_stubbed(:user, :company => company) } }
before(:each) do
company.stub(:users) { users }
View
8 spec/views/hour_logs/index.html.haml_spec.rb
@@ -7,7 +7,7 @@
hour_logs = []
3.times do
- hour_logs << Factory.stub(:hour_log)
+ hour_logs << build_stubbed(:hour_log)
end
hour_logs
@@ -17,7 +17,7 @@
companies = []
2.times do
- companies << Factory.stub(:company)
+ companies << build_stubbed(:company)
end
companies
@@ -32,7 +32,7 @@
end
context 'as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
it "lists all the hour logs" do
hour_logs.each do |h|
@@ -56,7 +56,7 @@
end
context 'as admin' do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
it "lists all the hour logs" do
hour_logs.each do |h|
View
14 spec/views/hour_logs/new.html.haml_spec.rb
@@ -3,13 +3,13 @@
describe "hour_logs/new" do
subject { rendered }
- let (:public_user) { Factory.stub :user }
- let (:company) { Factory.stub :company }
+ let (:public_user) { build_stubbed :user }
+ let (:company) { build_stubbed :company }
let (:approved_time_entries) do
approved = []
2.times do
- approved << Factory.stub(:time_entry, :public_user => public_user, :public_company => company, :status => 'approved')
+ approved << build_stubbed(:time_entry, :public_user => public_user, :public_company => company, :status => 'approved')
end
approved
@@ -19,7 +19,7 @@
hidden = []
2.times do
- hidden << Factory.stub(:time_entry, :public_user => public_user, :public_company => company, :status => 'hidden')
+ hidden << build_stubbed(:time_entry, :public_user => public_user, :public_company => company, :status => 'hidden')
end
hidden
@@ -29,7 +29,7 @@
submitted = []
2.times do
- submitted << Factory.stub(:time_entry, :public_user => public_user, :public_company => company, :status => 'submitted')
+ submitted << build_stubbed(:time_entry, :public_user => public_user, :public_company => company, :status => 'submitted')
end
submitted
@@ -47,7 +47,7 @@
end
context "logged in as client" do
- let (:user) { Factory.stub :user, :role => 'client', :company => company }
+ let (:user) { build_stubbed :user, :role => 'client', :company => company }
before do
render
@@ -70,7 +70,7 @@
end
context "logged in as admin" do
- let (:user) { Factory.stub :user, :role => 'admin' }
+ let (:user) { build_stubbed :user, :role => 'admin' }
before do
assign(:hidden_time_entries, hidden_time_entries)
View
14 spec/views/hour_logs/show.html.haml_spec.rb
@@ -3,15 +3,15 @@
describe "hour_logs/show" do
subject { rendered }
- let (:company) { Factory.stub :company }
- let (:public_user) { Factory.stub :user }
- let (:hour_log) { Factory.stub :hour_log, :company => company }
+ let (:company) { build_stubbed :company }
+ let (:public_user) { build_stubbed :user }
+ let (:hour_log) { build_stubbed :hour_log, :company => company }
let (:approved_time_entries) do
approved = []
10.times do
- approved << Factory.stub(:time_entry, :public_user => public_user, :company => company, :hour_log => hour_log, :status => 'approved')
+ approved << build_stubbed(:time_entry, :public_user => public_user, :company => company, :hour_log => hour_log, :status => 'approved')
end
approved
@@ -21,7 +21,7 @@
hidden = []
2.times do
- hidden << Factory.stub(:time_entry, :public_user => public_user, :company => company, :hour_log => hour_log, :status => 'hidden')
+ hidden << build_stubbed(:time_entry, :public_user => public_user, :company => company, :hour_log => hour_log, :status => 'hidden')
end
hidden
@@ -42,7 +42,7 @@
end
context "logged in as client" do
- let (:user) { Factory.stub :user, :role => 'client' }
+ let (:user) { build_stubbed :user, :role => 'client' }
it "lists all the approved time_entries" do
approved_time_entries.each do |t|
@@ -62,7 +62,7 @@
end
context "logged in as admin" do
- let (:user) { Factory.stub :user, :role => 'admin' }
+ let (:user) { build_stubbed :user, :role => 'admin' }
it "lists all the approved time_entries" do
approved_time_entries.each do |t|
View
6 spec/views/invoices/index.html.haml_spec.rb
@@ -6,7 +6,7 @@
invoices = []
2.times do
- invoices << Factory.stub(:invoice)
+ invoices << build_stubbed(:invoice)
end
invoices
@@ -20,7 +20,7 @@
end
context 'logged in as admin' do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
it "lists all the invoices" do
invoices.each do |invoice|
@@ -34,7 +34,7 @@
end
context 'logged in as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
it "lists all the invoices" do
invoices.each do |invoice|
View
6 spec/views/shared/_navigation_spec.rb
@@ -22,7 +22,7 @@
end
describe 'as client' do
- let (:user) { Factory.stub(:user, :role => 'client') }
+ let (:user) { build_stubbed(:user, :role => 'client') }
it { should_not have_link 'Companies' }
it { should_not have_link 'Users' }
@@ -32,7 +32,7 @@
end
describe 'as staff' do
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
it { should_not have_link 'Companies' }
it { should_not have_link 'Users' }
@@ -42,7 +42,7 @@
end
describe 'as admin' do
- let (:user) { Factory.stub(:user, :role => 'admin') }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
it { should have_link 'Hour Logs', :href => hour_logs_path }
it { should have_link 'Time Entries', :href => time_entries_path }
View
2  spec/views/shared/_prenav_spec.rb
@@ -21,7 +21,7 @@
['client', 'staff', 'admin'].each do |role|
describe "as #{role}" do
- let (:user) { Factory.stub(:user, :role => role) }
+ let (:user) { build_stubbed(:user, :role => role) }
it { should_not have_link 'Login' }
it { should have_link 'Logout', :href => destroy_user_session_path }
View
4 spec/views/time_entries/index.html.haml_spec.rb
@@ -2,12 +2,12 @@
describe "time_entries/index" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
let (:time_entries) do
time_entries = []
10.times do
- time_entries << Factory.stub(:time_entry, :user => user)
+ time_entries << build_stubbed(:time_entry, :user => user)
end
time_entries
View
6 spec/views/time_entries/new.html.haml_spec.rb
@@ -2,13 +2,13 @@
describe "time_entries/new" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'staff') }
- let (:time_entry) { Factory.build(:time_entry, :user => user) }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
+ let (:time_entry) { build(:time_entry, :user => user) }
let (:time_entries) do
time_entries = []
10.times do
- time_entries << Factory.stub(:time_entry, :user => user)
+ time_entries << build_stubbed(:time_entry, :user => user)
end
time_entries
View
2  spec/views/time_entries/upload.html.haml_spec.rb
@@ -2,7 +2,7 @@
describe "time_entries/upload" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'staff') }
+ let (:user) { build_stubbed(:user, :role => 'staff') }
before(:all) do
@data = TimeEntryImporter.read('spec/test_data/time_entries.csv')
View
2  spec/views/users/_destroy_confirm.html.haml_spec.rb
@@ -2,7 +2,7 @@
describe "users/_destroy_confirm" do
subject { rendered }
- let(:user) { Factory.stub(:user) }
+ let(:user) { build_stubbed(:user) }
before(:each) do
assign(:user, user)
View
4 spec/views/users/_form.html.haml_spec.rb
@@ -10,7 +10,7 @@
end
context "edit" do
- let(:user) { Factory.stub(:user) }
+ let(:user) { build_stubbed(:user) }
it { should have_selector "form[method='post'][action='#{user_path(user)}']" }
it { should have_selector "form input[type='submit']" }
@@ -18,7 +18,7 @@
end
context "new" do
- let(:user) { Factory.build(:user) }
+ let(:user) { build(:user) }
it { should have_selector "form[method='post'][action='#{users_path}']" }
it { should have_selector "form input[type='submit']" }
View
4 spec/views/users/index.html.haml_spec.rb
@@ -2,8 +2,8 @@
describe "users/index" do
subject { rendered }
- let (:user) { Factory.stub(:user, :role => 'admin') }
- let (:another_user) { Factory.stub(:user) }
+ let (:user) { build_stubbed(:user, :role => 'admin') }
+ let (:another_user) { build_stubbed(:user) }
let (:users) { [user, another_user] }
before(:each) do

No commit comments for this range

Something went wrong with that request. Please try again.