diff --git a/Gemfile.lock b/Gemfile.lock index 6858f8b1a..c564232ab 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,7 +46,7 @@ GEM activesupport (= 3.1.0.rc1) activesupport (3.1.0.rc1) multi_json (~> 1.0) - arel (2.1.3) + arel (2.1.4) bcrypt-ruby (2.1.4) builder (3.0.0) daemons (1.1.4) @@ -54,9 +54,9 @@ GEM activesupport (~> 3.0) daemons erubis (2.7.0) - factory_girl (1.3.3) + factory_girl (2.0.2) haml (3.1.2) - hike (1.1.0) + hike (1.2.0) i18n (0.6.0) imagesize (0.1.1) mail (2.3.0) @@ -64,10 +64,10 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) mechanize (2.0.1) - net-http-digest_auth (~> 1.1, >= 1.1.1) + net-http-digest_auth (>= 1.1.1, ~> 1.1) net-http-persistent (~> 1.8) nokogiri (~> 1.4) - webrobots (~> 0.0, >= 0.0.9) + webrobots (>= 0.0.9, ~> 0.0) memcache-client (1.8.5) mime-types (1.16) mocha (0.9.12) @@ -76,15 +76,15 @@ GEM net-http-persistent (1.8) nokogiri (1.5.0) pg (0.11.0) - polyglot (0.3.1) - rack (1.3.1) + polyglot (0.3.2) + rack (1.3.2) rack-cache (1.0.2) rack (>= 0.4) rack-mount (0.8.1) rack (>= 1.0.0) rack-ssl (1.3.2) rack - rack-test (0.6.0) + rack-test (0.6.1) rack (>= 1.0) rails (3.1.0.rc1) actionmailer (= 3.1.0.rc1) @@ -109,16 +109,17 @@ GEM simplecov (0.4.2) simplecov-html (~> 0.4.4) simplecov-html (0.4.5) - sprockets (2.0.0.beta.10) - hike (~> 1.0) + sprockets (2.0.0.beta.12) + hike (~> 1.2) rack (~> 1.0) - tilt (!= 1.3.0, ~> 1.1) + tilt (~> 1.1, != 1.3.0) super_exception_notifier (3.0.13) actionmailer rake thor (0.14.6) tilt (1.3.2) - treetop (1.4.9) + treetop (1.4.10) + polyglot polyglot (>= 0.3.1) tzinfo (0.3.29) webrobots (0.0.10) diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 61f4a03d5..7e9f6df95 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -15,6 +15,7 @@ class TagAliasesController < ApplicationController def create @tag_alias = TagAlias.create(params[:tag_alias]) + @tag_alias.delay.process! respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id})) end diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index 91ace2f76..36f829baf 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -15,6 +15,7 @@ class TagImplicationsController < ApplicationController def create @tag_implication = TagImplication.create(params[:tag_implication]) + @tag_implication.delay.process! respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id})) end diff --git a/app/models/post.rb b/app/models/post.rb index bac987551..2c9807bcc 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -41,6 +41,7 @@ class Post < ActiveRecord::Base scope :available_for_moderation, lambda {where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])} scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])} scope :tag_match, lambda {|query| Post.tag_match_helper(query)} + scope :exact_tag_match, lambda {|query| Post.exact_tag_match_helper(query)} scope :positive, where("score > 1") scope :negative, where("score < -1") search_methods :tag_match @@ -501,6 +502,11 @@ class Post < ActiveRecord::Base relation end + + def exact_tag_match_helper(q) + arel = Post.scoped + add_tag_string_search_relation({:related => [q].flatten, :include => [], :exclude => []}, arel) + end def tag_match_helper(q) unless q.is_a?(Hash) diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index 4eefe90fb..786c87951 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -1,11 +1,7 @@ class TagAlias < ActiveRecord::Base - attr_accessor :creator_ip_addr - after_save :update_posts - after_save :clear_cache - after_save :clear_remote_cache + before_save :clear_all_cache after_save :update_cache - after_destroy :clear_cache - after_destroy :clear_remote_cache + after_destroy :clear_all_cache before_validation :initialize_creator, :on => :create validates_presence_of :creator_id validates_uniqueness_of :antecedent_name @@ -25,8 +21,17 @@ class TagAlias < ActiveRecord::Base alias_hash.values.flatten.uniq end + def process! + update_column(:status, "processing") + update_posts + update_column(:status, "active") + rescue Exception => e + update_column(:status, "error: #{e}") + end + def initialize_creator self.creator_id = CurrentUser.user.id + self.creator_ip_addr = CurrentUser.ip_addr end def antecedent_tag @@ -44,6 +49,11 @@ class TagAlias < ActiveRecord::Base false end end + + def clear_all_cache + clear_cache + clear_remote_cache + end def clear_cache Cache.delete("ta:#{Cache.sanitize(antecedent_name)}") @@ -60,13 +70,15 @@ class TagAlias < ActiveRecord::Base end def update_posts - Post.tag_match(antecedent_name).find_each do |post| + Post.exact_tag_match(antecedent_name).find_each do |post| escaped_antecedent_name = Regexp.escape(antecedent_name) fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip - post.update_attributes( - :tag_string => fixed_tags - ) + CurrentUser.scoped(creator, creator_ip_addr) do + post.update_attributes( + :tag_string => fixed_tags + ) + end end end end diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 17966d9e8..e0a497f87 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -1,43 +1,19 @@ class TagImplication < ActiveRecord::Base - before_save :clear_cache before_save :update_descendant_names after_save :update_descendant_names_for_parent - after_save :update_cache - after_save :update_posts - after_destroy :clear_cache - after_destroy :clear_remote_cache belongs_to :creator, :class_name => "User" before_validation :initialize_creator, :on => :create validates_presence_of :creator_id validates_uniqueness_of :antecedent_name, :scope => :consequent_name validate :absence_of_circular_relation - - module CacheMethods - def clear_cache - Cache.delete("ti:#{Cache.sanitize(antecedent_name)}") - @descendants = nil - end - - def clear_remote_cache - Danbooru.config.other_server_hosts.each do |server| - Net::HTTP.delete(URI.parse("http://#{server}/tag_implications/#{id}/cache")) - end - end - - def update_cache - descendant_names_array - true - end - end module DescendantMethods extend ActiveSupport::Concern module ClassMethods + # assumes names are normalized def with_descendants(names) - names + Cache.get_multi(names.flatten, "ti") do |name| - ([name] + where(["antecedent_name = ?", name]).all.map {|x| x.descendant_names_array}).flatten - end.values.flatten.uniq + (names + where("antecedent_name in (?)", names).map(&:descendant_names_array)).flatten.uniq end end @@ -55,9 +31,7 @@ class TagImplication < ActiveRecord::Base end def descendant_names_array - Cache.get("ti:#{Cache.sanitize(antecedent_name)}") do - descendant_names.split(/ /) - end + descendant_names.split(/ /) end def update_descendant_names @@ -93,12 +67,20 @@ class TagImplication < ActiveRecord::Base end end - include CacheMethods include DescendantMethods include ParentMethods def initialize_creator self.creator_id = CurrentUser.user.id + self.creator_ip_addr = CurrentUser.ip_addr + end + + def process! + update_column(:status, "processing") + update_posts + update_column(:status, "active") + rescue Exception => e + update_column(:status, "error: #{e}") end def absence_of_circular_relation @@ -110,12 +92,14 @@ class TagImplication < ActiveRecord::Base end def update_posts - Post.tag_match(antecedent_name).find_each do |post| + Post.exact_tag_match(antecedent_name).find_each do |post| escaped_antecedent_name = Regexp.escape(antecedent_name) fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{antecedent_name} #{descendant_names} ").strip - post.update_attributes( - :tag_string => fixed_tags - ) + CurrentUser.scoped(creator, creator_ip_addr) do + post.update_attributes( + :tag_string => fixed_tags + ) + end end end diff --git a/app/views/static/jquery_test.html.erb b/app/views/static/jquery_test.html.erb deleted file mode 100644 index 261abb8cc..000000000 --- a/app/views/static/jquery_test.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -
-
- Lorem ipsum -
- -
- Lorem ipsum -
-
- - \ No newline at end of file diff --git a/app/views/static/terms_of_service.html.erb b/app/views/static/terms_of_service.html.erb index f99b6f3de..675c9df42 100644 --- a/app/views/static/terms_of_service.html.erb +++ b/app/views/static/terms_of_service.html.erb @@ -1,6 +1,6 @@
-

