Commit a734f1d 1 parent 98dc171 commit a734f1d Copy full SHA for a734f1d
File tree 8 files changed +60
-2
lines changed
8 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ class TicketTimer < ActiveRecord::Base
4
4
belongs_to :ticket
5
5
has_one :project , through : :ticket
6
6
7
- scope :created_by , lambda { | user | where admin_user_id : user . id }
7
+ scope :created_by , -> ( u ) { where admin_user_id : u . id }
8
8
9
9
def elapsed_time
10
10
Time . zone . now - created_at . to_time
Original file line number Diff line number Diff line change 28
28
# The :test delivery method accumulates sent emails in the
29
29
# ActionMailer::Base.deliveries array.
30
30
config . action_mailer . delivery_method = :test
31
+ config . action_mailer . default_url_options = { :host => 'sprintapp.test' }
31
32
32
33
# Use SQL instead of Active Record's schema dumper when creating the test database.
33
34
# This is necessary if your schema can't be completely dumped by the schema dumper,
Original file line number Diff line number Diff line change
1
+ FactoryGirl . define do
2
+ factory :admin_user do
3
+ first_name { Faker ::Name . first_name }
4
+ last_name { Faker ::Name . last_name }
5
+ sequence ( :email ) { |n | "user#{ n } @example.com" }
6
+ password 'password'
7
+ password_confirmation 'password'
8
+ role { 'admin' }
9
+
10
+ factory :employee do
11
+ role { 'employee' }
12
+ end
13
+ end
14
+ end
Original file line number Diff line number Diff line change
1
+ FactoryGirl . define do
2
+ factory :project do
3
+ association :client
4
+ association :product_owner , factory : :admin_user
5
+ sequence ( :name ) { |n | "Project #{ n } " }
6
+ start_date { Date . today }
7
+ members { [ create ( :employee ) ] }
8
+ end
9
+ end
Original file line number Diff line number Diff line change 1
1
FactoryGirl . define do
2
2
factory :ticket_priority do
3
3
sequence ( :name ) { |n | "Priority: #{ n } " }
4
- weight { : normal }
4
+ weight { ' normal' }
5
5
end
6
6
end
Original file line number Diff line number Diff line change
1
+ FactoryGirl . define do
2
+ factory :ticket_timer do
3
+ ticket
4
+ admin_user
5
+ end
6
+ end
Original file line number Diff line number Diff line change
1
+ FactoryGirl . define do
2
+ factory :ticket do
3
+ project
4
+ ticket_priority
5
+ ticket_category
6
+ association :status , factory : :ticket_status
7
+
8
+ sequence ( :name ) { |n | "Ticket #{ n } " }
9
+ description { Faker ::Lorem . paragraph }
10
+ end
11
+ end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe TicketTimer do
4
+
5
+ it { should belong_to :admin_user }
6
+ it { should belong_to :ticket }
7
+ it { should have_one ( :project ) . through ( :ticket ) }
8
+
9
+ describe '#created_by' do
10
+ subject ( :timer ) { create ( :ticket_timer ) }
11
+
12
+ it 'should find timers belonging to this user' do
13
+ TicketTimer . created_by ( timer . admin_user ) . should include ( timer )
14
+ end
15
+ end
16
+
17
+ end
You can’t perform that action at this time.
0 commit comments