rtt 0.0.0.47 → 0.0.0.48

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ class User < ActiveRecord::Base
3
+
4
+ BLANK_FIELD = ''
5
+ DEFAULT_NICK = 'Default user'
6
+
7
+ has_many :tasks
8
+ has_many :projects, :through => :tasks
9
+
10
+ def self.default
11
+ find_or_create_by_active(true)
12
+ end
13
+
14
+ def self.find_or_create_active
15
+ last_user = User.last
16
+ if last_user.present?
17
+ last_user.active = true
18
+ last_user.save
19
+ last_user
20
+ else
21
+ self.default
22
+ end
23
+ end
24
+
25
+ def activate
26
+ self.active = true
27
+ self.save
28
+ self
29
+ end
30
+
31
+ def deactivate
32
+ self.active = false
33
+ self.save
34
+ self
35
+ end
36
+
37
+ def full_name
38
+ "#{first_name.present? ? first_name : ''} #{last_name.present? ? last_name : ''}".strip
39
+ end
40
+
41
+ def full_name_and_nickname
42
+ "#{full_name.present? ? full_name : ''} #{full_name.present? ? "(#{nickname})" : nickname }".strip
43
+ end
44
+
45
+ def location
46
+ "#{self.city}#{self.city.present? && self.country.present? ? ', ' : ''}#{self.country}".strip
47
+ end
48
+ end
data/lib/rtt.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'thread'
3
- require 'rtt/boot'
4
- require 'active_support'
5
- %w( dm-core dm-validations dm-migrations highline/import).each { |lib| require lib }
6
- Dir[File.expand_path(File.join(File.dirname(__FILE__), 'rtt', '*'))].each { |lib| require lib; }
3
+ require File.expand_path 'lib/rtt/boot'
4
+ %w( active_support active_record highline/import).each { |lib| require lib }
5
+ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'extensions', '*'))].each { |lib| require lib; }
6
+ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'models', '*'))].each { |lib| require lib; }
7
+ Dir[File.expand_path(File.join(File.dirname(__FILE__), 'rtt', '*'))].each { |lib| require(lib) unless File.directory?(lib); }
7
8
 
8
9
  module Rtt
9
10
 
10
- VERSION = '1.0'
11
+ VERSION = '0.0.0.48'
11
12
 
12
13
  extend self
13
14
 
@@ -24,7 +25,7 @@ module Rtt
24
25
  end
25
26
 
26
27
  def current_user
27
- active = User.first :active => true
28
+ active = User.where(:active => true).first
28
29
  return active if active.present?
29
30
  User.find_or_create_active
30
31
  end
@@ -41,7 +42,7 @@ module Rtt
41
42
  user = if nickname.blank?
42
43
  current_user
43
44
  else
44
- User.first(:nickname => nickname)
45
+ User.where(:nickname => nickname).first
45
46
  end
46
47
  current_user.deactivate if current_user
47
48
  if user.blank? || configure
@@ -119,7 +120,7 @@ module Rtt
119
120
  raise ParametersNotMatchCommandSignatureError if project_name.blank?
120
121
  deactivate_current_project if current_project
121
122
  client = client(client_name) unless client_name.nil?
122
- project = Project.first_or_create :name => project_name
123
+ project = Project.find_or_create_by_name project_name
123
124
  project.client = client
124
125
  project.description = project_name
125
126
  unless project.active
@@ -150,21 +151,21 @@ module Rtt
150
151
  end
151
152
 
152
153
  def current_client
153
- Client.first :active => true
154
+ Client.where(:active => true).first
154
155
  end
155
156
 
156
157
  def current_project
157
- Project.first :active => true
158
+ Project.where(:active => true).first
158
159
  end
159
160
 
160
161
  def current_task
161
- Task.first :active => true
162
+ Task.where(:active => true).first
162
163
  end
163
164
 
164
165
  private
165
166
 
166
167
  def client(name)
167
- Client.first_or_create :name => name, :description => name
168
+ Client.find_or_create_by_name_and_description(name, name)
168
169
  end
169
170
 
170
171
  def deactivate_current_client
@@ -99,7 +99,14 @@ module Rtt
99
99
 
100
100
  def env_filters
101
101
  [ 'date', 'nickname', 'from', 'to', 'client', 'project' ].inject({}) do |filters, key|
