fixes #824
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
class TagAliasCorrectionsController < ApplicationController
|
class TagAliasCorrectionsController < ApplicationController
|
||||||
before_filter :moderator_only
|
before_filter :moderator_only
|
||||||
|
|
||||||
def new
|
|
||||||
@correction = TagAliasCorrection.new(params[:tag_alias_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@correction = TagAliasCorrection.new(params[:tag_alias_id])
|
@correction = TagAliasCorrection.new(params[:tag_alias_id])
|
||||||
|
|
||||||
@@ -13,7 +9,7 @@ class TagAliasCorrectionsController < ApplicationController
|
|||||||
flash[:notice] = "The fix has been queued and will be processed"
|
flash[:notice] = "The fix has been queued and will be processed"
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to tag_alias_correction_path(:id => params[:tag_alias_id])
|
redirect_to tag_alias_correction_path(:tag_alias_id => params[:tag_alias_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
17
app/controllers/tag_alias_requests_controller.rb
Normal file
17
app/controllers/tag_alias_requests_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
class TagAliasRequestsController < ApplicationController
|
||||||
|
before_filter :member_only
|
||||||
|
rescue_from TagAliasRequest::ValidationError, :with => :rescue_exception
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@tag_alias_request = TagAliasRequest.new(
|
||||||
|
params[:tag_alias_request][:antecedent_name],
|
||||||
|
params[:tag_alias_request][:consequent_name],
|
||||||
|
params[:tag_alias_request][:reason]
|
||||||
|
)
|
||||||
|
@tag_alias_request.create
|
||||||
|
redirect_to(forum_topic_path(@tag_alias_request.forum_topic))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
class TagAliasesController < ApplicationController
|
class TagAliasesController < ApplicationController
|
||||||
before_filter :admin_only, :only => [:approve, :destroy, :create]
|
before_filter :admin_only, :only => [:approve, :destroy, :new, :create]
|
||||||
respond_to :html, :xml, :json, :js
|
respond_to :html, :xml, :json, :js
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|||||||
17
app/controllers/tag_implication_requests_controller.rb
Normal file
17
app/controllers/tag_implication_requests_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
class TagImplicationRequestsController < ApplicationController
|
||||||
|
before_filter :member_only
|
||||||
|
rescue_from TagImplicationRequest::ValidationError, :with => :rescue_exception
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@tag_implication_request = TagImplicationRequest.new(
|
||||||
|
params[:tag_implication_request][:antecedent_name],
|
||||||
|
params[:tag_implication_request][:consequent_name],
|
||||||
|
params[:tag_implication_request][:reason]
|
||||||
|
)
|
||||||
|
@tag_implication_request.create
|
||||||
|
redirect_to(forum_topic_path(@tag_implication_request.forum_topic))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -143,10 +143,10 @@ protected
|
|||||||
when "moderator/dashboards"
|
when "moderator/dashboards"
|
||||||
/^\/moderator/
|
/^\/moderator/
|
||||||
|
|
||||||
when "tag_aliases", "tag_alias_corrections"
|
when "tag_aliases", "tag_alias_corrections", "tag_alias_requests"
|
||||||
/^\/tag_aliases/
|
/^\/tag_aliases/
|
||||||
|
|
||||||
when "tag_implications"
|
when "tag_implications", "tag_implication_requests"
|
||||||
/^\/tag_implications/
|
/^\/tag_implications/
|
||||||
|
|
||||||
when "wiki_pages", "wiki_page_versions"
|
when "wiki_pages", "wiki_page_versions"
|
||||||
|
|||||||
39
app/logical/tag_alias_request.rb
Normal file
39
app/logical/tag_alias_request.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
class TagAliasRequest
|
||||||
|
class ValidationError < Exception ; end
|
||||||
|
|
||||||
|
attr_reader :antecedent_name, :consequent_name, :reason, :tag_alias, :forum_topic
|
||||||
|
|
||||||
|
def initialize(antecedent_name, consequent_name, reason)
|
||||||
|
@antecedent_name = antecedent_name
|
||||||
|
@consequent_name = consequent_name
|
||||||
|
@reason = reason
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
TagAlias.transaction do
|
||||||
|
create_alias
|
||||||
|
create_forum_topic
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_alias
|
||||||
|
@tag_alias = TagAlias.create(:antecedent_name => antecedent_name, :consequent_name => consequent_name, :status => "pending")
|
||||||
|
if @tag_alias.errors.any?
|
||||||
|
raise ValidationError.new(@tag_alias.errors.full_messages.join("; "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_forum_topic
|
||||||
|
@forum_topic = ForumTopic.create(
|
||||||
|
:title => "Tag alias: #{antecedent_name} -> #{consequent_name}",
|
||||||
|
:original_post_attributes => {
|
||||||
|
:body => reason + "\n\n\"Link to alias\":/tag_aliases?search[id]=#{tag_alias.id}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if @forum_topic.errors.any?
|
||||||
|
raise ValidationError.new(@forum_topic.errors.full_messages.join("; "))
|
||||||
|
end
|
||||||
|
|
||||||
|
tag_alias.update_attribute(:forum_topic_id, @forum_topic.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
39
app/logical/tag_implication_request.rb
Normal file
39
app/logical/tag_implication_request.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
class TagImplicationRequest
|
||||||
|
class ValidationError < Exception ; end
|
||||||
|
|
||||||
|
attr_reader :antecedent_name, :consequent_name, :reason, :tag_implication, :forum_topic
|
||||||
|
|
||||||
|
def initialize(antecedent_name, consequent_name, reason)
|
||||||
|
@antecedent_name = antecedent_name
|
||||||
|
@consequent_name = consequent_name
|
||||||
|
@reason = reason
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
TagImplication.transaction do
|
||||||
|
create_implication
|
||||||
|
create_forum_topic
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_implication
|
||||||
|
@tag_implication = TagImplication.create(:antecedent_name => antecedent_name, :consequent_name => consequent_name, :status => "pending")
|
||||||
|
if @tag_implication.errors.any?
|
||||||
|
raise ValidationError.new(@tag_implication.errors.full_messages.join("; "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_forum_topic
|
||||||
|
@forum_topic = ForumTopic.create(
|
||||||
|
:title => "Tag implication: #{antecedent_name} -> #{consequent_name}",
|
||||||
|
:original_post_attributes => {
|
||||||
|
:body => reason + "\n\n\"Link to implication\":/tag_implications?search[id]=#{tag_implication.id}"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if @forum_topic.errors.any?
|
||||||
|
raise ValidationError.new(@forum_topic.errors.full_messages.join("; "))
|
||||||
|
end
|
||||||
|
|
||||||
|
tag_implication.update_attribute(:forum_topic_id, @forum_topic.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,10 +4,11 @@ class TagAlias < ActiveRecord::Base
|
|||||||
after_save :ensure_category_consistency
|
after_save :ensure_category_consistency
|
||||||
after_destroy :clear_all_cache
|
after_destroy :clear_all_cache
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
validates_presence_of :creator_id
|
validates_presence_of :creator_id, :antecedent_name, :consequent_name
|
||||||
validates_uniqueness_of :antecedent_name
|
validates_uniqueness_of :antecedent_name
|
||||||
validate :absence_of_transitive_relation
|
validate :absence_of_transitive_relation
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
|
belongs_to :forum_topic
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def name_matches(name)
|
def name_matches(name)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
after_save :update_descendant_names_for_parent
|
after_save :update_descendant_names_for_parent
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
validates_presence_of :creator_id
|
validates_presence_of :creator_id, :antecedent_name, :consequent_name
|
||||||
validates_uniqueness_of :antecedent_name, :scope => :consequent_name
|
validates_uniqueness_of :antecedent_name, :scope => :consequent_name
|
||||||
validate :absence_of_circular_relation
|
validate :absence_of_circular_relation
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
|
|
||||||
<p>You can try to fix this alias. This will clear the cache and re-save all posts associated with <strong><%= @correction.antecedent_name %></strong>.</p>
|
<p>You can try to fix this alias. This will clear the cache and re-save all posts associated with <strong><%= @correction.antecedent_name %></strong>.</p>
|
||||||
|
|
||||||
<%= form_tag(tag_alias_correction_path) do %>
|
<%= form_tag(tag_alias_correction_path(:tag_alias_id => @correction.tag_alias_id)) do %>
|
||||||
<%= hidden_field "tag_alias_id", params[:tag_alias_id] %>
|
|
||||||
<%= submit_tag "Fix" %>
|
<%= submit_tag "Fix" %>
|
||||||
<%= submit_tag "Cancel" %>
|
<%= submit_tag "Cancel" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
30
app/views/tag_alias_requests/new.html.erb
Normal file
30
app/views/tag_alias_requests/new.html.erb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div id="c-tag-aliases">
|
||||||
|
<div id="a-request-new">
|
||||||
|
<h1>Tag Alias Request</h1>
|
||||||
|
|
||||||
|
<p>You can request a new tag alias be created. This will create a corresponding forum topic for community review.</p>
|
||||||
|
|
||||||
|
<%= form_tag(tag_alias_request_path, :class => "simple_form") do %>
|
||||||
|
<div class="input">
|
||||||
|
<label>Antecedent</label>
|
||||||
|
<%= text_field "tag_alias_request", "antecedent_name" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label>Consequent</label>
|
||||||
|
<%= text_field "tag_alias_request", "consequent_name" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label>Reason</label>
|
||||||
|
<%= text_area "tag_alias_request", "reason" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<%= submit_tag "Submit" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render "tag_aliases/secondary_links" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tag_aliases_path %></li>
|
<li><%= link_to "Listing", tag_aliases_path %></li>
|
||||||
<li><%= link_to "New", new_tag_alias_path %></li>
|
<% if CurrentUser.is_admin? %>
|
||||||
|
<li><%= link_to "New", new_tag_alias_path %></li>
|
||||||
|
<% else %>
|
||||||
|
<li><%= link_to "Request", new_tag_alias_request_path %></li>
|
||||||
|
<% end %>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %></li>
|
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %></li>
|
||||||
</menu>
|
</menu>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
30
app/views/tag_implication_requests/new.html.erb
Normal file
30
app/views/tag_implication_requests/new.html.erb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div id="c-tag-implications">
|
||||||
|
<div id="a-request-new">
|
||||||
|
<h1>Tag Implication Request</h1>
|
||||||
|
|
||||||
|
<p>You can request a new tag implication be created. This will create a corresponding forum topic for community review.</p>
|
||||||
|
|
||||||
|
<%= form_tag(tag_implication_request_path, :class => "simple_form") do %>
|
||||||
|
<div class="input">
|
||||||
|
<label>Antecedent</label>
|
||||||
|
<%= text_field "tag_implication_request", "antecedent_name" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label>Consequent</label>
|
||||||
|
<%= text_field "tag_implication_request", "consequent_name" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<label>Reason</label>
|
||||||
|
<%= text_area "tag_implication_request", "reason" %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="input">
|
||||||
|
<%= submit_tag "Submit" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render "tag_implications/secondary_links" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tag_implications_path %></li>
|
<li><%= link_to "Listing", tag_implications_path %></li>
|
||||||
<li><%= link_to "New", new_tag_implication_path %></li>
|
<% if CurrentUser.is_admin? %>
|
||||||
|
<li><%= link_to "New", new_tag_implication_path %></li>
|
||||||
|
<% else %>
|
||||||
|
<li><%= link_to "Request", new_tag_implication_request_path %></li>
|
||||||
|
<% end %>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %></li>
|
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %></li>
|
||||||
</menu>
|
</menu>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -167,11 +167,13 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
resource :tag_alias_correction, :only => [:new, :create, :show]
|
resource :tag_alias_correction, :only => [:new, :create, :show]
|
||||||
|
resource :tag_alias_request, :only => [:new, :create]
|
||||||
resources :tag_implications do
|
resources :tag_implications do
|
||||||
member do
|
member do
|
||||||
post :approve
|
post :approve
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resource :tag_implication_request, :only => [:new, :create]
|
||||||
resources :tag_subscriptions do
|
resources :tag_subscriptions do
|
||||||
member do
|
member do
|
||||||
get :posts
|
get :posts
|
||||||
|
|||||||
33
test/functional/tag_alias_corrections_controller_test.rb
Normal file
33
test/functional/tag_alias_corrections_controller_test.rb
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TagAliasCorrectionsControllerTest < ActionController::TestCase
|
||||||
|
context "The tag alias correction controller" do
|
||||||
|
setup do
|
||||||
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
|
CurrentUser.user = @admin
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
context "show action" do
|
||||||
|
should "render" do
|
||||||
|
get :show, {:tag_alias_id => @tag_alias.id}, {:user => @admin.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "create action" do
|
||||||
|
should "render" do
|
||||||
|
post :create, {:tag_alias_id => @tag_alias.id, :commit => "Fix"}, {:user => @admin.id}
|
||||||
|
assert_redirected_to(tag_alias_correction_path(:tag_alias_id => @tag_alias.id))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
34
test/functional/tag_alias_requests_controller_test.rb
Normal file
34
test/functional/tag_alias_requests_controller_test.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TagAliasRequestsControllerTest < ActionController::TestCase
|
||||||
|
context "The tag alias request controller" do
|
||||||
|
setup do
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
context "new action" do
|
||||||
|
should "render" do
|
||||||
|
get :new, {}, {:user => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "create action" do
|
||||||
|
should "render" do
|
||||||
|
assert_difference("ForumTopic.count", 1) do
|
||||||
|
post :create, {:tag_alias_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc"}}, {:user => @user.id}
|
||||||
|
end
|
||||||
|
assert_redirected_to(forum_topic_path(ForumTopic.last))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
34
test/functional/tag_implication_requests_controller.rb
Normal file
34
test/functional/tag_implication_requests_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TagImplicationRequestsControllerTest < ActionController::TestCase
|
||||||
|
context "The tag implication request controller" do
|
||||||
|
setup do
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
context "new action" do
|
||||||
|
should "render" do
|
||||||
|
get :new, {}, {:user => @user.id}
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "create action" do
|
||||||
|
should "render" do
|
||||||
|
assert_difference("ForumTopic.count", 1) do
|
||||||
|
post :create, {:tag_implication_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc"}}, {:user => @user.id}
|
||||||
|
end
|
||||||
|
assert_redirected_to(forum_topic_path(ForumTopic.last))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TagImplicationsControllerTest < ActionController::TestCase
|
class TagImplicationsControllerTest < ActionController::TestCase
|
||||||
context "The tag implicationes controller" do
|
context "The tag implications controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = FactoryGirl.create(:admin_user)
|
@user = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TagAliasTest < ActiveSupport::TestCase
|
class TagAliasCorrectionTest < ActiveSupport::TestCase
|
||||||
context "A tag alias" do
|
context "A tag alias correction" do
|
||||||
setup do
|
setup do
|
||||||
@mod = FactoryGirl.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @mod
|
CurrentUser.user = @mod
|
||||||
|
|||||||
44
test/unit/tag_alias_request_test.rb
Normal file
44
test/unit/tag_alias_request_test.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TagAliasRequestTest < ActiveSupport::TestCase
|
||||||
|
context "A tag alias request" do
|
||||||
|
setup do
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
should "raise an exception if invalid" do
|
||||||
|
assert_raises(TagAliasRequest::ValidationError) do
|
||||||
|
TagAliasRequest.new("", "", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a tag alias" do
|
||||||
|
assert_difference("TagAlias.count", 1) do
|
||||||
|
TagAliasRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
assert_equal("pending", TagAlias.last.status)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a forum topic" do
|
||||||
|
assert_difference("ForumTopic.count", 1) do
|
||||||
|
TagAliasRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a forum post" do
|
||||||
|
assert_difference("ForumPost.count", 1) do
|
||||||
|
TagAliasRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
44
test/unit/tag_implication_request_test.rb
Normal file
44
test/unit/tag_implication_request_test.rb
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class TagImplicationRequestTest < ActiveSupport::TestCase
|
||||||
|
context "A tag implication request" do
|
||||||
|
setup do
|
||||||
|
@user = FactoryGirl.create(:user)
|
||||||
|
CurrentUser.user = @user
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
Delayed::Worker.delay_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
MEMCACHE.flush_all
|
||||||
|
CurrentUser.user = nil
|
||||||
|
CurrentUser.ip_addr = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
should "raise an exception if invalid" do
|
||||||
|
assert_raises(TagImplicationRequest::ValidationError) do
|
||||||
|
TagImplicationRequest.new("", "", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a tag implication" do
|
||||||
|
assert_difference("TagImplication.count", 1) do
|
||||||
|
TagImplicationRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
assert_equal("pending", TagImplication.last.status)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a forum topic" do
|
||||||
|
assert_difference("ForumTopic.count", 1) do
|
||||||
|
TagImplicationRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a forum post" do
|
||||||
|
assert_difference("ForumPost.count", 1) do
|
||||||
|
TagImplicationRequest.new("aaa", "bbb", "reason").create
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user