* Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3 * Fixed tests
This commit is contained in:
+55
-55
@@ -22,91 +22,91 @@ GIT
|
|||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/rgrove/sanitize.git
|
remote: git://github.com/rgrove/sanitize.git
|
||||||
revision: 052abea134e409c7f676f0cf56e6a2315b2a150b
|
revision: 4925ac8058320fa587b6bdd7556fdf76e2ad5d31
|
||||||
specs:
|
specs:
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: http://github.com/EmmanuelOga/ffaker.git
|
remote: http://github.com/EmmanuelOga/ffaker.git
|
||||||
revision: a2bff9d77503a9cf61eb274725b12e5683b2826c
|
revision: 8f7c679ec8c3d27aefe287e04e48e2702b865df9
|
||||||
specs:
|
specs:
|
||||||
ffaker (1.13.0)
|
ffaker (1.14.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://gemcutter.org/
|
remote: http://gemcutter.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (3.2.2)
|
actionmailer (3.2.3)
|
||||||
actionpack (= 3.2.2)
|
actionpack (= 3.2.3)
|
||||||
mail (~> 2.4.0)
|
mail (~> 2.4.4)
|
||||||
actionpack (3.2.2)
|
actionpack (3.2.3)
|
||||||
activemodel (= 3.2.2)
|
activemodel (= 3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
builder (~> 3.0.0)
|
builder (~> 3.0.0)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
journey (~> 1.0.1)
|
journey (~> 1.0.1)
|
||||||
rack (~> 1.4.0)
|
rack (~> 1.4.0)
|
||||||
rack-cache (~> 1.1)
|
rack-cache (~> 1.2)
|
||||||
rack-test (~> 0.6.1)
|
rack-test (~> 0.6.1)
|
||||||
sprockets (~> 2.1.2)
|
sprockets (~> 2.1.2)
|
||||||
activemodel (3.2.2)
|
activemodel (3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
builder (~> 3.0.0)
|
builder (~> 3.0.0)
|
||||||
activerecord (3.2.2)
|
activerecord (3.2.3)
|
||||||
activemodel (= 3.2.2)
|
activemodel (= 3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
arel (~> 3.0.2)
|
arel (~> 3.0.2)
|
||||||
tzinfo (~> 0.3.29)
|
tzinfo (~> 0.3.29)
|
||||||
activeresource (3.2.2)
|
activeresource (3.2.3)
|
||||||
activemodel (= 3.2.2)
|
activemodel (= 3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
activesupport (3.2.2)
|
activesupport (3.2.3)
|
||||||
i18n (~> 0.6)
|
i18n (~> 0.6)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
arel (3.0.2)
|
arel (3.0.2)
|
||||||
awesome_print (1.0.2)
|
awesome_print (1.0.2)
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
chronic (0.6.7)
|
chronic (0.6.7)
|
||||||
coderay (1.0.5)
|
coderay (1.0.6)
|
||||||
daemons (1.1.8)
|
daemons (1.1.8)
|
||||||
delayed_job (3.0.1)
|
delayed_job (3.0.3)
|
||||||
activesupport (~> 3.0)
|
activesupport (~> 3.0)
|
||||||
delayed_job_active_record (0.3.2)
|
delayed_job_active_record (0.3.2)
|
||||||
activerecord (> 2.1.0)
|
activerecord (> 2.1.0)
|
||||||
delayed_job (~> 3.0.0)
|
delayed_job (~> 3.0.0)
|
||||||
domain_name (0.5.2)
|
domain_name (0.5.3)
|
||||||
unf (~> 0.0.3)
|
unf (~> 0.0.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (1.3.0)
|
execjs (1.4.0)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
factory_girl (2.6.3)
|
factory_girl (3.3.0)
|
||||||
activesupport (>= 2.3.9)
|
activesupport (>= 3.0.0)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
journey (1.0.3)
|
journey (1.0.3)
|
||||||
json (1.6.5)
|
json (1.7.3)
|
||||||
libv8 (3.3.10.4)
|
libv8 (3.3.10.4)
|
||||||
mail (2.4.3)
|
mail (2.4.4)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
memcache-client (1.8.5)
|
memcache-client (1.8.5)
|
||||||
metaclass (0.0.1)
|
metaclass (0.0.1)
|
||||||
method_source (0.7.1)
|
method_source (0.7.1)
|
||||||
mime-types (1.17.2)
|
mime-types (1.18)
|
||||||
mocha (0.10.5)
|
mocha (0.11.4)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
multi_json (1.1.0)
|
multi_json (1.3.6)
|
||||||
net-http-digest_auth (1.2)
|
net-http-digest_auth (1.2.1)
|
||||||
net-http-persistent (2.5.2)
|
net-http-persistent (2.6)
|
||||||
newrelic_rpm (3.3.4.1)
|
newrelic_rpm (3.3.5)
|
||||||
nokogiri (1.5.2)
|
nokogiri (1.5.3)
|
||||||
ntlm-http (0.1.1)
|
ntlm-http (0.1.1)
|
||||||
pg (0.13.2)
|
pg (0.13.2)
|
||||||
polyamorous (0.5.0)
|
polyamorous (0.5.0)
|
||||||
activerecord (~> 3.0)
|
activerecord (~> 3.0)
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
pry (0.9.8.4)
|
pry (0.9.9.6)
|
||||||
coderay (~> 1.0.5)
|
coderay (~> 1.0.5)
|
||||||
method_source (~> 0.7.1)
|
method_source (~> 0.7.1)
|
||||||
slop (>= 2.4.4, < 3)
|
slop (>= 2.4.4, < 3)
|
||||||
@@ -117,17 +117,17 @@ GEM
|
|||||||
rack
|
rack
|
||||||
rack-test (0.6.1)
|
rack-test (0.6.1)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.2.2)
|
rails (3.2.3)
|
||||||
actionmailer (= 3.2.2)
|
actionmailer (= 3.2.3)
|
||||||
actionpack (= 3.2.2)
|
actionpack (= 3.2.3)
|
||||||
activerecord (= 3.2.2)
|
activerecord (= 3.2.3)
|
||||||
activeresource (= 3.2.2)
|
activeresource (= 3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
railties (= 3.2.2)
|
railties (= 3.2.3)
|
||||||
railties (3.2.2)
|
railties (3.2.3)
|
||||||
actionpack (= 3.2.2)
|
actionpack (= 3.2.3)
|
||||||
activesupport (= 3.2.2)
|
activesupport (= 3.2.3)
|
||||||
rack-ssl (~> 1.3.2)
|
rack-ssl (~> 1.3.2)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
@@ -136,8 +136,8 @@ GEM
|
|||||||
rdoc (3.12)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
rmagick (2.13.1)
|
rmagick (2.13.1)
|
||||||
sass (3.1.15)
|
sass (3.1.19)
|
||||||
sass-rails (3.2.4)
|
sass-rails (3.2.5)
|
||||||
railties (~> 3.2.0)
|
railties (~> 3.2.0)
|
||||||
sass (>= 3.1.10)
|
sass (>= 3.1.10)
|
||||||
tilt (~> 1.3)
|
tilt (~> 1.3)
|
||||||
@@ -146,35 +146,35 @@ GEM
|
|||||||
shoulda-matchers (~> 1.0.0)
|
shoulda-matchers (~> 1.0.0)
|
||||||
shoulda-context (1.0.0)
|
shoulda-context (1.0.0)
|
||||||
shoulda-matchers (1.0.0)
|
shoulda-matchers (1.0.0)
|
||||||
simple_form (2.0.1)
|
simple_form (2.0.2)
|
||||||
actionpack (~> 3.0)
|
actionpack (~> 3.0)
|
||||||
activemodel (~> 3.0)
|
activemodel (~> 3.0)
|
||||||
simplecov (0.6.1)
|
simplecov (0.6.4)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
simplecov-html (~> 0.5.3)
|
simplecov-html (~> 0.5.3)
|
||||||
simplecov-html (0.5.3)
|
simplecov-html (0.5.3)
|
||||||
slop (2.4.4)
|
slop (2.4.4)
|
||||||
sprockets (2.1.2)
|
sprockets (2.1.3)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
super_exception_notifier (3.0.13)
|
super_exception_notifier (3.0.13)
|
||||||
actionmailer
|
actionmailer
|
||||||
rake
|
rake
|
||||||
therubyracer (0.9.10)
|
therubyracer (0.10.1)
|
||||||
libv8 (~> 3.3.10)
|
libv8 (~> 3.3.10)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
tilt (1.3.3)
|
tilt (1.3.3)
|
||||||
treetop (1.4.10)
|
treetop (1.4.10)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.32)
|
tzinfo (0.3.33)
|
||||||
uglifier (1.2.3)
|
uglifier (1.2.4)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
multi_json (>= 1.0.2)
|
multi_json (>= 1.0.2)
|
||||||
unf (0.0.5)
|
unf (0.0.5)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.4)
|
unf_ext (0.0.5)
|
||||||
webrobots (0.0.13)
|
webrobots (0.0.13)
|
||||||
whenever (0.7.3)
|
whenever (0.7.3)
|
||||||
activesupport (>= 2.3.4)
|
activesupport (>= 2.3.4)
|
||||||
@@ -198,7 +198,7 @@ DEPENDENCIES
|
|||||||
nokogiri
|
nokogiri
|
||||||
pg
|
pg
|
||||||
pry
|
pry
|
||||||
rails (= 3.2.2)
|
rails (= 3.2.3)
|
||||||
rmagick
|
rmagick
|
||||||
sanitize!
|
sanitize!
|
||||||
sass-rails
|
sass-rails
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Downloads
|
|||||||
module Strategies
|
module Strategies
|
||||||
class Base
|
class Base
|
||||||
def self.strategies
|
def self.strategies
|
||||||
[Pixiv, Tinami, Pixa]
|
[Pixiv]
|
||||||
end
|
end
|
||||||
|
|
||||||
def rewrite(url, headers)
|
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
|
delegate :get, :site_name, :artist_name, :profile_url, :image_url, :tags, :artist_record, :unique_id, :to => :strategy
|
||||||
|
|
||||||
def self.strategies
|
def self.strategies
|
||||||
[Strategies::NicoSeiga, Strategies::Pixa, Strategies::Pixiv, Strategies::Tinami]
|
[Strategies::NicoSeiga, Strategies::Pixiv]
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(url)
|
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
|
|
||||||
+7
-10
@@ -1,5 +1,5 @@
|
|||||||
class TagAlias < ActiveRecord::Base
|
class TagAlias < ActiveRecord::Base
|
||||||
before_save :clear_all_cache
|
after_save :clear_all_cache
|
||||||
after_save :update_cache
|
after_save :update_cache
|
||||||
after_destroy :clear_all_cache
|
after_destroy :clear_all_cache
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
@@ -62,17 +62,14 @@ class TagAlias < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def clear_all_cache
|
def clear_all_cache
|
||||||
clear_cache
|
Danbooru.config.all_server_hosts.each do |host|
|
||||||
clear_remote_cache
|
delay.clear_cache(host)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_cache
|
def clear_cache(host = Socket.gethostname)
|
||||||
Cache.delete("ta:#{Cache.sanitize(antecedent_name)}")
|
if host == Socket.gethostname
|
||||||
end
|
Cache.delete("ta:#{Cache.sanitize(antecedent_name)}")
|
||||||
|
|
||||||
def clear_remote_cache
|
|
||||||
Danbooru.config.other_server_hosts.each do |server|
|
|
||||||
Net::HTTP.delete(URI.parse("http://#{server}/tag_aliases/#{id}/cache"))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ module Danbooru
|
|||||||
# Used in conjunction with load balancing to distribute files from one server to
|
# 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.
|
# the others. This should match whatever gethostname returns on the other servers.
|
||||||
def all_server_hosts
|
def all_server_hosts
|
||||||
[]
|
[server_host]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Names of other Danbooru servers.
|
# Names of other Danbooru servers.
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
Factory.define(:advertisement) do |f|
|
FactoryGirl.define do
|
||||||
f.referral_url "http://google.com"
|
factory(:advertisement) do
|
||||||
f.ad_type "vertical"
|
referral_url "http://google.com"
|
||||||
f.status "active"
|
ad_type "vertical"
|
||||||
f.width 728
|
status "active"
|
||||||
f.height 90
|
width 728
|
||||||
f.file_name "google.gif"
|
height 90
|
||||||
|
file_name "google.gif"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
Factory.define(:artist) do |f|
|
FactoryGirl.define do
|
||||||
f.name {rand(1_000_000).to_s}
|
factory(:artist) do
|
||||||
f.is_active true
|
name {rand(1_000_000).to_s}
|
||||||
|
is_active true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
Factory.define(:artist_url) do |f|
|
FactoryGirl.define do
|
||||||
f.artist {|x| x.association(:artist)}
|
factory(:artist_url) do
|
||||||
f.url {Faker::Internet.domain_name}
|
artist
|
||||||
end
|
url {Faker::Internet.domain_name}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
Factory.define(:ban) do |f|
|
FactoryGirl.define do
|
||||||
f.reason {Faker::Lorem.words.join(" ")}
|
factory(:ban) do |f|
|
||||||
f.duration 60
|
reason {Faker::Lorem.words.join(" ")}
|
||||||
end
|
duration 60
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
Factory.define(:comment) do |f|
|
FactoryGirl.define do
|
||||||
f.post {|x| x.association(:post)}
|
factory(:comment) do |f|
|
||||||
f.body {Faker::Lorem.sentences.join(" ")}
|
post
|
||||||
end
|
body {Faker::Lorem.sentences.join(" ")}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
Factory.define(:comment_vote) do |f|
|
FactoryGirl.define do
|
||||||
f.score 1
|
factory(:comment_vote) do
|
||||||
end
|
score 1
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:dmail) do |f|
|
FactoryGirl.define do
|
||||||
f.to {|x| x.association(:user)}
|
factory(:dmail) do
|
||||||
f.title {Faker::Lorem.words.join(" ")}
|
to :factory => :user
|
||||||
f.body {Faker::Lorem.sentences.join(" ")}
|
title {Faker::Lorem.words.join(" ")}
|
||||||
|
body {Faker::Lorem.sentences.join(" ")}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
Factory.define(:favorite) do |f|
|
FactoryGirl.define do
|
||||||
|
factory(:favorite)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
Factory.define(:forum_post) do |f|
|
FactoryGirl.define do
|
||||||
f.body {Faker::Lorem.sentences}
|
factory(:forum_post) do
|
||||||
end
|
body {Faker::Lorem.sentences.join(" ")}
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:forum_topic) do |f|
|
FactoryGirl.define do
|
||||||
f.title {Faker::Lorem.words}
|
factory(:forum_topic) do
|
||||||
f.is_sticky false
|
title {Faker::Lorem.words.join(" ")}
|
||||||
f.is_locked false
|
is_sticky false
|
||||||
end
|
is_locked false
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:ip_ban) do |f|
|
FactoryGirl.define do
|
||||||
f.creator {|x| x.association(:user)}
|
factory(:ip_ban) do
|
||||||
f.reason {Faker::Lorem.words.join(" ")}
|
creator :factory => :user
|
||||||
f.ip_addr "127.0.0.1"
|
reason {Faker::Lorem.words.join(" ")}
|
||||||
end
|
ip_addr "127.0.0.1"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
Factory.define(:janitor_trial) do |f|
|
FactoryGirl.define do
|
||||||
f.user {|x| x.association(:user)}
|
factory(:janitor_trial) do
|
||||||
|
user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
Factory.define(:mod_action) do |f|
|
FactoryGirl.define do
|
||||||
f.creator {|x| x.association(:user)}
|
factory(:mod_action) do
|
||||||
f.description "1234"
|
creator :factory => :user
|
||||||
|
description "1234"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
Factory.define(:news_update) do |f|
|
FactoryGirl.define do
|
||||||
f.message "xxx"
|
factory(:news_update) do
|
||||||
|
message "xxx"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+14
-12
@@ -1,12 +1,14 @@
|
|||||||
Factory.define(:note) do |f|
|
FactoryGirl.define do
|
||||||
f.creator {|x| x.association(:user)}
|
factory(:note) do
|
||||||
f.post {|x| x.association(:post)}
|
creator :factory => :user
|
||||||
f.x 0
|
post
|
||||||
f.y 0
|
x 0
|
||||||
f.width 0
|
y 0
|
||||||
f.height 0
|
width 0
|
||||||
f.is_active true
|
height 0
|
||||||
f.body {Faker::Lorem.sentences.join}
|
is_active true
|
||||||
f.updater_id {|x| x.association(:user)}
|
body {Faker::Lorem.sentences.join(" ")}
|
||||||
f.updater_ip_addr "127.0.0.1"
|
updater_id :factory => :user
|
||||||
end
|
updater_ip_addr "127.0.0.1"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:pool) do |f|
|
FactoryGirl.define do
|
||||||
f.name {(rand(1_000_000) + 100).to_s}
|
factory(:pool) do
|
||||||
f.creator {|x| x.association(:user)}
|
name {(rand(1_000_000) + 100).to_s}
|
||||||
f.description {Faker::Lorem.sentences}
|
association :creator, :factory => :user
|
||||||
|
description {Faker::Lorem.sentences.join(" ")}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+15
-13
@@ -1,13 +1,15 @@
|
|||||||
Factory.define(:post) do |f|
|
FactoryGirl.define do
|
||||||
f.md5 {|x| Time.now.to_f.to_s}
|
factory(:post) do
|
||||||
f.uploader {|x| x.association(:user)}
|
md5 {|x| Time.now.to_f.to_s}
|
||||||
f.uploader_ip_addr "127.0.0.1"
|
uploader :factory => :user
|
||||||
f.tag_string "tag1 tag2"
|
uploader_ip_addr "127.0.0.1"
|
||||||
f.tag_count 2
|
tag_string "tag1 tag2"
|
||||||
f.tag_count_general 2
|
tag_count 2
|
||||||
f.file_ext "jpg"
|
tag_count_general 2
|
||||||
f.image_width 100
|
file_ext "jpg"
|
||||||
f.image_height 200
|
image_width 100
|
||||||
f.file_size 2000
|
image_height 200
|
||||||
f.rating "q"
|
file_size 2000
|
||||||
end
|
rating "q"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
Factory.define(:post_appeal) do |f|
|
FactoryGirl.define do
|
||||||
f.reason "xxx"
|
factory(:post_appeal) do
|
||||||
|
reason "xxx"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
Factory.define(:post_flag) do |f|
|
FactoryGirl.define do
|
||||||
f.reason "xxx"
|
factory(:post_flag) do
|
||||||
f.is_resolved false
|
reason "xxx"
|
||||||
|
is_resolved false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
+18
-16
@@ -1,19 +1,21 @@
|
|||||||
Factory.define(:tag) do |f|
|
FactoryGirl.define do
|
||||||
f.name {Faker::Name.first_name.downcase}
|
factory(:tag) do
|
||||||
f.post_count 0
|
name {Faker::Name.first_name.downcase}
|
||||||
f.category {Tag.categories.general}
|
post_count 0
|
||||||
f.related_tags ""
|
category {Tag.categories.general}
|
||||||
f.related_tags_updated_at {Time.now}
|
related_tags ""
|
||||||
end
|
related_tags_updated_at {Time.now}
|
||||||
|
|
||||||
|
factory(:artist_tag) do
|
||||||
|
category {Tag.categories.artist}
|
||||||
|
end
|
||||||
|
|
||||||
Factory.define(:artist_tag, :parent => :tag) do |f|
|
factory(:copyright_tag) do
|
||||||
f.category {Tag.categories.artist}
|
category {Tag.categories.copyright}
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define(:copyright_tag, :parent => :tag) do |f|
|
factory(:character_tag) do
|
||||||
f.category {Tag.categories.copyright}
|
category {Tag.categories.character}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
Factory.define(:character_tag, :parent => :tag) do |f|
|
|
||||||
f.category {Tag.categories.character}
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FactoryGirl.define do
|
|||||||
antecedent_name "aaa"
|
antecedent_name "aaa"
|
||||||
consequent_name "bbb"
|
consequent_name "bbb"
|
||||||
|
|
||||||
after_create do |tag_alias|
|
after(:create) do |tag_alias|
|
||||||
tag_alias.process!
|
tag_alias.process!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FactoryGirl.define do
|
|||||||
antecedent_name "aaa"
|
antecedent_name "aaa"
|
||||||
consequent_name "bbb"
|
consequent_name "bbb"
|
||||||
|
|
||||||
after_create do |tag_implication|
|
after(:create) do |tag_implication|
|
||||||
tag_implication.process!
|
tag_implication.process!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:tag_subscription) do |f|
|
FactoryGirl.define do
|
||||||
f.name {Faker::Lorem.words.join(" ")}
|
factory(:tag_subscription) do
|
||||||
f.is_public true
|
name {Faker::Lorem.words.join(" ")}
|
||||||
f.tag_query "aaa"
|
is_public true
|
||||||
|
tag_query "aaa"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+40
-37
@@ -1,44 +1,47 @@
|
|||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
|
||||||
Factory.define(:upload) do |f|
|
FactoryGirl.define do
|
||||||
f.rating "s"
|
factory(:upload) do
|
||||||
f.uploader {|x| x.association(:user, :level => 200)}
|
rating "s"
|
||||||
f.uploader_ip_addr "127.0.0.1"
|
uploader :factory => :user, :level => 20
|
||||||
f.tag_string "special"
|
uploader_ip_addr "127.0.0.1"
|
||||||
f.status "pending"
|
tag_string "special"
|
||||||
end
|
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|
|
factory(:jpg_upload) do
|
||||||
f.source "http://www.google.com/intl/en_ALL/images/logo.gif"
|
content_type "image/jpeg"
|
||||||
end
|
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|
|
factory(:large_jpg_upload) do
|
||||||
f.content_type "image/jpeg"
|
file_ext "jpg"
|
||||||
f.file_path do
|
content_type "image/jpeg"
|
||||||
FileUtils.cp("#{Rails.root}/test/files/test.jpg", "#{Rails.root}/tmp")
|
file_path do
|
||||||
"#{Rails.root}/tmp/test.jpg"
|
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
|
||||||
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
|
|
||||||
|
|||||||
+36
-33
@@ -1,35 +1,38 @@
|
|||||||
Factory.define(:user) do |f|
|
FactoryGirl.define do
|
||||||
f.name {rand(1_000_000).to_s}
|
factory(:user) do
|
||||||
f.password "password"
|
name {rand(1_000_000).to_s}
|
||||||
f.password_hash {User.sha1("password")}
|
password "password"
|
||||||
f.email {Faker::Internet.email}
|
password_hash {User.sha1("password")}
|
||||||
f.default_image_size "large"
|
email {Faker::Internet.email}
|
||||||
f.base_upload_limit 10
|
default_image_size "large"
|
||||||
f.level 20
|
base_upload_limit 10
|
||||||
f.last_logged_in_at {Time.now}
|
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
|
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|
|
FactoryGirl.define do
|
||||||
f.user {|x| x.association(:user)}
|
factory(:user_feedback) do
|
||||||
f.category "positive"
|
user
|
||||||
f.body {Faker::Lorem.words.join(" ")}
|
category "positive"
|
||||||
|
body {Faker::Lorem.words.join(" ")}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
Factory.define(:user_password_reset_nonce) do |f|
|
FactoryGirl.define do
|
||||||
|
factory(:user_password_reset_nonce)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Factory.define(:wiki_page) do |f|
|
FactoryGirl.define do
|
||||||
f.creator {|x| x.association(:user)}
|
factory(:wiki_page) do
|
||||||
f.title {|x| Faker::Lorem.words.join(" ")}
|
creator :factory => :user
|
||||||
f.body {Faker::Lorem.sentences.join(" ")}
|
title {Faker::Lorem.words.join(" ")}
|
||||||
|
body {Faker::Lorem.sentences.join(" ")}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class AdvertisementHitsControllerTest < ActionController::TestCase
|
class AdvertisementHitsControllerTest < ActionController::TestCase
|
||||||
context "An advertisement hits controller" do
|
context "An advertisement hits controller" do
|
||||||
setup do
|
setup do
|
||||||
@ad = Factory.create(:advertisement)
|
@ad = FactoryGirl.create(:advertisement)
|
||||||
@advertiser = Factory.create(:admin_user)
|
@advertiser = FactoryGirl.create(:admin_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a new hit" do
|
should "create a new hit" do
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class AdvertisementsControllerTest < ActionController::TestCase
|
class AdvertisementsControllerTest < ActionController::TestCase
|
||||||
context "An advertisement controller" do
|
context "An advertisement controller" do
|
||||||
setup do
|
setup do
|
||||||
@ad = Factory.create(:advertisement)
|
@ad = FactoryGirl.create(:advertisement)
|
||||||
@advertiser = Factory.create(:admin_user)
|
@advertiser = FactoryGirl.create(:admin_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "get the new page" do
|
should "get the new page" do
|
||||||
@@ -29,7 +29,7 @@ class AdvertisementsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
should "create an ad" do
|
should "create an ad" do
|
||||||
assert_difference("Advertisement.count", 1) 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
|
end
|
||||||
ad = Advertisement.last
|
ad = Advertisement.last
|
||||||
assert_redirected_to(advertisement_path(ad))
|
assert_redirected_to(advertisement_path(ad))
|
||||||
@@ -50,7 +50,7 @@ class AdvertisementsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "block non-advertisers" do
|
should "block non-advertisers" do
|
||||||
regular_user = Factory.create(:user)
|
regular_user = FactoryGirl.create(:user)
|
||||||
get :index, {}, {:user_id => regular_user.id}
|
get :index, {}, {:user_id => regular_user.id}
|
||||||
assert_redirected_to("/static/access_denied")
|
assert_redirected_to("/static/access_denied")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ require 'test_helper'
|
|||||||
class ArtistVersionsControllerTest < ActionController::TestCase
|
class ArtistVersionsControllerTest < ActionController::TestCase
|
||||||
context "An artist versions controller" do
|
context "An artist versions controller" do
|
||||||
setup do
|
setup do
|
||||||
CurrentUser.user = Factory.create(:user)
|
CurrentUser.user = FactoryGirl.create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@artist = Factory.create(:artist)
|
@artist = FactoryGirl.create(:artist)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class ArtistsControllerTest < ActionController::TestCase
|
class ArtistsControllerTest < ActionController::TestCase
|
||||||
context "An artists controller" do
|
context "An artists controller" do
|
||||||
setup do
|
setup do
|
||||||
CurrentUser.user = Factory.create(:user)
|
CurrentUser.user = FactoryGirl.create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@artist = Factory.create(:artist)
|
@artist = FactoryGirl.create(:artist)
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -42,7 +42,7 @@ class ArtistsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
should "create an artist" do
|
should "create an artist" do
|
||||||
assert_difference("Artist.count", 1) 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
|
end
|
||||||
artist = Artist.last
|
artist = Artist.last
|
||||||
assert_redirected_to(artist_path(artist))
|
assert_redirected_to(artist_path(artist))
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ require 'test_helper'
|
|||||||
class BansControllerTest < ActionController::TestCase
|
class BansControllerTest < ActionController::TestCase
|
||||||
context "A bans controller" do
|
context "A bans controller" do
|
||||||
setup do
|
setup do
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @mod
|
CurrentUser.user = @mod
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@ban = Factory.create(:ban, :user_id => @user.id)
|
@ban = FactoryGirl.create(:ban, :user_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class CommentVotesControllerTest < ActionController::TestCase
|
class CommentVotesControllerTest < ActionController::TestCase
|
||||||
context "A comment votes controller" do
|
context "A comment votes controller" do
|
||||||
setup do
|
setup do
|
||||||
CurrentUser.user = @user = Factory.create(:user)
|
CurrentUser.user = @user = FactoryGirl.create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||||
@comment = Factory.create(:comment)
|
@comment = FactoryGirl.create(:comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -22,7 +22,7 @@ class CommentVotesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "fail silently on errors" do
|
should "fail silently on errors" do
|
||||||
Factory.create(:comment_vote, :comment => @comment)
|
FactoryGirl.create(:comment_vote, :comment => @comment)
|
||||||
assert_difference("CommentVote.count", 0) do
|
assert_difference("CommentVote.count", 0) do
|
||||||
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
|
post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ require 'test_helper'
|
|||||||
class CommentsControllerTest < ActionController::TestCase
|
class CommentsControllerTest < ActionController::TestCase
|
||||||
context "A comments controller" do
|
context "A comments controller" do
|
||||||
setup do
|
setup do
|
||||||
CurrentUser.user = Factory.create(:user)
|
CurrentUser.user = FactoryGirl.create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@comment = Factory.create(:comment, :post => @post)
|
@comment = FactoryGirl.create(:comment, :post => @post)
|
||||||
@user = Factory.create(:moderator_user)
|
@user = FactoryGirl.create(:moderator_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -38,7 +38,7 @@ class CommentsControllerTest < ActionController::TestCase
|
|||||||
context "create action"do
|
context "create action"do
|
||||||
should "create a comment" do
|
should "create a comment" do
|
||||||
assert_difference("Comment.count", 1) 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
|
end
|
||||||
comment = Comment.last
|
comment = Comment.last
|
||||||
assert_redirected_to post_path(comment.post)
|
assert_redirected_to post_path(comment.post)
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ require 'test_helper'
|
|||||||
class DmailsControllerTest < ActionController::TestCase
|
class DmailsControllerTest < ActionController::TestCase
|
||||||
context "The dmails controller" do
|
context "The dmails controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@unrelated_user = Factory.create(:user)
|
@unrelated_user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@dmail = Factory.create(:dmail, :owner => @user)
|
@dmail = FactoryGirl.create(:dmail, :owner => @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -73,7 +73,7 @@ class DmailsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
setup do
|
setup do
|
||||||
@user_2 = Factory.create(:user)
|
@user_2 = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create two messages, one for the sender and one for the recipient" do
|
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
|
class FavoritesControllerTest < ActionController::TestCase
|
||||||
context "The favorites controller" do
|
context "The favorites controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@post.add_favorite!(@user)
|
@post.add_favorite!(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a favorite for the current user" do
|
should "create a favorite for the current user" do
|
||||||
@@ -47,7 +47,7 @@ class FavoritesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@post.add_favorite!(@user)
|
@post.add_favorite!(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ require 'test_helper'
|
|||||||
class ForumPostsControllerTest < ActionController::TestCase
|
class ForumPostsControllerTest < ActionController::TestCase
|
||||||
context "The forum posts controller" do
|
context "The forum posts controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@other_user = Factory.create(:user)
|
@other_user = FactoryGirl.create(:user)
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
@forum_topic = Factory.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
@forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
||||||
@forum_post = Factory.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx")
|
@forum_post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx")
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ require 'test_helper'
|
|||||||
class ForumTopicsControllerTest < ActionController::TestCase
|
class ForumTopicsControllerTest < ActionController::TestCase
|
||||||
context "The forum topics controller" do
|
context "The forum topics controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@other_user = Factory.create(:user)
|
@other_user = FactoryGirl.create(:user)
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
@forum_topic = Factory.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
@forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -75,7 +75,7 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:forum_post, :topic_id => @forum_topic.id)
|
@post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy the topic and any associated posts" do
|
should "destroy the topic and any associated posts" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class IpBansControllerTest < ActionController::TestCase
|
class IpBansControllerTest < ActionController::TestCase
|
||||||
context "The ip bans controller" do
|
context "The ip bans controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -25,7 +25,7 @@ class IpBansControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
Factory.create(:ip_ban)
|
FactoryGirl.create(:ip_ban)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -43,7 +43,7 @@ class IpBansControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@ip_ban = Factory.create(:ip_ban)
|
@ip_ban = FactoryGirl.create(:ip_ban)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy an ip ban" do
|
should "destroy an ip ban" do
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class JanitorTrialsControllerTest < ActionController::TestCase
|
class JanitorTrialsControllerTest < ActionController::TestCase
|
||||||
context "The janitor trials controller" do
|
context "The janitor trials controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -30,7 +30,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "promote action" do
|
context "promote action" do
|
||||||
setup do
|
setup do
|
||||||
@janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id)
|
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "promote the janitor trial" do
|
should "promote the janitor trial" do
|
||||||
@@ -44,7 +44,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "demote action" do
|
context "demote action" do
|
||||||
setup do
|
setup do
|
||||||
@janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id)
|
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "demote the janitor trial" do
|
should "demote the janitor trial" do
|
||||||
@@ -58,7 +58,7 @@ class JanitorTrialsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
Factory.create(:janitor_trial)
|
FactoryGirl.create(:janitor_trial)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ module Maintenance
|
|||||||
class LoginRemindersControllerTest < ActionController::TestCase
|
class LoginRemindersControllerTest < ActionController::TestCase
|
||||||
context "A login reminder controller" do
|
context "A login reminder controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@blank_email_user = Factory.create(:user, :email => "")
|
@blank_email_user = FactoryGirl.create(:user, :email => "")
|
||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
ActionMailer::Base.delivery_method = :test
|
ActionMailer::Base.delivery_method = :test
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module Maintenance
|
|||||||
class PasswordResetsControllerTest < ActionController::TestCase
|
class PasswordResetsControllerTest < ActionController::TestCase
|
||||||
context "A password resets controller" do
|
context "A password resets controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user, :email => "abc@com.net")
|
@user = FactoryGirl.create(:user, :email => "abc@com.net")
|
||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
ActionMailer::Base.delivery_method = :test
|
ActionMailer::Base.delivery_method = :test
|
||||||
@@ -73,8 +73,8 @@ module Maintenance
|
|||||||
|
|
||||||
context "with valid parameters" do
|
context "with valid parameters" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@nonce = Factory.create(:user_password_reset_nonce, :email => @user.email)
|
@nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email)
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
get :edit, :email => @nonce.email, :key => @nonce.key
|
get :edit, :email => @nonce.email, :key => @nonce.key
|
||||||
end
|
end
|
||||||
@@ -98,8 +98,8 @@ module Maintenance
|
|||||||
|
|
||||||
context "with valid parameters" do
|
context "with valid parameters" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@nonce = Factory.create(:user_password_reset_nonce, :email => @user.email)
|
@nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email)
|
||||||
ActionMailer::Base.deliveries.clear
|
ActionMailer::Base.deliveries.clear
|
||||||
@old_password = @user.password_hash
|
@old_password = @user.password_hash
|
||||||
post :update, :email => @nonce.email, :key => @nonce.key
|
post :update, :email => @nonce.email, :key => @nonce.key
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Moderator
|
|||||||
class DashboardsControllerTest < ActionController::TestCase
|
class DashboardsControllerTest < ActionController::TestCase
|
||||||
context "The moderator dashboards controller" do
|
context "The moderator dashboards controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||||
@@ -13,7 +13,7 @@ module Moderator
|
|||||||
context "show action" do
|
context "show action" do
|
||||||
context "for mod actions" do
|
context "for mod actions" do
|
||||||
setup do
|
setup do
|
||||||
@mod_action = Factory.create(:mod_action)
|
@mod_action = FactoryGirl.create(:mod_action)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -25,7 +25,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for user feedbacks" do
|
context "for user feedbacks" do
|
||||||
setup do
|
setup do
|
||||||
@feedback = Factory.create(:user_feedback)
|
@feedback = FactoryGirl.create(:user_feedback)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -37,7 +37,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for wiki pages" do
|
context "for wiki pages" do
|
||||||
setup do
|
setup do
|
||||||
@wiki_page = Factory.create(:wiki_page)
|
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -49,7 +49,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for tags and uploads" do
|
context "for tags and uploads" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -61,8 +61,8 @@ module Moderator
|
|||||||
|
|
||||||
context "for notes"do
|
context "for notes"do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@note = Factory.create(:note, :post_id => @post.id)
|
@note = FactoryGirl.create(:note, :post_id => @post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -74,10 +74,10 @@ module Moderator
|
|||||||
|
|
||||||
context "for comments" do
|
context "for comments" do
|
||||||
setup 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
|
CurrentUser.scoped(@users[0], "1.2.3.4") do
|
||||||
@comment = Factory.create(:comment)
|
@comment = FactoryGirl.create(:comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
@users.each do |user|
|
@users.each do |user|
|
||||||
@@ -95,7 +95,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for artists" do
|
context "for artists" do
|
||||||
setup do
|
setup do
|
||||||
@artist = Factory.create(:artist)
|
@artist = FactoryGirl.create(:artist)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -107,7 +107,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for flags" do
|
context "for flags" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@post.flag!("blah")
|
@post.flag!("blah")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ module Moderator
|
|||||||
|
|
||||||
context "for appeals" do
|
context "for appeals" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :is_deleted => true)
|
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||||
@post.appeal!("blah")
|
@post.appeal!("blah")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ module Moderator
|
|||||||
class InvitationsControllerTest < ActionController::TestCase
|
class InvitationsControllerTest < ActionController::TestCase
|
||||||
context "The invitations controller" do
|
context "The invitations controller" do
|
||||||
setup do
|
setup do
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @mod
|
CurrentUser.user = @mod
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
|
|
||||||
@user_1 = Factory.create(:user)
|
@user_1 = FactoryGirl.create(:user)
|
||||||
@user_2 = Factory.create(:user, :inviter_id => @mod.id)
|
@user_2 = FactoryGirl.create(:user, :inviter_id => @mod.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render the new page" do
|
should "render the new page" do
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ module Moderator
|
|||||||
class IpAddrsControllerTest < ActionController::TestCase
|
class IpAddrsControllerTest < ActionController::TestCase
|
||||||
context "The ip addrs controller" do
|
context "The ip addrs controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:moderator_user)
|
@user = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Factory.create(:comment)
|
FactoryGirl.create(:comment)
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ module Moderator
|
|||||||
class ApprovalsControllerTest < ActionController::TestCase
|
class ApprovalsControllerTest < ActionController::TestCase
|
||||||
context "The moderator post approvals controller" do
|
context "The moderator post approvals controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
@post = Factory.create(:post, :is_pending => true)
|
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ module Moderator
|
|||||||
class DisapprovalsControllerTest < ActionController::TestCase
|
class DisapprovalsControllerTest < ActionController::TestCase
|
||||||
context "The moderator post disapprovals controller" do
|
context "The moderator post disapprovals controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
@post = Factory.create(:post, :is_pending => true)
|
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ module Moderator
|
|||||||
class PostsControllerTest < ActionController::TestCase
|
class PostsControllerTest < ActionController::TestCase
|
||||||
context "The moderator post disapprovals controller" do
|
context "The moderator post disapprovals controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
context "delete action" do
|
context "delete action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -25,7 +25,7 @@ module Moderator
|
|||||||
|
|
||||||
context "undelete action" do
|
context "undelete action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :is_deleted => true)
|
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ module Moderator
|
|||||||
class QueuesControllerTest < ActionController::TestCase
|
class QueuesControllerTest < ActionController::TestCase
|
||||||
context "The moderator post queues controller" do
|
context "The moderator post queues controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
@post = Factory.create(:post, :is_pending => true)
|
@post = FactoryGirl.create(:post, :is_pending => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ module Moderator
|
|||||||
class TagsControllerTest < ActionController::TestCase
|
class TagsControllerTest < ActionController::TestCase
|
||||||
context "The tags controller" do
|
context "The tags controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:moderator_user)
|
@user = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render the edit action" do
|
should "render the edit action" do
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class NewsUpdatesControllerTest < ActionController::TestCase
|
class NewsUpdatesControllerTest < ActionController::TestCase
|
||||||
context "the news updates controller" do
|
context "the news updates controller" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@news_update = Factory.create(:news_update)
|
@news_update = FactoryGirl.create(:news_update)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class NoteVersionsControllerTest < ActionController::TestCase
|
class NoteVersionsControllerTest < ActionController::TestCase
|
||||||
context "The note versions controller" do
|
context "The note versions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,8 +15,8 @@ class NoteVersionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@note = Factory.create(:note)
|
@note = FactoryGirl.create(:note)
|
||||||
@user_2 = Factory.create(:user)
|
@user_2 = FactoryGirl.create(:user)
|
||||||
|
|
||||||
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
||||||
@note.update_attributes(:body => "1 2")
|
@note.update_attributes(:body => "1 2")
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class NotesControllerTest < ActionController::TestCase
|
class NotesControllerTest < ActionController::TestCase
|
||||||
context "The notes controller" do
|
context "The notes controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -15,7 +15,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
Factory.create(:note)
|
FactoryGirl.create(:note)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all notes" do
|
should "list all notes" do
|
||||||
@@ -39,7 +39,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@note = Factory.create(:note)
|
@note = FactoryGirl.create(:note)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update a note" do
|
should "update a note" do
|
||||||
@@ -51,7 +51,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@note = Factory.create(:note)
|
@note = FactoryGirl.create(:note)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a note" do
|
should "destroy a note" do
|
||||||
@@ -63,7 +63,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "revert action" do
|
context "revert action" do
|
||||||
setup do
|
setup do
|
||||||
@note = Factory.create(:note, :body => "000")
|
@note = FactoryGirl.create(:note, :body => "000")
|
||||||
@note.update_attributes(:body => "111")
|
@note.update_attributes(:body => "111")
|
||||||
@note.update_attributes(:body => "222")
|
@note.update_attributes(:body => "222")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ require 'test_helper'
|
|||||||
class PoolElementsControllerTest < ActionController::TestCase
|
class PoolElementsControllerTest < ActionController::TestCase
|
||||||
context "The pools posts controller" do
|
context "The pools posts controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@pool = Factory.create(:pool, :name => "abc")
|
@pool = FactoryGirl.create(:pool, :name => "abc")
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class PoolVersionsControllerTest < ActionController::TestCase
|
class PoolVersionsControllerTest < ActionController::TestCase
|
||||||
context "The pool versions controller" do
|
context "The pool versions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,9 +15,9 @@ class PoolVersionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@pool = Factory.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
@user_2 = Factory.create(:user)
|
@user_2 = FactoryGirl.create(:user)
|
||||||
@user_3 = Factory.create(:user)
|
@user_3 = FactoryGirl.create(:user)
|
||||||
|
|
||||||
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
CurrentUser.scoped(@user_2, "1.2.3.4") do
|
||||||
@pool.update_attributes(:post_ids => "1 2")
|
@pool.update_attributes(:post_ids => "1 2")
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ require 'test_helper'
|
|||||||
class PoolsControllerTest < ActionController::TestCase
|
class PoolsControllerTest < ActionController::TestCase
|
||||||
context "The pools controller" do
|
context "The pools controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -16,7 +16,7 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
Factory.create(:pool, :name => "abc")
|
FactoryGirl.create(:pool, :name => "abc")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all pools" do
|
should "list all pools" do
|
||||||
@@ -32,7 +32,7 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
@pool = Factory.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -51,7 +51,7 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@pool = Factory.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update a pool" do
|
should "update a pool" do
|
||||||
@@ -63,7 +63,7 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@pool = Factory.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a pool" do
|
should "destroy a pool" do
|
||||||
@@ -75,7 +75,7 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "undelete action" do
|
context "undelete action" do
|
||||||
setup do
|
setup do
|
||||||
@pool = Factory.create(:pool)
|
@pool = FactoryGirl.create(:pool)
|
||||||
@pool.is_deleted = true
|
@pool.is_deleted = true
|
||||||
@pool.save
|
@pool.save
|
||||||
end
|
end
|
||||||
@@ -89,8 +89,8 @@ class PoolsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "revert action" do
|
context "revert action" do
|
||||||
setup do
|
setup do
|
||||||
@post_2 = Factory.create(:post)
|
@post_2 = FactoryGirl.create(:post)
|
||||||
@pool = Factory.create(:pool, :post_ids => "#{@post.id}")
|
@pool = FactoryGirl.create(:pool, :post_ids => "#{@post.id}")
|
||||||
CurrentUser.ip_addr = "1.2.3.4" # this is to get around the version collation
|
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}")
|
@pool.update_attributes(:post_ids => "#{@post.id} #{@post_2.id}")
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class PostAppealsControllerTest < ActionController::TestCase
|
class PostAppealsControllerTest < ActionController::TestCase
|
||||||
context "The post appeals controller" do
|
context "The post appeals controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -22,8 +22,8 @@ class PostAppealsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :is_deleted => true)
|
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||||
@post_appeal = Factory.create(:post_appeal, :post => @post)
|
@post_appeal = FactoryGirl.create(:post_appeal, :post => @post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -41,7 +41,7 @@ class PostAppealsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :is_deleted => true)
|
@post = FactoryGirl.create(:post, :is_deleted => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a new appeal" do
|
should "create a new appeal" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class PostFlagsControllerTest < ActionController::TestCase
|
class PostFlagsControllerTest < ActionController::TestCase
|
||||||
context "The post flags controller" do
|
context "The post flags controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -22,8 +22,8 @@ class PostFlagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@post_flag = Factory.create(:post_flag, :post => @post)
|
@post_flag = FactoryGirl.create(:post_flag, :post => @post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -41,7 +41,7 @@ class PostFlagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a new flag" do
|
should "create a new flag" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class PostVersionsControllerTest < ActionController::TestCase
|
class PostVersionsControllerTest < ActionController::TestCase
|
||||||
context "The post versions controller" do
|
context "The post versions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ class PostVersionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup 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 => "1 2", :source => "xxx")
|
||||||
@post.update_attributes(:tag_string => "2 3", :rating => "e")
|
@post.update_attributes(:tag_string => "2 3", :rating => "e")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class PostVotesControllerTest < ActionController::TestCase
|
class PostVotesControllerTest < ActionController::TestCase
|
||||||
context "The post vote controller" do
|
context "The post vote controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:privileged_user)
|
@user = FactoryGirl.create(:privileged_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require "test_helper"
|
|||||||
class PostsControllerTest < ActionController::TestCase
|
class PostsControllerTest < ActionController::TestCase
|
||||||
context "The posts controller" do
|
context "The posts controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
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
|
MEMCACHE.flush_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class SessionsControllerTest < ActionController::TestCase
|
class SessionsControllerTest < ActionController::TestCase
|
||||||
context "the sessions controller" do
|
context "the sessions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "new action" do
|
context "new action" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class TagAliasesControllerTest < ActionController::TestCase
|
class TagAliasesControllerTest < ActionController::TestCase
|
||||||
context "The tag aliases controller" do
|
context "The tag aliases controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:admin_user)
|
@user = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -17,7 +17,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup 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
|
end
|
||||||
|
|
||||||
should "list all tag aliass" do
|
should "list all tag aliass" do
|
||||||
@@ -41,7 +41,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_alias = Factory.create(:tag_alias)
|
@tag_alias = FactoryGirl.create(:tag_alias)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a tag_alias" do
|
should "destroy a tag_alias" do
|
||||||
@@ -53,7 +53,7 @@ class TagAliasesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy_cache action" do
|
context "destroy_cache action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa")
|
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "reset the cache" do
|
should "reset the cache" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class TagImplicationsControllerTest < ActionController::TestCase
|
class TagImplicationsControllerTest < ActionController::TestCase
|
||||||
context "The tag implicationes controller" do
|
context "The tag implicationes controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:admin_user)
|
@user = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -17,7 +17,7 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup 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
|
end
|
||||||
|
|
||||||
should "list all tag implications" do
|
should "list all tag implications" do
|
||||||
@@ -41,7 +41,7 @@ class TagImplicationsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_implication = Factory.create(:tag_implication, :creator => @user)
|
@tag_implication = FactoryGirl.create(:tag_implication, :creator => @user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a tag_implication" do
|
should "destroy a tag_implication" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class TagSubscriptionsControllerTest < ActionController::TestCase
|
class TagSubscriptionsControllerTest < ActionController::TestCase
|
||||||
context "The tag subscriptions controller" do
|
context "The tag subscriptions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_subscription = Factory.create(:tag_subscription, :name => "aaa")
|
@tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all visible tag subscriptions" do
|
should "list all visible tag subscriptions" do
|
||||||
@@ -26,7 +26,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "posts action" do
|
context "posts action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_subscription = Factory.create(:tag_subscription, :name => "aaa")
|
@tag_subscription = FactoryGirl.create(:tag_subscription, :name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all visible tag subscriptions" do
|
should "list all visible tag subscriptions" do
|
||||||
@@ -37,7 +37,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_subscription = Factory.create(:tag_subscription)
|
@tag_subscription = FactoryGirl.create(:tag_subscription)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -63,7 +63,7 @@ class TagSubscriptionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@tag_subscription = Factory.create(:tag_subscription)
|
@tag_subscription = FactoryGirl.create(:tag_subscription)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy the posts" do
|
should "destroy the posts" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class TagsControllerTest < ActionController::TestCase
|
class TagsControllerTest < ActionController::TestCase
|
||||||
context "The tags controller" do
|
context "The tags controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ class TagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
setup do
|
setup do
|
||||||
@tag = Factory.create(:tag, :name => "aaa")
|
@tag = FactoryGirl.create(:tag, :name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -26,7 +26,7 @@ class TagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@tag = Factory.create(:tag, :name => "aaa")
|
@tag = FactoryGirl.create(:tag, :name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -44,7 +44,7 @@ class TagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
@tag = Factory.create(:tag)
|
@tag = FactoryGirl.create(:tag)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -55,7 +55,7 @@ class TagsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@tag = Factory.create(:tag)
|
@tag = FactoryGirl.create(:tag)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update the tag" do
|
should "update the tag" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class UploadsControllerTest < ActionController::TestCase
|
class UploadsControllerTest < ActionController::TestCase
|
||||||
context "The uploads controller" do
|
context "The uploads controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:contributor_user)
|
@user = FactoryGirl.create(:contributor_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -21,7 +21,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "for a post that has already been uploaded" do
|
context "for a post that has already been uploaded" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :source => "aaa")
|
@post = FactoryGirl.create(:post, :source => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "initialize the post" do
|
should "initialize the post" do
|
||||||
@@ -34,7 +34,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@upload = Factory.create(:source_upload)
|
@upload = FactoryGirl.create(:source_upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -52,7 +52,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
@upload = Factory.create(:jpg_upload)
|
@upload = FactoryGirl.create(:jpg_upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -73,7 +73,7 @@ class UploadsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@upload = Factory.create(:jpg_upload)
|
@upload = FactoryGirl.create(:jpg_upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "process an unapproval" do
|
should "process an unapproval" do
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class UserFeedbacksControllerTest < ActionController::TestCase
|
class UserFeedbacksControllerTest < ActionController::TestCase
|
||||||
context "The user feedbacks controller" do
|
context "The user feedbacks controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@critic = Factory.create(:privileged_user)
|
@critic = FactoryGirl.create(:privileged_user)
|
||||||
CurrentUser.user = @critic
|
CurrentUser.user = @critic
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -23,7 +23,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
setup do
|
setup do
|
||||||
@user_feedback = Factory.create(:user_feedback)
|
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -34,7 +34,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@user_feedback = Factory.create(:user_feedback)
|
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -62,7 +62,7 @@ class UserFeedbacksControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@user_feedback = Factory.create(:user_feedback)
|
@user_feedback = FactoryGirl.create(:user_feedback)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "delete a feedback" do
|
should "delete a feedback" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class UsersControllerTest < ActionController::TestCase
|
class UsersControllerTest < ActionController::TestCase
|
||||||
context "The users controller" do
|
context "The users controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -14,7 +14,7 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
Factory.create(:user, :name => "abc")
|
FactoryGirl.create(:user, :name => "abc")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all users" do
|
should "list all users" do
|
||||||
@@ -30,7 +30,7 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -51,7 +51,7 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "edit action" do
|
context "edit action" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -62,7 +62,7 @@ class UsersControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update a user" do
|
should "update a user" do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class WikiPageVersionsControllerTest < ActionController::TestCase
|
class WikiPageVersionsControllerTest < ActionController::TestCase
|
||||||
context "The wiki page versions controller" do
|
context "The wiki page versions controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,7 +15,7 @@ class WikiPageVersionsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup 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 => "1 2")
|
||||||
@wiki_page.update_attributes(:body => "2 3")
|
@wiki_page.update_attributes(:body => "2 3")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class WikiPagesControllerTest < ActionController::TestCase
|
class WikiPagesControllerTest < ActionController::TestCase
|
||||||
context "The wiki pages controller" do
|
context "The wiki pages controller" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
@mod = Factory.create(:moderator_user)
|
@mod = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -15,8 +15,8 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "index action" do
|
context "index action" do
|
||||||
setup do
|
setup do
|
||||||
@wiki_page_abc = Factory.create(:wiki_page, :title => "abc")
|
@wiki_page_abc = FactoryGirl.create(:wiki_page, :title => "abc")
|
||||||
@wiki_page_def = Factory.create(:wiki_page, :title => "def")
|
@wiki_page_def = FactoryGirl.create(:wiki_page, :title => "def")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "list all wiki_pages" do
|
should "list all wiki_pages" do
|
||||||
@@ -32,7 +32,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
setup do
|
setup do
|
||||||
@wiki_page = Factory.create(:wiki_page)
|
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "render" do
|
should "render" do
|
||||||
@@ -57,7 +57,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "update action" do
|
context "update action" do
|
||||||
setup do
|
setup do
|
||||||
@wiki_page = Factory.create(:wiki_page)
|
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update a wiki_page" do
|
should "update a wiki_page" do
|
||||||
@@ -69,7 +69,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "destroy action" do
|
context "destroy action" do
|
||||||
setup do
|
setup do
|
||||||
@wiki_page = Factory.create(:wiki_page)
|
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy a wiki_page" do
|
should "destroy a wiki_page" do
|
||||||
@@ -81,7 +81,7 @@ class WikiPagesControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
context "revert action" do
|
context "revert action" do
|
||||||
setup 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")
|
||||||
@wiki_page.update_attributes(:body => "1 2 3")
|
@wiki_page.update_attributes(:body => "1 2 3")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class AdvertisementTest < ActiveSupport::TestCase
|
class AdvertisementTest < ActiveSupport::TestCase
|
||||||
context "An advertisement" do
|
context "An advertisement" do
|
||||||
setup 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
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class AliasAndImplicationImporterTest < ActiveSupport::TestCase
|
class AliasAndImplicationImporterTest < ActiveSupport::TestCase
|
||||||
context "The alias and implication importer" do
|
context "The alias and implication importer" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -20,7 +20,7 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "process it" do
|
should "process it" do
|
||||||
assert_difference("Delayed::Job.count", 2) do
|
assert_difference("Delayed::Job.count", 3) do
|
||||||
@importer.process!
|
@importer.process!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+25
-25
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class ArtistTest < ActiveSupport::TestCase
|
class ArtistTest < ActiveSupport::TestCase
|
||||||
context "An artist" do
|
context "An artist" do
|
||||||
setup do
|
setup do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -16,8 +16,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "with a matching tag alias" do
|
context "with a matching tag alias" do
|
||||||
setup 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")
|
||||||
@artist = Factory.create(:artist, :name => "aaa")
|
@artist = FactoryGirl.create(:artist, :name => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "know it has an alias" do
|
should "know it has an alias" do
|
||||||
@@ -31,8 +31,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "that has been banned" do
|
context "that has been banned" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post, :tag_string => "aaa")
|
@post = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
@artist = Factory.create(:artist, :name => "aaa")
|
@artist = FactoryGirl.create(:artist, :name => "aaa")
|
||||||
@artist.update_attributes({:is_banned => true}, :as => :admin)
|
@artist.update_attributes({:is_banned => true}, :as => :admin)
|
||||||
@post.reload
|
@post.reload
|
||||||
end
|
end
|
||||||
@@ -49,7 +49,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
should "create a new wiki page to store any note information" do
|
should "create a new wiki page to store any note information" do
|
||||||
artist = nil
|
artist = nil
|
||||||
assert_difference("WikiPage.count") do
|
assert_difference("WikiPage.count") do
|
||||||
artist = Factory.create(:artist, :name => "aaa", :notes => "testing")
|
artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing")
|
||||||
end
|
end
|
||||||
assert_equal("testing", artist.notes)
|
assert_equal("testing", artist.notes)
|
||||||
assert_equal("testing", artist.wiki_page.body)
|
assert_equal("testing", artist.wiki_page.body)
|
||||||
@@ -57,7 +57,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "update the wiki page when notes are assigned" do
|
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.update_attribute(:notes, "kokoko")
|
||||||
artist.reload
|
artist.reload
|
||||||
assert_equal("kokoko", artist.notes)
|
assert_equal("kokoko", artist.notes)
|
||||||
@@ -65,26 +65,26 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "normalize its name" do
|
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)
|
assert_equal("aaa_bbb", artist.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "resolve ambiguous urls" do
|
should "resolve ambiguous urls" do
|
||||||
bobross = Factory.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg")
|
bobross = FactoryGirl.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")
|
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")
|
matches = Artist.find_all_by_url("http://artists.com/bob/test.jpg")
|
||||||
assert_equal(1, matches.size)
|
assert_equal(1, matches.size)
|
||||||
assert_equal("bob", matches.first.name)
|
assert_equal("bob", matches.first.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "parse urls" do
|
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
|
artist.reload
|
||||||
assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort)
|
assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "make sure old urls are deleted" do
|
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.url_string = "http://not.rembrandt.com/test.jpg"
|
||||||
artist.save
|
artist.save
|
||||||
artist.reload
|
artist.reload
|
||||||
@@ -92,8 +92,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "find matches by url" do
|
should "find matches by url" do
|
||||||
a1 = Factory.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
a1 = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||||
a2 = Factory.create(:artist, :name => "subway", :url_string => "http://subway.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/test.jpg").map(&:name))
|
||||||
assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/another.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
|
end
|
||||||
|
|
||||||
should "not allow duplicates" do
|
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))
|
assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/test.jpg").map(&:name))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "hide deleted artists" do
|
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))
|
assert_equal([], Artist.find_all_by_url("http://warhol.com/a/image.jpg").map(&:name))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "normalize its other names" do
|
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)
|
assert_equal("aaa bbb ccc_ddd", artist.other_names)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "search on other names should return matches" do
|
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_nil(Artist.other_names_match("artist").first)
|
||||||
assert_not_nil(Artist.other_names_match("aaa").first)
|
assert_not_nil(Artist.other_names_match("aaa").first)
|
||||||
assert_not_nil(Artist.other_names_match("ccc_ddd").first)
|
assert_not_nil(Artist.other_names_match("ccc_ddd").first)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "search on group name and return matches" do
|
should "search on group name and return matches" do
|
||||||
cat_or_fish = Factory.create(:artist, :name => "cat_or_fish")
|
cat_or_fish = FactoryGirl.create(:artist, :name => "cat_or_fish")
|
||||||
yuu = Factory.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish")
|
||||||
cat_or_fish.reload
|
cat_or_fish.reload
|
||||||
assert_equal("yuu", cat_or_fish.member_names)
|
assert_equal("yuu", cat_or_fish.member_names)
|
||||||
assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first)
|
assert_not_nil(Artist.search(:group_name_contains => "cat_or_fish").first)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "have an associated wiki" do
|
should "have an associated wiki" do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = 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_not_nil(artist.wiki_page)
|
||||||
assert_equal("this is max", artist.wiki_page.body)
|
assert_equal("this is max", artist.wiki_page.body)
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "revert to prior versions" do
|
should "revert to prior versions" do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
reverter = Factory.create(:user)
|
reverter = FactoryGirl.create(:user)
|
||||||
artist = nil
|
artist = nil
|
||||||
assert_difference("ArtistVersion.count") do
|
assert_difference("ArtistVersion.count") do
|
||||||
artist = Factory.create(:artist, :other_names => "yyy")
|
artist = FactoryGirl.create(:artist, :other_names => "yyy")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_difference("ArtistVersion.count") do
|
assert_difference("ArtistVersion.count") do
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
|||||||
context "An artist url" do
|
context "An artist url" do
|
||||||
setup do
|
setup do
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
CurrentUser.user = Factory.create(:user)
|
CurrentUser.user = FactoryGirl.create(:user)
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -14,27 +14,27 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "always add a trailing slash when normalized" do
|
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.url)
|
||||||
assert_equal("http://monet.com/", url.normalized_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.url)
|
||||||
assert_equal("http://monet.com/", url.normalized_url)
|
assert_equal("http://monet.com/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "normalize fc2 urls" do
|
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://blog55.fc2.com/monet", url.url)
|
||||||
assert_equal("http://blog.fc2.com/monet/", url.normalized_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-imgs-55.fc2.com/monet", url.url)
|
||||||
assert_equal("http://blog.fc2.com/monet/", url.normalized_url)
|
assert_equal("http://blog.fc2.com/monet/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "normalize pixiv urls" do
|
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://img55.pixiv.net/monet", url.url)
|
||||||
assert_equal("http://img.pixiv.net/monet/", url.normalized_url)
|
assert_equal("http://img.pixiv.net/monet/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|||||||
+49
-49
@@ -4,7 +4,7 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
context "A ban" do
|
context "A ban" do
|
||||||
context "created by an admin" do
|
context "created by an admin" do
|
||||||
setup do
|
setup do
|
||||||
@banner = Factory.create(:admin_user)
|
@banner = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @banner
|
CurrentUser.user = @banner
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -16,38 +16,38 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not be valid against another admin" do
|
should "not be valid against another admin" do
|
||||||
user = Factory.create(:admin_user)
|
user = FactoryGirl.create(:admin_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be valid against anyone who is not an admin" do
|
should "be valid against anyone who is not an admin" do
|
||||||
user = Factory.create(:moderator_user)
|
user = FactoryGirl.create(:moderator_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:janitor_user)
|
user = FactoryGirl.create(:janitor_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:contributor_user)
|
user = FactoryGirl.create(:contributor_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:privileged_user)
|
user = FactoryGirl.create(:privileged_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "created by a moderator" do
|
context "created by a moderator" do
|
||||||
setup do
|
setup do
|
||||||
@banner = Factory.create(:moderator_user)
|
@banner = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @banner
|
CurrentUser.user = @banner
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -59,39 +59,39 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not be valid against an admin or moderator" do
|
should "not be valid against an admin or moderator" do
|
||||||
user = Factory.create(:admin_user)
|
user = FactoryGirl.create(:admin_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:moderator_user)
|
user = FactoryGirl.create(:moderator_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be valid against anyone who is not an admin or a moderator" do
|
should "be valid against anyone who is not an admin or a moderator" do
|
||||||
user = Factory.create(:janitor_user)
|
user = FactoryGirl.create(:janitor_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:contributor_user)
|
user = FactoryGirl.create(:contributor_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:privileged_user)
|
user = FactoryGirl.create(:privileged_user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
|
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
ban = Factory.create(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => @banner)
|
||||||
assert(ban.errors.empty?)
|
assert(ban.errors.empty?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "created by a janitor" do
|
context "created by a janitor" do
|
||||||
setup do
|
setup do
|
||||||
@banner = Factory.create(:janitor_user)
|
@banner = FactoryGirl.create(:janitor_user)
|
||||||
CurrentUser.user = @banner
|
CurrentUser.user = @banner
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
@@ -103,53 +103,53 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "always be invalid" do
|
should "always be invalid" do
|
||||||
user = Factory.create(:admin_user)
|
user = FactoryGirl.create(:admin_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:moderator_user)
|
user = FactoryGirl.create(:moderator_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:janitor_user)
|
user = FactoryGirl.create(:janitor_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:contributor_user)
|
user = FactoryGirl.create(:contributor_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:privileged_user)
|
user = FactoryGirl.create(:privileged_user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
|
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
ban = Factory.build(:ban, :user => user, :banner => @banner)
|
ban = FactoryGirl.build(:ban, :user => user, :banner => @banner)
|
||||||
ban.save
|
ban.save
|
||||||
assert(ban.errors.any?)
|
assert(ban.errors.any?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "initialize the expiration date" do
|
should "initialize the expiration date" do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
admin = Factory.create(:admin_user)
|
admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = admin
|
CurrentUser.user = admin
|
||||||
ban = Factory.create(:ban, :user => user, :banner => admin)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => admin)
|
||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
assert_not_nil(ban.expires_at)
|
assert_not_nil(ban.expires_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "update the user's feedback" do
|
should "update the user's feedback" do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
admin = Factory.create(:admin_user)
|
admin = FactoryGirl.create(:admin_user)
|
||||||
assert(user.feedback.empty?)
|
assert(user.feedback.empty?)
|
||||||
CurrentUser.user = admin
|
CurrentUser.user = admin
|
||||||
ban = Factory.create(:ban, :user => user, :banner => admin)
|
ban = FactoryGirl.create(:ban, :user => user, :banner => admin)
|
||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
assert(!user.feedback.empty?)
|
assert(!user.feedback.empty?)
|
||||||
assert_equal("negative", user.feedback.last.category)
|
assert_equal("negative", user.feedback.last.category)
|
||||||
@@ -159,10 +159,10 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
context "Searching for a ban" do
|
context "Searching for a ban" do
|
||||||
context "by user id" do
|
context "by user id" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -172,7 +172,7 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "when only expired bans exist" do
|
context "when only expired bans exist" do
|
||||||
setup do
|
setup do
|
||||||
@ban = Factory.create(:ban, :user => @user, :banner => @admin, :duration => -1)
|
@ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => -1)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not return expired bans" do
|
should "not return expired bans" do
|
||||||
@@ -182,7 +182,7 @@ class BanTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "when active bans still exist" do
|
context "when active bans still exist" do
|
||||||
setup do
|
setup do
|
||||||
@ban = Factory.create(:ban, :user => @user, :banner => @admin, :duration => 1)
|
@ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return active bans" do
|
should "return active bans" do
|
||||||
|
|||||||
+16
-16
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class CommentTest < ActiveSupport::TestCase
|
class CommentTest < ActiveSupport::TestCase
|
||||||
context "A comment" do
|
context "A comment" do
|
||||||
setup do
|
setup do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -21,7 +21,7 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "fail creation" do
|
should "fail creation" do
|
||||||
comment = Factory.build(:comment)
|
comment = FactoryGirl.build(:comment)
|
||||||
comment.save
|
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)
|
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
|
end
|
||||||
@@ -34,36 +34,36 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be created" do
|
should "be created" do
|
||||||
comment = Factory.build(:comment)
|
comment = FactoryGirl.build(:comment)
|
||||||
comment.save
|
comment.save
|
||||||
assert(comment.errors.empty?, comment.errors.full_messages.join(", "))
|
assert(comment.errors.empty?, comment.errors.full_messages.join(", "))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not bump the parent post" do
|
should "not bump the parent post" do
|
||||||
post = Factory.create(:post)
|
post = FactoryGirl.create(:post)
|
||||||
comment = Factory.create(:comment, :do_not_bump_post => "1", :post => post)
|
comment = FactoryGirl.create(:comment, :do_not_bump_post => "1", :post => post)
|
||||||
post.reload
|
post.reload
|
||||||
assert_nil(post.last_commented_at)
|
assert_nil(post.last_commented_at)
|
||||||
|
|
||||||
comment = Factory.create(:comment, :post => post)
|
comment = FactoryGirl.create(:comment, :post => post)
|
||||||
post.reload
|
post.reload
|
||||||
assert_not_nil(post.last_commented_at)
|
assert_not_nil(post.last_commented_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not update the post after exceeding the threshold" do
|
should "not update the post after exceeding the threshold" do
|
||||||
Danbooru.config.stubs(:comment_threshold).returns(1)
|
Danbooru.config.stubs(:comment_threshold).returns(1)
|
||||||
p = Factory.create(:post)
|
p = FactoryGirl.create(:post)
|
||||||
c1 = Factory.create(:comment, :post => p)
|
c1 = FactoryGirl.create(:comment, :post => p)
|
||||||
sleep 1
|
sleep 1
|
||||||
c2 = Factory.create(:comment, :post => p)
|
c2 = FactoryGirl.create(:comment, :post => p)
|
||||||
p.reload
|
p.reload
|
||||||
assert_equal(c1.created_at.to_s, p.last_commented_at.to_s)
|
assert_equal(c1.created_at.to_s, p.last_commented_at.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not allow duplicate votes" do
|
should "not allow duplicate votes" do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
post = Factory.create(:post)
|
post = FactoryGirl.create(:post)
|
||||||
c1 = Factory.create(:comment, :post => post)
|
c1 = FactoryGirl.create(:comment, :post => post)
|
||||||
comment_vote = c1.vote!("up")
|
comment_vote = c1.vote!("up")
|
||||||
assert_equal([], comment_vote.errors.full_messages)
|
assert_equal([], comment_vote.errors.full_messages)
|
||||||
comment_vote = c1.vote!("up")
|
comment_vote = c1.vote!("up")
|
||||||
@@ -71,16 +71,16 @@ class CommentTest < ActiveSupport::TestCase
|
|||||||
assert_equal(1, CommentVote.count)
|
assert_equal(1, CommentVote.count)
|
||||||
assert_equal(1, CommentVote.last.score)
|
assert_equal(1, CommentVote.last.score)
|
||||||
|
|
||||||
c2 = Factory.create(:comment, :post => post)
|
c2 = FactoryGirl.create(:comment, :post => post)
|
||||||
comment_vote = c2.vote!("up")
|
comment_vote = c2.vote!("up")
|
||||||
assert_equal([], comment_vote.errors.full_messages)
|
assert_equal([], comment_vote.errors.full_messages)
|
||||||
assert_equal(2, CommentVote.count)
|
assert_equal(2, CommentVote.count)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be searchable" do
|
should "be searchable" do
|
||||||
c1 = Factory.create(:comment, :body => "aaa bbb ccc")
|
c1 = FactoryGirl.create(:comment, :body => "aaa bbb ccc")
|
||||||
c2 = Factory.create(:comment, :body => "aaa ddd")
|
c2 = FactoryGirl.create(:comment, :body => "aaa ddd")
|
||||||
c3 = Factory.create(:comment, :body => "eee")
|
c3 = FactoryGirl.create(:comment, :body => "eee")
|
||||||
|
|
||||||
matches = Comment.body_matches("aaa")
|
matches = Comment.body_matches("aaa")
|
||||||
assert_equal(2, matches.count)
|
assert_equal(2, matches.count)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "The current user" do
|
context "The current user" do
|
||||||
should "be set only within the scope of the block" 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.user)
|
||||||
assert_nil(CurrentUser.ip_addr)
|
assert_nil(CurrentUser.ip_addr)
|
||||||
@@ -24,8 +24,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "A scoped current user" do
|
context "A scoped current user" do
|
||||||
should "reset the current user after the block has exited" do
|
should "reset the current user after the block has exited" do
|
||||||
user1 = Factory.create(:user)
|
user1 = FactoryGirl.create(:user)
|
||||||
user2 = Factory.create(:user)
|
user2 = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user1
|
CurrentUser.user = user1
|
||||||
CurrentUser.scoped(user2, nil) do
|
CurrentUser.scoped(user2, nil) do
|
||||||
assert_equal(user2.id, CurrentUser.user.id)
|
assert_equal(user2.id, CurrentUser.user.id)
|
||||||
@@ -34,8 +34,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "reset the current user even if an exception is thrown" do
|
should "reset the current user even if an exception is thrown" do
|
||||||
user1 = Factory.create(:user)
|
user1 = FactoryGirl.create(:user)
|
||||||
user2 = Factory.create(:user)
|
user2 = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user1
|
CurrentUser.user = user1
|
||||||
assert_raises(RuntimeError) do
|
assert_raises(RuntimeError) do
|
||||||
CurrentUser.scoped(user2, nil) do
|
CurrentUser.scoped(user2, nil) do
|
||||||
|
|||||||
+10
-10
@@ -4,7 +4,7 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
context "A dmail" do
|
context "A dmail" do
|
||||||
setup do
|
setup do
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
ActionMailer::Base.delivery_method = :test
|
ActionMailer::Base.delivery_method = :test
|
||||||
@@ -18,7 +18,7 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "search" do
|
context "search" do
|
||||||
should "return results based on title contents" 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")
|
matches = Dmail.search_message("xxx")
|
||||||
assert(matches.any?)
|
assert(matches.any?)
|
||||||
matches = Dmail.search_message("aaa")
|
matches = Dmail.search_message("aaa")
|
||||||
@@ -26,7 +26,7 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "return results based on body contents" do
|
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")
|
matches = Dmail.search_message("xxx")
|
||||||
assert(matches.any?)
|
assert(matches.any?)
|
||||||
matches = Dmail.search_message("aaa")
|
matches = Dmail.search_message("aaa")
|
||||||
@@ -35,14 +35,14 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "should parse user names" do
|
should "should parse user names" do
|
||||||
dmail = Factory.build(:dmail, :owner => @user)
|
dmail = FactoryGirl.build(:dmail, :owner => @user)
|
||||||
dmail.to_id = nil
|
dmail.to_id = nil
|
||||||
dmail.to_name = @user.name
|
dmail.to_name = @user.name
|
||||||
assert(dmail.to_id == @user.id)
|
assert(dmail.to_id == @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "construct a response" do
|
should "construct a response" do
|
||||||
dmail = Factory.create(:dmail, :owner => @user)
|
dmail = FactoryGirl.create(:dmail, :owner => @user)
|
||||||
response = dmail.build_response
|
response = dmail.build_response
|
||||||
assert_equal("Re: #{dmail.title}", response.title)
|
assert_equal("Re: #{dmail.title}", response.title)
|
||||||
assert_equal(dmail.from_id, response.to_id)
|
assert_equal(dmail.from_id, response.to_id)
|
||||||
@@ -50,28 +50,28 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "create a copy for each user" do
|
should "create a copy for each user" do
|
||||||
@new_user = Factory.create(:user)
|
@new_user = FactoryGirl.create(:user)
|
||||||
assert_difference("Dmail.count", 2) do
|
assert_difference("Dmail.count", 2) do
|
||||||
Dmail.create_split(:to_id => @new_user.id, :title => "foo", :body => "foo")
|
Dmail.create_split(:to_id => @new_user.id, :title => "foo", :body => "foo")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "send an email if the user wants it" do
|
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
|
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||||
Factory.create(:dmail, :to => user, :owner => @user)
|
FactoryGirl.create(:dmail, :to => user, :owner => @user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be marked as read after the user reads it" do
|
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?)
|
assert(!dmail.is_read?)
|
||||||
dmail.mark_as_read!
|
dmail.mark_as_read!
|
||||||
assert(dmail.is_read?)
|
assert(dmail.is_read?)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "notify the recipient he has mail" do
|
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?)
|
assert(dmail.to(true).has_mail?)
|
||||||
dmail.mark_as_read!
|
dmail.mark_as_read!
|
||||||
assert(!dmail.to(true).has_mail?)
|
assert(!dmail.to(true).has_mail?)
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
require 'test_helper'
|
# require 'test_helper'
|
||||||
|
#
|
||||||
module Downloads
|
# module Downloads
|
||||||
class PixaTest < ActiveSupport::TestCase
|
# class PixaTest < ActiveSupport::TestCase
|
||||||
context "a download for a pixa image" do
|
# context "a download for a pixa image" do
|
||||||
setup do
|
# setup do
|
||||||
@source = "http://file0.pixa.cc/illustrations/6f/d6/3f/f9/51/61/29/72/23/ac/middle/sse.jpg?1317405928"
|
# @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")
|
# @tempfile = Tempfile.new("danbooru-test")
|
||||||
@download = Downloads::File.new(@source, @tempfile.path)
|
# @download = Downloads::File.new(@source, @tempfile.path)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
should "work" do
|
# should "work" do
|
||||||
@download.download!
|
# @download.download!
|
||||||
assert_equal(104627, ::File.size(@tempfile.path))
|
# assert_equal(104627, ::File.size(@tempfile.path))
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
require 'test_helper'
|
# require 'test_helper'
|
||||||
|
#
|
||||||
module Downloads
|
# module Downloads
|
||||||
class TinamiTest < ActiveSupport::TestCase
|
# class TinamiTest < ActiveSupport::TestCase
|
||||||
context "a download for a pixa image" do
|
# context "a download for a pixa image" do
|
||||||
setup do
|
# setup do
|
||||||
@source = "http://img.tinami.com/illust2/img/330/4e85ecd880a8f.jpg"
|
# @source = "http://img.tinami.com/illust2/img/330/4e85ecd880a8f.jpg"
|
||||||
@tempfile = Tempfile.new("danbooru-test")
|
# @tempfile = Tempfile.new("danbooru-test")
|
||||||
@download = Downloads::File.new(@source, @tempfile.path)
|
# @download = Downloads::File.new(@source, @tempfile.path)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
should "work" do
|
# should "work" do
|
||||||
@download.download!
|
# @download.download!
|
||||||
assert_equal(201248, ::File.size(@tempfile.path))
|
# assert_equal(201248, ::File.size(@tempfile.path))
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|||||||
+10
-10
@@ -2,7 +2,7 @@ require 'test_helper'
|
|||||||
|
|
||||||
class FavoriteTest < ActiveSupport::TestCase
|
class FavoriteTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
user = Factory.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -16,8 +16,8 @@ class FavoriteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "A favorite" do
|
context "A favorite" do
|
||||||
should "delete from all tables" do
|
should "delete from all tables" do
|
||||||
user1 = Factory.create(:user)
|
user1 = FactoryGirl.create(:user)
|
||||||
p1 = Factory.create(:post)
|
p1 = FactoryGirl.create(:post)
|
||||||
|
|
||||||
user1.add_favorite!(p1)
|
user1.add_favorite!(p1)
|
||||||
assert_equal(1, Favorite.count)
|
assert_equal(1, Favorite.count)
|
||||||
@@ -27,10 +27,10 @@ class FavoriteTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "know which table it belongs to" do
|
should "know which table it belongs to" do
|
||||||
user1 = Factory.create(:user)
|
user1 = FactoryGirl.create(:user)
|
||||||
user2 = Factory.create(:user)
|
user2 = FactoryGirl.create(:user)
|
||||||
p1 = Factory.create(:post)
|
p1 = FactoryGirl.create(:post)
|
||||||
p2 = Factory.create(:post)
|
p2 = FactoryGirl.create(:post)
|
||||||
|
|
||||||
user1.add_favorite!(p1)
|
user1.add_favorite!(p1)
|
||||||
user1.add_favorite!(p2)
|
user1.add_favorite!(p2)
|
||||||
@@ -47,9 +47,9 @@ class FavoriteTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "not allow duplicates" do
|
should "not allow duplicates" do
|
||||||
user1 = Factory.create(:user)
|
user1 = FactoryGirl.create(:user)
|
||||||
p1 = Factory.create(:post)
|
p1 = FactoryGirl.create(:post)
|
||||||
p2 = Factory.create(:post)
|
p2 = FactoryGirl.create(:post)
|
||||||
user1.add_favorite!(p1)
|
user1.add_favorite!(p1)
|
||||||
user1.add_favorite!(p1)
|
user1.add_favorite!(p1)
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class ForumPostTest < ActiveSupport::TestCase
|
class ForumPostTest < ActiveSupport::TestCase
|
||||||
context "A forum post" do
|
context "A forum post" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@topic = Factory.create(:forum_topic)
|
@topic = FactoryGirl.create(:forum_topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -16,7 +16,7 @@ class ForumPostTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "belonging to a locked topic" do
|
context "belonging to a locked topic" do
|
||||||
setup 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)
|
@topic.update_attribute(:is_locked, true)
|
||||||
@post.reload
|
@post.reload
|
||||||
end
|
end
|
||||||
@@ -36,26 +36,26 @@ class ForumPostTest < ActiveSupport::TestCase
|
|||||||
should "update its parent when saved" do
|
should "update its parent when saved" do
|
||||||
sleep 1
|
sleep 1
|
||||||
original_topic_updated_at = @topic.updated_at
|
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
|
@topic.reload
|
||||||
assert_not_equal(original_topic_updated_at, @topic.updated_at)
|
assert_not_equal(original_topic_updated_at, @topic.updated_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be searchable by body content" do
|
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(1, ForumPost.body_matches("xxx").count)
|
||||||
assert_equal(0, ForumPost.body_matches("aaa").count)
|
assert_equal(0, ForumPost.body_matches("aaa").count)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "initialize its creator" do
|
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)
|
assert_equal(@user.id, post.creator_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "updated by a second user" do
|
context "updated by a second user" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:forum_post, :topic_id => @topic.id)
|
@post = FactoryGirl.create(:forum_post, :topic_id => @topic.id)
|
||||||
@second_user = Factory.create(:user)
|
@second_user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @second_user
|
CurrentUser.user = @second_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ require 'test_helper'
|
|||||||
class ForumTopicTest < ActiveSupport::TestCase
|
class ForumTopicTest < ActiveSupport::TestCase
|
||||||
context "A forum topic" do
|
context "A forum topic" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@topic = Factory.create(:forum_topic, :title => "xxx")
|
@topic = FactoryGirl.create(:forum_topic, :title => "xxx")
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
@@ -17,7 +17,7 @@ class ForumTopicTest < ActiveSupport::TestCase
|
|||||||
context "constructed with nested attributes for its original post" do
|
context "constructed with nested attributes for its original post" do
|
||||||
should "create a matching forum post" do
|
should "create a matching forum post" do
|
||||||
assert_difference(["ForumTopic.count", "ForumPost.count"], 1) 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
|
end
|
||||||
end
|
end
|
||||||
@@ -33,7 +33,7 @@ class ForumTopicTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "updated by a second user" do
|
context "updated by a second user" do
|
||||||
setup do
|
setup do
|
||||||
@second_user = Factory.create(:user)
|
@second_user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @second_user
|
CurrentUser.user = @second_user
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class ForumTopicTest < ActiveSupport::TestCase
|
|||||||
context "with multiple posts that has been deleted" do
|
context "with multiple posts that has been deleted" do
|
||||||
setup do
|
setup do
|
||||||
5.times do
|
5.times do
|
||||||
Factory.create(:forum_post, :topic_id => @topic.id)
|
FactoryGirl.create(:forum_post, :topic_id => @topic.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ require 'test_helper'
|
|||||||
|
|
||||||
class IpBanTest < ActiveSupport::TestCase
|
class IpBanTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -15,14 +15,14 @@ class IpBanTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "be able to count the number of comments an IP address is associated with" do
|
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")
|
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)
|
assert_equal([{"ip_addr" => "127.0.0.1", "count" => "1"}], counts)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be able to count any updates from a user, groupiny by IP address" do
|
should "be able to count any updates from a user, groupiny by IP address" do
|
||||||
CurrentUser.scoped(@user, "1.2.3.4") 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])
|
counts = IpBan.query([comment.creator_id])
|
||||||
assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts["comments"])
|
assert_equal([{"ip_addr" => "1.2.3.4", "count" => "1"}], counts["comments"])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ require 'test_helper'
|
|||||||
class JanitorTrialTest < ActiveSupport::TestCase
|
class JanitorTrialTest < ActiveSupport::TestCase
|
||||||
context "A janitor trial" do
|
context "A janitor trial" do
|
||||||
setup do
|
setup do
|
||||||
@admin = Factory.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @admin
|
CurrentUser.user = @admin
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -31,7 +31,7 @@ class JanitorTrialTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "upon demotion" do
|
context "upon demotion" do
|
||||||
setup do
|
setup do
|
||||||
@janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id)
|
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a negative feedback record" do
|
should "create a negative feedback record" do
|
||||||
@@ -43,7 +43,7 @@ class JanitorTrialTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "upon promotion" do
|
context "upon promotion" do
|
||||||
setup do
|
setup do
|
||||||
@janitor_trial = Factory.create(:janitor_trial, :user_id => @user.id)
|
@janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "destroy the trial object" do
|
should "destroy the trial object" do
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module Maintenance
|
|||||||
class LoginReminderMailerTest < ActionMailer::TestCase
|
class LoginReminderMailerTest < ActionMailer::TestCase
|
||||||
context "The login reminder mailer" do
|
context "The login reminder mailer" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "send the notie" do
|
should "send the notie" do
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ module Moderator
|
|||||||
class IpAddrSearchTest < ActiveSupport::TestCase
|
class IpAddrSearchTest < ActiveSupport::TestCase
|
||||||
context "an ip addr search" do
|
context "an ip addr search" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now)
|
||||||
Factory.create(:comment)
|
FactoryGirl.create(:comment)
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ module Moderator
|
|||||||
class TagBatchChangeTest < ActiveSupport::TestCase
|
class TagBatchChangeTest < ActiveSupport::TestCase
|
||||||
context "a tag batch change" do
|
context "a tag batch change" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:moderator_user)
|
@user = FactoryGirl.create(:moderator_user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@post = Factory.create(:post, :tag_string => "aaa")
|
@post = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
|||||||
+10
-10
@@ -3,7 +3,7 @@ require 'test_helper'
|
|||||||
class NoteTest < ActiveSupport::TestCase
|
class NoteTest < ActiveSupport::TestCase
|
||||||
context "In all cases" do
|
context "In all cases" do
|
||||||
setup do
|
setup do
|
||||||
@user = Factory.create(:user)
|
@user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = @user
|
CurrentUser.user = @user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
MEMCACHE.flush_all
|
MEMCACHE.flush_all
|
||||||
@@ -16,12 +16,12 @@ class NoteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "creating a note" do
|
context "creating a note" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "create a version" do
|
should "create a version" do
|
||||||
assert_difference("NoteVersion.count", 1) do
|
assert_difference("NoteVersion.count", 1) do
|
||||||
@note = Factory.create(:note, :post => @post)
|
@note = FactoryGirl.create(:note, :post => @post)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal(1, @note.versions.count)
|
assert_equal(1, @note.versions.count)
|
||||||
@@ -30,7 +30,7 @@ class NoteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "update the post's last_noted_at field" do
|
should "update the post's last_noted_at field" do
|
||||||
assert_nil(@post.last_noted_at)
|
assert_nil(@post.last_noted_at)
|
||||||
@note = Factory.create(:note, :post => @post)
|
@note = FactoryGirl.create(:note, :post => @post)
|
||||||
@post.reload
|
@post.reload
|
||||||
assert_not_nil(@post.last_noted_at)
|
assert_not_nil(@post.last_noted_at)
|
||||||
end
|
end
|
||||||
@@ -42,7 +42,7 @@ class NoteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
should "fail" do
|
should "fail" do
|
||||||
assert_difference("Note.count", 0) do
|
assert_difference("Note.count", 0) do
|
||||||
@note = Factory.build(:note, :post => @post)
|
@note = FactoryGirl.build(:note, :post => @post)
|
||||||
@note.save
|
@note.save
|
||||||
end
|
end
|
||||||
assert_equal(["Post is note locked"], @note.errors.full_messages)
|
assert_equal(["Post is note locked"], @note.errors.full_messages)
|
||||||
@@ -52,8 +52,8 @@ class NoteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "updating a note" do
|
context "updating a note" do
|
||||||
setup do
|
setup do
|
||||||
@post = Factory.create(:post)
|
@post = FactoryGirl.create(:post)
|
||||||
@note = Factory.create(:note, :post => @post)
|
@note = FactoryGirl.create(:note, :post => @post)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "increment the updater's note_update_count" do
|
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
|
context "when notes have been vandalized by one user" do
|
||||||
setup do
|
setup do
|
||||||
@vandal = Factory.create(:user)
|
@vandal = FactoryGirl.create(:user)
|
||||||
@note = Factory.create(:note, :x => 100, :y => 100)
|
@note = FactoryGirl.create(:note, :x => 100, :y => 100)
|
||||||
CurrentUser.scoped(@vandal, "127.0.0.1") do
|
CurrentUser.scoped(@vandal, "127.0.0.1") do
|
||||||
@note.update_attributes(:x => 2000, :y => 2000)
|
@note.update_attributes(:x => 2000, :y => 2000)
|
||||||
end
|
end
|
||||||
@@ -110,7 +110,7 @@ class NoteTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "searching for a note" do
|
context "searching for a note" do
|
||||||
setup do
|
setup do
|
||||||
@note = Factory.create(:note, :body => "aaa")
|
@note = FactoryGirl.create(:note, :body => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "where the body contains the string 'aaa'" do
|
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