fixed all tests

This commit is contained in:
albert
2011-07-22 19:25:56 -04:00
parent 5d05769c2c
commit 5da43c54f0
6 changed files with 16 additions and 12 deletions

View File

@@ -31,7 +31,7 @@ class Ban < ActiveRecord::Base
def update_feedback
if user
feedback = user.feedback.build
feedback.is_positive = false
feedback.category = "negative"
feedback.body = "Banned: #{reason}"
feedback.creator_id = banner_id
feedback.save

View File

@@ -31,7 +31,7 @@ class JanitorTrial < ActiveRecord::Base
def create_feedback
user.feedback.create(
:is_positive => false,
:category => "negative",
:body => "Demoted from janitor trial"
)
end

View File

@@ -1,5 +1,5 @@
Factory.define(:artist) do |f|
f.name {Faker::Name.first_name}
f.name {rand(1_000_000).to_s}
f.creator {|x| x.association(:user)}
f.is_active true
end

View File

@@ -70,9 +70,13 @@ class DmailsControllerTest < ActionController::TestCase
end
context "create action" do
setup do
@user_2 = Factory.create(:user)
end
should "create two messages, one for the sender and one for the recipient" do
assert_difference("Dmail.count", 2) do
dmail_attribs = Factory.attributes_for(:dmail).merge(:to_id => Factory.create(:user).id)
dmail_attribs = {:to_id => @user_2.id, :title => "abc", :body => "abc", :is_read => false}
post :create, {:dmail => dmail_attribs}, {:user_id => @user.id}
assert_redirected_to dmail_path(Dmail.last)
end

View File

@@ -152,7 +152,7 @@ class BanTest < ActiveSupport::TestCase
ban = Factory.create(:ban, :user => user, :banner => admin)
CurrentUser.user = nil
assert(!user.feedback.empty?)
assert(!user.feedback.last.is_positive?)
assert_equal("negative", user.feedback.last.category)
end
end

View File

@@ -21,8 +21,8 @@ class TagSubscriptionTest < ActiveSupport::TestCase
posts << Factory.create(:post, :tag_string => "bbb")
posts << Factory.create(:post, :tag_string => "ccc")
posts << Factory.create(:post, :tag_string => "ddd")
sub_1 = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :owner => user, :name => "zzz")
sub_2 = Factory.create(:tag_subscription, :tag_query => "ccc", :owner => user, :name => "yyy")
sub_1 = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz")
sub_2 = Factory.create(:tag_subscription, :tag_query => "ccc", :creator => user, :name => "yyy")
assert_equal([posts[1].id, posts[0].id], TagSubscription.find_posts(user.id, "zzz").map(&:id))
assert_equal([posts[2].id, posts[1].id, posts[0].id], TagSubscription.find_posts(user.id).map(&:id))
end
@@ -33,15 +33,15 @@ class TagSubscriptionTest < ActiveSupport::TestCase
posts << Factory.create(:post, :tag_string => "aaa")
posts << Factory.create(:post, :tag_string => "bbb")
posts << Factory.create(:post, :tag_string => "ccc")
sub = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :owner => user, :name => "zzz")
sub = Factory.create(:tag_subscription, :tag_query => "aaa bbb", :creator => user, :name => "zzz")
assert_equal("#{posts[1].id},#{posts[0].id}", sub.post_ids)
end
should "find posts based on its cached post ids" do
user = Factory.create(:user)
subs = []
subs << Factory.create(:tag_subscription, :tag_query => "aaa", :owner => user, :name => "zzz")
subs << Factory.create(:tag_subscription, :tag_query => "bbb", :owner => user, :name => "yyy")
subs << Factory.create(:tag_subscription, :tag_query => "aaa", :creator => user, :name => "zzz")
subs << Factory.create(:tag_subscription, :tag_query => "bbb", :creator => user, :name => "yyy")
assert_equal([], TagSubscription.find_posts(user.id))
assert_equal([], TagSubscription.find_posts(user.id, "zzz"))
assert_equal([], TagSubscription.find_posts(user.id, "yyy"))
@@ -66,8 +66,8 @@ class TagSubscriptionTest < ActiveSupport::TestCase
posts << Factory.create(:post, :tag_string => "bbb")
posts << Factory.create(:post, :tag_string => "ccc")
subscriptions = []
subscriptions << Factory.create(:tag_subscription, :tag_query => "aaa", :owner => users[0])
subscriptions << Factory.create(:tag_subscription, :tag_query => "bbb", :owner => users[1])
subscriptions << Factory.create(:tag_subscription, :tag_query => "aaa", :creator => users[0])
subscriptions << Factory.create(:tag_subscription, :tag_query => "bbb", :creator => users[1])
TagSubscription.process_all
subscriptions.each {|x| x.reload}
assert_equal("#{posts[0].id}", subscriptions[0].post_ids)