mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-06 04:40:18 +01:00
Fix #592 be able to set default tags for a project. Default tags can now be specified when creating or editing a project, and they will be applied to any new todos created in that project.
This commit is contained in:
parent
3d3b658763
commit
42bea2490b
8 changed files with 122 additions and 13 deletions
21
spec/controllers/projects_controller_spec.rb
Normal file
21
spec/controllers/projects_controller_spec.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe ProjectsController do
|
||||
it "should save default tags" do
|
||||
project = Project.new
|
||||
|
||||
projects = mock(:project_list, :build => project,
|
||||
:active => mock(:meh, :count => 0), :size => 0)
|
||||
|
||||
user = mock_model(User, :projects => projects, :prefs => {},
|
||||
:contexts => mock(:context_list, :find => []))
|
||||
controller.stub!(:current_user).and_return(user)
|
||||
controller.stub!(:login_required).and_return(true)
|
||||
controller.stub!(:set_time_zone).and_return(true)
|
||||
controller.stub!(:mobile?).and_return(true)
|
||||
|
||||
get 'create', :project => {:name => "fooproject", :default_tags => "a,b"}
|
||||
|
||||
project.default_tags.should == 'a,b'
|
||||
end
|
||||
end
|
||||
41
spec/controllers/todos_controller_spec.rb
Normal file
41
spec/controllers/todos_controller_spec.rb
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe TodosController do
|
||||
it "should add project's default tags to todos" do
|
||||
p = mock_model(Project, :new_record_before_save? => false)
|
||||
p.should_receive(:default_tags).twice.and_return('abcd,efgh')
|
||||
todo = mock_model(Todo, :save => true, :update_state_from_project => nil,
|
||||
:tags => mock(:tag_list, :reload => nil))
|
||||
todo.stub!(:project_id=)
|
||||
todo.should_receive(:tag_with).with('abcd,efgh')
|
||||
projects = mock(:project_list, :find_or_create_by_name => p, :find => [p])
|
||||
todos = mock(:todo_list, :build => todo)
|
||||
|
||||
user = mock_model(User, :todos => todos, :projects => projects, :prefs => {},
|
||||
:contexts => mock(:context_list, :find => []))
|
||||
controller.stub!(:current_user).and_return(user)
|
||||
controller.stub!(:login_required).and_return(true)
|
||||
controller.stub!(:set_time_zone).and_return(true)
|
||||
controller.stub!(:mobile?).and_return(true)
|
||||
get 'create', :project_name => "zzzz", :tag_list => '', :todo => {}
|
||||
end
|
||||
|
||||
it "should append project's default tags to todos" do
|
||||
p = mock_model(Project, :new_record_before_save? => false)
|
||||
p.should_receive(:default_tags).twice.and_return('abcd,efgh')
|
||||
todo = mock_model(Todo, :save => true, :update_state_from_project => nil,
|
||||
:tags => mock(:tag_list, :reload => nil))
|
||||
todo.stub!(:project_id=)
|
||||
todo.should_receive(:tag_with).with('111,222,abcd,efgh')
|
||||
projects = mock(:project_list, :find_or_create_by_name => p, :find => [p])
|
||||
todos = mock(:todo_list, :build => todo)
|
||||
|
||||
user = mock_model(User, :todos => todos, :projects => projects, :prefs => {},
|
||||
:contexts => mock(:context_list, :find => []))
|
||||
controller.stub!(:current_user).and_return(user)
|
||||
controller.stub!(:login_required).and_return(true)
|
||||
controller.stub!(:set_time_zone).and_return(true)
|
||||
controller.stub!(:mobile?).and_return(true)
|
||||
get 'create', :project_name => "zzzz", :tag_list => '111,222', :todo => {}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue