Remove single alias/implication requests.
* Remove the single alias and implication request forms. From now on, bulk update requests are the only way to request aliases or implications. * Remove the forum topic ID field from the bulk update request form. Instead, to attach a BUR to an existing topic you go to the topic then you click "Request alias/implication" at the top of the page. * Update the bulk update request form to give better examples for the script format and to explain the difference between aliases and implications.
This commit is contained in:
@@ -5,7 +5,7 @@ class BulkUpdateRequestsController < ApplicationController
|
||||
before_action :load_bulk_update_request, :except => [:new, :create, :index]
|
||||
|
||||
def new
|
||||
@bulk_update_request = BulkUpdateRequest.new
|
||||
@bulk_update_request = BulkUpdateRequest.new(bur_params(:create))
|
||||
respond_with(@bulk_update_request)
|
||||
end
|
||||
|
||||
@@ -57,6 +57,6 @@ class BulkUpdateRequestsController < ApplicationController
|
||||
permitted_params += %i[title reason forum_topic_id] if context == :create
|
||||
permitted_params += %i[forum_topic_id forum_post_id] if context == :update && CurrentUser.is_admin?
|
||||
|
||||
params.require(:bulk_update_request).permit(permitted_params)
|
||||
params.fetch(:bulk_update_request, {}).permit(permitted_params)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
class TagAliasRequestsController < ApplicationController
|
||||
before_action :member_only
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
@tag_alias_request = TagAliasRequest.new(tar_params)
|
||||
@tag_alias_request.create
|
||||
|
||||
if @tag_alias_request.invalid?
|
||||
render :action => "new"
|
||||
else
|
||||
redirect_to forum_topic_path(@tag_alias_request.forum_topic)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tar_params
|
||||
params.require(:tag_alias_request).permit(:antecedent_name, :consequent_name, :reason, :skip_secondary_validations)
|
||||
end
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
class TagImplicationRequestsController < ApplicationController
|
||||
before_action :member_only
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
@tag_implication_request = TagImplicationRequest.new(tir_params)
|
||||
@tag_implication_request.create
|
||||
|
||||
if @tag_implication_request.invalid?
|
||||
render :action => "new"
|
||||
else
|
||||
redirect_to forum_topic_path(@tag_implication_request.forum_topic)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tir_params
|
||||
params.require(:tag_implication_request).permit(:antecedent_name, :consequent_name, :reason, :skip_secondary_validations)
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,17 @@
|
||||
module BulkUpdateRequestsHelper
|
||||
def bur_script_example
|
||||
<<~EOS
|
||||
create alias kitty -> cat
|
||||
remove alias kitty -> cat
|
||||
|
||||
create implication cat -> animal
|
||||
remove implication cat -> animal
|
||||
|
||||
mass update kitty -> cat
|
||||
category touhou -> copyright
|
||||
EOS
|
||||
end
|
||||
|
||||
def approved?(command, antecedent, consequent)
|
||||
return false unless CurrentUser.is_moderator?
|
||||
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
class TagAliasRequest
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_reader :antecedent_name, :consequent_name, :reason, :skip_secondary_validations, :tag_alias, :forum_topic
|
||||
|
||||
validate :validate_tag_alias
|
||||
validate :validate_forum_topic
|
||||
|
||||
def self.topic_title(antecedent_name, consequent_name)
|
||||
"Tag alias: #{antecedent_name} -> #{consequent_name}"
|
||||
end
|
||||
|
||||
def self.command_string(antecedent_name, consequent_name, id=nil)
|
||||
if id
|
||||
return "[ta:#{id}]"
|
||||
@@ -17,68 +6,4 @@ class TagAliasRequest
|
||||
|
||||
"create alias [[#{antecedent_name}]] -> [[#{consequent_name}]]"
|
||||
end
|
||||
|
||||
def initialize(attributes)
|
||||
@antecedent_name = attributes[:antecedent_name].strip.tr(" ", "_")
|
||||
@consequent_name = attributes[:consequent_name].strip.tr(" ", "_")
|
||||
@reason = attributes[:reason]
|
||||
self.skip_secondary_validations = attributes[:skip_secondary_validations]
|
||||
end
|
||||
|
||||
def create
|
||||
return false if invalid?
|
||||
|
||||
TagAlias.transaction do
|
||||
@tag_alias = build_tag_alias
|
||||
@tag_alias.save
|
||||
|
||||
@forum_topic = build_forum_topic(@tag_alias.id)
|
||||
@forum_topic.save
|
||||
|
||||
@tag_alias.forum_topic_id = @forum_topic.id
|
||||
@tag_alias.forum_post_id = @forum_topic.posts.first.id
|
||||
@tag_alias.save
|
||||
end
|
||||
end
|
||||
|
||||
def build_tag_alias
|
||||
x = TagAlias.new(
|
||||
:antecedent_name => antecedent_name,
|
||||
:consequent_name => consequent_name,
|
||||
:skip_secondary_validations => skip_secondary_validations
|
||||
)
|
||||
x.status = "pending"
|
||||
x
|
||||
end
|
||||
|
||||
def build_forum_topic(tag_alias_id)
|
||||
ForumTopic.new(
|
||||
:title => TagAliasRequest.topic_title(antecedent_name, consequent_name),
|
||||
:original_post_attributes => {
|
||||
:body => TagAliasRequest.command_string(antecedent_name, consequent_name, tag_alias_id) + "\n\nReason: #{reason}"
|
||||
},
|
||||
:category_id => 1
|
||||
)
|
||||
end
|
||||
|
||||
def validate_tag_alias
|
||||
ta = @tag_alias || build_tag_alias
|
||||
|
||||
if ta.invalid?
|
||||
self.errors.add(:base, ta.errors.full_messages.join("; "))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def validate_forum_topic
|
||||
ft = @forum_topic || build_forum_topic(nil)
|
||||
if ft.invalid?
|
||||
self.errors.add(:base, ft.errors.full_messages.join("; "))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def skip_secondary_validations=(v)
|
||||
@skip_secondary_validations = v.to_s.truthy?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
class TagImplicationRequest
|
||||
include ActiveModel::Validations
|
||||
|
||||
attr_reader :antecedent_name, :consequent_name, :reason, :tag_implication, :forum_topic, :skip_secondary_validations
|
||||
|
||||
validate :validate_tag_implication
|
||||
validate :validate_forum_topic
|
||||
|
||||
def self.topic_title(antecedent_name, consequent_name)
|
||||
"Tag implication: #{antecedent_name} -> #{consequent_name}"
|
||||
end
|
||||
|
||||
def self.command_string(antecedent_name, consequent_name, id=nil)
|
||||
if id
|
||||
return "[ti:#{id}]"
|
||||
@@ -17,68 +6,4 @@ class TagImplicationRequest
|
||||
|
||||
"create implication [[#{antecedent_name}]] -> [[#{consequent_name}]]"
|
||||
end
|
||||
|
||||
def initialize(attributes)
|
||||
@antecedent_name = attributes[:antecedent_name].strip.tr(" ", "_")
|
||||
@consequent_name = attributes[:consequent_name].strip.tr(" ", "_")
|
||||
@reason = attributes[:reason]
|
||||
self.skip_secondary_validations = attributes[:skip_secondary_validations]
|
||||
end
|
||||
|
||||
def create
|
||||
return false if invalid?
|
||||
|
||||
TagImplication.transaction do
|
||||
@tag_implication = build_tag_implication
|
||||
@tag_implication.save
|
||||
|
||||
@forum_topic = build_forum_topic(@tag_implication.id)
|
||||
@forum_topic.save
|
||||
|
||||
@tag_implication.forum_topic_id = @forum_topic.id
|
||||
@tag_implication.forum_post_id = @forum_topic.posts.first.id
|
||||
@tag_implication.save
|
||||
end
|
||||
end
|
||||
|
||||
def build_tag_implication
|
||||
x = TagImplication.new(
|
||||
:antecedent_name => antecedent_name,
|
||||
:consequent_name => consequent_name,
|
||||
:skip_secondary_validations => skip_secondary_validations
|
||||
)
|
||||
x.status = "pending"
|
||||
x
|
||||
end
|
||||
|
||||
def build_forum_topic(tag_implication_id)
|
||||
ForumTopic.new(
|
||||
:title => TagImplicationRequest.topic_title(antecedent_name, consequent_name),
|
||||
:original_post_attributes => {
|
||||
:body => TagImplicationRequest.command_string(antecedent_name, consequent_name, tag_implication_id) + "\n\nReason: #{reason}"
|
||||
},
|
||||
:category_id => 1
|
||||
)
|
||||
end
|
||||
|
||||
def validate_tag_implication
|
||||
ti = @tag_implication || build_tag_implication
|
||||
|
||||
if ti.invalid?
|
||||
self.errors.add(:base, ti.errors.full_messages.join("; "))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def validate_forum_topic
|
||||
ft = @forum_topic || build_forum_topic(nil)
|
||||
if ft.invalid?
|
||||
self.errors.add(:base, ft.errors.full_messages.join("; "))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def skip_secondary_validations=(v)
|
||||
@skip_secondary_validations = v.to_s.truthy?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class TagAlias < TagRelationship
|
||||
ForumUpdater.new(
|
||||
forum_topic,
|
||||
forum_post: post,
|
||||
expected_title: TagAliasRequest.topic_title(antecedent_name, consequent_name),
|
||||
expected_title: "Tag alias: #{antecedent_name} -> #{consequent_name}",
|
||||
skip_update: !TagRelationship::SUPPORT_HARD_CODED
|
||||
)
|
||||
end
|
||||
|
||||
@@ -202,7 +202,7 @@ class TagImplication < TagRelationship
|
||||
ForumUpdater.new(
|
||||
forum_topic,
|
||||
forum_post: post,
|
||||
expected_title: TagImplicationRequest.topic_title(antecedent_name, consequent_name),
|
||||
expected_title: "Tag implication: #{antecedent_name} -> #{consequent_name}",
|
||||
skip_update: !TagRelationship::SUPPORT_HARD_CODED
|
||||
)
|
||||
end
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
<%= simple_form_for(@bulk_update_request) do |f| %>
|
||||
<%= error_messages_for("bulk_update_request") %>
|
||||
|
||||
<% if @bulk_update_request.new_record? %>
|
||||
<%= f.input :title, :as => :string %>
|
||||
<% end %>
|
||||
<p>
|
||||
Request aliases or implications using the format shown below. An alias makes the first tag a
|
||||
synonym for the second tag. An implication makes the first tag automatically add the second tag.
|
||||
A mass update replaces the first tag with the second tag without making it a permanent alias.
|
||||
</p>
|
||||
|
||||
<div class="input">
|
||||
<label class="text optional" for="bulk_update_request_script">Script</label>
|
||||
<%= text_area :bulk_update_request, :script, :size => "50x10" %>
|
||||
<p><a href="#" id="script-help-link">Help</a></p>
|
||||
<ul class="hint" id="script-help" title="Bulk Update Request Help">
|
||||
<li>unalias aaa -> bbb</li>
|
||||
<li>unimply aaa -> bbb</li>
|
||||
<li>alias aaa -> bbb</li>
|
||||
<li>imply aaa -> bbb</li>
|
||||
<li>update aaa -> bbb</li>
|
||||
<li>category tag_name -> category_name</li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>
|
||||
<% if @bulk_update_request.new_record? && @bulk_update_request.forum_topic.present? %>
|
||||
This request will be attached to
|
||||
<%= link_to "topic ##{@bulk_update_request.forum_topic_id}: #{@bulk_update_request.forum_topic.title}" %>.
|
||||
<% elsif @bulk_update_request.new_record? && @bulk_update_request.forum_topic.blank? %>
|
||||
This request will create a new forum topic. To attach this request to an existing topic, find
|
||||
the forum topic and click "Request alias/implication" at the top of the page.
|
||||
|
||||
<%= f.input :title, label: "Forum Title", as: :string %>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<%= f.input :script, label: "Request", as: :text, placeholder: bur_script_example, input_html: { size: "50x15" } %>
|
||||
|
||||
<% if @bulk_update_request.new_record? %>
|
||||
<div class="input">
|
||||
@@ -35,25 +37,11 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @bulk_update_request.new_record? %>
|
||||
<%= f.input :forum_topic_id, :hint => " (optional)" %>
|
||||
<% elsif @bulk_update_request.persisted? && CurrentUser.is_admin? %>
|
||||
<% if @bulk_update_request.persisted? && CurrentUser.is_admin? %>
|
||||
<%= f.input :forum_topic_id %>
|
||||
<%= f.input :forum_post_id %>
|
||||
<% end %>
|
||||
|
||||
<%= f.button :submit, :value => "Submit" %>
|
||||
<%= f.submit value: "Submit" %>
|
||||
<%= dtext_preview_button "bulk_update_request", "reason" %>
|
||||
<% end %>
|
||||
|
||||
<%= content_for(:html_header) do %>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#script-help").hide();
|
||||
$("#script-help-link").click(function() {
|
||||
$("#script-help").dialog({width: "30em"});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
@@ -1,5 +1,5 @@
|
||||
<div id="c-bulk-update-requests">
|
||||
<div id="a-new">
|
||||
<div id="a-new" class="fixed-width-container">
|
||||
<h1>New Bulk Update Request</h1>
|
||||
|
||||
<%= render "form" %>
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<%= subnav_link_to "New", new_forum_topic_path %>
|
||||
<%= subnav_link_to "Request alias", new_tag_alias_request_path %>
|
||||
<%= subnav_link_to "Request implication", new_tag_implication_request_path %>
|
||||
<%= subnav_link_to "Request BUR", new_bulk_update_request_path %>
|
||||
<%= subnav_link_to "Mark all as read", mark_all_as_read_forum_topics_path, :method => :post, :"data-shortcut" => "shift+r" %>
|
||||
|
||||
<% if @forum_topic %>
|
||||
<%= subnav_link_to "Request alias/implication", new_bulk_update_request_path(bulk_update_request: { forum_topic_id: @forum_topic.id }) %>
|
||||
<% else %>
|
||||
<%= subnav_link_to "Request alias/implication", new_bulk_update_request_path %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= subnav_link_to "Search", search_forum_posts_path %>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= subnav_link_to "Listing", tag_aliases_path %>
|
||||
<%= subnav_link_to "MetaSearch", meta_searches_tags_path %>
|
||||
<%= subnav_link_to "Request alias", new_tag_alias_request_path %>
|
||||
<%= subnav_link_to "Request bulk update", new_bulk_update_request_path %>
|
||||
<%= subnav_link_to "Request alias", new_bulk_update_request_path %>
|
||||
<%= subnav_link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<%= subnav_link_to "Listing", tag_implications_path %>
|
||||
<%= subnav_link_to "MetaSearch", meta_searches_tags_path %>
|
||||
<%= subnav_link_to "Request implication", new_tag_implication_request_path %>
|
||||
<%= subnav_link_to "Request bulk update", new_bulk_update_request_path %>
|
||||
<%= subnav_link_to "Request implication", new_bulk_update_request_path %>
|
||||
<%= subnav_link_to "Help", wiki_pages_path(:title => "help:tag_implications") %>
|
||||
<% end %>
|
||||
|
||||
@@ -267,13 +267,11 @@ Rails.application.routes.draw do
|
||||
post :approve
|
||||
end
|
||||
end
|
||||
resource :tag_alias_request, :only => [:new, :create]
|
||||
resources :tag_implications do
|
||||
member do
|
||||
post :approve
|
||||
end
|
||||
end
|
||||
resource :tag_implication_request, :only => [:new, :create]
|
||||
resources :uploads do
|
||||
collection do
|
||||
post :preprocess
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagAliasRequestsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The tag alias request controller" do
|
||||
setup do
|
||||
@user = create(:user)
|
||||
end
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get_auth new_tag_alias_request_path, @user
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
post_auth tag_alias_request_path, @user, params: {:tag_alias_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}}
|
||||
end
|
||||
assert_redirected_to(forum_topic_path(ForumTopic.last))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,43 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagImplicationRequestsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The tag implication request controller" do
|
||||
setup do
|
||||
travel_to(1.month.ago) do
|
||||
@user = create(:user)
|
||||
end
|
||||
end
|
||||
|
||||
context "new action" do
|
||||
should "render" do
|
||||
get_auth new_tag_implication_request_path, @user
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "create forum post" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
post_auth tag_implication_request_path, @user, params: {:tag_implication_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}}
|
||||
end
|
||||
assert_redirected_to(forum_topic_path(ForumTopic.last))
|
||||
end
|
||||
|
||||
should "create a pending implication" do
|
||||
params = {
|
||||
:tag_implication_request => {
|
||||
:antecedent_name => "foo",
|
||||
:consequent_name => "bar",
|
||||
:reason => "blah blah",
|
||||
:skip_secondary_validations => true
|
||||
}
|
||||
}
|
||||
|
||||
assert_difference("ForumTopic.count") do
|
||||
post_auth tag_implication_request_path, @user, params: params
|
||||
end
|
||||
assert_redirected_to(forum_topic_path(ForumTopic.last))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,56 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagAliasRequestTest < ActiveSupport::TestCase
|
||||
context "A tag alias request" do
|
||||
setup do
|
||||
@user = FactoryBot.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "handle invalid attributes" do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "", :consequent_name => "", :reason => "reason", :skip_secondary_validations => true)
|
||||
tar.create
|
||||
assert(tar.invalid?)
|
||||
end
|
||||
|
||||
should "handle secondary validations" do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => false)
|
||||
tar.create
|
||||
assert(tar.invalid?)
|
||||
end
|
||||
|
||||
should "create a tag alias" do
|
||||
assert_difference("TagAlias.count", 1) do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tar.create
|
||||
end
|
||||
assert_equal("pending", TagAlias.last.status)
|
||||
end
|
||||
|
||||
should "create a forum topic" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tar.create
|
||||
end
|
||||
end
|
||||
|
||||
should "create a forum post" do
|
||||
assert_difference("ForumPost.count", 1) do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tar.create
|
||||
end
|
||||
end
|
||||
|
||||
should "save the forum post id" do
|
||||
tar = TagAliasRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tar.create
|
||||
assert_equal(tar.forum_topic.posts.first.id, tar.tag_alias.forum_post.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -204,7 +204,7 @@ class TagAliasTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@admin = FactoryBot.create(:admin_user)
|
||||
CurrentUser.scoped(@admin) do
|
||||
@topic = FactoryBot.create(:forum_topic, :title => TagAliasRequest.topic_title("aaa", "bbb"))
|
||||
@topic = FactoryBot.create(:forum_topic, :title => "Tag alias: aaa -> bbb")
|
||||
@post = FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => TagAliasRequest.command_string("aaa", "bbb"))
|
||||
@alias = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :forum_post => @post, :status => "pending")
|
||||
end
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagImplicationRequestTest < ActiveSupport::TestCase
|
||||
context "A tag implication request" do
|
||||
setup do
|
||||
@user = FactoryBot.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "handle invalid attributes" do
|
||||
tir = TagImplicationRequest.new(:antecedent_name => "", :consequent_name => "", :reason => "reason", :skip_secondary_validations => true)
|
||||
tir.create
|
||||
assert(tir.invalid?)
|
||||
end
|
||||
|
||||
should "handle secondary validations" do
|
||||
tir = TagImplicationRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => false)
|
||||
tir.create
|
||||
assert(tir.invalid?)
|
||||
end
|
||||
|
||||
should "create a tag implication" do
|
||||
assert_difference("TagImplication.count", 1) do
|
||||
tir = TagImplicationRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tir.create
|
||||
end
|
||||
assert_equal("pending", TagImplication.last.status)
|
||||
end
|
||||
|
||||
should "create a forum topic" do
|
||||
assert_difference("ForumTopic.count", 1) do
|
||||
tir = TagImplicationRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tir.create
|
||||
end
|
||||
end
|
||||
|
||||
should "create a forum post" do
|
||||
assert_difference("ForumPost.count", 1) do
|
||||
tir = TagImplicationRequest.new(:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "reason", :skip_secondary_validations => true)
|
||||
tir.create
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -264,7 +264,7 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
context "with an associated forum topic" do
|
||||
setup do
|
||||
@admin = FactoryBot.create(:admin_user)
|
||||
@topic = FactoryBot.create(:forum_topic, :title => TagImplicationRequest.topic_title("aaa", "bbb"))
|
||||
@topic = FactoryBot.create(:forum_topic, :title => "Tag implication: aaa -> bbb")
|
||||
@post = FactoryBot.create(:forum_post, topic_id: @topic.id, :body => TagImplicationRequest.command_string("aaa", "bbb"))
|
||||
@implication = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :forum_post => @post, :status => "pending")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user