* Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3 * Fixed tests
This commit is contained in:
110
Gemfile.lock
110
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
|
||||
|
||||
@@ -2,7 +2,7 @@ module Downloads
|
||||
module Strategies
|
||||
class Base
|
||||
def self.strategies
|
||||
[Pixiv, Tinami, Pixa]
|
||||
[Pixiv]
|
||||
end
|
||||
|
||||
def rewrite(url, headers)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Factory.define(:favorite) do |f|
|
||||
FactoryGirl.define do
|
||||
factory(:favorite)
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
Factory.define(:news_update) do |f|
|
||||
f.message "xxx"
|
||||
FactoryGirl.define do
|
||||
factory(:news_update) do
|
||||
message "xxx"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -1,3 +1,5 @@
|
||||
Factory.define(:post_appeal) do |f|
|
||||
f.reason "xxx"
|
||||
FactoryGirl.define do
|
||||
factory(:post_appeal) do
|
||||
reason "xxx"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Factory.define(:user_password_reset_nonce) do |f|
|
||||
FactoryGirl.define do
|
||||
factory(:user_password_reset_nonce)
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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?)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user