102
- filters[key.to_sym] = env_variable(key) if env_variable(key).present?
102
+ if env_variable(key).present?
103
+ value = if key == 'date' || key == 'from' || key == 'to'
104
+ Date.parse(env_variable(key))
105
+ else
106
+ env_variable(key)
107
+ end
108
+ filters[key.to_sym] = value
109
+ end
103
110
  filters
104
111
  end
105
112
  end
@@ -152,7 +159,8 @@ module Rtt
152
159
  when ConfigureCommand
153
160
  case cmd.name.downcase
154
161
  when 'task'
155
- update_task(cmd.optional, env_filters)
162
+ name = cmd.next_optional
163
+ update_task(name, env_filters)
156
164
  when 'project'
157
165
  name = cmd.next_optional
158
166
  client = cmd.next_optional
@@ -6,7 +6,7 @@ module Rtt
6
6
  say "Please fill in your Client information"
7
7
  say "======================================"
8
8
  client = if name.blank?
9
- if (active_client = Client.first :active => true) && agree_or_enter("Want to modify current")
9
+ if (active_client = Client.where(:active => true).first) && agree_or_enter("Want to modify current")
10
10
  active_client
11
11
  else
12
12
  modify_name_or_create_model(:client, name)
@@ -29,7 +29,7 @@ module Rtt
29
29
  say "======================================="
30
30
  project = if name.blank?
31
31
  project_name = ask_or_default('Project name', "Project name:", name, /^\w+$/)
32
- Project.first_or_create(:name => project_name)
32
+ Project.find_or_create_by_name(project_name)
33
33
  else
34
34
  modify_name_or_create_model(:project, name)
35
35
  end
@@ -37,7 +37,7 @@ module Rtt
37
37
  client_found = false
38
38
  while !client_found
39
39
  client_name=(ask("Client name:") { |q| q.validate = /^\w+$/ }) if client_name.blank?
40
- client = Client.first :name => client_name
40
+ client = Client.where(:name => client_name).first
41
41
  if client.blank?
42
42
  say "A Client with this name is not registered."
43
43
  create_client = agree_or_enter("Want to created a Client with that name")
@@ -69,7 +69,7 @@ module Rtt
69
69
  if !skip_name || nickname.blank? || nickname == User::DEFAULT_NICK
70
70
  nickname = ask_or_default('nickname', 'Nickname (Required):', nickname, /^\w+$/)
71
71
  end
72
- existing = User.first :nickname => nickname
72
+ existing = User.where(:nickname => nickname).first
73
73
  first_name = ask_or_default('first name', "First name:", (existing.first_name if existing.present?))
74
74
  last_name = ask_or_default('last name', 'Last name:', (existing.last_name if existing.present?))
75
75
  company = ask_or_default('company', 'Company:', (existing.company if existing.present?))
@@ -91,7 +91,11 @@ module Rtt
91
91
 
92
92
  def configure_task(name = nil, conditions = {})
93
93
  conditions.merge!(name.blank? ? { :active => true } : { :name => name })
94
- task = name.blank? ? Task.first(conditions) : Task.first_or_create(conditions)
94
+ task = if name.blank?
95
+ Task.where(conditions).first
96
+ else
97
+ Task.where(conditions).first || Task.create(conditions)
98
+ end
95
99
  if task.present?
96
100
  say "Modify the task information (with name: #{task.name})"
97
101
  say "================================"
@@ -152,8 +156,8 @@ module Rtt
152
156
 
153
157
  def modify_name_or_create_model(model_name, name)
154
158
  class_name = model_name.to_s.capitalize
155
- klazz = "Rtt::#{class_name}".constantize
156
- instance = klazz.first :name => name
159
+ klazz = class_name.constantize
160
+ instance = klazz.where(:name => name).first
157
161
  if instance.present?
158
162
  instance.name=(ask("#{class_name} name:") { |q| q.validate = /^\w+$/ }) unless agree_or_enter('Want to keep current name')
159
163
  instance.save
@@ -5,17 +5,22 @@ module Rtt
5
5
  #
6
6
  #
7
7
  def query options = {}
8
- Task.all(rtt_build_conditions(options))
8
+ relation = Task.where(rtt_build_conditions(options))
9
+ relation = relation.where(table[:date].gt(Date.parse(options.delete(:from)))) if options[:from]
10
+ relation = relation.where(table[:date].lt(Date.parse(options.delete(:to)))) if options[:to]
11
+ relation
9
12
  end