Terms of Service

+

Terms of Service

By accessing the "<%= Danbooru.config.app_name %>" website ("Site") you agree to the following terms of service. If you do not agree to these terms, then please do not access the Site.

-
Post/Comment Limiting
+

Post/Comment Limiting

You cannot upload a post or comment during the first week of signing up.

After the initial period, you can post up to one comment an hour and a variable number of posts based on how many of your previous uploads were approved or deleted.

-
Prohibited Content
+

Prohibited Content

In addition, you may not use the Site to upload any of the following:

  • Non-anime: Photographs of American porn actresses, for example, are prohibited. Photographs of cosplayers, figures, or prominent figures in the industry are acceptable.
  • @@ -34,7 +34,7 @@
-

Copyright Infringement

+

Copyright Infringement

If you believe a post infringes upon your copyright, please send an email to the <%= mail_to Danbooru.config.contact_email, "webmaster", :encode => "hex" %> with the following pieces of information:

    @@ -45,14 +45,14 @@
-

Privacy Policy

+

Privacy Policy

The Site will not disclose the IP address, email address, password, or DMails of any user except to the staff.

The Site is allowed to make public everything else, including but not limited to: uploaded posts, favorited posts, comments, forum posts, wiki edits, and note edits.

-

Agreement

+

Agreement

By clicking on the "I Agree" link, you have read all the terms and have agreed to them.

<%= link_to("I Agree", params[:url] || "/", :onclick => "Cookie.put('tos', '1')") %> | <%= link_to("Cancel", "/") %>

diff --git a/db/development_structure.sql b/db/development_structure.sql index 91fbfe239..3317975ee 100644 --- a/db/development_structure.sql +++ b/db/development_structure.sql @@ -2250,7 +2250,9 @@ CREATE TABLE tag_aliases ( antecedent_name character varying(255) NOT NULL, consequent_name character varying(255) NOT NULL, creator_id integer NOT NULL, + creator_ip_addr inet NOT NULL, forum_topic_id integer, + status character varying(255) DEFAULT 'pending'::character varying NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone ); @@ -2285,7 +2287,9 @@ CREATE TABLE tag_implications ( consequent_name character varying(255) NOT NULL, descendant_names text NOT NULL, creator_id integer NOT NULL, + creator_ip_addr inet NOT NULL, forum_topic_id integer, + status character varying(255) DEFAULT 'pending'::character varying NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone ); diff --git a/db/migrate/20100211191709_create_tag_aliases.rb b/db/migrate/20100211191709_create_tag_aliases.rb index 329fa58b4..7b943c3e4 100644 --- a/db/migrate/20100211191709_create_tag_aliases.rb +++ b/db/migrate/20100211191709_create_tag_aliases.rb @@ -4,7 +4,9 @@ class CreateTagAliases < ActiveRecord::Migration t.column :antecedent_name, :string, :null => false t.column :consequent_name, :string, :null => false t.column :creator_id, :integer, :null => false + t.column :creator_ip_addr, :inet, :null => false t.column :forum_topic_id, :integer + t.column :status, :text, :null => false, :default => "pending" t.timestamps end diff --git a/db/migrate/20100211191716_create_tag_implications.rb b/db/migrate/20100211191716_create_tag_implications.rb index 8db2a6975..2e2e70ebb 100644 --- a/db/migrate/20100211191716_create_tag_implications.rb +++ b/db/migrate/20100211191716_create_tag_implications.rb @@ -5,7 +5,9 @@ class CreateTagImplications < ActiveRecord::Migration t.column :consequent_name, :string, :null => false t.column :descendant_names, :text, :null => false t.column :creator_id, :integer, :null => false + t.column :creator_ip_addr, :inet, :null => false t.column :forum_topic_id, :integer + t.column :status, :text, :null => false, :default => "pending" t.timestamps end diff --git a/script/testing/reset_post_1.sh b/script/testing/reset_post_1.sh deleted file mode 100755 index 176111dbb..000000000 --- a/script/testing/reset_post_1.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -psql -c "UPDATE posts SET is_flagged = false, is_pending = true, approver_id = null WHERE id = 1" danbooru2 -psql -c "DELETE FROM unapprovals" danbooru2 diff --git a/test/factories/tag_alias.rb b/test/factories/tag_alias.rb index aebf276b8..058108709 100644 --- a/test/factories/tag_alias.rb +++ b/test/factories/tag_alias.rb @@ -1,4 +1,10 @@ -Factory.define(:tag_alias) do |f| - f.antecedent_name "aaa" - f.consequent_name "bbb" +FactoryGirl.define do + factory :tag_alias do + antecedent_name "aaa" + consequent_name "bbb" + + after_create do |tag_alias| + tag_alias.process! + end + end end diff --git a/test/factories/tag_implication.rb b/test/factories/tag_implication.rb index 86b20a633..205c63a58 100644 --- a/test/factories/tag_implication.rb +++ b/test/factories/tag_implication.rb @@ -1,4 +1,10 @@ -Factory.define(:tag_implication) do |f| - f.antecedent_name "aaa" - f.consequent_name "bbb" +FactoryGirl.define do + factory :tag_implication do + antecedent_name "aaa" + consequent_name "bbb" + + after_create do |tag_implication| + tag_implication.process! + end + end end diff --git a/test/functional/tag_aliases_controller_test.rb b/test/functional/tag_aliases_controller_test.rb index 81977549f..ae7aa6fde 100644 --- a/test/functional/tag_aliases_controller_test.rb +++ b/test/functional/tag_aliases_controller_test.rb @@ -7,6 +7,7 @@ class TagAliasesControllerTest < ActionController::TestCase CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all + Delayed::Worker.delay_jobs = false end teardown do diff --git a/test/functional/tag_implications_controller_test.rb b/test/functional/tag_implications_controller_test.rb index 6fb742839..5278cef62 100644 --- a/test/functional/tag_implications_controller_test.rb +++ b/test/functional/tag_implications_controller_test.rb @@ -7,6 +7,7 @@ class TagImplicationsControllerTest < ActionController::TestCase CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all + Delayed::Worker.delay_jobs = false end teardown do diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index f38d92425..19713df88 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -1,4 +1,4 @@ -require_relative '../test_helper' +require 'test_helper' class TagAliasTest < ActiveSupport::TestCase context "A tag alias" do @@ -15,14 +15,14 @@ class TagAliasTest < ActiveSupport::TestCase end should "populate the creator information" do - ta = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal(CurrentUser.user.id, ta.creator_id) end should "convert a tag to its normalized version" do tag1 = Factory.create(:tag, :name => "aaa") tag2 = Factory.create(:tag, :name => "bbb") - ta = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") normalized_tags = TagAlias.to_aliased(["aaa", "ccc"]) assert_equal(["bbb", "ccc"], normalized_tags.sort) end @@ -30,7 +30,7 @@ class TagAliasTest < ActiveSupport::TestCase should "update the cache" do tag1 = Factory.create(:tag, :name => "aaa") tag2 = Factory.create(:tag, :name => "bbb") - ta = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal("bbb", MEMCACHE.get("ta:aaa")) ta.destroy assert_nil(MEMCACHE.get("ta:aaa")) @@ -42,7 +42,7 @@ class TagAliasTest < ActiveSupport::TestCase post2 = Factory.create(:post, :tag_string => "ccc ddd") assert_equal("aaa bbb", post1.tag_string) assert_equal("ccc ddd", post2.tag_string) - ta = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc") + ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc") post1.reload post2.reload assert_equal("ccc bbb", post1.tag_string) @@ -50,7 +50,7 @@ class TagAliasTest < ActiveSupport::TestCase end should "not validate for transitive relations" do - ta1 = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta1 = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_difference("TagAlias.count", 0) do ta3 = Factory.build(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ddd") ta3.save @@ -60,15 +60,15 @@ class TagAliasTest < ActiveSupport::TestCase end should "record the alias's creator in the tag history" do - user = Factory.create(:user) - p1 = nil - CurrentUser.scoped(user, "127.0.0.1") do - p1 = Factory.create(:post, :tag_string => "aaa bbb ccc") + uploader = Factory.create(:user) + post = nil + CurrentUser.scoped(uploader, "127.0.0.1") do + post = Factory.create(:post, :tag_string => "aaa bbb ccc") end - ta1 = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "xxx") - p1.reload - assert_not_equal(ta1.creator_id, p1.uploader_id) - assert_equal(ta1.creator_id, p1.versions.last.updater_id) + tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "xxx") + post.reload + assert_not_equal(tag_alias.creator_id, post.uploader_id) + assert_equal(tag_alias.creator_id, post.versions.last.updater_id) end end end diff --git a/test/unit/tag_implication_test.rb b/test/unit/tag_implication_test.rb index 84e10d5c2..2a61969e4 100644 --- a/test/unit/tag_implication_test.rb +++ b/test/unit/tag_implication_test.rb @@ -16,12 +16,12 @@ class TagImplicationTest < ActiveSupport::TestCase end should "populate the creator information" do - ti = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal(CurrentUser.user.id, ti.creator_id) end should "not validate when a circular relation is created" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti2 = Factory.build(:tag_implication, :antecedent_name => "bbb", :consequent_name => "aaa") ti2.save assert(ti2.errors.any?, "Tag implication should not have validated.") @@ -29,34 +29,18 @@ class TagImplicationTest < ActiveSupport::TestCase end should "not allow for duplicates" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti2 = Factory.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti2.save assert(ti2.errors.any?, "Tag implication should not have validated.") assert_equal("Antecedent name has already been taken", ti2.errors.full_messages.join("")) end - should "clear the cache upon saving" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - assert_equal(["bbb"], ti1.descendant_names_array) - assert_equal(["bbb"], MEMCACHE.get("ti:aaa")) - ti1.update_attributes( - :consequent_name => "ccc" - ) - assert_equal(["ccc"], MEMCACHE.get("ti:aaa")) - end - - should "clear the cache upon destruction" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti1.destroy - assert_nil(MEMCACHE.get("ti:aaa")) - end - should "calculate all its descendants" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") assert_equal("ccc", ti1.descendant_names) assert_equal(["ccc"], ti1.descendant_names_array) - ti2 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal("bbb ccc", ti2.descendant_names) assert_equal(["bbb", "ccc"], ti2.descendant_names_array) ti1.reload @@ -64,15 +48,9 @@ class TagImplicationTest < ActiveSupport::TestCase assert_equal(["ccc"], ti1.descendant_names_array) end - should "cache its descendants" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - assert_equal(["bbb"], ti1.descendant_names_array) - assert_equal(["bbb"], MEMCACHE.get("ti:aaa")) - end - should "update its descendants on save" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = Factory.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") ti2.update_attributes( :antecedent_name => "bbb" ) @@ -83,10 +61,10 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update the decendants for its parent on save" do - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = Factory.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") - ti3 = Factory.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") - ti4 = Factory.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "eee") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") + ti3 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + ti4 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "eee") ti1.reload ti2.reload ti3.reload @@ -99,8 +77,8 @@ class TagImplicationTest < ActiveSupport::TestCase should "update any affected post upon save" do p1 = Factory.create(:post, :tag_string => "aaa bbb ccc") - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") - ti2 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") + ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy") p1.reload assert_equal("aaa yyy xxx bbb ccc", p1.tag_string) end @@ -111,7 +89,7 @@ class TagImplicationTest < ActiveSupport::TestCase CurrentUser.scoped(user, "127.0.0.1") do p1 = Factory.create(:post, :tag_string => "aaa bbb ccc") end - ti1 = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") + ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") p1.reload assert_not_equal(ti1.creator_id, p1.uploader_id) assert_equal(ti1.creator_id, p1.versions.last.updater_id)