Commit a6be9ed5
Changed files (3)
config/routes.rb
@@ -26,7 +26,7 @@ Cake::Application.routes.draw do
resources :categories, :only => [:show]
# /tags
- match 'tags/:id' => 'tags#show', :method => 'GET'
+ resources :tags, :only => [:show]
# /search
get "search/index"
spec/controllers/tag_controller_spec.rb
@@ -0,0 +1,39 @@
+require "spec_helper"
+
+describe TagsController do
+ describe :show do
+ let(:tag) { "cake" }
+ let(:tagged_tutorial) { FactoryGirl.create(:tutorial) }
+ let(:untagged_tutorial) { FactoryGirl.create(:tutorial) }
+ let(:tagged_cake) { FactoryGirl.create(:creation) }
+ let(:untagged_cake) { FactoryGirl.create(:creation) }
+
+ before :each do
+ tagged_tutorial.tag_list.add(tag)
+ tagged_tutorial.save
+ tagged_cake.tag_list.add(tag)
+ tagged_cake.save
+ get :show, :id => tag
+ end
+
+ it "should return each tutorial that is tagged" do
+ assigns(:tutorials).should include(tagged_tutorial)
+ end
+
+ it "should not return tutorials that are not tagged" do
+ assigns(:tutorials).should_not include(untagged_tutorial)
+ end
+
+ it "should return each cake that is tagged" do
+ assigns(:creations).should include(tagged_cake)
+ end
+
+ it "should not return cakes that are not tagged" do
+ assigns(:creations).should_not include(untagged_cake)
+ end
+
+ it "should include the tag" do
+ assigns(:tag).should == tag
+ end
+ end
+end