10
13
 
11
14
  private
12
15
 
16
+ def table
17
+ @table ||= Task.arel_table
18
+ end
19
+
13
20
  def rtt_build_conditions options
14
21
  # default filter for today unless a date range is specified
15
22
  options[:date] = Date.today.strftime('%d-%m-%Y') if options[:to].blank? and options[:from].blank? and options[:date].blank?
16
- conditions = options
17
- conditions[:date.gte] = Date.parse(options.delete(:from)) if options[:from]
18
- conditions[:date.lte] = Date.parse(options.delete(:to)) if options[:to]
23
+ conditions = options.reject { |k,_| k.to_s == 'from' || k.to_s == 'to' }
19
24
  conditions[:date] = Date.parse(options.delete(:date)) if options[:date]
20
25
  conditions[:user] = { :nickname => options.delete(:nickname) } if options[:nickname]
21
26
  conditions[:project] = { :name => options.delete(:project) } if options[:project]
@@ -32,7 +32,7 @@ module Rtt
32
32
  end
33
33
 
34
34
  def custom_user_is_defined?
35
- current_user.present? && current_user.nickname != Rtt::User::DEFAULT_NICK
35
+ current_user.present? && current_user.nickname != User::DEFAULT_NICK
36
36
  end
37
37
 
38
38
  def fill_user_information(pdf)
@@ -89,7 +89,7 @@ module Rtt
89
89
  task = self.data[:rows].first
90
90
  return true if task.nil?
91
91
  return false if !(field == 'Client' || field == 'Project' || field == 'User')
92
- (REPORT_FIELD_OUTPUT[field].call(task) if task.present?) == eval("Rtt::#{field}::DEFAULT_NAME")
92
+ (REPORT_FIELD_OUTPUT[field].call(task) if task.present?) == eval("#{field}::DEFAULT_NAME")
93
93
  end
94
94
 
95
95
  #
@@ -101,8 +101,7 @@ module Rtt
101
101
  path = options.delete(extension)
102
102
  fixed_fields = extract_fixed_fields(options)
103
103
  fixed_fields_and_values = fixed_fields.inject({}) { |hash, key| hash[key] = options[key.downcase.to_sym]; hash }
104
- filter_options = options.merge({ :order => [:date.desc] })
105
- @data = { :fixed_fields => fixed_fields_and_values, :rows => query(filter_options) }
104
+ @data = { :fixed_fields => fixed_fields_and_values, :rows => query(options).order('date desc') }
106
105
  filename_path = full_path(path)
107
106
  case extension
108
107
  when :pdf
data/lib/rtt/storage.rb CHANGED
@@ -1,31 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'active_record'
4
+ require 'logger'
2
5
  module Rtt
3
6
  module Storage
4
7
 
5
- DEFAULT_STORAGE_NAME = :rtt
8
+ def database_file
9
+ File.expand_path(File.join(File.dirname(__FILE__), '..', '..') + config[:production][:database])
10
+ end
6
11
 
7
12
  def export filename
8
13
  require 'fileutils'
9
- FileUtils.cp(File.join( File.dirname(__FILE__), '..', '..', 'db', "#{DEFAULT_STORAGE_NAME.to_s}.sqlite3"), filename)
14
+ FileUtils.cp(database_file, filename)
10
15
  end
11
16
 
12
17
  def import filename
13
18
  require 'fileutils'
14
- FileUtils.cp(filename, File.join( File.dirname(__FILE__), '..', '..', 'db', "#{DEFAULT_STORAGE_NAME.to_s}.sqlite3"))
19
+ FileUtils.cp(filename, database_file)
15
20
  end
16
21
 
17
- def init(database = :rtt)
18
- DataMapper.setup(:default, {:adapter => "sqlite3", :database => File.join( File.dirname(__FILE__), '..', '..', 'db', "#{database.to_s}.sqlite3") })
19
- migrate unless missing_tables
20
- #DataObjects::Sqlite3.logger = DataMapper::Logger.new(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'log', 'sqlite3.log')), 0)
22
+ def config(env)
23
+ @config ||= YAML::load_file(File.join(File.dirname(__FILE__), '..', '..', 'db', 'config.yml'))[env.to_s]
21
24
  end
22
25
 
23
- def migrate #:nodoc:
24
- DataMapper.auto_migrate!
26
+ def init(env = :production)
27
+ ActiveRecord::Base.establish_connection(config(env))
28
+ ActiveRecord::Base.logger = Logger.new(File.open(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'log', 'database.log')), 'a'))
29
+ silence_stream(STDOUT) do
30
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'db', 'schema.rb')) unless tables_exists?
31
+ end
25
32
  end
26
33
 
27
- def missing_tables
28
- %W(rtt_projects rtt_users rtt_clients rtt_tasks).reject { |table| DataMapper.repository.storage_exists?(table) }.empty?
34
+ def tables_exists?
35
+ %w(projects clients tasks users).any? { |t| ActiveRecord::Base.connection.tables.include?(t) }
29
36
  end
30
37
  end
31
38
  end
data/rtt.gemspec CHANGED
@@ -1,40 +1,34 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{rtt}
5
- s.version = "0.0.0.47"
4
+ s.name = "rtt"
5
+ s.version = "0.0.0.48"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Marcelo Giorgi"]
9
- s.date = %q{2012-02-26}
10
- s.default_executable = %q{rtt}
11
- s.description = %q{RTT is a tool for tracking time}
12
- s.email = %q{marklazz.uy@gmail.com}
9
+ s.date = "2012-07-30"
10
+ s.description = "RTT is a tool for tracking time"
11
+ s.email = "marklazz.uy@gmail.com"
13
12
  s.executables = ["rtt"]
14
- s.extra_rdoc_files = ["LICENSE", "README.rdoc", "bin/rtt", "lib/rtt.rb", "lib/rtt/array_extensions.rb", "lib/rtt/boot.rb", "lib/rtt/client.rb", "lib/rtt/cmd_line_parser.rb", "lib/rtt/hash_extensions.rb", "lib/rtt/interactive_configurator.rb", "lib/rtt/project.rb", "lib/rtt/query_builder.rb", "lib/rtt/report_generator.rb", "lib/rtt/storage.rb", "lib/rtt/system_extensions.rb", "lib/rtt/task.rb", "lib/rtt/user.rb", "tasks/rtt.rake"]
15
- s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "USAGE.txt", "bin/rtt", "db/rtt.sqlite3", "db/test.sqlite3", "lib/rtt.rb", "lib/rtt/array_extensions.rb", "lib/rtt/boot.rb", "lib/rtt/client.rb", "lib/rtt/cmd_line_parser.rb", "lib/rtt/hash_extensions.rb", "lib/rtt/interactive_configurator.rb", "lib/rtt/project.rb", "lib/rtt/query_builder.rb", "lib/rtt/report_generator.rb", "lib/rtt/storage.rb", "lib/rtt/system_extensions.rb", "lib/rtt/task.rb", "lib/rtt/user.rb", "log/rtt.sqlite3", "rtt.gemspec", "spec/datamapper_spec_helper.rb", "spec/lib/rtt/task_spec.rb", "spec/lib/rtt_spec.rb", "tasks/rtt.rake"]
16
- s.homepage = %q{http://github.com/marklazz/rtt}
13
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc", "bin/rtt", "lib/extensions/array.rb", "lib/extensions/date.rb", "lib/extensions/hash.rb", "lib/extensions/kernel.rb", "lib/models/client.rb", "lib/models/project.rb", "lib/models/task.rb", "lib/models/user.rb", "lib/rtt.rb", "lib/rtt/boot.rb", "lib/rtt/cmd_line_parser.rb", "lib/rtt/interactive_configurator.rb", "lib/rtt/query_builder.rb", "lib/rtt/report_generator.rb", "lib/rtt/storage.rb", "tasks/rtt.rake"]
14
+ s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "USAGE.txt", "bin/rtt", "db/config.yml", "db/schema.rb", "db/test.sqlite3", "lib/extensions/array.rb", "lib/extensions/date.rb", "lib/extensions/hash.rb", "lib/extensions/kernel.rb", "lib/models/client.rb", "lib/models/project.rb", "lib/models/task.rb", "lib/models/user.rb", "lib/rtt.rb", "lib/rtt/boot.rb", "lib/rtt/cmd_line_parser.rb", "lib/rtt/interactive_configurator.rb", "lib/rtt/query_builder.rb", "lib/rtt/report_generator.rb", "lib/rtt/storage.rb", "spec/ar_spec_helper.rb", "spec/lib/models/task_spec.rb", "spec/lib/rtt_spec.rb", "tasks/rtt.rake", "Manifest", "rtt.gemspec"]
15
+ s.homepage = "http://github.com/marklazz/rtt"
17
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rtt", "--main", "README.rdoc"]
18
17
  s.require_paths = ["lib"]
19
- s.rubyforge_project = %q{rtt}
20
- s.rubygems_version = %q{1.6.2}
21
- s.summary = %q{RTT is a tool for tracking time}
18
+ s.rubyforge_project = "rtt"
19
+ s.rubygems_version = "1.8.23"
20
+ s.summary = "RTT is a tool for tracking time"
22
21
 
23
22
  if s.respond_to? :specification_version then
24
23
  s.specification_version = 3
25
24
 
26
25
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
26
  s.add_runtime_dependency(%q<highline>, ["= 1.5.2"])
28
- s.add_runtime_dependency(%q<activesupport>, ["<= 2.3.8", ">= 2.3.5"])
27
+ s.add_runtime_dependency(%q<activerecord>, ["= 3.2.6"])
28
+ s.add_runtime_dependency(%q<activesupport>, ["= 3.2.6"])
29
29
  s.add_runtime_dependency(%q<prawn>, ["= 0.8.4"])
30
- s.add_runtime_dependency(%q<dm-core>, ["= 1.0.0"])
31
- s.add_runtime_dependency(%q<dm-validations>, ["= 1.0.0"])
32
- s.add_runtime_dependency(%q<dm-migrations>, ["= 1.0.0"])
33
- s.add_runtime_dependency(%q<dm-sqlite-adapter>, ["= 1.0.0"])
34
30
  s.add_runtime_dependency(%q<rake>, ["= 0.8.2"])
35
- s.add_runtime_dependency(%q<addressable>, ["= 2.2.7"])
36
31
  s.add_runtime_dependency(%q<allison>, ["= 2.0.3"])
37
- s.add_runtime_dependency(%q<data_objects>, ["= 0.10.2"])
38
32
  s.add_runtime_dependency(%q<extlib>, ["= 0.9.15"])
39
33
  s.add_runtime_dependency(%q<json_pure>, ["= 1.6.5"])
40
34
  s.add_runtime_dependency(%q<prawn-core>, ["= 0.8.4"])
@@ -51,16 +45,11 @@ Gem::Specification.new do |s|
51
45
  s.add_runtime_dependency(%q<echoe>, ["= 4.5.6"])
52
46
  else
53
47
  s.add_dependency(%q<highline>, ["= 1.5.2"])
54
- s.add_dependency(%q<activesupport>, ["<= 2.3.8", ">= 2.3.5"])
48
+ s.add_dependency(%q<activerecord>, ["= 3.2.6"])
49
+ s.add_dependency(%q<activesupport>, ["= 3.2.6"])
55
50
  s.add_dependency(%q<prawn>, ["= 0.8.4"])
56
- s.add_dependency(%q<dm-core>, ["= 1.0.0"])
57
- s.add_dependency(%q<dm-validations>, ["= 1.0.0"])
58
- s.add_dependency(%q<dm-migrations>, ["= 1.0.0"])
59
- s.add_dependency(%q<dm-sqlite-adapter>, ["= 1.0.0"])
60
51
  s.add_dependency(%q<rake>, ["= 0.8.2"])
61
- s.add_dependency(%q<addressable>, ["= 2.2.7"])
62
52
  s.add_dependency(%q<allison>, ["= 2.0.3"])
63
- s.add_dependency(%q<data_objects>, ["= 0.10.2"])
64
53
  s.add_dependency(%q<extlib>, ["= 0.9.15"])
65
54
  s.add_dependency(%q<json_pure>, ["= 1.6.5"])
66
55
  s.add_dependency(%q<prawn-core>, ["= 0.8.4"])
@@ -78,16 +67,11 @@ Gem::Specification.new do |s|
78
67
  end
79
68
  else
80
69
  s.add_dependency(%q<highline>, ["= 1.5.2"])
81
- s.add_dependency(%q<activesupport>, ["<= 2.3.8", ">= 2.3.5"])
70
+ s.add_dependency(%q<activerecord>, ["= 3.2.6"])
71
+ s.add_dependency(%q<activesupport>, ["= 3.2.6"])
82
72
  s.add_dependency(%q<prawn>, ["= 0.8.4"])
83
- s.add_dependency(%q<dm-core>, ["= 1.0.0"])
84
- s.add_dependency(%q<dm-validations>, ["= 1.0.0"])
85
- s.add_dependency(%q<dm-migrations>, ["= 1.0.0"])
86
- s.add_dependency(%q<dm-sqlite-adapter>, ["= 1.0.0"])
87
73
  s.add_dependency(%q<rake>, ["= 0.8.2"])
88
- s.add_dependency(%q<addressable>, ["= 2.2.7"])
89
74
  s.add_dependency(%q<allison>, ["= 2.0.3"])
90
- s.add_dependency(%q<data_objects>, ["= 0.10.2"])
91
75
  s.add_dependency(%q<extlib>, ["= 0.9.15"])
92
76
  s.add_dependency(%q<json_pure>, ["= 1.6.5"])
93
77
  s.add_dependency(%q<prawn-core>, ["= 0.8.4"])
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require File.expand_path('lib/rtt')
4
+
5
+ def setup_testing_env
6
+ Rtt.init(:test)
7
+ User.destroy_all
8
+ Client.destroy_all
9
+ Project.destroy_all
10
+ Task.destroy_all
11
+ end
@@ -1,11 +1,10 @@
1
1
  require 'mocha'
2
- require File.join( File.dirname(__FILE__), '..', '..', 'datamapper_spec_helper')
2
+ require File.expand_path(File.join( File.dirname(__FILE__), '..', '..', 'ar_spec_helper'))
3
3
 
4
- describe Rtt::Task do
4
+ describe Task do
5
5
 
6
6
  before do
7
- Rtt.init(:test)
8
- Rtt.migrate
7
+ setup_testing_env
9
8
  @task_name = 'a_name'
10
9
  @now = Time.now
11
10
  end
@@ -16,7 +15,7 @@ describe Rtt::Task do
16
15
 
17
16
  before do
18
17
  start_at = Time.parse('May 10 13:45:00 2010', @now)
19
- @task = Rtt::Task.create :name => @task_name, :start_at => start_at.to_datetime, :date => start_at.to_date
18
+ @task = Task.create :name => @task_name, :start_at => start_at.to_datetime, :date => start_at.to_date
20
19
  end
21
20
 
22
21
  context 'task has end_at: 2010-05-10 14:15:01' do
@@ -58,12 +57,12 @@ describe Rtt::Task do
58
57
  end
59
58
 
60
59
  it 'should have 2 tasks with the same name' do
61
- Rtt::Task.all(:name => @task_name).length.should == 2
60
+ Task.where(:name => @task_name).count.should == 2
62
61
  end
63
62
 
64
63
  it 'should return 11h15m for 2010-05-10' do
65
64
  date = Time.parse('2010-05-10', @now).to_date
66
- task = Rtt::Task.first(:name => @task_name, :date => date)
65
+ task = Task.where(:name => @task_name, :date => date).first
67
66
  task.duration.should == '10h14m'
68
67
  end
69
68
 
@@ -82,18 +81,18 @@ describe Rtt::Task do
82
81
  end
83
82
 
84
83
  it 'should have 3 tasks with the same name' do
85
- Rtt::Task.all(:name => @task_name).length.should == 3
84
+ Task.where(:name => @task_name).count.should == 3
86
85
  end
87
86
 
88
87
  it 'should return 11h15m for 2010-05-11' do
89
88
  date = Time.parse('2010-05-11', @now).to_date
90
- task = Rtt::Task.first(:name => @task_name, :date => date)
89
+ task = Task.where(:name => @task_name, :date => date).first
91
90
  task.duration.should == '23h59m'
92
91
  end
93
92
 
94
93
  it 'should return 11h15m for 2010-05-10' do
95
94
  date = Time.parse('2010-05-10', @now).to_date
96
- task = Rtt::Task.first(:name => @task_name, :date => date)
95
+ task = Task.where(:name => @task_name, :date => date).first
97
96
  task.duration.should == '10h14m'
98
97
  end
99
98