added moderator/tag
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
before_filter :moderator_only
|
before_filter :moderator_only
|
||||||
|
rescue_from TagBatchChange::Error, :with => :error
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
@@ -10,5 +11,9 @@ module Moderator
|
|||||||
tag_batch_change.execute
|
tag_batch_change.execute
|
||||||
redirect_to edit_moderator_tag_path, :notice => "Posts updated"
|
redirect_to edit_moderator_tag_path, :notice => "Posts updated"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def error
|
||||||
|
redirect_to edit_moderator_tag_path, :notice => "Error"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
29
test/functional/moderator/tags_controller_test.rb
Normal file
29
test/functional/moderator/tags_controller_test.rb
Normal 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
|
||||||
Reference in New Issue
Block a user