FIX: We should use category_id instead of category_name to perform

operations, now that the subcategory names are not unique.
This commit is contained in:
Robin Ward
2014-07-16 15:39:39 -04:00
parent 612dcb5805
commit fb8dda7f42
14 changed files with 51 additions and 48 deletions

View File

@ -719,8 +719,8 @@ describe TopicsController do
end
it 'triggers a change of category' do
Topic.any_instance.expects(:change_category).with('incredible').returns(true)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: 'incredible'
Topic.any_instance.expects(:change_category_to_id).with(123).returns(true)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category_id: 123
end
it "returns errors with invalid titles" do
@ -729,8 +729,8 @@ describe TopicsController do
end
it "returns errors with invalid categories" do
Topic.any_instance.expects(:change_category).returns(false)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: ''
Topic.any_instance.expects(:change_category_to_id).returns(false)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title
expect(response).not_to be_success
end
@ -740,8 +740,8 @@ describe TopicsController do
end
it "can add a category to an uncategorized topic" do
Topic.any_instance.expects(:change_category).with('incredible').returns(true)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category: 'incredible'
Topic.any_instance.expects(:change_category_to_id).with(456).returns(true)
xhr :put, :update, topic_id: @topic.id, slug: @topic.title, category_id: 456
response.should be_success
end
end