diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 98e77093..3ee3b81b 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -7,7 +7,7 @@ describe ProjectsController do projects = mock(:project_list, :build => project, :active => mock(:meh, :count => 0), :size => 0) - user = mock_model(User, :projects => projects, :prefs => {}, + user = mock_model(User, :projects => projects, :prefs => mock(:locale => :en), :contexts => mock(:context_list, :find => [])) controller.stub!(:current_user).and_return(user) controller.stub!(:login_required).and_return(true) diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb index 6a230605..749e0b33 100644 --- a/spec/factories/factories.rb +++ b/spec/factories/factories.rb @@ -9,4 +9,13 @@ Factory.define :context do |c| c.sequence(:name) { |n| "testcontext#{n}" } c.hide false c.created_at Time.now.utc -end \ No newline at end of file +end + +Factory.define :project do |p| + p.sequence(:name) { |n| "testproject#{n}" } +end + +Factory.define :todo do |t| + t.sequence(:description) { |n| "testtodo#{n}" } + t.association :context +end diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 3f9a8278..5818defb 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -129,23 +129,27 @@ describe Todo do describe 'when update_state_from_project is called' do it "should unhide when project is active" do - project = mock_model(Project, :hidden? => false) - todo = Todo.new(:state => 'project_hidden', :project => project) + project = Factory.create(:project) + todo = Factory.create(:todo, :project => project, :state => 'project_hidden') + todo.hide! todo.should be_project_hidden todo.update_state_from_project todo.should be_active end it "should unhide when project is null" do - todo = Todo.new(:state => 'project_hidden', :project => nil) + todo = Factory.create(:todo, :project => nil) + todo.hide! todo.should be_project_hidden todo.update_state_from_project todo.should be_active end it "should hide when project is hidden" do - project = mock_model(Project, :hidden? => true) - todo = Todo.new(:state => 'active', :project => project) + project = Factory.create(:project) + project.hide! + todo = Factory.create(:todo, :project => project) + todo.should be_active todo.update_state_from_project todo.should be_project_hidden diff --git a/spec/views/todos/_toggle_notes.rhtml_spec.rb b/spec/views/todos/_toggle_notes.rhtml_spec.rb deleted file mode 100644 index 9553e74f..00000000 --- a/spec/views/todos/_toggle_notes.rhtml_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require File.dirname(__FILE__) + '/../../spec_helper' - -describe "/todos/_toggle_notes.rhtml" do - # include ControllerHelper - - before :each do - @item = mock_model(Todo, :notes => "this is a note") - @controller.template.stub!(:set_default_external!) - end - - it "should render" do - render :partial => "/todos/toggle_notes", :object => @item - response.should have_tag("div.todo_notes") - end - - it "should auto-link URLs" do - @item.stub!(:notes).and_return("http://www.google.com/") - render :partial => "/todos/toggle_notes", :object => @item - response.should have_tag("a[href=\"http://www.google.com/\"]") - end - - it "should auto-link embedded URLs" do - @item.stub!(:notes).and_return("this is cool: http://www.google.com/") - render :partial => "/todos/toggle_notes", :object => @item - response.should have_tag("a[href=\"http://www.google.com/\"]") - end - - it "should parse Textile URLs correctly" do - @item.stub!(:notes).and_return("\"link\":http://www.google.com/") - render :partial => "/todos/toggle_notes", :object => @item - response.should have_tag("a[href=\"http://www.google.com/\"]") - end -end