mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 03:00:12 +01:00
parent
556c68c2e6
commit
6014ce7a6f
4 changed files with 20 additions and 3 deletions
|
|
@ -14,6 +14,8 @@ class Project < ActiveRecord::Base
|
|||
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
|
||||
scope :with_namepart, lambda { |body| where("name LIKE ?", body + '%') }
|
||||
|
||||
before_create :set_last_reviewed_now
|
||||
|
||||
validates_presence_of :name
|
||||
validates_length_of :name, :maximum => 255
|
||||
validates_uniqueness_of :name, :scope => "user_id"
|
||||
|
|
@ -47,6 +49,10 @@ class Project < ActiveRecord::Base
|
|||
NullProject.new
|
||||
end
|
||||
|
||||
def set_last_reviewed_now
|
||||
self.last_reviewed = Time.now
|
||||
end
|
||||
|
||||
def hide_todos
|
||||
todos.each do |t|
|
||||
unless t.completed? || t.deferred?
|
||||
|
|
|
|||
|
|
@ -123,13 +123,13 @@ end
|
|||
Then /^the project "([^"]*)" should have (\d+) actions listed$/ do |project_name, count|
|
||||
project = @current_user.projects.where(:name => project_name).first
|
||||
expect(project).to_not be_nil
|
||||
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
||||
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']"
|
||||
expect(page.find(:xpath, xpath).text).to eq("#{project.name} (#{count} actions)")
|
||||
end
|
||||
|
||||
Then /^the project "([^"]*)" should have (\d+) deferred actions listed$/ do |project_name, deferred|
|
||||
project = @current_user.projects.where(:name => project_name).first
|
||||
expect(project).to_not be_nil
|
||||
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']//span[@class='needsreview']"
|
||||
xpath = "//div[@id='list-active-projects-container']//div[@id='project_#{project.id}']"
|
||||
expect(page.find(:xpath, xpath).text).to eq("#{project.name} (#{deferred} deferred actions)")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ class ProjectFromTodoTest < ActiveSupport::TestCase
|
|||
assert_equal project.default_context, todo.context
|
||||
end
|
||||
|
||||
def test_project_is_marked_as_reviewed
|
||||
todo = todos(:upgrade_rails)
|
||||
project = ProjectFromTodo.new(todo).create
|
||||
refute project.needs_review?(users(:admin_user))
|
||||
end
|
||||
|
||||
def test_invalid_project_from_invalid_todo
|
||||
todo = todos(:upgrade_rails)
|
||||
todo.description = ""
|
||||
|
|
|
|||
|
|
@ -89,7 +89,12 @@ class ProjectTest < ActiveSupport::TestCase
|
|||
|
||||
def test_review_completedprojects
|
||||
@timemachine.complete!
|
||||
assert !@timemachine.needs_review?(users(:admin_user))
|
||||
refute @timemachine.needs_review?(users(:admin_user))
|
||||
end
|
||||
|
||||
def test_new_project_is_reviewed
|
||||
project = users(:admin_user).projects.create!(:name => "test1")
|
||||
refute project.needs_review?(users(:admin_user))
|
||||
end
|
||||
|
||||
def test_complete_project
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue