From 17881068e198f8424cdd2f6559cf40d3ed27f365 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 1 Jun 2012 19:22:58 -0400 Subject: [PATCH] * Removed Pixa/Tinami sources * Upgraded to Rails 3.2.3 * Fixed tests --- Gemfile.lock | 110 ++++---- app/logical/downloads/strategies/base.rb | 2 +- app/logical/downloads/strategies/pixa.rb | 19 -- app/logical/downloads/strategies/tinami.rb | 19 -- app/logical/sources/site.rb | 2 +- app/logical/sources/strategies/pixa.rb | 83 ------ app/logical/sources/strategies/tinami.rb | 81 ------ app/models/tag_alias.rb | 17 +- config/danbooru_default_config.rb | 2 +- test/factories/advertisement.rb | 16 +- test/factories/artist.rb | 9 +- test/factories/artist_url.rb | 10 +- test/factories/ban.rb | 10 +- test/factories/comment.rb | 10 +- test/factories/comment_vote.rb | 8 +- test/factories/dmail.rb | 10 +- test/factories/favorite.rb | 3 +- test/factories/forum_post.rb | 8 +- test/factories/forum_topic.rb | 12 +- test/factories/ip_ban.rb | 12 +- test/factories/janitor_trial.rb | 6 +- test/factories/mod_action.rb | 8 +- test/factories/news_update.rb | 6 +- test/factories/note.rb | 26 +- test/factories/pool.rb | 10 +- test/factories/post.rb | 28 +- test/factories/post_appeal.rb | 6 +- test/factories/post_flag.rb | 8 +- test/factories/tag.rb | 34 +-- test/factories/tag_alias.rb | 2 +- test/factories/tag_implication.rb | 2 +- test/factories/tag_subscription.rb | 10 +- test/factories/upload.rb | 77 +++--- test/factories/user.rb | 69 ++--- test/factories/user_feedback.rb | 10 +- test/factories/user_password_reset_nonce.rb | 3 +- test/factories/wiki_page.rb | 10 +- .../advertisement_hits_controller_test.rb | 4 +- .../advertisements_controller_test.rb | 8 +- .../artist_versions_controller_test.rb | 4 +- test/functional/artists_controller_test.rb | 8 +- test/functional/bans_controller_test.rb | 6 +- .../comment_votes_controller_test.rb | 6 +- test/functional/comments_controller_test.rb | 10 +- test/functional/dmails_controller_test.rb | 8 +- test/functional/favorites_controller_test.rb | 8 +- .../functional/forum_posts_controller_test.rb | 10 +- .../forum_topics_controller_test.rb | 10 +- test/functional/ip_bans_controller_test.rb | 6 +- .../janitor_trials_controller_test.rb | 10 +- .../user/login_reminders_controller_test.rb | 4 +- .../user/password_resets_controller_test.rb | 10 +- .../moderator/dashboards_controller_test.rb | 24 +- .../moderator/invitations_controller_test.rb | 6 +- .../moderator/ip_addrs_controller_test.rb | 4 +- .../post/approvals_controller_test.rb | 4 +- .../post/disapprovals_controller_test.rb | 4 +- .../moderator/post/posts_controller_test.rb | 6 +- .../moderator/post/queues_controller_test.rb | 4 +- .../moderator/tags_controller_test.rb | 4 +- .../news_updates_controller_test.rb | 4 +- .../note_versions_controller_test.rb | 6 +- test/functional/notes_controller_test.rb | 12 +- .../pool_elements_controller_test.rb | 8 +- .../pool_versions_controller_test.rb | 8 +- test/functional/pools_controller_test.rb | 20 +- .../post_appeals_controller_test.rb | 8 +- test/functional/post_flags_controller_test.rb | 8 +- .../post_versions_controller_test.rb | 4 +- test/functional/post_votes_controller_test.rb | 4 +- test/functional/posts_controller_test.rb | 4 +- test/functional/sessions_controller_test.rb | 2 +- .../functional/tag_aliases_controller_test.rb | 8 +- .../tag_implications_controller_test.rb | 6 +- .../tag_subscriptions_controller_test.rb | 10 +- test/functional/tags_controller_test.rb | 10 +- test/functional/uploads_controller_test.rb | 10 +- .../user_feedbacks_controller_test.rb | 10 +- test/functional/users_controller_test.rb | 10 +- .../wiki_page_versions_controller_test.rb | 4 +- test/functional/wiki_pages_controller_test.rb | 16 +- test/unit/advertisement_test.rb | 2 +- .../alias_and_implication_importer_test.rb | 4 +- test/unit/artist_test.rb | 50 ++-- test/unit/artist_url_test.rb | 12 +- test/unit/ban_test.rb | 98 +++---- test/unit/comment_test.rb | 32 +-- test/unit/current_user_test.rb | 10 +- test/unit/dmail_test.rb | 20 +- test/unit/downloads/pixa_test.rb | 36 +-- test/unit/downloads/tinami_test.rb | 36 +-- test/unit/favorite_test.rb | 20 +- test/unit/forum_post_test.rb | 16 +- test/unit/forum_topic_test.rb | 10 +- test/unit/ip_ban_test.rb | 6 +- test/unit/janitor_trial_test.rb | 8 +- .../user/login_reminder_mailer_test.rb | 2 +- test/unit/moderator/ip_addr_search_test.rb | 4 +- test/unit/moderator/tag_batch_change_test.rb | 4 +- test/unit/note_test.rb | 20 +- test/unit/pool_test.rb | 30 +-- test/unit/post_appeal_test.rb | 4 +- test/unit/post_disapproval_test.rb | 12 +- test/unit/post_flag_test.rb | 4 +- test/unit/post_pruner_test.rb | 14 +- test/unit/post_sets/favorite_test.rb | 8 +- test/unit/post_sets/pool_test.rb | 10 +- test/unit/post_sets/post_test.rb | 18 +- test/unit/post_test.rb | 254 +++++++++--------- test/unit/post_version_test.rb | 12 +- test/unit/post_vote_test.rb | 4 +- test/unit/related_tag_calculator_test.rb | 26 +- test/unit/related_tag_query_test.rb | 14 +- test/unit/sources/pixa_test.rb | 78 +++--- test/unit/sources/tinami_test.rb | 76 +++--- test/unit/tag_alias_test.rb | 21 +- test/unit/tag_implication_test.rb | 14 +- test/unit/tag_subscription_test.rb | 52 ++-- test/unit/tag_test.rb | 22 +- test/unit/upload_test.rb | 26 +- test/unit/user_feedback_test.rb | 10 +- test/unit/user_password_reset_nonce_test.rb | 6 +- test/unit/user_test.rb | 62 ++--- test/unit/wiki_page_test.rb | 12 +- 124 files changed, 1063 insertions(+), 1214 deletions(-) delete mode 100644 app/logical/downloads/strategies/pixa.rb delete mode 100644 app/logical/downloads/strategies/tinami.rb delete mode 100644 app/logical/sources/strategies/pixa.rb delete mode 100644 app/logical/sources/strategies/tinami.rb diff --git a/Gemfile.lock b/Gemfile.lock index 7b8a71072..28d181a73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,91 +22,91 @@ GIT GIT remote: git://github.com/rgrove/sanitize.git - revision: 052abea134e409c7f676f0cf56e6a2315b2a150b + revision: 4925ac8058320fa587b6bdd7556fdf76e2ad5d31 specs: sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) GIT remote: http://github.com/EmmanuelOga/ffaker.git - revision: a2bff9d77503a9cf61eb274725b12e5683b2826c + revision: 8f7c679ec8c3d27aefe287e04e48e2702b865df9 specs: - ffaker (1.13.0) + ffaker (1.14.0) GEM remote: http://gemcutter.org/ specs: - actionmailer (3.2.2) - actionpack (= 3.2.2) - mail (~> 2.4.0) - actionpack (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + actionmailer (3.2.3) + actionpack (= 3.2.3) + mail (~> 2.4.4) + actionpack (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) - activemodel (3.2.2) - activesupport (= 3.2.2) + activemodel (3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) - activerecord (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + activerecord (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - activesupport (3.2.2) + activeresource (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + activesupport (3.2.3) i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) awesome_print (1.0.2) builder (3.0.0) chronic (0.6.7) - coderay (1.0.5) + coderay (1.0.6) daemons (1.1.8) - delayed_job (3.0.1) + delayed_job (3.0.3) activesupport (~> 3.0) delayed_job_active_record (0.3.2) activerecord (> 2.1.0) delayed_job (~> 3.0.0) - domain_name (0.5.2) + domain_name (0.5.3) unf (~> 0.0.3) erubis (2.7.0) - execjs (1.3.0) + execjs (1.4.0) multi_json (~> 1.0) - factory_girl (2.6.3) - activesupport (>= 2.3.9) + factory_girl (3.3.0) + activesupport (>= 3.0.0) hike (1.2.1) i18n (0.6.0) journey (1.0.3) - json (1.6.5) + json (1.7.3) libv8 (3.3.10.4) - mail (2.4.3) + mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) memcache-client (1.8.5) metaclass (0.0.1) method_source (0.7.1) - mime-types (1.17.2) - mocha (0.10.5) + mime-types (1.18) + mocha (0.11.4) metaclass (~> 0.0.1) - multi_json (1.1.0) - net-http-digest_auth (1.2) - net-http-persistent (2.5.2) - newrelic_rpm (3.3.4.1) - nokogiri (1.5.2) + multi_json (1.3.6) + net-http-digest_auth (1.2.1) + net-http-persistent (2.6) + newrelic_rpm (3.3.5) + nokogiri (1.5.3) ntlm-http (0.1.1) pg (0.13.2) polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) - pry (0.9.8.4) + pry (0.9.9.6) coderay (~> 1.0.5) method_source (~> 0.7.1) slop (>= 2.4.4, < 3) @@ -117,17 +117,17 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.2) - actionmailer (= 3.2.2) - actionpack (= 3.2.2) - activerecord (= 3.2.2) - activeresource (= 3.2.2) - activesupport (= 3.2.2) + rails (3.2.3) + actionmailer (= 3.2.3) + actionpack (= 3.2.3) + activerecord (= 3.2.3) + activeresource (= 3.2.3) + activesupport (= 3.2.3) bundler (~> 1.0) - railties (= 3.2.2) - railties (3.2.2) - actionpack (= 3.2.2) - activesupport (= 3.2.2) + railties (= 3.2.3) + railties (3.2.3) + actionpack (= 3.2.3) + activesupport (= 3.2.3) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -136,8 +136,8 @@ GEM rdoc (3.12) json (~> 1.4) rmagick (2.13.1) - sass (3.1.15) - sass-rails (3.2.4) + sass (3.1.19) + sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) @@ -146,35 +146,35 @@ GEM shoulda-matchers (~> 1.0.0) shoulda-context (1.0.0) shoulda-matchers (1.0.0) - simple_form (2.0.1) + simple_form (2.0.2) actionpack (~> 3.0) activemodel (~> 3.0) - simplecov (0.6.1) + simplecov (0.6.4) multi_json (~> 1.0) simplecov-html (~> 0.5.3) simplecov-html (0.5.3) slop (2.4.4) - sprockets (2.1.2) + sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) super_exception_notifier (3.0.13) actionmailer rake - therubyracer (0.9.10) + therubyracer (0.10.1) libv8 (~> 3.3.10) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) + tzinfo (0.3.33) + uglifier (1.2.4) execjs (>= 0.3.0) multi_json (>= 1.0.2) unf (0.0.5) unf_ext - unf_ext (0.0.4) + unf_ext (0.0.5) webrobots (0.0.13) whenever (0.7.3) activesupport (>= 2.3.4) @@ -198,7 +198,7 @@ DEPENDENCIES nokogiri pg pry - rails (= 3.2.2) + rails (= 3.2.3) rmagick sanitize! sass-rails diff --git a/app/logical/downloads/strategies/base.rb b/app/logical/downloads/strategies/base.rb index 399286c16..177ccaf95 100644 --- a/app/logical/downloads/strategies/base.rb +++ b/app/logical/downloads/strategies/base.rb @@ -2,7 +2,7 @@ module Downloads module Strategies class Base def self.strategies - [Pixiv, Tinami, Pixa] + [Pixiv] end def rewrite(url, headers) diff --git a/app/logical/downloads/strategies/pixa.rb b/app/logical/downloads/strategies/pixa.rb deleted file mode 100644 index 472bbae22..000000000 --- a/app/logical/downloads/strategies/pixa.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Downloads - module Strategies - class Pixa < Base - def rewrite(url, headers) - if url =~ /https?:\/\/(?:\w+\.)?pixa\.cc/ - url, headers = rewrite_headers(url, headers) - end - - return [url, headers] - end - - protected - def rewrite_headers(url, headers) - headers["Referer"] = "http://www.pixa.cc" - return [url, headers] - end - end - end -end diff --git a/app/logical/downloads/strategies/tinami.rb b/app/logical/downloads/strategies/tinami.rb deleted file mode 100644 index fad2fd7e1..000000000 --- a/app/logical/downloads/strategies/tinami.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Downloads - module Strategies - class Tinami < Base - def rewrite(url, headers) - if url =~ /https?:\/\/(?:\w+\.)?tinami\.com/ - url, headers = rewrite_headers(url, headers) - end - - return [url, headers] - end - - protected - def rewrite_headers(url, headers) - headers["Referer"] = "http://www.tinami.com/view" - return [url, headers] - end - end - end -end diff --git a/app/logical/sources/site.rb b/app/logical/sources/site.rb index 0ebd99ac1..fc42cc610 100644 --- a/app/logical/sources/site.rb +++ b/app/logical/sources/site.rb @@ -4,7 +4,7 @@ module Sources delegate :get, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy def self.strategies - [Strategies::NicoSeiga, Strategies::Pixa, Strategies::Pixiv, Strategies::Tinami] + [Strategies::NicoSeiga, Strategies::Pixiv] end def initialize(url) diff --git a/app/logical/sources/strategies/pixa.rb b/app/logical/sources/strategies/pixa.rb deleted file mode 100644 index 930421e87..000000000 --- a/app/logical/sources/strategies/pixa.rb +++ /dev/null @@ -1,83 +0,0 @@ -module Sources - module Strategies - class Pixa < Base - def self.url_match?(url) - url =~ /^https?:\/\/(?:\w+\.)?pixa\.cc/ - end - - def site_name - "Pixa" - end - - def unique_id - profile_url =~ /\/show\/([^\/]+)/ - "pixa" + $1 - end - - def get - agent.get(URI.parse(normalized_url).request_uri) do |page| - @artist_name, @profile_url = get_profile_from_page(page) - @image_url = get_image_url_from_page(page) - @tags = get_tags_from_page(page) - end - end - - protected - def normalized_url - if url =~ /show_original/ - url.sub(/show_original/, "show") - else - url - end - end - - def get_profile_from_page(page) - links = page.search("p.profile_name a") - - if links.any? - profile_url = "http://www.pixa.cc" + links[0]["href"] - artist_name = links[0].text - return [artist_name, profile_url] - else - return [] - end - end - - def get_image_url_from_page(page) - img = page.search("img.illust_image").first - if img - img.attr("src") - else - nil - end - end - - def get_tags_from_page(page) - links = page.search("div#tag_list a") - - if links.any? - links.map do |node| - [node.inner_text, "http://www.pixa.cc" + node.attr("href")] - end - else - [] - end - end - - def agent - @agent ||= begin - mech = Mechanize.new - - mech.get("http://www.pixa.cc") do |page| - page.form_with(:action => "/session") do |form| - form['email'] = Danbooru.config.pixa_login - form['password'] = Danbooru.config.pixa_password - end.click_button - end - - mech - end - end - end - end -end diff --git a/app/logical/sources/strategies/tinami.rb b/app/logical/sources/strategies/tinami.rb deleted file mode 100644 index 18f15109a..000000000 --- a/app/logical/sources/strategies/tinami.rb +++ /dev/null @@ -1,81 +0,0 @@ -module Sources - module Strategies - class Tinami < Base - def self.url_match?(url) - url =~ /^https?:\/\/(?:\w+\.)?tinami\.com/ - end - - def site_name - "Tinami" - end - - def unique_id - profile_url =~ /\/profile\/(\d+)/ - "tinami" + $1 - end - - def get - agent.get(URI.parse(url).request_uri) do |page| - @artist_name, @profile_url = get_profile_from_page(page) - @image_url = get_image_url_from_page(page) - @tags = get_tags_from_page(page) - end - end - - protected - def get_profile_from_page(page) - links = page.search("div.prof a") - - if links.any? - profile_url = "http://www.tinami.com" + links[0]["href"] - else - profile_url = nil - end - - links = page.search("div.prof p a strong") - - if links.any? - artist_name = links[0].text - else - artist_name = nil - end - - return [artist_name, profile_url].compact - end - - def get_image_url_from_page(page) - img = page.search("img.captify[rel=caption]").first - if img - img.attr("src") - else - nil - end - end - - def get_tags_from_page(page) - links = page.search("div.tag a") - - links.map do |node| - [node.text, "http://www.tinami.com" + node.attr("href")] - end - end - - def agent - @agent ||= begin - mech = Mechanize.new - - mech.get("http://www.tinami.com/login") do |page| - page.form_with do |form| - form["action_login"] = "true" - form['username'] = Danbooru.config.tinami_login - form['password'] = Danbooru.config.tinami_password - form["rem"] = "1" - end.click_button - end - - mech - end - end - end - end -end diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index e68748836..8895a742f 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -1,5 +1,5 @@ class TagAlias < ActiveRecord::Base - before_save :clear_all_cache + after_save :clear_all_cache after_save :update_cache after_destroy :clear_all_cache before_validation :initialize_creator, :on => :create @@ -62,17 +62,14 @@ class TagAlias < ActiveRecord::Base end def clear_all_cache - clear_cache - clear_remote_cache + Danbooru.config.all_server_hosts.each do |host| + delay.clear_cache(host) + end end - def clear_cache - Cache.delete("ta:#{Cache.sanitize(antecedent_name)}") - end - - def clear_remote_cache - Danbooru.config.other_server_hosts.each do |server| - Net::HTTP.delete(URI.parse("http://#{server}/tag_aliases/#{id}/cache")) + def clear_cache(host = Socket.gethostname) + if host == Socket.gethostname + Cache.delete("ta:#{Cache.sanitize(antecedent_name)}") end end diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index da62a1148..b69006d7d 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -146,7 +146,7 @@ module Danbooru # Used in conjunction with load balancing to distribute files from one server to # the others. This should match whatever gethostname returns on the other servers. def all_server_hosts - [] + [server_host] end # Names of other Danbooru servers. diff --git a/test/factories/advertisement.rb b/test/factories/advertisement.rb index a93d641b1..5e2b7bec3 100644 --- a/test/factories/advertisement.rb +++ b/test/factories/advertisement.rb @@ -1,8 +1,10 @@ -Factory.define(:advertisement) do |f| - f.referral_url "http://google.com" - f.ad_type "vertical" - f.status "active" - f.width 728 - f.height 90 - f.file_name "google.gif" +FactoryGirl.define do + factory(:advertisement) do + referral_url "http://google.com" + ad_type "vertical" + status "active" + width 728 + height 90 + file_name "google.gif" + end end diff --git a/test/factories/artist.rb b/test/factories/artist.rb index bcad070da..100c70cfe 100644 --- a/test/factories/artist.rb +++ b/test/factories/artist.rb @@ -1,4 +1,7 @@ -Factory.define(:artist) do |f| - f.name {rand(1_000_000).to_s} - f.is_active true +FactoryGirl.define do + factory(:artist) do + name {rand(1_000_000).to_s} + is_active true + end end + diff --git a/test/factories/artist_url.rb b/test/factories/artist_url.rb index aa40a774b..48a01ac80 100644 --- a/test/factories/artist_url.rb +++ b/test/factories/artist_url.rb @@ -1,4 +1,6 @@ -Factory.define(:artist_url) do |f| - f.artist {|x| x.association(:artist)} - f.url {Faker::Internet.domain_name} -end +FactoryGirl.define do + factory(:artist_url) do + artist + url {Faker::Internet.domain_name} + end +end \ No newline at end of file diff --git a/test/factories/ban.rb b/test/factories/ban.rb index 63e69c289..fe2025c5f 100644 --- a/test/factories/ban.rb +++ b/test/factories/ban.rb @@ -1,4 +1,6 @@ -Factory.define(:ban) do |f| - f.reason {Faker::Lorem.words.join(" ")} - f.duration 60 -end +FactoryGirl.define do + factory(:ban) do |f| + reason {Faker::Lorem.words.join(" ")} + duration 60 + end +end \ No newline at end of file diff --git a/test/factories/comment.rb b/test/factories/comment.rb index a3e080a58..4107b7c0f 100644 --- a/test/factories/comment.rb +++ b/test/factories/comment.rb @@ -1,4 +1,6 @@ -Factory.define(:comment) do |f| - f.post {|x| x.association(:post)} - f.body {Faker::Lorem.sentences.join(" ")} -end +FactoryGirl.define do + factory(:comment) do |f| + post + body {Faker::Lorem.sentences.join(" ")} + end +end \ No newline at end of file diff --git a/test/factories/comment_vote.rb b/test/factories/comment_vote.rb index 09f1e644d..0050bc92c 100644 --- a/test/factories/comment_vote.rb +++ b/test/factories/comment_vote.rb @@ -1,3 +1,5 @@ -Factory.define(:comment_vote) do |f| - f.score 1 -end +FactoryGirl.define do + factory(:comment_vote) do + score 1 + end +end \ No newline at end of file diff --git a/test/factories/dmail.rb b/test/factories/dmail.rb index 76e55bf25..c29e560a2 100644 --- a/test/factories/dmail.rb +++ b/test/factories/dmail.rb @@ -1,5 +1,7 @@ -Factory.define(:dmail) do |f| - f.to {|x| x.association(:user)} - f.title {Faker::Lorem.words.join(" ")} - f.body {Faker::Lorem.sentences.join(" ")} +FactoryGirl.define do + factory(:dmail) do + to :factory => :user + title {Faker::Lorem.words.join(" ")} + body {Faker::Lorem.sentences.join(" ")} + end end diff --git a/test/factories/favorite.rb b/test/factories/favorite.rb index effbf8d47..32e1960f1 100644 --- a/test/factories/favorite.rb +++ b/test/factories/favorite.rb @@ -1,2 +1,3 @@ -Factory.define(:favorite) do |f| +FactoryGirl.define do + factory(:favorite) end diff --git a/test/factories/forum_post.rb b/test/factories/forum_post.rb index 8b2f32546..92d3b3d71 100644 --- a/test/factories/forum_post.rb +++ b/test/factories/forum_post.rb @@ -1,3 +1,5 @@ -Factory.define(:forum_post) do |f| - f.body {Faker::Lorem.sentences} -end +FactoryGirl.define do + factory(:forum_post) do + body {Faker::Lorem.sentences.join(" ")} + end +end \ No newline at end of file diff --git a/test/factories/forum_topic.rb b/test/factories/forum_topic.rb index 0c15642b3..469e30951 100644 --- a/test/factories/forum_topic.rb +++ b/test/factories/forum_topic.rb @@ -1,5 +1,7 @@ -Factory.define(:forum_topic) do |f| - f.title {Faker::Lorem.words} - f.is_sticky false - f.is_locked false -end +FactoryGirl.define do + factory(:forum_topic) do + title {Faker::Lorem.words.join(" ")} + is_sticky false + is_locked false + end +end \ No newline at end of file diff --git a/test/factories/ip_ban.rb b/test/factories/ip_ban.rb index a767bc09a..a38ce584b 100644 --- a/test/factories/ip_ban.rb +++ b/test/factories/ip_ban.rb @@ -1,5 +1,7 @@ -Factory.define(:ip_ban) do |f| - f.creator {|x| x.association(:user)} - f.reason {Faker::Lorem.words.join(" ")} - f.ip_addr "127.0.0.1" -end +FactoryGirl.define do + factory(:ip_ban) do + creator :factory => :user + reason {Faker::Lorem.words.join(" ")} + ip_addr "127.0.0.1" + end +end \ No newline at end of file diff --git a/test/factories/janitor_trial.rb b/test/factories/janitor_trial.rb index b863d9b91..1e86fb487 100644 --- a/test/factories/janitor_trial.rb +++ b/test/factories/janitor_trial.rb @@ -1,3 +1,5 @@ -Factory.define(:janitor_trial) do |f| - f.user {|x| x.association(:user)} +FactoryGirl.define do + factory(:janitor_trial) do + user + end end diff --git a/test/factories/mod_action.rb b/test/factories/mod_action.rb index a92bd012c..0b5e1d95b 100644 --- a/test/factories/mod_action.rb +++ b/test/factories/mod_action.rb @@ -1,4 +1,6 @@ -Factory.define(:mod_action) do |f| - f.creator {|x| x.association(:user)} - f.description "1234" +FactoryGirl.define do + factory(:mod_action) do + creator :factory => :user + description "1234" + end end diff --git a/test/factories/news_update.rb b/test/factories/news_update.rb index 5d10eb23d..d2e046d12 100644 --- a/test/factories/news_update.rb +++ b/test/factories/news_update.rb @@ -1,3 +1,5 @@ -Factory.define(:news_update) do |f| - f.message "xxx" +FactoryGirl.define do + factory(:news_update) do + message "xxx" + end end diff --git a/test/factories/note.rb b/test/factories/note.rb index eb0f3c2e3..d1bf916e2 100644 --- a/test/factories/note.rb +++ b/test/factories/note.rb @@ -1,12 +1,14 @@ -Factory.define(:note) do |f| - f.creator {|x| x.association(:user)} - f.post {|x| x.association(:post)} - f.x 0 - f.y 0 - f.width 0 - f.height 0 - f.is_active true - f.body {Faker::Lorem.sentences.join} - f.updater_id {|x| x.association(:user)} - f.updater_ip_addr "127.0.0.1" -end +FactoryGirl.define do + factory(:note) do + creator :factory => :user + post + x 0 + y 0 + width 0 + height 0 + is_active true + body {Faker::Lorem.sentences.join(" ")} + updater_id :factory => :user + updater_ip_addr "127.0.0.1" + end +end \ No newline at end of file diff --git a/test/factories/pool.rb b/test/factories/pool.rb index f38d2e5a3..5d600b230 100644 --- a/test/factories/pool.rb +++ b/test/factories/pool.rb @@ -1,5 +1,7 @@ -Factory.define(:pool) do |f| - f.name {(rand(1_000_000) + 100).to_s} - f.creator {|x| x.association(:user)} - f.description {Faker::Lorem.sentences} +FactoryGirl.define do + factory(:pool) do + name {(rand(1_000_000) + 100).to_s} + association :creator, :factory => :user + description {Faker::Lorem.sentences.join(" ")} + end end diff --git a/test/factories/post.rb b/test/factories/post.rb index f635e1854..ba9569c2c 100644 --- a/test/factories/post.rb +++ b/test/factories/post.rb @@ -1,13 +1,15 @@ -Factory.define(:post) do |f| - f.md5 {|x| Time.now.to_f.to_s} - f.uploader {|x| x.association(:user)} - f.uploader_ip_addr "127.0.0.1" - f.tag_string "tag1 tag2" - f.tag_count 2 - f.tag_count_general 2 - f.file_ext "jpg" - f.image_width 100 - f.image_height 200 - f.file_size 2000 - f.rating "q" -end +FactoryGirl.define do + factory(:post) do + md5 {|x| Time.now.to_f.to_s} + uploader :factory => :user + uploader_ip_addr "127.0.0.1" + tag_string "tag1 tag2" + tag_count 2 + tag_count_general 2 + file_ext "jpg" + image_width 100 + image_height 200 + file_size 2000 + rating "q" + end +end \ No newline at end of file diff --git a/test/factories/post_appeal.rb b/test/factories/post_appeal.rb index 6e1465a2f..e7e3263d5 100644 --- a/test/factories/post_appeal.rb +++ b/test/factories/post_appeal.rb @@ -1,3 +1,5 @@ -Factory.define(:post_appeal) do |f| - f.reason "xxx" +FactoryGirl.define do + factory(:post_appeal) do + reason "xxx" + end end diff --git a/test/factories/post_flag.rb b/test/factories/post_flag.rb index 638c20d19..651dab0ac 100644 --- a/test/factories/post_flag.rb +++ b/test/factories/post_flag.rb @@ -1,4 +1,6 @@ -Factory.define(:post_flag) do |f| - f.reason "xxx" - f.is_resolved false +FactoryGirl.define do + factory(:post_flag) do + reason "xxx" + is_resolved false + end end \ No newline at end of file diff --git a/test/factories/tag.rb b/test/factories/tag.rb index 06abf7b5a..3ea55a4e6 100644 --- a/test/factories/tag.rb +++ b/test/factories/tag.rb @@ -1,19 +1,21 @@ -Factory.define(:tag) do |f| - f.name {Faker::Name.first_name.downcase} - f.post_count 0 - f.category {Tag.categories.general} - f.related_tags "" - f.related_tags_updated_at {Time.now} -end +FactoryGirl.define do + factory(:tag) do + name {Faker::Name.first_name.downcase} + post_count 0 + category {Tag.categories.general} + related_tags "" + related_tags_updated_at {Time.now} + + factory(:artist_tag) do + category {Tag.categories.artist} + end -Factory.define(:artist_tag, :parent => :tag) do |f| - f.category {Tag.categories.artist} -end + factory(:copyright_tag) do + category {Tag.categories.copyright} + end -Factory.define(:copyright_tag, :parent => :tag) do |f| - f.category {Tag.categories.copyright} -end - -Factory.define(:character_tag, :parent => :tag) do |f| - f.category {Tag.categories.character} + factory(:character_tag) do + category {Tag.categories.character} + end + end end diff --git a/test/factories/tag_alias.rb b/test/factories/tag_alias.rb index 058108709..d5f5bc6d6 100644 --- a/test/factories/tag_alias.rb +++ b/test/factories/tag_alias.rb @@ -3,7 +3,7 @@ FactoryGirl.define do antecedent_name "aaa" consequent_name "bbb" - after_create do |tag_alias| + after(:create) do |tag_alias| tag_alias.process! end end diff --git a/test/factories/tag_implication.rb b/test/factories/tag_implication.rb index 205c63a58..99da38b1f 100644 --- a/test/factories/tag_implication.rb +++ b/test/factories/tag_implication.rb @@ -3,7 +3,7 @@ FactoryGirl.define do antecedent_name "aaa" consequent_name "bbb" - after_create do |tag_implication| + after(:create) do |tag_implication| tag_implication.process! end end diff --git a/test/factories/tag_subscription.rb b/test/factories/tag_subscription.rb index a2802dde1..857b7d957 100644 --- a/test/factories/tag_subscription.rb +++ b/test/factories/tag_subscription.rb @@ -1,5 +1,7 @@ -Factory.define(:tag_subscription) do |f| - f.name {Faker::Lorem.words.join(" ")} - f.is_public true - f.tag_query "aaa" +FactoryGirl.define do + factory(:tag_subscription) do + name {Faker::Lorem.words.join(" ")} + is_public true + tag_query "aaa" + end end diff --git a/test/factories/upload.rb b/test/factories/upload.rb index 0ab078627..69b1c24fa 100644 --- a/test/factories/upload.rb +++ b/test/factories/upload.rb @@ -1,44 +1,47 @@ require 'fileutils' -Factory.define(:upload) do |f| - f.rating "s" - f.uploader {|x| x.association(:user, :level => 200)} - f.uploader_ip_addr "127.0.0.1" - f.tag_string "special" - f.status "pending" -end +FactoryGirl.define do + factory(:upload) do + rating "s" + uploader :factory => :user, :level => 20 + uploader_ip_addr "127.0.0.1" + tag_string "special" + status "pending" + + factory(:source_upload) do + source "http://www.google.com/intl/en_ALL/images/logo.gif" + end -Factory.define(:source_upload, :parent => :upload) do |f| - f.source "http://www.google.com/intl/en_ALL/images/logo.gif" -end + factory(:jpg_upload) do + content_type "image/jpeg" + file_path do + FileUtils.cp("#{Rails.root}/test/files/test.jpg", "#{Rails.root}/tmp") + "#{Rails.root}/tmp/test.jpg" + end + end -Factory.define(:jpg_upload, :parent => :upload) do |f| - f.content_type "image/jpeg" - f.file_path do - FileUtils.cp("#{Rails.root}/test/files/test.jpg", "#{Rails.root}/tmp") - "#{Rails.root}/tmp/test.jpg" + factory(:large_jpg_upload) do + file_ext "jpg" + content_type "image/jpeg" + file_path do + FileUtils.cp("#{Rails.root}/test/files/test-large.jpg", "#{Rails.root}/tmp") + "#{Rails.root}/tmp/test-large.jpg" + end + end + + factory(:png_upload) do + file_path do + FileUtils.cp("#{Rails.root}/test/files/test.png", "#{Rails.root}/tmp") + "#{Rails.root}/tmp/test.png" + end + end + + factory(:gif_upload) do + file_path do + FileUtils.cp("#{Rails.root}/test/files/test.gif", "#{Rails.root}/tmp") + "#{Rails.root}/tmp/test.gif" + end + end end end -Factory.define(:large_jpg_upload, :parent => :upload) do |f| - f.file_ext "jpg" - f.content_type "image/jpeg" - f.file_path do - FileUtils.cp("#{Rails.root}/test/files/test-large.jpg", "#{Rails.root}/tmp") - "#{Rails.root}/tmp/test-large.jpg" - end -end - -Factory.define(:png_upload, :parent => :upload) do |f| - f.file_path do - FileUtils.cp("#{Rails.root}/test/files/test.png", "#{Rails.root}/tmp") - "#{Rails.root}/tmp/test.png" - end -end - -Factory.define(:gif_upload, :parent => :upload) do |f| - f.file_path do - FileUtils.cp("#{Rails.root}/test/files/test.gif", "#{Rails.root}/tmp") - "#{Rails.root}/tmp/test.gif" - end -end diff --git a/test/factories/user.rb b/test/factories/user.rb index ea5979b45..8ea0aca43 100644 --- a/test/factories/user.rb +++ b/test/factories/user.rb @@ -1,35 +1,38 @@ -Factory.define(:user) do |f| - f.name {rand(1_000_000).to_s} - f.password "password" - f.password_hash {User.sha1("password")} - f.email {Faker::Internet.email} - f.default_image_size "large" - f.base_upload_limit 10 - f.level 20 - f.last_logged_in_at {Time.now} +FactoryGirl.define do + factory(:user) do + name {rand(1_000_000).to_s} + password "password" + password_hash {User.sha1("password")} + email {Faker::Internet.email} + default_image_size "large" + base_upload_limit 10 + level 20 + last_logged_in_at {Time.now} + + factory(:banned_user) do + is_banned true + ban {|x| x.association(:ban)} + end + + factory(:privileged_user) do + level 30 + end + + factory(:contributor_user) do + level 33 + end + + factory(:janitor_user) do + level 35 + end + + factory(:moderator_user) do + level 40 + end + + factory(:admin_user) do + level 50 + end + end end -Factory.define(:banned_user, :parent => :user) do |f| - f.is_banned true - f.ban {|x| x.association(:ban)} -end - -Factory.define(:privileged_user, :parent => :user) do |f| - f.level 30 -end - -Factory.define(:contributor_user, :parent => :user) do |f| - f.level 33 -end - -Factory.define(:janitor_user, :parent => :user) do |f| - f.level 35 -end - -Factory.define(:moderator_user, :parent => :user) do |f| - f.level 40 -end - -Factory.define(:admin_user, :parent => :user) do |f| - f.level 50 -end diff --git a/test/factories/user_feedback.rb b/test/factories/user_feedback.rb index 78e19b114..d508d4813 100644 --- a/test/factories/user_feedback.rb +++ b/test/factories/user_feedback.rb @@ -1,5 +1,7 @@ -Factory.define(:user_feedback) do |f| - f.user {|x| x.association(:user)} - f.category "positive" - f.body {Faker::Lorem.words.join(" ")} +FactoryGirl.define do + factory(:user_feedback) do + user + category "positive" + body {Faker::Lorem.words.join(" ")} + end end diff --git a/test/factories/user_password_reset_nonce.rb b/test/factories/user_password_reset_nonce.rb index d1cd0076d..e5918bf30 100644 --- a/test/factories/user_password_reset_nonce.rb +++ b/test/factories/user_password_reset_nonce.rb @@ -1,2 +1,3 @@ -Factory.define(:user_password_reset_nonce) do |f| +FactoryGirl.define do + factory(:user_password_reset_nonce) end diff --git a/test/factories/wiki_page.rb b/test/factories/wiki_page.rb index 2b38885b6..6ab693245 100644 --- a/test/factories/wiki_page.rb +++ b/test/factories/wiki_page.rb @@ -1,5 +1,7 @@ -Factory.define(:wiki_page) do |f| - f.creator {|x| x.association(:user)} - f.title {|x| Faker::Lorem.words.join(" ")} - f.body {Faker::Lorem.sentences.join(" ")} +FactoryGirl.define do + factory(:wiki_page) do + creator :factory => :user + title {Faker::Lorem.words.join(" ")} + body {Faker::Lorem.sentences.join(" ")} + end end diff --git a/test/functional/advertisement_hits_controller_test.rb b/test/functional/advertisement_hits_controller_test.rb index 34b2ff5eb..7a554268a 100644 --- a/test/functional/advertisement_hits_controller_test.rb +++ b/test/functional/advertisement_hits_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class AdvertisementHitsControllerTest < ActionController::TestCase context "An advertisement hits controller" do setup do - @ad = Factory.create(:advertisement) - @advertiser = Factory.create(:admin_user) + @ad = FactoryGirl.create(:advertisement) + @advertiser = FactoryGirl.create(:admin_user) end should "create a new hit" do diff --git a/test/functional/advertisements_controller_test.rb b/test/functional/advertisements_controller_test.rb index af22a0864..844868812 100644 --- a/test/functional/advertisements_controller_test.rb +++ b/test/functional/advertisements_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class AdvertisementsControllerTest < ActionController::TestCase context "An advertisement controller" do setup do - @ad = Factory.create(:advertisement) - @advertiser = Factory.create(:admin_user) + @ad = FactoryGirl.create(:advertisement) + @advertiser = FactoryGirl.create(:admin_user) end should "get the new page" do @@ -29,7 +29,7 @@ class AdvertisementsControllerTest < ActionController::TestCase should "create an ad" do assert_difference("Advertisement.count", 1) do - post :create, {:advertisement => Factory.attributes_for(:advertisement)}, {:user_id => @advertiser.id} + post :create, {:advertisement => FactoryGirl.attributes_for(:advertisement)}, {:user_id => @advertiser.id} end ad = Advertisement.last assert_redirected_to(advertisement_path(ad)) @@ -50,7 +50,7 @@ class AdvertisementsControllerTest < ActionController::TestCase end should "block non-advertisers" do - regular_user = Factory.create(:user) + regular_user = FactoryGirl.create(:user) get :index, {}, {:user_id => regular_user.id} assert_redirected_to("/static/access_denied") end diff --git a/test/functional/artist_versions_controller_test.rb b/test/functional/artist_versions_controller_test.rb index 20b50ba61..8bb9d89e2 100644 --- a/test/functional/artist_versions_controller_test.rb +++ b/test/functional/artist_versions_controller_test.rb @@ -3,9 +3,9 @@ require 'test_helper' class ArtistVersionsControllerTest < ActionController::TestCase context "An artist versions controller" do setup do - CurrentUser.user = Factory.create(:user) + CurrentUser.user = FactoryGirl.create(:user) CurrentUser.ip_addr = "127.0.0.1" - @artist = Factory.create(:artist) + @artist = FactoryGirl.create(:artist) end teardown do diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index ee5f92a5f..2ea722932 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class ArtistsControllerTest < ActionController::TestCase context "An artists controller" do setup do - CurrentUser.user = Factory.create(:user) + CurrentUser.user = FactoryGirl.create(:user) CurrentUser.ip_addr = "127.0.0.1" - @artist = Factory.create(:artist) - @user = Factory.create(:user) + @artist = FactoryGirl.create(:artist) + @user = FactoryGirl.create(:user) end teardown do @@ -42,7 +42,7 @@ class ArtistsControllerTest < ActionController::TestCase should "create an artist" do assert_difference("Artist.count", 1) do - post :create, {:artist => Factory.attributes_for(:artist)}, {:user_id => @user.id} + post :create, {:artist => FactoryGirl.attributes_for(:artist)}, {:user_id => @user.id} end artist = Artist.last assert_redirected_to(artist_path(artist)) diff --git a/test/functional/bans_controller_test.rb b/test/functional/bans_controller_test.rb index d58a60a5f..380845026 100644 --- a/test/functional/bans_controller_test.rb +++ b/test/functional/bans_controller_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class BansControllerTest < ActionController::TestCase context "A bans controller" do setup do - @mod = Factory.create(:moderator_user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.user = @mod CurrentUser.ip_addr = "127.0.0.1" - @user = Factory.create(:user) - @ban = Factory.create(:ban, :user_id => @user.id) + @user = FactoryGirl.create(:user) + @ban = FactoryGirl.create(:ban, :user_id => @user.id) end teardown do diff --git a/test/functional/comment_votes_controller_test.rb b/test/functional/comment_votes_controller_test.rb index d963d22c0..1bc9ef58b 100644 --- a/test/functional/comment_votes_controller_test.rb +++ b/test/functional/comment_votes_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class CommentVotesControllerTest < ActionController::TestCase context "A comment votes controller" do setup do - CurrentUser.user = @user = Factory.create(:user) + CurrentUser.user = @user = FactoryGirl.create(:user) CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - @comment = Factory.create(:comment) + @comment = FactoryGirl.create(:comment) end teardown do @@ -22,7 +22,7 @@ class CommentVotesControllerTest < ActionController::TestCase end should "fail silently on errors" do - Factory.create(:comment_vote, :comment => @comment) + FactoryGirl.create(:comment_vote, :comment => @comment) assert_difference("CommentVote.count", 0) do post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id} assert_response :success diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 658f98191..a8f216faa 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -3,12 +3,12 @@ require 'test_helper' class CommentsControllerTest < ActionController::TestCase context "A comments controller" do setup do - CurrentUser.user = Factory.create(:user) + CurrentUser.user = FactoryGirl.create(:user) CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - @post = Factory.create(:post) - @comment = Factory.create(:comment, :post => @post) - @user = Factory.create(:moderator_user) + @post = FactoryGirl.create(:post) + @comment = FactoryGirl.create(:comment, :post => @post) + @user = FactoryGirl.create(:moderator_user) end teardown do @@ -38,7 +38,7 @@ class CommentsControllerTest < ActionController::TestCase context "create action"do should "create a comment" do assert_difference("Comment.count", 1) do - post :create, {:comment => Factory.attributes_for(:comment, :post_id => @post.id)}, {:user_id => @user.id} + post :create, {:comment => FactoryGirl.attributes_for(:comment, :post_id => @post.id)}, {:user_id => @user.id} end comment = Comment.last assert_redirected_to post_path(comment.post) diff --git a/test/functional/dmails_controller_test.rb b/test/functional/dmails_controller_test.rb index ad5e212c2..2c0d544bf 100644 --- a/test/functional/dmails_controller_test.rb +++ b/test/functional/dmails_controller_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class DmailsControllerTest < ActionController::TestCase context "The dmails controller" do setup do - @user = Factory.create(:user) - @unrelated_user = Factory.create(:user) + @user = FactoryGirl.create(:user) + @unrelated_user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @dmail = Factory.create(:dmail, :owner => @user) + @dmail = FactoryGirl.create(:dmail, :owner => @user) end teardown do @@ -73,7 +73,7 @@ class DmailsControllerTest < ActionController::TestCase context "create action" do setup do - @user_2 = Factory.create(:user) + @user_2 = FactoryGirl.create(:user) end should "create two messages, one for the sender and one for the recipient" do diff --git a/test/functional/favorites_controller_test.rb b/test/functional/favorites_controller_test.rb index 987db1f4d..e44a1e6b8 100644 --- a/test/functional/favorites_controller_test.rb +++ b/test/functional/favorites_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class FavoritesControllerTest < ActionController::TestCase context "The favorites controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class FavoritesControllerTest < ActionController::TestCase context "index action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.add_favorite!(@user) end @@ -35,7 +35,7 @@ class FavoritesControllerTest < ActionController::TestCase context "create action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "create a favorite for the current user" do @@ -47,7 +47,7 @@ class FavoritesControllerTest < ActionController::TestCase context "destroy action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.add_favorite!(@user) end diff --git a/test/functional/forum_posts_controller_test.rb b/test/functional/forum_posts_controller_test.rb index 9fc007c98..17f83531e 100644 --- a/test/functional/forum_posts_controller_test.rb +++ b/test/functional/forum_posts_controller_test.rb @@ -3,13 +3,13 @@ require 'test_helper' class ForumPostsControllerTest < ActionController::TestCase context "The forum posts controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @other_user = Factory.create(:user) - @mod = Factory.create(:moderator_user) - @forum_topic = Factory.create(:forum_topic, :title => "my forum topic", :creator => @user) - @forum_post = Factory.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx") + @other_user = FactoryGirl.create(:user) + @mod = FactoryGirl.create(:moderator_user) + @forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user) + @forum_post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx") end teardown do diff --git a/test/functional/forum_topics_controller_test.rb b/test/functional/forum_topics_controller_test.rb index 8bb3756c8..812a7da9b 100644 --- a/test/functional/forum_topics_controller_test.rb +++ b/test/functional/forum_topics_controller_test.rb @@ -3,12 +3,12 @@ require 'test_helper' class ForumTopicsControllerTest < ActionController::TestCase context "The forum topics controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @other_user = Factory.create(:user) - @mod = Factory.create(:moderator_user) - @forum_topic = Factory.create(:forum_topic, :title => "my forum topic", :creator => @user) + @other_user = FactoryGirl.create(:user) + @mod = FactoryGirl.create(:moderator_user) + @forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user) end teardown do @@ -75,7 +75,7 @@ class ForumTopicsControllerTest < ActionController::TestCase context "destroy action" do setup do - @post = Factory.create(:forum_post, :topic_id => @forum_topic.id) + @post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id) end should "destroy the topic and any associated posts" do diff --git a/test/functional/ip_bans_controller_test.rb b/test/functional/ip_bans_controller_test.rb index 984d58728..3de7ce78a 100644 --- a/test/functional/ip_bans_controller_test.rb +++ b/test/functional/ip_bans_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class IpBansControllerTest < ActionController::TestCase context "The ip bans controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" end @@ -25,7 +25,7 @@ class IpBansControllerTest < ActionController::TestCase context "index action" do setup do - Factory.create(:ip_ban) + FactoryGirl.create(:ip_ban) end should "render" do @@ -43,7 +43,7 @@ class IpBansControllerTest < ActionController::TestCase context "destroy action" do setup do - @ip_ban = Factory.create(:ip_ban) + @ip_ban = FactoryGirl.create(:ip_ban) end should "destroy an ip ban" do diff --git a/test/functional/janitor_trials_controller_test.rb b/test/functional/janitor_trials_controller_test.rb index 235790c45..cf72f9e36 100644 --- a/test/functional/janitor_trials_controller_test.rb +++ b/test/functional/janitor_trials_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class JanitorTrialsControllerTest < ActionController::TestCase context "The janitor trials controller" do setup do - @admin = Factory.create(:admin_user) - @user = Factory.create(:user) + @admin = FactoryGirl.create(:admin_user) + @user = FactoryGirl.create(:user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" end @@ -30,7 +30,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "promote action" do setup do - @janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) end should "promote the janitor trial" do @@ -44,7 +44,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "demote action" do setup do - @janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) end should "demote the janitor trial" do @@ -58,7 +58,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "index action" do setup do - Factory.create(:janitor_trial) + FactoryGirl.create(:janitor_trial) end should "render" do diff --git a/test/functional/maintenance/user/login_reminders_controller_test.rb b/test/functional/maintenance/user/login_reminders_controller_test.rb index 99e97c1dd..f33357fe1 100644 --- a/test/functional/maintenance/user/login_reminders_controller_test.rb +++ b/test/functional/maintenance/user/login_reminders_controller_test.rb @@ -5,8 +5,8 @@ module Maintenance class LoginRemindersControllerTest < ActionController::TestCase context "A login reminder controller" do setup do - @user = Factory.create(:user) - @blank_email_user = Factory.create(:user, :email => "") + @user = FactoryGirl.create(:user) + @blank_email_user = FactoryGirl.create(:user, :email => "") CurrentUser.user = nil CurrentUser.ip_addr = "127.0.0.1" ActionMailer::Base.delivery_method = :test diff --git a/test/functional/maintenance/user/password_resets_controller_test.rb b/test/functional/maintenance/user/password_resets_controller_test.rb index db0c1a3d4..8c03073a5 100644 --- a/test/functional/maintenance/user/password_resets_controller_test.rb +++ b/test/functional/maintenance/user/password_resets_controller_test.rb @@ -5,7 +5,7 @@ module Maintenance class PasswordResetsControllerTest < ActionController::TestCase context "A password resets controller" do setup do - @user = Factory.create(:user, :email => "abc@com.net") + @user = FactoryGirl.create(:user, :email => "abc@com.net") CurrentUser.user = nil CurrentUser.ip_addr = "127.0.0.1" ActionMailer::Base.delivery_method = :test @@ -73,8 +73,8 @@ module Maintenance context "with valid parameters" do setup do - @user = Factory.create(:user) - @nonce = Factory.create(:user_password_reset_nonce, :email => @user.email) + @user = FactoryGirl.create(:user) + @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) ActionMailer::Base.deliveries.clear get :edit, :email => @nonce.email, :key => @nonce.key end @@ -98,8 +98,8 @@ module Maintenance context "with valid parameters" do setup do - @user = Factory.create(:user) - @nonce = Factory.create(:user_password_reset_nonce, :email => @user.email) + @user = FactoryGirl.create(:user) + @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) ActionMailer::Base.deliveries.clear @old_password = @user.password_hash post :update, :email => @nonce.email, :key => @nonce.key diff --git a/test/functional/moderator/dashboards_controller_test.rb b/test/functional/moderator/dashboards_controller_test.rb index bc553ed36..8a62b3590 100644 --- a/test/functional/moderator/dashboards_controller_test.rb +++ b/test/functional/moderator/dashboards_controller_test.rb @@ -4,7 +4,7 @@ module Moderator class DashboardsControllerTest < ActionController::TestCase context "The moderator dashboards controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) @@ -13,7 +13,7 @@ module Moderator context "show action" do context "for mod actions" do setup do - @mod_action = Factory.create(:mod_action) + @mod_action = FactoryGirl.create(:mod_action) end should "render" do @@ -25,7 +25,7 @@ module Moderator context "for user feedbacks" do setup do - @feedback = Factory.create(:user_feedback) + @feedback = FactoryGirl.create(:user_feedback) end should "render" do @@ -37,7 +37,7 @@ module Moderator context "for wiki pages" do setup do - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) end should "render" do @@ -49,7 +49,7 @@ module Moderator context "for tags and uploads" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "render" do @@ -61,8 +61,8 @@ module Moderator context "for notes"do setup do - @post = Factory.create(:post) - @note = Factory.create(:note, :post_id => @post.id) + @post = FactoryGirl.create(:post) + @note = FactoryGirl.create(:note, :post_id => @post.id) end should "render" do @@ -74,10 +74,10 @@ module Moderator context "for comments" do setup do - @users = (0..5).map {Factory.create(:user)} + @users = (0..5).map {FactoryGirl.create(:user)} CurrentUser.scoped(@users[0], "1.2.3.4") do - @comment = Factory.create(:comment) + @comment = FactoryGirl.create(:comment) end @users.each do |user| @@ -95,7 +95,7 @@ module Moderator context "for artists" do setup do - @artist = Factory.create(:artist) + @artist = FactoryGirl.create(:artist) end should "render" do @@ -107,7 +107,7 @@ module Moderator context "for flags" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.flag!("blah") end @@ -119,7 +119,7 @@ module Moderator context "for appeals" do setup do - @post = Factory.create(:post, :is_deleted => true) + @post = FactoryGirl.create(:post, :is_deleted => true) @post.appeal!("blah") end diff --git a/test/functional/moderator/invitations_controller_test.rb b/test/functional/moderator/invitations_controller_test.rb index 901e9f02f..b38664816 100644 --- a/test/functional/moderator/invitations_controller_test.rb +++ b/test/functional/moderator/invitations_controller_test.rb @@ -4,13 +4,13 @@ module Moderator class InvitationsControllerTest < ActionController::TestCase context "The invitations controller" do setup do - @mod = Factory.create(:moderator_user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.user = @mod CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @user_1 = Factory.create(:user) - @user_2 = Factory.create(:user, :inviter_id => @mod.id) + @user_1 = FactoryGirl.create(:user) + @user_2 = FactoryGirl.create(:user, :inviter_id => @mod.id) end should "render the new page" do diff --git a/test/functional/moderator/ip_addrs_controller_test.rb b/test/functional/moderator/ip_addrs_controller_test.rb index c390e896f..bf64c5764 100644 --- a/test/functional/moderator/ip_addrs_controller_test.rb +++ b/test/functional/moderator/ip_addrs_controller_test.rb @@ -4,10 +4,10 @@ module Moderator class IpAddrsControllerTest < ActionController::TestCase context "The ip addrs controller" do setup do - @user = Factory.create(:moderator_user) + @user = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - Factory.create(:comment) + FactoryGirl.create(:comment) MEMCACHE.flush_all end diff --git a/test/functional/moderator/post/approvals_controller_test.rb b/test/functional/moderator/post/approvals_controller_test.rb index 1551b7665..0fad190cb 100644 --- a/test/functional/moderator/post/approvals_controller_test.rb +++ b/test/functional/moderator/post/approvals_controller_test.rb @@ -5,11 +5,11 @@ module Moderator class ApprovalsControllerTest < ActionController::TestCase context "The moderator post approvals controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post, :is_pending => true) + @post = FactoryGirl.create(:post, :is_pending => true) end context "create action" do diff --git a/test/functional/moderator/post/disapprovals_controller_test.rb b/test/functional/moderator/post/disapprovals_controller_test.rb index 0c20275bc..40a8bda3e 100644 --- a/test/functional/moderator/post/disapprovals_controller_test.rb +++ b/test/functional/moderator/post/disapprovals_controller_test.rb @@ -5,11 +5,11 @@ module Moderator class DisapprovalsControllerTest < ActionController::TestCase context "The moderator post disapprovals controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post, :is_pending => true) + @post = FactoryGirl.create(:post, :is_pending => true) end context "create action" do diff --git a/test/functional/moderator/post/posts_controller_test.rb b/test/functional/moderator/post/posts_controller_test.rb index 9759b0533..34f64b063 100644 --- a/test/functional/moderator/post/posts_controller_test.rb +++ b/test/functional/moderator/post/posts_controller_test.rb @@ -5,14 +5,14 @@ module Moderator class PostsControllerTest < ActionController::TestCase context "The moderator post disapprovals controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" end context "delete action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "render" do @@ -25,7 +25,7 @@ module Moderator context "undelete action" do setup do - @post = Factory.create(:post, :is_deleted => true) + @post = FactoryGirl.create(:post, :is_deleted => true) end should "render" do diff --git a/test/functional/moderator/post/queues_controller_test.rb b/test/functional/moderator/post/queues_controller_test.rb index 01d0b1fe5..d6e934109 100644 --- a/test/functional/moderator/post/queues_controller_test.rb +++ b/test/functional/moderator/post/queues_controller_test.rb @@ -5,11 +5,11 @@ module Moderator class QueuesControllerTest < ActionController::TestCase context "The moderator post queues controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post, :is_pending => true) + @post = FactoryGirl.create(:post, :is_pending => true) end context "show action" do diff --git a/test/functional/moderator/tags_controller_test.rb b/test/functional/moderator/tags_controller_test.rb index 63a3bfa57..b54764b90 100644 --- a/test/functional/moderator/tags_controller_test.rb +++ b/test/functional/moderator/tags_controller_test.rb @@ -4,10 +4,10 @@ module Moderator class TagsControllerTest < ActionController::TestCase context "The tags controller" do setup do - @user = Factory.create(:moderator_user) + @user = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "render the edit action" do diff --git a/test/functional/news_updates_controller_test.rb b/test/functional/news_updates_controller_test.rb index 82953828c..690955125 100644 --- a/test/functional/news_updates_controller_test.rb +++ b/test/functional/news_updates_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class NewsUpdatesControllerTest < ActionController::TestCase context "the news updates controller" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @news_update = Factory.create(:news_update) + @news_update = FactoryGirl.create(:news_update) end teardown do diff --git a/test/functional/note_versions_controller_test.rb b/test/functional/note_versions_controller_test.rb index de02d2e50..e88ed0a7c 100644 --- a/test/functional/note_versions_controller_test.rb +++ b/test/functional/note_versions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class NoteVersionsControllerTest < ActionController::TestCase context "The note versions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,8 +15,8 @@ class NoteVersionsControllerTest < ActionController::TestCase context "index action" do setup do - @note = Factory.create(:note) - @user_2 = Factory.create(:user) + @note = FactoryGirl.create(:note) + @user_2 = FactoryGirl.create(:user) CurrentUser.scoped(@user_2, "1.2.3.4") do @note.update_attributes(:body => "1 2") diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index 70e3c351e..d35b3ee50 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class NotesControllerTest < ActionController::TestCase context "The notes controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end teardown do @@ -15,7 +15,7 @@ class NotesControllerTest < ActionController::TestCase context "index action" do setup do - Factory.create(:note) + FactoryGirl.create(:note) end should "list all notes" do @@ -39,7 +39,7 @@ class NotesControllerTest < ActionController::TestCase context "update action" do setup do - @note = Factory.create(:note) + @note = FactoryGirl.create(:note) end should "update a note" do @@ -51,7 +51,7 @@ class NotesControllerTest < ActionController::TestCase context "destroy action" do setup do - @note = Factory.create(:note) + @note = FactoryGirl.create(:note) end should "destroy a note" do @@ -63,7 +63,7 @@ class NotesControllerTest < ActionController::TestCase context "revert action" do setup do - @note = Factory.create(:note, :body => "000") + @note = FactoryGirl.create(:note, :body => "000") @note.update_attributes(:body => "111") @note.update_attributes(:body => "222") end diff --git a/test/functional/pool_elements_controller_test.rb b/test/functional/pool_elements_controller_test.rb index e76087142..143c821ed 100644 --- a/test/functional/pool_elements_controller_test.rb +++ b/test/functional/pool_elements_controller_test.rb @@ -3,12 +3,12 @@ require 'test_helper' class PoolElementsControllerTest < ActionController::TestCase context "The pools posts controller" do setup do - @user = Factory.create(:user) - @mod = Factory.create(:moderator_user) + @user = FactoryGirl.create(:user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) - @pool = Factory.create(:pool, :name => "abc") + @post = FactoryGirl.create(:post) + @pool = FactoryGirl.create(:pool, :name => "abc") end teardown do diff --git a/test/functional/pool_versions_controller_test.rb b/test/functional/pool_versions_controller_test.rb index e7fe5235d..1249079f2 100644 --- a/test/functional/pool_versions_controller_test.rb +++ b/test/functional/pool_versions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PoolVersionsControllerTest < ActionController::TestCase context "The pool versions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,9 +15,9 @@ class PoolVersionsControllerTest < ActionController::TestCase context "index action" do setup do - @pool = Factory.create(:pool) - @user_2 = Factory.create(:user) - @user_3 = Factory.create(:user) + @pool = FactoryGirl.create(:pool) + @user_2 = FactoryGirl.create(:user) + @user_3 = FactoryGirl.create(:user) CurrentUser.scoped(@user_2, "1.2.3.4") do @pool.update_attributes(:post_ids => "1 2") diff --git a/test/functional/pools_controller_test.rb b/test/functional/pools_controller_test.rb index 9222f95c6..c9ee3ab91 100644 --- a/test/functional/pools_controller_test.rb +++ b/test/functional/pools_controller_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class PoolsControllerTest < ActionController::TestCase context "The pools controller" do setup do - @user = Factory.create(:user) - @mod = Factory.create(:moderator_user) + @user = FactoryGirl.create(:user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end teardown do @@ -16,7 +16,7 @@ class PoolsControllerTest < ActionController::TestCase context "index action" do setup do - Factory.create(:pool, :name => "abc") + FactoryGirl.create(:pool, :name => "abc") end should "list all pools" do @@ -32,7 +32,7 @@ class PoolsControllerTest < ActionController::TestCase context "show action" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) end should "render" do @@ -51,7 +51,7 @@ class PoolsControllerTest < ActionController::TestCase context "update action" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) end should "update a pool" do @@ -63,7 +63,7 @@ class PoolsControllerTest < ActionController::TestCase context "destroy action" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) end should "destroy a pool" do @@ -75,7 +75,7 @@ class PoolsControllerTest < ActionController::TestCase context "undelete action" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) @pool.is_deleted = true @pool.save end @@ -89,8 +89,8 @@ class PoolsControllerTest < ActionController::TestCase context "revert action" do setup do - @post_2 = Factory.create(:post) - @pool = Factory.create(:pool, :post_ids => "#{@post.id}") + @post_2 = FactoryGirl.create(:post) + @pool = FactoryGirl.create(:pool, :post_ids => "#{@post.id}") CurrentUser.ip_addr = "1.2.3.4" # this is to get around the version collation @pool.update_attributes(:post_ids => "#{@post.id} #{@post_2.id}") CurrentUser.ip_addr = "127.0.0.1" diff --git a/test/functional/post_appeals_controller_test.rb b/test/functional/post_appeals_controller_test.rb index 0c151b613..0a0dd897f 100644 --- a/test/functional/post_appeals_controller_test.rb +++ b/test/functional/post_appeals_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostAppealsControllerTest < ActionController::TestCase context "The post appeals controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -22,8 +22,8 @@ class PostAppealsControllerTest < ActionController::TestCase context "index action" do setup do - @post = Factory.create(:post, :is_deleted => true) - @post_appeal = Factory.create(:post_appeal, :post => @post) + @post = FactoryGirl.create(:post, :is_deleted => true) + @post_appeal = FactoryGirl.create(:post_appeal, :post => @post) end should "render" do @@ -41,7 +41,7 @@ class PostAppealsControllerTest < ActionController::TestCase context "create action" do setup do - @post = Factory.create(:post, :is_deleted => true) + @post = FactoryGirl.create(:post, :is_deleted => true) end should "create a new appeal" do diff --git a/test/functional/post_flags_controller_test.rb b/test/functional/post_flags_controller_test.rb index 2165e7122..acbcbd211 100644 --- a/test/functional/post_flags_controller_test.rb +++ b/test/functional/post_flags_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostFlagsControllerTest < ActionController::TestCase context "The post flags controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -22,8 +22,8 @@ class PostFlagsControllerTest < ActionController::TestCase context "index action" do setup do - @post = Factory.create(:post) - @post_flag = Factory.create(:post_flag, :post => @post) + @post = FactoryGirl.create(:post) + @post_flag = FactoryGirl.create(:post_flag, :post => @post) end should "render" do @@ -41,7 +41,7 @@ class PostFlagsControllerTest < ActionController::TestCase context "create action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "create a new flag" do diff --git a/test/functional/post_versions_controller_test.rb b/test/functional/post_versions_controller_test.rb index 766974201..cdb5e3a56 100644 --- a/test/functional/post_versions_controller_test.rb +++ b/test/functional/post_versions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostVersionsControllerTest < ActionController::TestCase context "The post versions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class PostVersionsControllerTest < ActionController::TestCase context "index action" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.update_attributes(:tag_string => "1 2", :source => "xxx") @post.update_attributes(:tag_string => "2 3", :rating => "e") end diff --git a/test/functional/post_votes_controller_test.rb b/test/functional/post_votes_controller_test.rb index 8bd9e60be..1d596b31f 100644 --- a/test/functional/post_votes_controller_test.rb +++ b/test/functional/post_votes_controller_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class PostVotesControllerTest < ActionController::TestCase context "The post vote controller" do setup do - @user = Factory.create(:privileged_user) + @user = FactoryGirl.create(:privileged_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end teardown do diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 6bbf2919f..452c60888 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -3,10 +3,10 @@ require "test_helper" class PostsControllerTest < ActionController::TestCase context "The posts controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post, :uploader_id => @user.id, :tag_string => "aaaa") + @post = FactoryGirl.create(:post, :uploader_id => @user.id, :tag_string => "aaaa") MEMCACHE.flush_all end diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb index de0c94e2d..d32a7e586 100644 --- a/test/functional/sessions_controller_test.rb +++ b/test/functional/sessions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class SessionsControllerTest < ActionController::TestCase context "the sessions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end context "new action" do diff --git a/test/functional/tag_aliases_controller_test.rb b/test/functional/tag_aliases_controller_test.rb index ae7aa6fde..3e8004b46 100644 --- a/test/functional/tag_aliases_controller_test.rb +++ b/test/functional/tag_aliases_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagAliasesControllerTest < ActionController::TestCase context "The tag aliases controller" do setup do - @user = Factory.create(:admin_user) + @user = FactoryGirl.create(:admin_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -17,7 +17,7 @@ class TagAliasesControllerTest < ActionController::TestCase context "index action" do setup do - @tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") end should "list all tag aliass" do @@ -41,7 +41,7 @@ class TagAliasesControllerTest < ActionController::TestCase context "destroy action" do setup do - @tag_alias = Factory.create(:tag_alias) + @tag_alias = FactoryGirl.create(:tag_alias) end should "destroy a tag_alias" do @@ -53,7 +53,7 @@ class TagAliasesControllerTest < ActionController::TestCase context "destroy_cache action" do setup do - @tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa") + @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa") end should "reset the cache" do diff --git a/test/functional/tag_implications_controller_test.rb b/test/functional/tag_implications_controller_test.rb index 5278cef62..850fb0cf7 100644 --- a/test/functional/tag_implications_controller_test.rb +++ b/test/functional/tag_implications_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagImplicationsControllerTest < ActionController::TestCase context "The tag implicationes controller" do setup do - @user = Factory.create(:admin_user) + @user = FactoryGirl.create(:admin_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -17,7 +17,7 @@ class TagImplicationsControllerTest < ActionController::TestCase context "index action" do setup do - @tag_implication = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :creator => @user) + @tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :creator => @user) end should "list all tag implications" do @@ -41,7 +41,7 @@ class TagImplicationsControllerTest < ActionController::TestCase context "destroy action" do setup do - @tag_implication = Factory.create(:tag_implication, :creator => @user) + @tag_implication = FactoryGirl.create(:tag_implication, :creator => @user) end should "destroy a tag_implication" do diff --git a/test/functional/tag_subscriptions_controller_test.rb b/test/functional/tag_subscriptions_controller_test.rb index 1923098ac..a342e1ac5 100644 --- a/test/functional/tag_subscriptions_controller_test.rb +++ b/test/functional/tag_subscriptions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagSubscriptionsControllerTest < ActionController::TestCase context "The tag subscriptions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase context "index action" do setup do - @tag_subscription = Factory.create(:tag_subscription, :name => "aaa") + @tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa") end should "list all visible tag subscriptions" do @@ -26,7 +26,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase context "posts action" do setup do - @tag_subscription = Factory.create(:tag_subscription, :name => "aaa") + @tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa") end should "list all visible tag subscriptions" do @@ -37,7 +37,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase context "edit action" do setup do - @tag_subscription = Factory.create(:tag_subscription) + @tag_subscription = FactoryGirl.create(:tag_subscription) end should "render" do @@ -63,7 +63,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase context "destroy action" do setup do - @tag_subscription = Factory.create(:tag_subscription) + @tag_subscription = FactoryGirl.create(:tag_subscription) end should "destroy the posts" do diff --git a/test/functional/tags_controller_test.rb b/test/functional/tags_controller_test.rb index 408abefa4..3d732c574 100644 --- a/test/functional/tags_controller_test.rb +++ b/test/functional/tags_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagsControllerTest < ActionController::TestCase context "The tags controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class TagsControllerTest < ActionController::TestCase context "edit action" do setup do - @tag = Factory.create(:tag, :name => "aaa") + @tag = FactoryGirl.create(:tag, :name => "aaa") end should "render" do @@ -26,7 +26,7 @@ class TagsControllerTest < ActionController::TestCase context "index action" do setup do - @tag = Factory.create(:tag, :name => "aaa") + @tag = FactoryGirl.create(:tag, :name => "aaa") end should "render" do @@ -44,7 +44,7 @@ class TagsControllerTest < ActionController::TestCase context "show action" do setup do - @tag = Factory.create(:tag) + @tag = FactoryGirl.create(:tag) end should "render" do @@ -55,7 +55,7 @@ class TagsControllerTest < ActionController::TestCase context "update action" do setup do - @tag = Factory.create(:tag) + @tag = FactoryGirl.create(:tag) end should "update the tag" do diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 5e9197c7d..2d7e5dfeb 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class UploadsControllerTest < ActionController::TestCase context "The uploads controller" do setup do - @user = Factory.create(:contributor_user) + @user = FactoryGirl.create(:contributor_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -21,7 +21,7 @@ class UploadsControllerTest < ActionController::TestCase context "for a post that has already been uploaded" do setup do - @post = Factory.create(:post, :source => "aaa") + @post = FactoryGirl.create(:post, :source => "aaa") end should "initialize the post" do @@ -34,7 +34,7 @@ class UploadsControllerTest < ActionController::TestCase context "index action" do setup do - @upload = Factory.create(:source_upload) + @upload = FactoryGirl.create(:source_upload) end should "render" do @@ -52,7 +52,7 @@ class UploadsControllerTest < ActionController::TestCase context "show action" do setup do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) end should "render" do @@ -73,7 +73,7 @@ class UploadsControllerTest < ActionController::TestCase context "update action" do setup do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) end should "process an unapproval" do diff --git a/test/functional/user_feedbacks_controller_test.rb b/test/functional/user_feedbacks_controller_test.rb index b3aeff62f..7cedfbd77 100644 --- a/test/functional/user_feedbacks_controller_test.rb +++ b/test/functional/user_feedbacks_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class UserFeedbacksControllerTest < ActionController::TestCase context "The user feedbacks controller" do setup do - @user = Factory.create(:user) - @critic = Factory.create(:privileged_user) + @user = FactoryGirl.create(:user) + @critic = FactoryGirl.create(:privileged_user) CurrentUser.user = @critic CurrentUser.ip_addr = "127.0.0.1" end @@ -23,7 +23,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase context "edit action" do setup do - @user_feedback = Factory.create(:user_feedback) + @user_feedback = FactoryGirl.create(:user_feedback) end should "render" do @@ -34,7 +34,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase context "index action" do setup do - @user_feedback = Factory.create(:user_feedback) + @user_feedback = FactoryGirl.create(:user_feedback) end should "render" do @@ -62,7 +62,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase context "destroy action" do setup do - @user_feedback = Factory.create(:user_feedback) + @user_feedback = FactoryGirl.create(:user_feedback) end should "delete a feedback" do diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index d020de189..6c4e49fd8 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class UsersControllerTest < ActionController::TestCase context "The users controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -14,7 +14,7 @@ class UsersControllerTest < ActionController::TestCase context "index action" do setup do - Factory.create(:user, :name => "abc") + FactoryGirl.create(:user, :name => "abc") end should "list all users" do @@ -30,7 +30,7 @@ class UsersControllerTest < ActionController::TestCase context "show action" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "render" do @@ -51,7 +51,7 @@ class UsersControllerTest < ActionController::TestCase context "edit action" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "render" do @@ -62,7 +62,7 @@ class UsersControllerTest < ActionController::TestCase context "update action" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "update a user" do diff --git a/test/functional/wiki_page_versions_controller_test.rb b/test/functional/wiki_page_versions_controller_test.rb index 8921e75c5..ea8084a67 100644 --- a/test/functional/wiki_page_versions_controller_test.rb +++ b/test/functional/wiki_page_versions_controller_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class WikiPageVersionsControllerTest < ActionController::TestCase context "The wiki page versions controller" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class WikiPageVersionsControllerTest < ActionController::TestCase context "index action" do setup do - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) @wiki_page.update_attributes(:body => "1 2") @wiki_page.update_attributes(:body => "2 3") end diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index e8d32c91c..895a6ee28 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class WikiPagesControllerTest < ActionController::TestCase context "The wiki pages controller" do setup do - @user = Factory.create(:user) - @mod = Factory.create(:moderator_user) + @user = FactoryGirl.create(:user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,8 +15,8 @@ class WikiPagesControllerTest < ActionController::TestCase context "index action" do setup do - @wiki_page_abc = Factory.create(:wiki_page, :title => "abc") - @wiki_page_def = Factory.create(:wiki_page, :title => "def") + @wiki_page_abc = FactoryGirl.create(:wiki_page, :title => "abc") + @wiki_page_def = FactoryGirl.create(:wiki_page, :title => "def") end should "list all wiki_pages" do @@ -32,7 +32,7 @@ class WikiPagesControllerTest < ActionController::TestCase context "show action" do setup do - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) end should "render" do @@ -57,7 +57,7 @@ class WikiPagesControllerTest < ActionController::TestCase context "update action" do setup do - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) end should "update a wiki_page" do @@ -69,7 +69,7 @@ class WikiPagesControllerTest < ActionController::TestCase context "destroy action" do setup do - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) end should "destroy a wiki_page" do @@ -81,7 +81,7 @@ class WikiPagesControllerTest < ActionController::TestCase context "revert action" do setup do - @wiki_page = Factory.create(:wiki_page, :body => "1") + @wiki_page = FactoryGirl.create(:wiki_page, :body => "1") @wiki_page.update_attributes(:body => "1 2") @wiki_page.update_attributes(:body => "1 2 3") end diff --git a/test/unit/advertisement_test.rb b/test/unit/advertisement_test.rb index e8e2555f4..b158067de 100644 --- a/test/unit/advertisement_test.rb +++ b/test/unit/advertisement_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class AdvertisementTest < ActiveSupport::TestCase context "An advertisement" do setup do - @ad = Factory.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg")) + @ad = FactoryGirl.create(:advertisement, :file => upload_jpeg("#{Rails.root}/test/files/test.jpg")) end teardown do diff --git a/test/unit/alias_and_implication_importer_test.rb b/test/unit/alias_and_implication_importer_test.rb index 8bc7806ee..776283c9d 100644 --- a/test/unit/alias_and_implication_importer_test.rb +++ b/test/unit/alias_and_implication_importer_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class AliasAndImplicationImporterTest < ActiveSupport::TestCase context "The alias and implication importer" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -20,7 +20,7 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase end should "process it" do - assert_difference("Delayed::Job.count", 2) do + assert_difference("Delayed::Job.count", 3) do @importer.process! end end diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index c0e50c638..0aadc6f28 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ArtistTest < ActiveSupport::TestCase context "An artist" do setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,8 +16,8 @@ class ArtistTest < ActiveSupport::TestCase context "with a matching tag alias" do setup do - @tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - @artist = Factory.create(:artist, :name => "aaa") + @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + @artist = FactoryGirl.create(:artist, :name => "aaa") end should "know it has an alias" do @@ -31,8 +31,8 @@ class ArtistTest < ActiveSupport::TestCase context "that has been banned" do setup do - @post = Factory.create(:post, :tag_string => "aaa") - @artist = Factory.create(:artist, :name => "aaa") + @post = FactoryGirl.create(:post, :tag_string => "aaa") + @artist = FactoryGirl.create(:artist, :name => "aaa") @artist.update_attributes({:is_banned => true}, :as => :admin) @post.reload end @@ -49,7 +49,7 @@ class ArtistTest < ActiveSupport::TestCase should "create a new wiki page to store any note information" do artist = nil assert_difference("WikiPage.count") do - artist = Factory.create(:artist, :name => "aaa", :notes => "testing") + artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") end assert_equal("testing", artist.notes) assert_equal("testing", artist.wiki_page.body) @@ -57,7 +57,7 @@ class ArtistTest < ActiveSupport::TestCase end should "update the wiki page when notes are assigned" do - artist = Factory.create(:artist, :name => "aaa", :notes => "testing") + artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") artist.update_attribute(:notes, "kokoko") artist.reload assert_equal("kokoko", artist.notes) @@ -65,26 +65,26 @@ class ArtistTest < ActiveSupport::TestCase end should "normalize its name" do - artist = Factory.create(:artist, :name => " AAA BBB ") + artist = FactoryGirl.create(:artist, :name => " AAA BBB ") assert_equal("aaa_bbb", artist.name) end should "resolve ambiguous urls" do - bobross = Factory.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg") - bob = Factory.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg") + bobross = FactoryGirl.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg") + bob = FactoryGirl.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg") matches = Artist.find_all_by_url("http://artists.com/bob/test.jpg") assert_equal(1, matches.size) assert_equal("bob", matches.first.name) end should "parse urls" do - artist = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com") + artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com") artist.reload assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort) end should "make sure old urls are deleted" do - artist = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") + artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") artist.url_string = "http://not.rembrandt.com/test.jpg" artist.save artist.reload @@ -92,8 +92,8 @@ class ArtistTest < ActiveSupport::TestCase end should "find matches by url" do - a1 = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") - a2 = Factory.create(:artist, :name => "subway", :url_string => "http://subway.com/test.jpg") + a1 = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") + a2 = FactoryGirl.create(:artist, :name => "subway", :url_string => "http://subway.com/test.jpg") assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/test.jpg").map(&:name)) assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/another.jpg").map(&:name)) @@ -101,39 +101,39 @@ class ArtistTest < ActiveSupport::TestCase end should "not allow duplicates" do - Factory.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg\nhttp://warhol.com/b/image.jpg") + FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg\nhttp://warhol.com/b/image.jpg") assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/test.jpg").map(&:name)) end should "hide deleted artists" do - Factory.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false) + FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false) assert_equal([], Artist.find_all_by_url("http://warhol.com/a/image.jpg").map(&:name)) end should "normalize its other names" do - artist = Factory.create(:artist, :name => "a1", :other_names => "aaa, bbb, ccc ddd") + artist = FactoryGirl.create(:artist, :name => "a1", :other_names => "aaa, bbb, ccc ddd") assert_equal("aaa bbb ccc_ddd", artist.other_names) end should "search on other names should return matches" do - artist = Factory.create(:artist, :name => "artist", :other_names => "aaa, ccc ddd") + artist = FactoryGirl.create(:artist, :name => "artist", :other_names => "aaa, ccc ddd") assert_nil(Artist.other_names_match("artist").first) assert_not_nil(Artist.other_names_match("aaa").first) assert_not_nil(Artist.other_names_match("ccc_ddd").first) end should "search on group name and return matches" do - cat_or_fish = Factory.create(:artist, :name => "cat_or_fish") - yuu = Factory.create(:artist, :name => "yuu", :group_name => "cat_or_fish") + cat_or_fish = FactoryGirl.create(:artist, :name => "cat_or_fish") + yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish") cat_or_fish.reload assert_equal("yuu", cat_or_fish.member_names) assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first) end should "have an associated wiki" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user - artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:title => "xxx", :body => "this is max"}) + artist = FactoryGirl.create(:artist, :name => "max", :wiki_page_attributes => {:title => "xxx", :body => "this is max"}) assert_not_nil(artist.wiki_page) assert_equal("this is max", artist.wiki_page.body) @@ -143,11 +143,11 @@ class ArtistTest < ActiveSupport::TestCase end should "revert to prior versions" do - user = Factory.create(:user) - reverter = Factory.create(:user) + user = FactoryGirl.create(:user) + reverter = FactoryGirl.create(:user) artist = nil assert_difference("ArtistVersion.count") do - artist = Factory.create(:artist, :other_names => "yyy") + artist = FactoryGirl.create(:artist, :other_names => "yyy") end assert_difference("ArtistVersion.count") do diff --git a/test/unit/artist_url_test.rb b/test/unit/artist_url_test.rb index e6a4f2fc5..5575201db 100644 --- a/test/unit/artist_url_test.rb +++ b/test/unit/artist_url_test.rb @@ -4,7 +4,7 @@ class ArtistUrlTest < ActiveSupport::TestCase context "An artist url" do setup do MEMCACHE.flush_all - CurrentUser.user = Factory.create(:user) + CurrentUser.user = FactoryGirl.create(:user) CurrentUser.ip_addr = "127.0.0.1" end @@ -14,27 +14,27 @@ class ArtistUrlTest < ActiveSupport::TestCase end should "always add a trailing slash when normalized" do - url = Factory.create(:artist_url, :url => "http://monet.com") + url = FactoryGirl.create(:artist_url, :url => "http://monet.com") assert_equal("http://monet.com", url.url) assert_equal("http://monet.com/", url.normalized_url) - url = Factory.create(:artist_url, :url => "http://monet.com/") + url = FactoryGirl.create(:artist_url, :url => "http://monet.com/") assert_equal("http://monet.com/", url.url) assert_equal("http://monet.com/", url.normalized_url) end should "normalize fc2 urls" do - url = Factory.create(:artist_url, :url => "http://blog55.fc2.com/monet") + url = FactoryGirl.create(:artist_url, :url => "http://blog55.fc2.com/monet") assert_equal("http://blog55.fc2.com/monet", url.url) assert_equal("http://blog.fc2.com/monet/", url.normalized_url) - url = Factory.create(:artist_url, :url => "http://blog-imgs-55.fc2.com/monet") + url = FactoryGirl.create(:artist_url, :url => "http://blog-imgs-55.fc2.com/monet") assert_equal("http://blog-imgs-55.fc2.com/monet", url.url) assert_equal("http://blog.fc2.com/monet/", url.normalized_url) end should "normalize pixiv urls" do - url = Factory.create(:artist_url, :url => "http://img55.pixiv.net/monet") + url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/monet") assert_equal("http://img55.pixiv.net/monet", url.url) assert_equal("http://img.pixiv.net/monet/", url.normalized_url) end diff --git a/test/unit/ban_test.rb b/test/unit/ban_test.rb index 7f3f1aca0..432ed6155 100644 --- a/test/unit/ban_test.rb +++ b/test/unit/ban_test.rb @@ -4,7 +4,7 @@ class BanTest < ActiveSupport::TestCase context "A ban" do context "created by an admin" do setup do - @banner = Factory.create(:admin_user) + @banner = FactoryGirl.create(:admin_user) CurrentUser.user = @banner CurrentUser.ip_addr = "127.0.0.1" end @@ -16,38 +16,38 @@ class BanTest < ActiveSupport::TestCase end should "not be valid against another admin" do - user = Factory.create(:admin_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:admin_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) end should "be valid against anyone who is not an admin" do - user = Factory.create(:moderator_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:moderator_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:janitor_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:janitor_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:contributor_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:contributor_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:privileged_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:privileged_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) end end context "created by a moderator" do setup do - @banner = Factory.create(:moderator_user) + @banner = FactoryGirl.create(:moderator_user) CurrentUser.user = @banner CurrentUser.ip_addr = "127.0.0.1" end @@ -59,39 +59,39 @@ class BanTest < ActiveSupport::TestCase end should "not be valid against an admin or moderator" do - user = Factory.create(:admin_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:admin_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:moderator_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:moderator_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) end should "be valid against anyone who is not an admin or a moderator" do - user = Factory.create(:janitor_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:janitor_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:contributor_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:contributor_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:privileged_user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:privileged_user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = Factory.create(:user) - ban = Factory.create(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:user) + ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) end end context "created by a janitor" do setup do - @banner = Factory.create(:janitor_user) + @banner = FactoryGirl.create(:janitor_user) CurrentUser.user = @banner CurrentUser.ip_addr = "127.0.0.1" end @@ -103,53 +103,53 @@ class BanTest < ActiveSupport::TestCase end should "always be invalid" do - user = Factory.create(:admin_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:admin_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:moderator_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:moderator_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:janitor_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:janitor_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:contributor_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:contributor_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:privileged_user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:privileged_user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = Factory.create(:user) - ban = Factory.build(:ban, :user => user, :banner => @banner) + user = FactoryGirl.create(:user) + ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) end end should "initialize the expiration date" do - user = Factory.create(:user) - admin = Factory.create(:admin_user) + user = FactoryGirl.create(:user) + admin = FactoryGirl.create(:admin_user) CurrentUser.user = admin - ban = Factory.create(:ban, :user => user, :banner => admin) + ban = FactoryGirl.create(:ban, :user => user, :banner => admin) CurrentUser.user = nil assert_not_nil(ban.expires_at) end should "update the user's feedback" do - user = Factory.create(:user) - admin = Factory.create(:admin_user) + user = FactoryGirl.create(:user) + admin = FactoryGirl.create(:admin_user) assert(user.feedback.empty?) CurrentUser.user = admin - ban = Factory.create(:ban, :user => user, :banner => admin) + ban = FactoryGirl.create(:ban, :user => user, :banner => admin) CurrentUser.user = nil assert(!user.feedback.empty?) assert_equal("negative", user.feedback.last.category) @@ -159,10 +159,10 @@ class BanTest < ActiveSupport::TestCase context "Searching for a ban" do context "by user id" do setup do - @admin = Factory.create(:admin_user) + @admin = FactoryGirl.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end teardown do @@ -172,7 +172,7 @@ class BanTest < ActiveSupport::TestCase context "when only expired bans exist" do setup do - @ban = Factory.create(:ban, :user => @user, :banner => @admin, :duration => -1) + @ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => -1) end should "not return expired bans" do @@ -182,7 +182,7 @@ class BanTest < ActiveSupport::TestCase context "when active bans still exist" do setup do - @ban = Factory.create(:ban, :user => @user, :banner => @admin, :duration => 1) + @ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => 1) end should "return active bans" do diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index a6b48d7cd..80e3d70ca 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class CommentTest < ActiveSupport::TestCase context "A comment" do setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -21,7 +21,7 @@ class CommentTest < ActiveSupport::TestCase end should "fail creation" do - comment = Factory.build(:comment) + comment = FactoryGirl.build(:comment) comment.save assert_equal(["Creator can not post comments within 1 week of sign up, and can only post 5 comments per hour after that"], comment.errors.full_messages) end @@ -34,36 +34,36 @@ class CommentTest < ActiveSupport::TestCase end should "be created" do - comment = Factory.build(:comment) + comment = FactoryGirl.build(:comment) comment.save assert(comment.errors.empty?, comment.errors.full_messages.join(", ")) end should "not bump the parent post" do - post = Factory.create(:post) - comment = Factory.create(:comment, :do_not_bump_post => "1", :post => post) + post = FactoryGirl.create(:post) + comment = FactoryGirl.create(:comment, :do_not_bump_post => "1", :post => post) post.reload assert_nil(post.last_commented_at) - comment = Factory.create(:comment, :post => post) + comment = FactoryGirl.create(:comment, :post => post) post.reload assert_not_nil(post.last_commented_at) end should "not update the post after exceeding the threshold" do Danbooru.config.stubs(:comment_threshold).returns(1) - p = Factory.create(:post) - c1 = Factory.create(:comment, :post => p) + p = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:comment, :post => p) sleep 1 - c2 = Factory.create(:comment, :post => p) + c2 = FactoryGirl.create(:comment, :post => p) p.reload assert_equal(c1.created_at.to_s, p.last_commented_at.to_s) end should "not allow duplicate votes" do - user = Factory.create(:user) - post = Factory.create(:post) - c1 = Factory.create(:comment, :post => post) + user = FactoryGirl.create(:user) + post = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:comment, :post => post) comment_vote = c1.vote!("up") assert_equal([], comment_vote.errors.full_messages) comment_vote = c1.vote!("up") @@ -71,16 +71,16 @@ class CommentTest < ActiveSupport::TestCase assert_equal(1, CommentVote.count) assert_equal(1, CommentVote.last.score) - c2 = Factory.create(:comment, :post => post) + c2 = FactoryGirl.create(:comment, :post => post) comment_vote = c2.vote!("up") assert_equal([], comment_vote.errors.full_messages) assert_equal(2, CommentVote.count) end should "be searchable" do - c1 = Factory.create(:comment, :body => "aaa bbb ccc") - c2 = Factory.create(:comment, :body => "aaa ddd") - c3 = Factory.create(:comment, :body => "eee") + c1 = FactoryGirl.create(:comment, :body => "aaa bbb ccc") + c2 = FactoryGirl.create(:comment, :body => "aaa ddd") + c3 = FactoryGirl.create(:comment, :body => "eee") matches = Comment.body_matches("aaa") assert_equal(2, matches.count) diff --git a/test/unit/current_user_test.rb b/test/unit/current_user_test.rb index be895e56b..ac586df80 100644 --- a/test/unit/current_user_test.rb +++ b/test/unit/current_user_test.rb @@ -8,7 +8,7 @@ class ArtistTest < ActiveSupport::TestCase context "The current user" do should "be set only within the scope of the block" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) assert_nil(CurrentUser.user) assert_nil(CurrentUser.ip_addr) @@ -24,8 +24,8 @@ class ArtistTest < ActiveSupport::TestCase context "A scoped current user" do should "reset the current user after the block has exited" do - user1 = Factory.create(:user) - user2 = Factory.create(:user) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) CurrentUser.user = user1 CurrentUser.scoped(user2, nil) do assert_equal(user2.id, CurrentUser.user.id) @@ -34,8 +34,8 @@ class ArtistTest < ActiveSupport::TestCase end should "reset the current user even if an exception is thrown" do - user1 = Factory.create(:user) - user2 = Factory.create(:user) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) CurrentUser.user = user1 assert_raises(RuntimeError) do CurrentUser.scoped(user2, nil) do diff --git a/test/unit/dmail_test.rb b/test/unit/dmail_test.rb index 1f1b7cfca..734603dd2 100644 --- a/test/unit/dmail_test.rb +++ b/test/unit/dmail_test.rb @@ -4,7 +4,7 @@ class DmailTest < ActiveSupport::TestCase context "A dmail" do setup do MEMCACHE.flush_all - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" ActionMailer::Base.delivery_method = :test @@ -18,7 +18,7 @@ class DmailTest < ActiveSupport::TestCase context "search" do should "return results based on title contents" do - dmail = Factory.create(:dmail, :title => "xxx", :owner => @user) + dmail = FactoryGirl.create(:dmail, :title => "xxx", :owner => @user) matches = Dmail.search_message("xxx") assert(matches.any?) matches = Dmail.search_message("aaa") @@ -26,7 +26,7 @@ class DmailTest < ActiveSupport::TestCase end should "return results based on body contents" do - dmail = Factory.create(:dmail, :body => "xxx", :owner => @user) + dmail = FactoryGirl.create(:dmail, :body => "xxx", :owner => @user) matches = Dmail.search_message("xxx") assert(matches.any?) matches = Dmail.search_message("aaa") @@ -35,14 +35,14 @@ class DmailTest < ActiveSupport::TestCase end should "should parse user names" do - dmail = Factory.build(:dmail, :owner => @user) + dmail = FactoryGirl.build(:dmail, :owner => @user) dmail.to_id = nil dmail.to_name = @user.name assert(dmail.to_id == @user.id) end should "construct a response" do - dmail = Factory.create(:dmail, :owner => @user) + dmail = FactoryGirl.create(:dmail, :owner => @user) response = dmail.build_response assert_equal("Re: #{dmail.title}", response.title) assert_equal(dmail.from_id, response.to_id) @@ -50,28 +50,28 @@ class DmailTest < ActiveSupport::TestCase end should "create a copy for each user" do - @new_user = Factory.create(:user) + @new_user = FactoryGirl.create(:user) assert_difference("Dmail.count", 2) do Dmail.create_split(:to_id => @new_user.id, :title => "foo", :body => "foo") end end should "send an email if the user wants it" do - user = Factory.create(:user, :receive_email_notifications => true) + user = FactoryGirl.create(:user, :receive_email_notifications => true) assert_difference("ActionMailer::Base.deliveries.size", 1) do - Factory.create(:dmail, :to => user, :owner => @user) + FactoryGirl.create(:dmail, :to => user, :owner => @user) end end should "be marked as read after the user reads it" do - dmail = Factory.create(:dmail, :owner => @user) + dmail = FactoryGirl.create(:dmail, :owner => @user) assert(!dmail.is_read?) dmail.mark_as_read! assert(dmail.is_read?) end should "notify the recipient he has mail" do - dmail = Factory.create(:dmail, :owner => @user) + dmail = FactoryGirl.create(:dmail, :owner => @user) assert(dmail.to(true).has_mail?) dmail.mark_as_read! assert(!dmail.to(true).has_mail?) diff --git a/test/unit/downloads/pixa_test.rb b/test/unit/downloads/pixa_test.rb index 7f78a5240..680448fba 100644 --- a/test/unit/downloads/pixa_test.rb +++ b/test/unit/downloads/pixa_test.rb @@ -1,18 +1,18 @@ -require 'test_helper' - -module Downloads - class PixaTest < ActiveSupport::TestCase - context "a download for a pixa image" do - setup do - @source = "http://file0.pixa.cc/illustrations/6f/d6/3f/f9/51/61/29/72/23/ac/middle/sse.jpg?1317405928" - @tempfile = Tempfile.new("danbooru-test") - @download = Downloads::File.new(@source, @tempfile.path) - end - - should "work" do - @download.download! - assert_equal(104627, ::File.size(@tempfile.path)) - end - end - end -end +# require 'test_helper' +# +# module Downloads +# class PixaTest < ActiveSupport::TestCase +# context "a download for a pixa image" do +# setup do +# @source = "http://file0.pixa.cc/illustrations/6f/d6/3f/f9/51/61/29/72/23/ac/middle/sse.jpg?1317405928" +# @tempfile = Tempfile.new("danbooru-test") +# @download = Downloads::File.new(@source, @tempfile.path) +# end +# +# should "work" do +# @download.download! +# assert_equal(104627, ::File.size(@tempfile.path)) +# end +# end +# end +# end diff --git a/test/unit/downloads/tinami_test.rb b/test/unit/downloads/tinami_test.rb index 7eb3e9740..66eae0229 100644 --- a/test/unit/downloads/tinami_test.rb +++ b/test/unit/downloads/tinami_test.rb @@ -1,18 +1,18 @@ -require 'test_helper' - -module Downloads - class TinamiTest < ActiveSupport::TestCase - context "a download for a pixa image" do - setup do - @source = "http://img.tinami.com/illust2/img/330/4e85ecd880a8f.jpg" - @tempfile = Tempfile.new("danbooru-test") - @download = Downloads::File.new(@source, @tempfile.path) - end - - should "work" do - @download.download! - assert_equal(201248, ::File.size(@tempfile.path)) - end - end - end -end +# require 'test_helper' +# +# module Downloads +# class TinamiTest < ActiveSupport::TestCase +# context "a download for a pixa image" do +# setup do +# @source = "http://img.tinami.com/illust2/img/330/4e85ecd880a8f.jpg" +# @tempfile = Tempfile.new("danbooru-test") +# @download = Downloads::File.new(@source, @tempfile.path) +# end +# +# should "work" do +# @download.download! +# assert_equal(201248, ::File.size(@tempfile.path)) +# end +# end +# end +# end diff --git a/test/unit/favorite_test.rb b/test/unit/favorite_test.rb index b949521ba..2f07593fe 100644 --- a/test/unit/favorite_test.rb +++ b/test/unit/favorite_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class FavoriteTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,8 +16,8 @@ class FavoriteTest < ActiveSupport::TestCase context "A favorite" do should "delete from all tables" do - user1 = Factory.create(:user) - p1 = Factory.create(:post) + user1 = FactoryGirl.create(:user) + p1 = FactoryGirl.create(:post) user1.add_favorite!(p1) assert_equal(1, Favorite.count) @@ -27,10 +27,10 @@ class FavoriteTest < ActiveSupport::TestCase end should "know which table it belongs to" do - user1 = Factory.create(:user) - user2 = Factory.create(:user) - p1 = Factory.create(:post) - p2 = Factory.create(:post) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + p1 = FactoryGirl.create(:post) + p2 = FactoryGirl.create(:post) user1.add_favorite!(p1) user1.add_favorite!(p2) @@ -47,9 +47,9 @@ class FavoriteTest < ActiveSupport::TestCase end should "not allow duplicates" do - user1 = Factory.create(:user) - p1 = Factory.create(:post) - p2 = Factory.create(:post) + user1 = FactoryGirl.create(:user) + p1 = FactoryGirl.create(:post) + p2 = FactoryGirl.create(:post) user1.add_favorite!(p1) user1.add_favorite!(p1) diff --git a/test/unit/forum_post_test.rb b/test/unit/forum_post_test.rb index 85a6d684c..32324bde8 100644 --- a/test/unit/forum_post_test.rb +++ b/test/unit/forum_post_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class ForumPostTest < ActiveSupport::TestCase context "A forum post" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @topic = Factory.create(:forum_topic) + @topic = FactoryGirl.create(:forum_topic) end teardown do @@ -16,7 +16,7 @@ class ForumPostTest < ActiveSupport::TestCase context "belonging to a locked topic" do setup do - @post = Factory.create(:forum_post, :topic_id => @topic.id, :body => "zzz") + @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "zzz") @topic.update_attribute(:is_locked, true) @post.reload end @@ -36,26 +36,26 @@ class ForumPostTest < ActiveSupport::TestCase should "update its parent when saved" do sleep 1 original_topic_updated_at = @topic.updated_at - post = Factory.create(:forum_post, :topic_id => @topic.id) + post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) @topic.reload assert_not_equal(original_topic_updated_at, @topic.updated_at) end should "be searchable by body content" do - post = Factory.create(:forum_post, :topic_id => @topic.id, :body => "xxx") + post = FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "xxx") assert_equal(1, ForumPost.body_matches("xxx").count) assert_equal(0, ForumPost.body_matches("aaa").count) end should "initialize its creator" do - post = Factory.create(:forum_post, :topic_id => @topic.id) + post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) assert_equal(@user.id, post.creator_id) end context "updated by a second user" do setup do - @post = Factory.create(:forum_post, :topic_id => @topic.id) - @second_user = Factory.create(:user) + @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) + @second_user = FactoryGirl.create(:user) CurrentUser.user = @second_user end diff --git a/test/unit/forum_topic_test.rb b/test/unit/forum_topic_test.rb index 87b828fe7..ece7e7353 100644 --- a/test/unit/forum_topic_test.rb +++ b/test/unit/forum_topic_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class ForumTopicTest < ActiveSupport::TestCase context "A forum topic" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @topic = Factory.create(:forum_topic, :title => "xxx") + @topic = FactoryGirl.create(:forum_topic, :title => "xxx") end teardown do @@ -17,7 +17,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "constructed with nested attributes for its original post" do should "create a matching forum post" do assert_difference(["ForumTopic.count", "ForumPost.count"], 1) do - @topic = Factory.create(:forum_topic, :title => "abc", :original_post_attributes => {:body => "abc"}) + @topic = FactoryGirl.create(:forum_topic, :title => "abc", :original_post_attributes => {:body => "abc"}) end end end @@ -33,7 +33,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "updated by a second user" do setup do - @second_user = Factory.create(:user) + @second_user = FactoryGirl.create(:user) CurrentUser.user = @second_user end @@ -46,7 +46,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "with multiple posts that has been deleted" do setup do 5.times do - Factory.create(:forum_post, :topic_id => @topic.id) + FactoryGirl.create(:forum_post, :topic_id => @topic.id) end end diff --git a/test/unit/ip_ban_test.rb b/test/unit/ip_ban_test.rb index 055c975d0..019201cca 100644 --- a/test/unit/ip_ban_test.rb +++ b/test/unit/ip_ban_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class IpBanTest < ActiveSupport::TestCase setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -15,14 +15,14 @@ class IpBanTest < ActiveSupport::TestCase end should "be able to count the number of comments an IP address is associated with" do - comment = Factory.create(:comment) + comment = FactoryGirl.create(:comment) counts = IpBan.count_by_ip_addr("comments", [comment.creator_id], "creator_id", "ip_addr") assert_equal([{"ip_addr" => "127.0.0.1", "count" => "1"}], counts) end should "be able to count any updates from a user, groupiny by IP address" do CurrentUser.scoped(@user, "1.2.3.4") do - comment = Factory.create(:comment, :body => "aaa") + comment = FactoryGirl.create(:comment, :body => "aaa") counts = IpBan.query([comment.creator_id]) assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts["comments"]) end diff --git a/test/unit/janitor_trial_test.rb b/test/unit/janitor_trial_test.rb index 3b8f5cf0f..0fcd42615 100644 --- a/test/unit/janitor_trial_test.rb +++ b/test/unit/janitor_trial_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class JanitorTrialTest < ActiveSupport::TestCase context "A janitor trial" do setup do - @admin = Factory.create(:admin_user) - @user = Factory.create(:user) + @admin = FactoryGirl.create(:admin_user) + @user = FactoryGirl.create(:user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -31,7 +31,7 @@ class JanitorTrialTest < ActiveSupport::TestCase context "upon demotion" do setup do - @janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) end should "create a negative feedback record" do @@ -43,7 +43,7 @@ class JanitorTrialTest < ActiveSupport::TestCase context "upon promotion" do setup do - @janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) end should "destroy the trial object" do diff --git a/test/unit/maintenance/user/login_reminder_mailer_test.rb b/test/unit/maintenance/user/login_reminder_mailer_test.rb index 5e46a93c1..43febdeb0 100644 --- a/test/unit/maintenance/user/login_reminder_mailer_test.rb +++ b/test/unit/maintenance/user/login_reminder_mailer_test.rb @@ -5,7 +5,7 @@ module Maintenance class LoginReminderMailerTest < ActionMailer::TestCase context "The login reminder mailer" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "send the notie" do diff --git a/test/unit/moderator/ip_addr_search_test.rb b/test/unit/moderator/ip_addr_search_test.rb index 72e89198d..b9e01daa5 100644 --- a/test/unit/moderator/ip_addr_search_test.rb +++ b/test/unit/moderator/ip_addr_search_test.rb @@ -4,11 +4,11 @@ module Moderator class IpAddrSearchTest < ActiveSupport::TestCase context "an ip addr search" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - Factory.create(:comment) + FactoryGirl.create(:comment) MEMCACHE.flush_all end diff --git a/test/unit/moderator/tag_batch_change_test.rb b/test/unit/moderator/tag_batch_change_test.rb index 8c6ba8512..11c54a3de 100644 --- a/test/unit/moderator/tag_batch_change_test.rb +++ b/test/unit/moderator/tag_batch_change_test.rb @@ -4,10 +4,10 @@ module Moderator class TagBatchChangeTest < ActiveSupport::TestCase context "a tag batch change" do setup do - @user = Factory.create(:moderator_user) + @user = FactoryGirl.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post, :tag_string => "aaa") + @post = FactoryGirl.create(:post, :tag_string => "aaa") end teardown do diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index d9769ed60..4cec97135 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class NoteTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,12 +16,12 @@ class NoteTest < ActiveSupport::TestCase context "creating a note" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end should "create a version" do assert_difference("NoteVersion.count", 1) do - @note = Factory.create(:note, :post => @post) + @note = FactoryGirl.create(:note, :post => @post) end assert_equal(1, @note.versions.count) @@ -30,7 +30,7 @@ class NoteTest < ActiveSupport::TestCase should "update the post's last_noted_at field" do assert_nil(@post.last_noted_at) - @note = Factory.create(:note, :post => @post) + @note = FactoryGirl.create(:note, :post => @post) @post.reload assert_not_nil(@post.last_noted_at) end @@ -42,7 +42,7 @@ class NoteTest < ActiveSupport::TestCase should "fail" do assert_difference("Note.count", 0) do - @note = Factory.build(:note, :post => @post) + @note = FactoryGirl.build(:note, :post => @post) @note.save end assert_equal(["Post is note locked"], @note.errors.full_messages) @@ -52,8 +52,8 @@ class NoteTest < ActiveSupport::TestCase context "updating a note" do setup do - @post = Factory.create(:post) - @note = Factory.create(:note, :post => @post) + @post = FactoryGirl.create(:post) + @note = FactoryGirl.create(:note, :post => @post) end should "increment the updater's note_update_count" do @@ -91,8 +91,8 @@ class NoteTest < ActiveSupport::TestCase context "when notes have been vandalized by one user" do setup do - @vandal = Factory.create(:user) - @note = Factory.create(:note, :x => 100, :y => 100) + @vandal = FactoryGirl.create(:user) + @note = FactoryGirl.create(:note, :x => 100, :y => 100) CurrentUser.scoped(@vandal, "127.0.0.1") do @note.update_attributes(:x => 2000, :y => 2000) end @@ -110,7 +110,7 @@ class NoteTest < ActiveSupport::TestCase context "searching for a note" do setup do - @note = Factory.create(:note, :body => "aaa") + @note = FactoryGirl.create(:note, :body => "aaa") end context "where the body contains the string 'aaa'" do diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index cfffc2977..6b544974e 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class PoolTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -15,7 +15,7 @@ class PoolTest < ActiveSupport::TestCase context "A name" do setup do - @pool = Factory.create(:pool, :name => "xxx") + @pool = FactoryGirl.create(:pool, :name => "xxx") end should "be mapped to a pool id" do @@ -25,7 +25,7 @@ class PoolTest < ActiveSupport::TestCase context "An id number" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) end should "be mapped to a pool id" do @@ -39,10 +39,10 @@ class PoolTest < ActiveSupport::TestCase context "Reverting a pool" do setup do - @pool = Factory.create(:pool) - @p1 = Factory.create(:post) - @p2 = Factory.create(:post) - @p3 = Factory.create(:post) + @pool = FactoryGirl.create(:pool) + @p1 = FactoryGirl.create(:post) + @p2 = FactoryGirl.create(:post) + @p3 = FactoryGirl.create(:post) CurrentUser.ip_addr = "1.2.3.4" @pool.add!(@p1) CurrentUser.ip_addr = "1.2.3.5" @@ -81,9 +81,9 @@ class PoolTest < ActiveSupport::TestCase context "Updating a pool" do setup do - @pool = Factory.create(:pool) - @p1 = Factory.create(:post) - @p2 = Factory.create(:post) + @pool = FactoryGirl.create(:pool) + @p1 = FactoryGirl.create(:post) + @p2 = FactoryGirl.create(:post) end context "by adding a new post" do @@ -194,10 +194,10 @@ class PoolTest < ActiveSupport::TestCase context "An existing pool" do setup do - @pool = Factory.create(:pool) - @p1 = Factory.create(:post) - @p2 = Factory.create(:post) - @p3 = Factory.create(:post) + @pool = FactoryGirl.create(:pool) + @p1 = FactoryGirl.create(:post) + @p2 = FactoryGirl.create(:post) + @p3 = FactoryGirl.create(:post) @pool.add!(@p1) @pool.add!(@p2) @pool.add!(@p3) @@ -249,7 +249,7 @@ class PoolTest < ActiveSupport::TestCase context "An anonymous pool" do setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user end diff --git a/test/unit/post_appeal_test.rb b/test/unit/post_appeal_test.rb index 5b8922e9e..ff7a46d8a 100644 --- a/test/unit/post_appeal_test.rb +++ b/test/unit/post_appeal_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostAppealTest < ActiveSupport::TestCase context "In all cases" do setup do - @alice = Factory.create(:user) + @alice = FactoryGirl.create(:user) CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -17,7 +17,7 @@ class PostAppealTest < ActiveSupport::TestCase context "a user" do setup do - @post = Factory.create(:post, :tag_string => "aaa", :is_deleted => true) + @post = FactoryGirl.create(:post, :tag_string => "aaa", :is_deleted => true) end should "not be able to appeal a post more than twice" do diff --git a/test/unit/post_disapproval_test.rb b/test/unit/post_disapproval_test.rb index 323d2ef75..3355197ce 100644 --- a/test/unit/post_disapproval_test.rb +++ b/test/unit/post_disapproval_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostDisapprovalTest < ActiveSupport::TestCase context "In all cases" do setup do - @alice = Factory.create(:moderator_user) + @alice = FactoryGirl.create(:moderator_user) CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,8 +16,8 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "A post disapproval" do setup do - @post_1 = Factory.create(:post, :is_pending => true) - @post_2 = Factory.create(:post, :is_pending => true) + @post_1 = FactoryGirl.create(:post, :is_pending => true) + @post_2 = FactoryGirl.create(:post, :is_pending => true) end context "made by alice" do @@ -38,7 +38,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "when the current user is brittony" do setup do - @brittony = Factory.create(:moderator_user) + @brittony = FactoryGirl.create(:moderator_user) CurrentUser.user = @brittony end @@ -51,8 +51,8 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "for a post that has been approved" do setup do - @post = Factory.create(:post) - @user = Factory.create(:user) + @post = FactoryGirl.create(:post) + @user = FactoryGirl.create(:user) @disapproval = PostDisapproval.create(:user => @user, :post => @post) end diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb index f143ff01d..270eceac9 100644 --- a/test/unit/post_flag_test.rb +++ b/test/unit/post_flag_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostFlagTest < ActiveSupport::TestCase context "In all cases" do setup do - @alice = Factory.create(:user) + @alice = FactoryGirl.create(:user) CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,7 +16,7 @@ class PostFlagTest < ActiveSupport::TestCase context "a user" do setup do - @post = Factory.create(:post, :tag_string => "aaa") + @post = FactoryGirl.create(:post, :tag_string => "aaa") end should "not be able to flag a post more than twice" do diff --git a/test/unit/post_pruner_test.rb b/test/unit/post_pruner_test.rb index 3acd23d35..e3167128d 100644 --- a/test/unit/post_pruner_test.rb +++ b/test/unit/post_pruner_test.rb @@ -2,19 +2,19 @@ require 'test_helper' class PostPrunerTest < ActiveSupport::TestCase setup do - @user = Factory.create(:admin_user) + @user = FactoryGirl.create(:admin_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @flagger = Factory.create(:user) - @old_post = Factory.create(:post, :created_at => 5.days.ago, :is_pending => true) - @unresolved_flagged_post = Factory.create(:post, :is_flagged => true) - @resolved_flagged_post = Factory.create(:post, :is_flagged => true) + @flagger = FactoryGirl.create(:user) + @old_post = FactoryGirl.create(:post, :created_at => 5.days.ago, :is_pending => true) + @unresolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true) + @resolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true) CurrentUser.scoped(@flagger, "127.0.0.2") do - @unresolved_post_flag = Factory.create(:post_flag, :created_at => 5.days.ago, :is_resolved => false, :post_id => @unresolved_flagged_post.id) - @resolved_post_flag = Factory.create(:post_flag, :created_at => 5.days.ago, :is_resolved => true, :post_id => @resolved_flagged_post.id) + @unresolved_post_flag = FactoryGirl.create(:post_flag, :created_at => 5.days.ago, :is_resolved => false, :post_id => @unresolved_flagged_post.id) + @resolved_post_flag = FactoryGirl.create(:post_flag, :created_at => 5.days.ago, :is_resolved => true, :post_id => @resolved_flagged_post.id) end PostPruner.new.prune! diff --git a/test/unit/post_sets/favorite_test.rb b/test/unit/post_sets/favorite_test.rb index f5293b044..28a42e2ef 100644 --- a/test/unit/post_sets/favorite_test.rb +++ b/test/unit/post_sets/favorite_test.rb @@ -4,14 +4,14 @@ module PostSets class FavoriteTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @post_1 = Factory.create(:post) - @post_2 = Factory.create(:post) - @post_3 = Factory.create(:post) + @post_1 = FactoryGirl.create(:post) + @post_2 = FactoryGirl.create(:post) + @post_3 = FactoryGirl.create(:post) @post_2.add_favorite!(@user) @post_1.add_favorite!(@user) @post_3.add_favorite!(@user) diff --git a/test/unit/post_sets/pool_test.rb b/test/unit/post_sets/pool_test.rb index fe727773a..9e99e080b 100644 --- a/test/unit/post_sets/pool_test.rb +++ b/test/unit/post_sets/pool_test.rb @@ -4,15 +4,15 @@ module PostSets class PoolTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @post_1 = Factory.create(:post) - @post_2 = Factory.create(:post) - @post_3 = Factory.create(:post) - @pool = Factory.create(:pool) + @post_1 = FactoryGirl.create(:post) + @post_2 = FactoryGirl.create(:post) + @post_3 = FactoryGirl.create(:post) + @pool = FactoryGirl.create(:pool) @pool.add!(@post_2) @pool.add!(@post_1) @pool.add!(@post_3) diff --git a/test/unit/post_sets/post_test.rb b/test/unit/post_sets/post_test.rb index 6274205af..cbf433256 100644 --- a/test/unit/post_sets/post_test.rb +++ b/test/unit/post_sets/post_test.rb @@ -5,14 +5,14 @@ module PostSets class PostTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @post_1 = Factory.create(:post, :tag_string => "a") - @post_2 = Factory.create(:post, :tag_string => "b") - @post_3 = Factory.create(:post, :tag_string => "c") + @post_1 = FactoryGirl.create(:post, :tag_string => "a") + @post_2 = FactoryGirl.create(:post, :tag_string => "b") + @post_3 = FactoryGirl.create(:post, :tag_string => "c") end teardown do @@ -33,8 +33,8 @@ module PostSets context "a set for the 'a' tag query" do setup do - @post_4 = Factory.create(:post, :tag_string => "a") - @post_5 = Factory.create(:post, :tag_string => "a") + @post_4 = FactoryGirl.create(:post, :tag_string => "a") + @post_5 = FactoryGirl.create(:post, :tag_string => "a") end context "with no page" do @@ -108,7 +108,7 @@ module PostSets context "for a privileged user" do setup do - CurrentUser.user = Factory.create(:privileged_user) + CurrentUser.user = FactoryGirl.create(:privileged_user) end should "pass" do @@ -142,7 +142,7 @@ module PostSets context "that has a matching wiki page" do setup do - @wiki_page = Factory.create(:wiki_page, :title => "a") + @wiki_page = FactoryGirl.create(:wiki_page, :title => "a") end should "find the wiki page" do @@ -153,7 +153,7 @@ module PostSets context "that has a matching artist" do setup do - @artist = Factory.create(:artist, :name => "a") + @artist = FactoryGirl.create(:artist, :name => "a") end should "find the artist" do diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 8654feb08..2361a1d5e 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class PostTest < ActiveSupport::TestCase setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,7 +16,7 @@ class PostTest < ActiveSupport::TestCase context "Deletion:" do context "Annihilating a post" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end context "that is status locked" do @@ -40,7 +40,7 @@ class PostTest < ActiveSupport::TestCase context "Deleting a post" do context "that is status locked" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.update_attributes({:is_status_locked => true}, :as => :admin) end @@ -52,7 +52,7 @@ class PostTest < ActiveSupport::TestCase end should "update the fast count" do - post = Factory.create(:post, :tag_string => "aaa") + post = FactoryGirl.create(:post, :tag_string => "aaa") assert_equal(1, Post.fast_count) assert_equal(1, Post.fast_count("aaa")) post.delete! @@ -61,14 +61,14 @@ class PostTest < ActiveSupport::TestCase end should "toggle the is_deleted flag" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) assert_equal(false, post.is_deleted?) post.delete! assert_equal(true, post.is_deleted?) end should "decrement the tag counts" do - post = Factory.create(:post, :tag_string => "aaa") + post = FactoryGirl.create(:post, :tag_string => "aaa") assert_equal(1, Tag.find_by_name("aaa").post_count) post.delete! assert_equal(0, Tag.find_by_name("aaa").post_count) @@ -79,17 +79,17 @@ class PostTest < ActiveSupport::TestCase context "Parenting:" do context "Assignining a parent to a post" do should "update the has_children flag on the parent" do - p1 = Factory.create(:post) + p1 = FactoryGirl.create(:post) assert(!p1.has_children?, "Parent should not have any children") - c1 = Factory.create(:post, :parent_id => p1.id) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) p1.reload assert(p1.has_children?, "Parent not updated after child was added") end should "update the has_children flag on the old parent" do - p1 = Factory.create(:post) - p2 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + p2 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) c1.parent_id = p2.id c1.save p1.reload @@ -99,15 +99,15 @@ class PostTest < ActiveSupport::TestCase end should "validate that the parent exists" do - post = Factory.build(:post, :parent_id => 1_000_000) + post = FactoryGirl.build(:post, :parent_id => 1_000_000) post.save assert(post.errors[:parent].any?, "Parent should be invalid") end should "fail if the parent has a parent" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) - c2 = Factory.build(:post, :parent_id => c1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) + c2 = FactoryGirl.build(:post, :parent_id => c1.id) c2.save assert(c2.errors[:parent].any?, "Parent should be invalid") end @@ -116,17 +116,17 @@ class PostTest < ActiveSupport::TestCase context "Destroying a post with" do context "a parent" do should "reset the has_children flag of the parent" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) c1.delete! p1.reload assert_equal(false, p1.has_children?) end should "reassign favorites to the parent" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) - user = Factory.create(:user) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) + user = FactoryGirl.create(:user) c1.add_favorite!(user) c1.delete! p1.reload @@ -135,8 +135,8 @@ class PostTest < ActiveSupport::TestCase end should "update the parent's has_children flag" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) c1.delete! p1.reload assert(!p1.has_children?, "Parent should not have children") @@ -145,15 +145,15 @@ class PostTest < ActiveSupport::TestCase context "one child" do should "remove the has_children flag" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) p1.delete! assert_equal(false, p1.has_children?) end should "remove the parent of that child" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) p1.delete! c1.reload assert_nil(c1.parent) @@ -162,10 +162,10 @@ class PostTest < ActiveSupport::TestCase context "two or more children" do should "reparent all children to the first child" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) - c2 = Factory.create(:post, :parent_id => p1.id) - c3 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) + c2 = FactoryGirl.create(:post, :parent_id => p1.id) + c3 = FactoryGirl.create(:post, :parent_id => p1.id) p1.delete! c1.reload c2.reload @@ -179,8 +179,8 @@ class PostTest < ActiveSupport::TestCase context "Undestroying a post with a parent" do should "not preserve the parent's has_children flag" do - p1 = Factory.create(:post) - c1 = Factory.create(:post, :parent_id => p1.id) + p1 = FactoryGirl.create(:post) + c1 = FactoryGirl.create(:post, :parent_id => p1.id) c1.delete! c1.undelete! p1.reload @@ -193,7 +193,7 @@ class PostTest < ActiveSupport::TestCase context "Moderation:" do context "A deleted post" do setup do - @post = Factory.create(:post, :is_deleted => true) + @post = FactoryGirl.create(:post, :is_deleted => true) end context "that is status locked" do @@ -225,7 +225,7 @@ class PostTest < ActiveSupport::TestCase context "An approved post" do should "be flagged" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) assert_difference("PostFlag.count", 1) do post.flag!("bad") end @@ -234,7 +234,7 @@ class PostTest < ActiveSupport::TestCase end should "not be flagged if no reason is given" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) assert_difference("PostFlag.count", 0) do assert_raises(PostFlag::Error) do post.flag!("") @@ -245,14 +245,14 @@ class PostTest < ActiveSupport::TestCase context "An unapproved post" do should "preserve the approver's identity when approved" do - post = Factory.create(:post, :is_pending => true) + post = FactoryGirl.create(:post, :is_pending => true) post.approve! assert_equal(post.approver_id, CurrentUser.id) end context "that was uploaded by person X" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.flag!("reason") end @@ -269,9 +269,9 @@ class PostTest < ActiveSupport::TestCase context "that was previously approved by person X" do setup do - @user = Factory.create(:janitor_user, :name => "xxx") - @user2 = Factory.create(:janitor_user, :name => "yyy") - @post = Factory.create(:post, :approver_id => @user.id) + @user = FactoryGirl.create(:janitor_user, :name => "xxx") + @user2 = FactoryGirl.create(:janitor_user, :name => "yyy") + @post = FactoryGirl.create(:post, :approver_id => @user.id) @post.flag!("bad") end @@ -294,7 +294,7 @@ class PostTest < ActiveSupport::TestCase context "that has been reapproved" do should "no longer be flagged or pending" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) post.flag!("bad") post.approve! assert(post.errors.empty?, post.errors.full_messages.join(", ")) @@ -307,7 +307,7 @@ class PostTest < ActiveSupport::TestCase context "A status locked post" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.update_attributes({:is_status_locked => true}, :as => :admin) end @@ -334,13 +334,13 @@ class PostTest < ActiveSupport::TestCase context "Tagging:" do context "A post" do setup do - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end context "tagged with a metatag" do context "for a parent" do setup do - @parent = Factory.create(:post) + @parent = FactoryGirl.create(:post) end should "update the parent relationships for both posts" do @@ -355,7 +355,7 @@ class PostTest < ActiveSupport::TestCase context "for a pool" do context "id" do setup do - @pool = Factory.create(:pool) + @pool = FactoryGirl.create(:pool) @post.update_attributes(:tag_string => "aaa pool:#{@pool.id}") end @@ -370,7 +370,7 @@ class PostTest < ActiveSupport::TestCase context "name" do context "that exists" do setup do - @pool = Factory.create(:pool, :name => "abc") + @pool = FactoryGirl.create(:pool, :name => "abc") @post.update_attributes(:tag_string => "aaa pool:abc") end @@ -423,7 +423,7 @@ class PostTest < ActiveSupport::TestCase end should "have an array representation of its tags" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) post.set_tag_string("aaa bbb") assert_equal(%w(aaa bbb), post.tag_array) assert_equal(%w(tag1 tag2), post.tag_array_was) @@ -431,7 +431,7 @@ class PostTest < ActiveSupport::TestCase context "that has been updated" do should "increment the updater's post_update_count" do - post = Factory.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") assert_difference("CurrentUser.post_update_count", 1) do post.update_attributes(:tag_string => "zzz") @@ -440,8 +440,8 @@ class PostTest < ActiveSupport::TestCase end should "reset its tag array cache" do - post = Factory.create(:post, :tag_string => "aaa bbb ccc") - user = Factory.create(:user) + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + user = FactoryGirl.create(:user) assert_equal(%w(aaa bbb ccc), post.tag_array) post.tag_string = "ddd eee fff" post.tag_string = "ddd eee fff" @@ -452,14 +452,14 @@ class PostTest < ActiveSupport::TestCase should "create the actual tag records" do assert_difference("Tag.count", 3) do - post = Factory.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") end end should "update the post counts of relevant tag records" do - post1 = Factory.create(:post, :tag_string => "aaa bbb ccc") - post2 = Factory.create(:post, :tag_string => "bbb ccc ddd") - post3 = Factory.create(:post, :tag_string => "ccc ddd eee") + post1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + post2 = FactoryGirl.create(:post, :tag_string => "bbb ccc ddd") + post3 = FactoryGirl.create(:post, :tag_string => "ccc ddd eee") assert_equal(1, Tag.find_by_name("aaa").post_count) assert_equal(2, Tag.find_by_name("bbb").post_count) assert_equal(3, Tag.find_by_name("ccc").post_count) @@ -474,10 +474,10 @@ class PostTest < ActiveSupport::TestCase end should "update its tag counts" do - artist_tag = Factory.create(:artist_tag) - copyright_tag = Factory.create(:copyright_tag) - general_tag = Factory.create(:tag) - new_post = Factory.create(:post, :tag_string => "#{artist_tag.name} #{copyright_tag.name} #{general_tag.name}") + artist_tag = FactoryGirl.create(:artist_tag) + copyright_tag = FactoryGirl.create(:copyright_tag) + general_tag = FactoryGirl.create(:tag) + new_post = FactoryGirl.create(:post, :tag_string => "#{artist_tag.name} #{copyright_tag.name} #{general_tag.name}") assert_equal(1, new_post.tag_count_artist) assert_equal(1, new_post.tag_count_copyright) assert_equal(1, new_post.tag_count_general) @@ -494,7 +494,7 @@ class PostTest < ActiveSupport::TestCase end should "merge any changes that were made after loading the initial set of tags part 1" do - post = Factory.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") # user a adds post_edited_by_user_a = Post.find(post.id) @@ -517,7 +517,7 @@ class PostTest < ActiveSupport::TestCase # This is the same as part 1, only the order of operations is reversed. # The results should be the same. - post = Factory.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") # user a removes adds post_edited_by_user_a = Post.find(post.id) @@ -539,7 +539,7 @@ class PostTest < ActiveSupport::TestCase context "that has been tagged with a metatag" do should "not include the metatag in its tag string" do - post = Factory.create(:post) + post = FactoryGirl.create(:post) post.tag_string = "aaa pool:1234 pool:test rating:s fav:bob" post.save assert_equal("aaa", post.tag_string) @@ -551,10 +551,10 @@ class PostTest < ActiveSupport::TestCase context "Favorites:" do context "Removing a post from a user's favorites" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) @post.add_favorite!(@user) end @@ -571,7 +571,7 @@ class PostTest < ActiveSupport::TestCase end should "not decrement the user's favorite_count if the user did not favorite the post" do - @post2 = Factory.create(:post) + @post2 = FactoryGirl.create(:post) assert_difference("CurrentUser.favorite_count", 0) do @post2.remove_favorite!(@user) CurrentUser.reload @@ -581,10 +581,10 @@ class PostTest < ActiveSupport::TestCase context "Adding a post to a user's favorites" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end teardown do @@ -626,8 +626,8 @@ class PostTest < ActiveSupport::TestCase context "Pools:" do context "Removing a post from a pool" do should "update the post's pool string" do - post = Factory.create(:post) - pool = Factory.create(:pool) + post = FactoryGirl.create(:post) + pool = FactoryGirl.create(:pool) post.add_pool!(pool) post.remove_pool!(pool) post.reload @@ -640,8 +640,8 @@ class PostTest < ActiveSupport::TestCase context "Adding a post to a pool" do should "update the post's pool string" do - post = Factory.create(:post) - pool = Factory.create(:pool) + post = FactoryGirl.create(:post) + pool = FactoryGirl.create(:pool) post.add_pool!(pool) post.reload assert_equal("pool:#{pool.id}", post.pool_string) @@ -658,10 +658,10 @@ class PostTest < ActiveSupport::TestCase context "Uploading:" do context "Uploading a post" do should "capture who uploaded the post" do - post = Factory.create(:post) - user1 = Factory.create(:user) - user2 = Factory.create(:user) - user3 = Factory.create(:user) + post = FactoryGirl.create(:post) + user1 = FactoryGirl.create(:user) + user2 = FactoryGirl.create(:user) + user3 = FactoryGirl.create(:user) post.uploader = user1 assert_equal(user1.id, post.uploader_id) @@ -676,9 +676,9 @@ class PostTest < ActiveSupport::TestCase context "Searching:" do should "return posts for 1 tag" do - post1 = Factory.create(:post, :tag_string => "aaa") - post2 = Factory.create(:post, :tag_string => "aaa bbb") - post3 = Factory.create(:post, :tag_string => "bbb ccc") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") relation = Post.tag_match("aaa") assert_equal(2, relation.count) assert_equal(post2.id, relation.all[0].id) @@ -686,27 +686,27 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a 2 tag join" do - post1 = Factory.create(:post, :tag_string => "aaa") - post2 = Factory.create(:post, :tag_string => "aaa bbb") - post3 = Factory.create(:post, :tag_string => "bbb ccc") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") relation = Post.tag_match("aaa bbb") assert_equal(1, relation.count) assert_equal(post2.id, relation.first.id) end should "return posts for 1 tag with exclusion" do - post1 = Factory.create(:post, :tag_string => "aaa") - post2 = Factory.create(:post, :tag_string => "aaa bbb") - post3 = Factory.create(:post, :tag_string => "bbb ccc") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") relation = Post.tag_match("aaa -bbb") assert_equal(1, relation.count) assert_equal(post1.id, relation.first.id) end should "return posts for 1 tag with a pattern" do - post1 = Factory.create(:post, :tag_string => "aaa") - post2 = Factory.create(:post, :tag_string => "aaab bbb") - post3 = Factory.create(:post, :tag_string => "bbb ccc") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + post2 = FactoryGirl.create(:post, :tag_string => "aaab bbb") + post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") relation = Post.tag_match("a*") assert_equal(2, relation.count) assert_equal(post2.id, relation.all[0].id) @@ -714,18 +714,18 @@ class PostTest < ActiveSupport::TestCase end should "return posts for 2 tags, one with a pattern" do - post1 = Factory.create(:post, :tag_string => "aaa") - post2 = Factory.create(:post, :tag_string => "aaab bbb") - post3 = Factory.create(:post, :tag_string => "bbb ccc") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + post2 = FactoryGirl.create(:post, :tag_string => "aaab bbb") + post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") relation = Post.tag_match("a* bbb") assert_equal(1, relation.count) assert_equal(post2.id, relation.first.id) end should "return posts for the metatag" do - post1 = Factory.create(:post) - post2 = Factory.create(:post) - post3 = Factory.create(:post) + post1 = FactoryGirl.create(:post) + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) relation = Post.tag_match("id:#{post2.id}") assert_equal(1, relation.count) assert_equal(post2.id, relation.first.id) @@ -738,10 +738,10 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the metatag" do - post1 = Factory.create(:post) - post2 = Factory.create(:post) - post3 = Factory.create(:post) - user = Factory.create(:user) + post1 = FactoryGirl.create(:post) + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) + user = FactoryGirl.create(:user) post1.add_favorite!(user) relation = Post.tag_match("fav:#{user.name}") assert_equal(1, relation.count) @@ -749,10 +749,10 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the metatag" do - post1 = Factory.create(:post) - post2 = Factory.create(:post) - post3 = Factory.create(:post) - pool = Factory.create(:pool, :name => "xxx") + post1 = FactoryGirl.create(:post) + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) + pool = FactoryGirl.create(:pool, :name => "xxx") post1.add_pool!(pool) relation = Post.tag_match("pool:xxx") assert_equal(1, relation.count) @@ -760,14 +760,14 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the metatag" do - second_user = Factory.create(:user) - post1 = Factory.create(:post, :uploader => CurrentUser.user) + second_user = FactoryGirl.create(:user) + post1 = FactoryGirl.create(:post, :uploader => CurrentUser.user) assert_equal(CurrentUser.id, post1.uploader_id) CurrentUser.scoped(second_user, "127.0.0.2") do - post2 = Factory.create(:post) - post3 = Factory.create(:post) + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) end relation = Post.tag_match("uploader:#{CurrentUser.user.name}") @@ -776,53 +776,53 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a list of md5 hashes" do - post1 = Factory.create(:post, :md5 => "abcd") - post2 = Factory.create(:post) - post3 = Factory.create(:post) + post1 = FactoryGirl.create(:post, :md5 => "abcd") + post2 = FactoryGirl.create(:post) + post3 = FactoryGirl.create(:post) relation = Post.tag_match("md5:abcd") assert_equal(1, relation.count) assert_equal(post1.id, relation.first.id) end should "return posts for a source search" do - post1 = Factory.create(:post, :source => "abcd") - post2 = Factory.create(:post, :source => "abcdefg") - post3 = Factory.create(:post, :source => "xyz") + post1 = FactoryGirl.create(:post, :source => "abcd") + post2 = FactoryGirl.create(:post, :source => "abcdefg") + post3 = FactoryGirl.create(:post, :source => "xyz") relation = Post.tag_match("source:abcde") assert_equal(1, relation.count) assert_equal(post2.id, relation.first.id) end should "return posts for a tag subscription search" do - post1 = Factory.create(:post, :tag_string => "aaa") - sub = Factory.create(:tag_subscription, :tag_query => "aaa", :name => "zzz") + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + sub = FactoryGirl.create(:tag_subscription, :tag_query => "aaa", :name => "zzz") TagSubscription.process_all relation = Post.tag_match("sub:#{CurrentUser.name}") assert_equal(1, relation.count) end should "return posts for a particular rating" do - post1 = Factory.create(:post, :rating => "s") - post2 = Factory.create(:post, :rating => "q") - post3 = Factory.create(:post, :rating => "e") + post1 = FactoryGirl.create(:post, :rating => "s") + post2 = FactoryGirl.create(:post, :rating => "q") + post3 = FactoryGirl.create(:post, :rating => "e") relation = Post.tag_match("rating:e") assert_equal(1, relation.count) assert_equal(post3.id, relation.first.id) end should "return posts for a particular negated rating" do - post1 = Factory.create(:post, :rating => "s") - post2 = Factory.create(:post, :rating => "s") - post3 = Factory.create(:post, :rating => "e") + post1 = FactoryGirl.create(:post, :rating => "s") + post2 = FactoryGirl.create(:post, :rating => "s") + post3 = FactoryGirl.create(:post, :rating => "e") relation = Post.tag_match("-rating:s") assert_equal(1, relation.count) assert_equal(post3.id, relation.first.id) end should "return posts ordered by a particular attribute" do - post1 = Factory.create(:post, :rating => "s") - post2 = Factory.create(:post, :rating => "s") - post3 = Factory.create(:post, :rating => "e", :score => 5, :image_width => 1000) + post1 = FactoryGirl.create(:post, :rating => "s") + post2 = FactoryGirl.create(:post, :rating => "s") + post3 = FactoryGirl.create(:post, :rating => "e", :score => 5, :image_width => 1000) relation = Post.tag_match("order:id") assert_equal(post1.id, relation.first.id) relation = Post.tag_match("order:mpixels") @@ -832,14 +832,14 @@ class PostTest < ActiveSupport::TestCase end should "fail for exclusive tag searches with no other tag" do - post1 = Factory.create(:post, :rating => "s", :tag_string => "aaa") + post1 = FactoryGirl.create(:post, :rating => "s", :tag_string => "aaa") assert_raise(::Post::SearchError) do relation = Post.tag_match("-aaa") end end should "succeed for exclusive tag searches combined with a metatag" do - post1 = Factory.create(:post, :rating => "s", :tag_string => "aaa") + post1 = FactoryGirl.create(:post, :rating => "s", :tag_string => "aaa") assert_nothing_raised do relation = Post.tag_match("-aaa id:>0") end @@ -848,8 +848,8 @@ class PostTest < ActiveSupport::TestCase context "Voting:" do should "not allow duplicate votes" do - user = Factory.create(:user) - post = Factory.create(:post) + user = FactoryGirl.create(:user) + post = FactoryGirl.create(:post) CurrentUser.scoped(user, "127.0.0.1") do assert_nothing_raised {post.vote!("up")} assert_raises(PostVote::Error) {post.vote!("up")} @@ -864,7 +864,7 @@ class PostTest < ActiveSupport::TestCase context "Creating a post" do should "increment the post count" do assert_equal(0, Post.fast_count("")) - post = Factory.create(:post, :tag_string => "aaa bbb") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb") assert_equal(1, Post.fast_count("")) assert_equal(1, Post.fast_count("aaa")) assert_equal(1, Post.fast_count("bbb")) @@ -884,7 +884,7 @@ class PostTest < ActiveSupport::TestCase context "Reverting: " do context "a post that has been updated" do setup do - @post = Factory.create(:post, :rating => "q", :tag_string => "aaa") + @post = FactoryGirl.create(:post, :rating => "q", :tag_string => "aaa") @post.update_attributes(:tag_string => "aaa bbb ccc ddd") @post.update_attributes(:tag_string => "bbb xxx yyy", :source => "xyz") @post.update_attributes(:tag_string => "bbb mmm yyy", :source => "abc") diff --git a/test/unit/post_version_test.rb b/test/unit/post_version_test.rb index 02a2d768f..a1b867237 100644 --- a/test/unit/post_version_test.rb +++ b/test/unit/post_version_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostVersionTest < ActiveSupport::TestCase context "A post" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,7 +16,7 @@ class PostVersionTest < ActiveSupport::TestCase context "that has multiple versions: " do setup do - @post = Factory.create(:post, :tag_string => "1") + @post = FactoryGirl.create(:post, :tag_string => "1") @post.update_attributes(:tag_string => "1 2") @post.update_attributes(:tag_string => "2 3") end @@ -41,8 +41,8 @@ class PostVersionTest < ActiveSupport::TestCase context "that has been created" do setup do - @parent = Factory.create(:post) - @post = Factory.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") + @parent = FactoryGirl.create(:post) + @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") end should "also create a version" do @@ -57,8 +57,8 @@ class PostVersionTest < ActiveSupport::TestCase context "that has been updated" do setup do - @parent = Factory.create(:post) - @post = Factory.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @parent = FactoryGirl.create(:post) + @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") @post.update_attributes(:tag_string => "bbb ccc xxx", :source => "") end diff --git a/test/unit/post_vote_test.rb b/test/unit/post_vote_test.rb index 9ef9a0f23..a2989ac1d 100644 --- a/test/unit/post_vote_test.rb +++ b/test/unit/post_vote_test.rb @@ -2,12 +2,12 @@ require 'test_helper' class PostVoteTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all - @post = Factory.create(:post) + @post = FactoryGirl.create(:post) end context "Voting for a post" do diff --git a/test/unit/related_tag_calculator_test.rb b/test/unit/related_tag_calculator_test.rb index b73502436..9d80f06be 100644 --- a/test/unit/related_tag_calculator_test.rb +++ b/test/unit/related_tag_calculator_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RelatedTagCalculatorTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,27 +16,27 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase context "A related tag calculator" do should "calculate related tags for a tag" do posts = [] - posts << Factory.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << Factory.create(:post, :tag_string => "aaa bbb ccc") - posts << Factory.create(:post, :tag_string => "aaa bbb") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") assert_equal({"aaa" => 3, "bbb" => 3, "ccc" => 2, "ddd" => 1}, RelatedTagCalculator.calculate_from_sample("aaa", 10)) end should "calculate related tags for multiple tag" do posts = [] - posts << Factory.create(:post, :tag_string => "aaa bbb ccc") - posts << Factory.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << Factory.create(:post, :tag_string => "aaa eee fff") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryGirl.create(:post, :tag_string => "aaa eee fff") assert_equal({"aaa"=>2, "bbb"=>2, "ddd"=>1, "ccc"=>2}, RelatedTagCalculator.calculate_from_sample("aaa bbb", 10)) end should "calculate typed related tags for a tag" do posts = [] - posts << Factory.create(:post, :tag_string => "aaa bbb art:ccc copy:ddd") - posts << Factory.create(:post, :tag_string => "aaa bbb art:ccc") - posts << Factory.create(:post, :tag_string => "aaa bbb") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb art:ccc copy:ddd") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb art:ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") assert_equal({"ccc" => 2}, RelatedTagCalculator.calculate_from_sample("aaa", 10, Tag.categories.artist)) assert_equal({"ddd" => 1}, RelatedTagCalculator.calculate_from_sample("aaa", 10, Tag.categories.copyright)) @@ -44,9 +44,9 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase should "convert a hash into string format" do posts = [] - posts << Factory.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << Factory.create(:post, :tag_string => "aaa bbb ccc") - posts << Factory.create(:post, :tag_string => "aaa bbb") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") tag = Tag.find_by_name("aaa") counts = RelatedTagCalculator.calculate_from_sample("aaa", 10) diff --git a/test/unit/related_tag_query_test.rb b/test/unit/related_tag_query_test.rb index 0f6d4ff58..d286112b7 100644 --- a/test/unit/related_tag_query_test.rb +++ b/test/unit/related_tag_query_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RelatedTagQueryTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -11,8 +11,8 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "a related tag query without a category constraint" do setup do - @post_1 = Factory.create(:post, :tag_string => "aaa bbb") - @post_2 = Factory.create(:post, :tag_string => "aaa bbb ccc") + @post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + @post_2 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") end context "for a tag that already exists" do @@ -52,7 +52,7 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "for a tag with a wiki page" do setup do - @wiki_page = Factory.create(:wiki_page, :title => "aaa", :body => "[[bbb]] [[ccc]]") + @wiki_page = FactoryGirl.create(:wiki_page, :title => "aaa", :body => "[[bbb]] [[ccc]]") @query = RelatedTagQuery.new("aaa", "") end @@ -64,9 +64,9 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "a related tag query with a category constraint" do setup do - @post_1 = Factory.create(:post, :tag_string => "aaa bbb") - @post_2 = Factory.create(:post, :tag_string => "aaa art:ccc") - @post_3 = Factory.create(:post, :tag_string => "aaa copy:ddd") + @post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + @post_2 = FactoryGirl.create(:post, :tag_string => "aaa art:ccc") + @post_3 = FactoryGirl.create(:post, :tag_string => "aaa copy:ddd") @query = RelatedTagQuery.new("aaa", "artist") end diff --git a/test/unit/sources/pixa_test.rb b/test/unit/sources/pixa_test.rb index 232caf4d2..e9daa280a 100644 --- a/test/unit/sources/pixa_test.rb +++ b/test/unit/sources/pixa_test.rb @@ -1,39 +1,39 @@ -# encoding: UTF-8 - -require 'test_helper' - -module Sources - class PixaTest < ActiveSupport::TestCase - context "The source site for pixa" do - setup do - @site = Sources::Site.new("http://www.pixa.cc/illustrations/show/75575") - @site.get - end - - should "get the profile" do - assert_equal("http://www.pixa.cc/profiles/show/9191", @site.profile_url) - end - - should "get the artist name" do - assert_equal("air", @site.artist_name) - end - - should "get the image url" do - assert_equal("http://file0.pixa.cc/illustrations/34/cb/df/70/49/b4/52/2d/42/c6/middle/110910魔法少女のコピー.jpg?1315664621", @site.image_url) - end - - should "get the tags" do - assert(@site.tags.size > 0) - first_tag = @site.tags.first - assert_equal(2, first_tag.size) - assert(first_tag[0] =~ /./) - end - - should "convert a page into a json representation" do - assert_nothing_raised do - @site.to_json - end - end - end - end -end +# # encoding: UTF-8 +# +# require 'test_helper' +# +# module Sources +# class PixaTest < ActiveSupport::TestCase +# context "The source site for pixa" do +# setup do +# @site = Sources::Site.new("http://www.pixa.cc/illustrations/show/75575") +# @site.get +# end +# +# should "get the profile" do +# assert_equal("http://www.pixa.cc/profiles/show/9191", @site.profile_url) +# end +# +# should "get the artist name" do +# assert_equal("air", @site.artist_name) +# end +# +# should "get the image url" do +# assert_equal("http://file0.pixa.cc/illustrations/34/cb/df/70/49/b4/52/2d/42/c6/middle/110910魔法少女のコピー.jpg?1315664621", @site.image_url) +# end +# +# should "get the tags" do +# assert(@site.tags.size > 0) +# first_tag = @site.tags.first +# assert_equal(2, first_tag.size) +# assert(first_tag[0] =~ /./) +# end +# +# should "convert a page into a json representation" do +# assert_nothing_raised do +# @site.to_json +# end +# end +# end +# end +# end diff --git a/test/unit/sources/tinami_test.rb b/test/unit/sources/tinami_test.rb index 0f0d52066..62234c832 100644 --- a/test/unit/sources/tinami_test.rb +++ b/test/unit/sources/tinami_test.rb @@ -1,38 +1,38 @@ -# encoding: UTF-8 - -require 'test_helper' - -module Sources - class TinamiTest < ActiveSupport::TestCase - context "The source site for tinami" do - context "for tinami" do - setup do - @site = Sources::Site.new("http://www.tinami.com/view/308311") - @site.get - end - - should "get the profile" do - assert_equal("http://www.tinami.com/creator/profile/29399", @site.profile_url) - end - - should "get the artist name" do - assert_match(/ROM/, @site.artist_name) - end - - should "get the image url" do - assert_equal("http://img.tinami.com/illust2/img/336/4e80b9773c084.png", @site.image_url) - end - - should "get the tags" do - assert(@site.tags.size > 0) - end - - should "convert a page into a json representation" do - assert_nothing_raised do - @site.to_json - end - end - end - end - end -end +# # encoding: UTF-8 +# +# require 'test_helper' +# +# module Sources +# class TinamiTest < ActiveSupport::TestCase +# context "The source site for tinami" do +# context "for tinami" do +# setup do +# @site = Sources::Site.new("http://www.tinami.com/view/308311") +# @site.get +# end +# +# should "get the profile" do +# assert_equal("http://www.tinami.com/creator/profile/29399", @site.profile_url) +# end +# +# should "get the artist name" do +# assert_match(/ROM/, @site.artist_name) +# end +# +# should "get the image url" do +# assert_equal("http://img.tinami.com/illust2/img/336/4e80b9773c084.png", @site.image_url) +# end +# +# should "get the tags" do +# assert(@site.tags.size > 0) +# end +# +# should "convert a page into a json representation" do +# assert_nothing_raised do +# @site.to_json +# end +# end +# end +# end +# end +# end diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index d25410480..2747dad98 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -3,10 +3,11 @@ require 'test_helper' class TagAliasTest < ActiveSupport::TestCase context "A tag alias" do setup do - user = Factory.create(:user) + 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 @@ -20,16 +21,16 @@ class TagAliasTest < ActiveSupport::TestCase end should "convert a tag to its normalized version" do - tag1 = Factory.create(:tag, :name => "aaa") - tag2 = Factory.create(:tag, :name => "bbb") + tag1 = FactoryGirl.create(:tag, :name => "aaa") + tag2 = FactoryGirl.create(:tag, :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 should "update the cache" do - tag1 = Factory.create(:tag, :name => "aaa") - tag2 = Factory.create(:tag, :name => "bbb") + tag1 = FactoryGirl.create(:tag, :name => "aaa") + tag2 = FactoryGirl.create(:tag, :name => "bbb") ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_nil(MEMCACHE.get("ta:aaa")) ta.update_cache @@ -40,8 +41,8 @@ class TagAliasTest < ActiveSupport::TestCase should "update any affected posts when saved" do assert_equal(0, TagAlias.count) - post1 = Factory.create(:post, :tag_string => "aaa bbb") - post2 = Factory.create(:post, :tag_string => "ccc ddd") + post1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post2 = FactoryGirl.create(:post, :tag_string => "ccc ddd") assert_equal("aaa bbb", post1.tag_string) assert_equal("ccc ddd", post2.tag_string) ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc") @@ -54,7 +55,7 @@ class TagAliasTest < ActiveSupport::TestCase should "not validate for transitive relations" do 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 = FactoryGirl.build(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ddd") ta3.save assert(ta3.errors.any?, "Tag alias should be invalid") assert_equal("Tag alias can not create a transitive relation with another tag alias", ta3.errors.full_messages.join) @@ -62,10 +63,10 @@ class TagAliasTest < ActiveSupport::TestCase end should "record the alias's creator in the tag history" do - uploader = Factory.create(:user) + uploader = FactoryGirl.create(:user) post = nil CurrentUser.scoped(uploader, "127.0.0.1") do - post = Factory.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") end tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "xxx") post.reload diff --git a/test/unit/tag_implication_test.rb b/test/unit/tag_implication_test.rb index 052309608..b6d2b81b9 100644 --- a/test/unit/tag_implication_test.rb +++ b/test/unit/tag_implication_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class TagImplicationTest < ActiveSupport::TestCase context "A tag implication" do setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) MEMCACHE.flush_all end @@ -22,7 +22,7 @@ class TagImplicationTest < ActiveSupport::TestCase should "not validate when a circular relation is created" do ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = Factory.build(:tag_implication, :antecedent_name => "bbb", :consequent_name => "aaa") + ti2 = FactoryGirl.build(:tag_implication, :antecedent_name => "bbb", :consequent_name => "aaa") ti2.save assert(ti2.errors.any?, "Tag implication should not have validated.") assert_equal("Tag implication can not create a circular relation with another tag implication", ti2.errors.full_messages.join("")) @@ -30,7 +30,7 @@ class TagImplicationTest < ActiveSupport::TestCase should "not allow for duplicates" do ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = Factory.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryGirl.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("")) @@ -94,7 +94,7 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update any affected post upon save" do - p1 = Factory.create(:post, :tag_string => "aaa bbb ccc") + p1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy") p1.reload @@ -102,10 +102,10 @@ class TagImplicationTest < ActiveSupport::TestCase end should "record the implication's creator in the tag history" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) p1 = nil CurrentUser.scoped(user, "127.0.0.1") do - p1 = Factory.create(:post, :tag_string => "aaa bbb ccc") + p1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") end ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") p1.reload diff --git a/test/unit/tag_subscription_test.rb b/test/unit/tag_subscription_test.rb index b34c0354a..9ebee0de8 100644 --- a/test/unit/tag_subscription_test.rb +++ b/test/unit/tag_subscription_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class TagSubscriptionTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,39 +16,39 @@ class TagSubscriptionTest < ActiveSupport::TestCase context "A tag subscription" do should "find the union of all posts for each tag in its tag query" do posts = [] - user = Factory.create(:user) - posts << Factory.create(:post, :tag_string => "aaa") - posts << Factory.create(:post, :tag_string => "bbb") - posts << Factory.create(:post, :tag_string => "ccc") - posts << Factory.create(:post, :tag_string => "ddd") - sub_1 = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz") - sub_2 = Factory.create(:tag_subscription, :tag_query => "ccc", :creator => user, :name => "yyy") + user = FactoryGirl.create(:user) + posts << FactoryGirl.create(:post, :tag_string => "aaa") + posts << FactoryGirl.create(:post, :tag_string => "bbb") + posts << FactoryGirl.create(:post, :tag_string => "ccc") + posts << FactoryGirl.create(:post, :tag_string => "ddd") + sub_1 = FactoryGirl.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz") + sub_2 = FactoryGirl.create(:tag_subscription, :tag_query => "ccc", :creator => user, :name => "yyy") assert_equal([posts[1].id, posts[0].id], TagSubscription.find_posts(user.id, "zzz").map(&:id)) assert_equal([posts[2].id, posts[1].id, posts[0].id], TagSubscription.find_posts(user.id).map(&:id)) end should "cache its tag query results" do posts = [] - user = Factory.create(:user) - posts << Factory.create(:post, :tag_string => "aaa") - posts << Factory.create(:post, :tag_string => "bbb") - posts << Factory.create(:post, :tag_string => "ccc") - sub = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz") + user = FactoryGirl.create(:user) + posts << FactoryGirl.create(:post, :tag_string => "aaa") + posts << FactoryGirl.create(:post, :tag_string => "bbb") + posts << FactoryGirl.create(:post, :tag_string => "ccc") + sub = FactoryGirl.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz") assert_equal("#{posts[1].id},#{posts[0].id}", sub.post_ids) end should "find posts based on its cached post ids" do - user = Factory.create(:user) + user = FactoryGirl.create(:user) subs = [] - subs << Factory.create(:tag_subscription, :tag_query => "aaa", :creator => user, :name => "zzz") - subs << Factory.create(:tag_subscription, :tag_query => "bbb", :creator => user, :name => "yyy") + subs << FactoryGirl.create(:tag_subscription, :tag_query => "aaa", :creator => user, :name => "zzz") + subs << FactoryGirl.create(:tag_subscription, :tag_query => "bbb", :creator => user, :name => "yyy") assert_equal([], TagSubscription.find_posts(user.id)) assert_equal([], TagSubscription.find_posts(user.id, "zzz")) assert_equal([], TagSubscription.find_posts(user.id, "yyy")) posts = [] - posts << Factory.create(:post, :tag_string => "aaa") - posts << Factory.create(:post, :tag_string => "bbb") - posts << Factory.create(:post, :tag_string => "ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa") + posts << FactoryGirl.create(:post, :tag_string => "bbb") + posts << FactoryGirl.create(:post, :tag_string => "ccc") subs.each {|x| x.process; x.save} assert_equal([posts[1].id, posts[0].id], TagSubscription.find_posts(user.id).map(&:id)) assert_equal([posts[0].id], TagSubscription.find_posts(user.id, "zzz").map(&:id)) @@ -59,15 +59,15 @@ class TagSubscriptionTest < ActiveSupport::TestCase context "A tag subscription manager" do should "process all active tag subscriptions" do users = [] - users << Factory.create(:user) - users << Factory.create(:user) + users << FactoryGirl.create(:user) + users << FactoryGirl.create(:user) posts = [] - posts << Factory.create(:post, :tag_string => "aaa") - posts << Factory.create(:post, :tag_string => "bbb") - posts << Factory.create(:post, :tag_string => "ccc") + posts << FactoryGirl.create(:post, :tag_string => "aaa") + posts << FactoryGirl.create(:post, :tag_string => "bbb") + posts << FactoryGirl.create(:post, :tag_string => "ccc") subscriptions = [] - subscriptions << Factory.create(:tag_subscription, :tag_query => "aaa", :creator => users[0]) - subscriptions << Factory.create(:tag_subscription, :tag_query => "bbb", :creator => users[1]) + subscriptions << FactoryGirl.create(:tag_subscription, :tag_query => "aaa", :creator => users[0]) + subscriptions << FactoryGirl.create(:tag_subscription, :tag_query => "bbb", :creator => users[1]) TagSubscription.process_all subscriptions.each {|x| x.reload} assert_equal("#{posts[0].id}", subscriptions[0].post_ids) diff --git a/test/unit/tag_test.rb b/test/unit/tag_test.rb index 423ae2af4..bd5a69e4d 100644 --- a/test/unit/tag_test.rb +++ b/test/unit/tag_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class TagTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) + user = FactoryGirl.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -20,18 +20,18 @@ class TagTest < ActiveSupport::TestCase end should "fetch for a single tag" do - Factory.create(:artist_tag, :name => "test") + FactoryGirl.create(:artist_tag, :name => "test") assert_equal(Tag.categories.artist, Tag.category_for("test")) end should "fetch for a single tag with strange markup" do - Factory.create(:artist_tag, :name => "!@$%") + FactoryGirl.create(:artist_tag, :name => "!@$%") assert_equal(Tag.categories.artist, Tag.category_for("!@$%")) end should "fetch for multiple tags" do - Factory.create(:artist_tag, :name => "aaa") - Factory.create(:copyright_tag, :name => "bbb") + FactoryGirl.create(:artist_tag, :name => "aaa") + FactoryGirl.create(:copyright_tag, :name => "bbb") categories = Tag.categories_for(%w(aaa bbb ccc)) assert_equal(Tag.categories.artist, categories["aaa"]) assert_equal(Tag.categories.copyright, categories["bbb"]) @@ -85,12 +85,12 @@ class TagTest < ActiveSupport::TestCase end should "know its category name" do - @tag = Factory.create(:artist_tag) + @tag = FactoryGirl.create(:artist_tag) assert_equal("Artist", @tag.category_name) end should "reset its category after updating" do - tag = Factory.create(:artist_tag) + tag = FactoryGirl.create(:artist_tag) assert_equal(Tag.categories.artist, MEMCACHE.get("tc:#{tag.name}")) tag.update_attribute(:category, Tag.categories.copyright) @@ -118,8 +118,8 @@ class TagTest < ActiveSupport::TestCase end should "parse a query" do - tag1 = Factory.create(:tag, :name => "abc") - tag2 = Factory.create(:tag, :name => "acb") + tag1 = FactoryGirl.create(:tag, :name => "abc") + tag2 = FactoryGirl.create(:tag, :name => "acb") assert_equal(["abc"], Tag.parse_query("md5:abc")[:md5]) assert_equal([:between, 1, 2], Tag.parse_query("id:1..2")[:post_id]) @@ -135,14 +135,14 @@ class TagTest < ActiveSupport::TestCase context "A tag" do should "be found when one exists" do - tag = Factory.create(:tag) + tag = FactoryGirl.create(:tag) assert_difference("Tag.count", 0) do Tag.find_or_create_by_name(tag.name) end end should "change the type for an existing tag" do - tag = Factory.create(:tag) + tag = FactoryGirl.create(:tag) assert_difference("Tag.count", 0) do assert_equal(Tag.categories.general, tag.category) Tag.find_or_create_by_name("artist:#{tag.name}") diff --git a/test/unit/upload_test.rb b/test/unit/upload_test.rb index 37b05f405..680713a2d 100644 --- a/test/unit/upload_test.rb +++ b/test/unit/upload_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class UploadTest < ActiveSupport::TestCase context "In all cases" do setup do - user = Factory.create(:contributor_user) + user = FactoryGirl.create(:contributor_user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -23,21 +23,21 @@ class UploadTest < ActiveSupport::TestCase context "image size calculator" do should "discover the dimensions for a JPG" do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)} assert_equal(500, @upload.image_width) assert_equal(335, @upload.image_height) end should "discover the dimensions for a PNG" do - @upload = Factory.create(:png_upload) + @upload = FactoryGirl.create(:png_upload) assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)} assert_equal(768, @upload.image_width) assert_equal(1024, @upload.image_height) end should "discover the dimensions for a GIF" do - @upload = Factory.create(:gif_upload) + @upload = FactoryGirl.create(:gif_upload) assert_nothing_raised {@upload.calculate_dimensions(@upload.file_path)} assert_equal(400, @upload.image_width) assert_equal(400, @upload.image_height) @@ -46,7 +46,7 @@ class UploadTest < ActiveSupport::TestCase context "content type calculator" do should "know how to parse jpeg, png, gif, and swf file extensions" do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) assert_equal("image/jpeg", @upload.file_ext_to_content_type("test.jpeg")) assert_equal("image/gif", @upload.file_ext_to_content_type("test.gif")) assert_equal("image/png", @upload.file_ext_to_content_type("test.png")) @@ -55,7 +55,7 @@ class UploadTest < ActiveSupport::TestCase end should "know how to parse jpeg, png, gif, and swf content types" do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) assert_equal("jpg", @upload.content_type_to_file_ext("image/jpeg")) assert_equal("gif", @upload.content_type_to_file_ext("image/gif")) assert_equal("png", @upload.content_type_to_file_ext("image/png")) @@ -66,7 +66,7 @@ class UploadTest < ActiveSupport::TestCase context "downloader" do should "initialize the final path and content type after downloading a file" do - @upload = Factory.create(:source_upload) + @upload = FactoryGirl.create(:source_upload) path = "#{Rails.root}/tmp/test.download.jpg" assert_nothing_raised {@upload.download_from_source(path)} assert(File.exists?(path)) @@ -101,7 +101,7 @@ class UploadTest < ActiveSupport::TestCase context "hash calculator" do should "caculate the hash" do - @upload = Factory.create(:jpg_upload) + @upload = FactoryGirl.create(:jpg_upload) @upload.calculate_hash(@upload.file_path) assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", @upload.md5) end @@ -115,7 +115,7 @@ class UploadTest < ActiveSupport::TestCase end should "generate several resized versions of the image" do - @upload = Factory.create(:large_jpg_upload) + @upload = FactoryGirl.create(:large_jpg_upload) @upload.calculate_hash(@upload.file_path) @upload.calculate_dimensions(@upload.file_path) assert_nothing_raised {@upload.generate_resizes(@upload.file_path)} @@ -127,7 +127,7 @@ class UploadTest < ActiveSupport::TestCase end should "increment the uploaders post_upload_count" do - @upload = Factory.create(:source_upload) + @upload = FactoryGirl.create(:source_upload) assert_difference("CurrentUser.post_upload_count", 1) do @upload.process! CurrentUser.reload @@ -135,7 +135,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a downloaded image" do - @upload = Factory.create(:source_upload, + @upload = FactoryGirl.create(:source_upload, :rating => "s", :uploader_ip_addr => "127.0.0.1", :tag_string => "hoge foo" @@ -160,7 +160,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for an uploaded image" do - @upload = Factory.create(:jpg_upload, + @upload = FactoryGirl.create(:jpg_upload, :rating => "s", :uploader_ip_addr => "127.0.0.1", :tag_string => "hoge foo" @@ -185,7 +185,7 @@ class UploadTest < ActiveSupport::TestCase end should "delete the temporary file upon completion" do - @upload = Factory.create(:source_upload, + @upload = FactoryGirl.create(:source_upload, :rating => "s", :uploader_ip_addr => "127.0.0.1", :tag_string => "hoge foo" diff --git a/test/unit/user_feedback_test.rb b/test/unit/user_feedback_test.rb index 45fe7bb4c..86a8bfab8 100644 --- a/test/unit/user_feedback_test.rb +++ b/test/unit/user_feedback_test.rb @@ -13,16 +13,16 @@ class UserFeedbackTest < ActiveSupport::TestCase end should "should not validate if the creator is not privileged" do - user = Factory.create(:user) - privileged = Factory.create(:privileged_user) - member = Factory.create(:user) + user = FactoryGirl.create(:user) + privileged = FactoryGirl.create(:privileged_user) + member = FactoryGirl.create(:user) CurrentUser.user = privileged - feedback = Factory.create(:user_feedback, :user => user) + feedback = FactoryGirl.create(:user_feedback, :user => user) assert(feedback.errors.empty?) CurrentUser.user = member - feedback = Factory.build(:user_feedback, :user => user) + feedback = FactoryGirl.build(:user_feedback, :user => user) feedback.save assert(feedback.errors.any?) end diff --git a/test/unit/user_password_reset_nonce_test.rb b/test/unit/user_password_reset_nonce_test.rb index 4133af6c1..45372a8e4 100644 --- a/test/unit/user_password_reset_nonce_test.rb +++ b/test/unit/user_password_reset_nonce_test.rb @@ -4,8 +4,8 @@ class UserPasswordResetNonceTest < ActiveSupport::TestCase context "Creating a new nonce" do context "with a valid email" do setup do - @user = Factory.create(:user, :email => "aaa@b.net") - @nonce = Factory.create(:user_password_reset_nonce, :email => @user.email) + @user = FactoryGirl.create(:user, :email => "aaa@b.net") + @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) end should "validate" do @@ -24,7 +24,7 @@ class UserPasswordResetNonceTest < ActiveSupport::TestCase context "with a blank email" do setup do - @user = Factory.create(:user, :email => "") + @user = FactoryGirl.create(:user, :email => "") @nonce = UserPasswordResetNonce.new(:email => "") end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index eec5c541b..98cd335fd 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase context "A user" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all @@ -16,7 +16,7 @@ class UserTest < ActiveSupport::TestCase context "that has been invited by a mod" do setup do - @mod = Factory.create(:moderator_user) + @mod = FactoryGirl.create(:moderator_user) end should "work" do @@ -34,10 +34,10 @@ class UserTest < ActiveSupport::TestCase context "who has negeative feedback and is trying to change their name" do setup do - @mod = Factory.create(:moderator_user) + @mod = FactoryGirl.create(:moderator_user) CurrentUser.scoped(@mod, "127.0.0.1") do - Factory.create(:user_feedback, :user => @user, :category => "negative") + FactoryGirl.create(:user_feedback, :user => @user, :category => "negative") end end @@ -49,8 +49,8 @@ class UserTest < ActiveSupport::TestCase end should "not validate if the originating ip address is banned" do - Factory.create(:ip_ban) - user = Factory.build(:user) + FactoryGirl.create(:ip_ban) + user = FactoryGirl.build(:user) user.save assert(user.errors.any?) assert_equal("IP address is banned", user.errors.full_messages.join) @@ -63,7 +63,7 @@ class UserTest < ActiveSupport::TestCase @user.update_column(:level, User::Levels::MEMBER) 40.times do - Factory.create(:post, :uploader => @user, :is_deleted => true) + FactoryGirl.create(:post, :uploader => @user, :is_deleted => true) end assert(!@user.can_upload?) @@ -74,8 +74,8 @@ class UserTest < ActiveSupport::TestCase Danbooru.config.stubs(:member_comment_limit).returns(10) assert(@user.can_comment_vote?) 10.times do - comment = Factory.create(:comment) - Factory.create(:comment_vote, :comment_id => comment.id) + comment = FactoryGirl.create(:comment) + FactoryGirl.create(:comment_vote, :comment_id => comment.id) end assert(!@user.can_comment_vote?) @@ -91,14 +91,14 @@ class UserTest < ActiveSupport::TestCase @user.update_column(:created_at, 1.year.ago) assert(@user.can_comment?) (Danbooru.config.member_comment_limit).times do - Factory.create(:comment) + FactoryGirl.create(:comment) end assert(!@user.can_comment?) end should "verify" do assert(@user.is_verified?) - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @user.generate_email_verification_key @user.save assert(!@user.is_verified?) @@ -115,41 +115,41 @@ class UserTest < ActiveSupport::TestCase end should "normalize its level" do - user = Factory.create(:user, :level => User::Levels::ADMIN) + user = FactoryGirl.create(:user, :level => User::Levels::ADMIN) assert(user.is_moderator?) assert(user.is_janitor?) assert(user.is_contributor?) assert(user.is_privileged?) - user = Factory.create(:user, :level => User::Levels::MODERATOR) + user = FactoryGirl.create(:user, :level => User::Levels::MODERATOR) assert(!user.is_admin?) assert(user.is_moderator?) assert(user.is_janitor?) assert(user.is_contributor?) assert(user.is_privileged?) - user = Factory.create(:user, :level => User::Levels::JANITOR) + user = FactoryGirl.create(:user, :level => User::Levels::JANITOR) assert(!user.is_admin?) assert(!user.is_moderator?) assert(user.is_janitor?) assert(user.is_contributor?) assert(user.is_privileged?) - user = Factory.create(:user, :level => User::Levels::CONTRIBUTOR) + user = FactoryGirl.create(:user, :level => User::Levels::CONTRIBUTOR) assert(!user.is_admin?) assert(!user.is_moderator?) assert(!user.is_janitor?) assert(user.is_contributor?) assert(user.is_privileged?) - user = Factory.create(:user, :level => User::Levels::PRIVILEGED) + user = FactoryGirl.create(:user, :level => User::Levels::PRIVILEGED) assert(!user.is_admin?) assert(!user.is_moderator?) assert(!user.is_janitor?) assert(!user.is_contributor?) assert(user.is_privileged?) - user = Factory.create(:user) + user = FactoryGirl.create(:user) assert(!user.is_admin?) assert(!user.is_moderator?) assert(!user.is_janitor?) @@ -163,12 +163,12 @@ class UserTest < ActiveSupport::TestCase end should "be fetched given a user id" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) assert_equal(@user.name, User.id_to_name(@user.id)) end should "be updated" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @user.update_attribute(:name, "danzig") assert_equal(@user.name, User.id_to_name(@user.id)) end @@ -176,7 +176,7 @@ class UserTest < ActiveSupport::TestCase context "ip address" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end context "in the json representation" do @@ -194,7 +194,7 @@ class UserTest < ActiveSupport::TestCase context "cookie password hash" do setup do - @user = Factory.create(:user, :name => "albert", :password_hash => "1234") + @user = FactoryGirl.create(:user, :name => "albert", :password_hash => "1234") end should "be correct" do @@ -208,7 +208,7 @@ class UserTest < ActiveSupport::TestCase context "password" do should "match the confirmation" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @user.password = "zugzug5" @user.password_confirmation = "zugzug5" @user.save @@ -217,7 +217,7 @@ class UserTest < ActiveSupport::TestCase end should "match the confirmation" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @user.password = "zugzug6" @user.password_confirmation = "zugzug5" @user.save @@ -225,7 +225,7 @@ class UserTest < ActiveSupport::TestCase end should "not be too short" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) @user.password = "x5" @user.password_confirmation = "x5" @user.save @@ -233,38 +233,38 @@ class UserTest < ActiveSupport::TestCase end should "should be reset" do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) new_pass = @user.reset_password assert(User.authenticate(@user.name, new_pass), "Authentication should have succeeded") end should "not change the password if the password and old password are blank" do - @user = Factory.create(:user, :password => "67890") + @user = FactoryGirl.create(:user, :password => "67890") @user.update_attributes(:password => "", :old_password => "") assert_equal(User.sha1("67890"), @user.password_hash) end should "not change the password if the old password is incorrect" do - @user = Factory.create(:user, :password => "67890") + @user = FactoryGirl.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "abcdefg") assert_equal(User.sha1("67890"), @user.password_hash) end should "not change the password if the old password is blank" do - @user = Factory.create(:user, :password => "67890") + @user = FactoryGirl.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "") assert_equal(User.sha1("67890"), @user.password_hash) end should "change the password if the old password is correct" do - @user = Factory.create(:user, :password => "67890") + @user = FactoryGirl.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "67890") assert_equal(User.sha1("12345"), @user.password_hash) end context "in the json representation" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "not appear" do @@ -274,7 +274,7 @@ class UserTest < ActiveSupport::TestCase context "in the xml representation" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) end should "not appear" do diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index 1e5ca1688..577f6c27c 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -13,10 +13,10 @@ class WikiPageTest < ActiveSupport::TestCase context "A wiki page" do context "updated by a janitor" do setup do - @user = Factory.create(:janitor_user) + @user = FactoryGirl.create(:janitor_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @wiki_page = Factory.create(:wiki_page) + @wiki_page = FactoryGirl.create(:wiki_page) end should "allow the is_locked attribute to be updated" do @@ -28,10 +28,10 @@ class WikiPageTest < ActiveSupport::TestCase context "updated by a regular user" do setup do - @user = Factory.create(:user) + @user = FactoryGirl.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @wiki_page = Factory.create(:wiki_page, :title => "HOT POTATO") + @wiki_page = FactoryGirl.create(:wiki_page, :title => "HOT POTATO") end should "not allow the is_locked attribute to be updated" do @@ -53,7 +53,7 @@ class WikiPageTest < ActiveSupport::TestCase should "create versions" do assert_difference("WikiPageVersion.count") do - @wiki_page = Factory.create(:wiki_page, :title => "xxx") + @wiki_page = FactoryGirl.create(:wiki_page, :title => "xxx") end assert_difference("WikiPageVersion.count") do @@ -72,7 +72,7 @@ class WikiPageTest < ActiveSupport::TestCase end should "differentiate between updater and creator" do - another_user = Factory.create(:user) + another_user = FactoryGirl.create(:user) CurrentUser.scoped(another_user, "127.0.0.1") do @wiki_page.title = "yyy" @wiki_page.save