added moderator/tag

This commit is contained in:
albert
2011-08-03 18:40:37 -04:00
parent 3e2b2e7418
commit 09d7bba90a
2 changed files with 34 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
module Moderator
class TagsController < ApplicationController
before_filter :moderator_only
rescue_from TagBatchChange::Error, :with => :error
def edit
end
@@ -10,5 +11,9 @@ module Moderator
tag_batch_change.execute
redirect_to edit_moderator_tag_path, :notice => "Posts updated"
end
def error
redirect_to edit_moderator_tag_path, :notice => "Error"
end
end
end

View File

@@ -0,0 +1,29 @@
require 'test_helper'
module Moderator
class TagsControllerTest < ActionController::TestCase
context "The tags controller" do
setup do
@user = Factory.create(:moderator_user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@post = Factory.create(:post)
end
should "render the edit action" do
get :edit, {}, {:user_id => @user.id}
assert_response :success
end
should "execute the update action" do
post :update, {:tag => {:predicate => "aaa", :consequent => "bbb"}}, {:user_id => @user.id}
assert_redirected_to edit_moderator_tag_path
end
should "fail gracefully if the update action fails" do
post :update, {:tag => {:predicate => "", :consequent => "bbb"}}, {:user_id => @user.id}
assert_redirected_to edit_moderator_tag_path
end
end
end
end