fixed tests

This commit is contained in:
albert
2011-02-02 16:55:36 -05:00
parent 099c75f9b6
commit c80df378d8
14 changed files with 27 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ class Artist < ActiveRecord::Base
belongs_to :creator, :class_name => "User"
has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name"
has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl"
has_many :versions, :order => "artist_versions.id", :class_name => "ArtistVersion"
has_many :versions, :order => "artist_versions.id ASC", :class_name => "ArtistVersion"
has_one :wiki_page, :foreign_key => "title", :primary_key => "name"
has_one :tag_alias, :foreign_key => "antecedent_name", :primary_key => "name"
accepts_nested_attributes_for :wiki_page

View File

@@ -3,7 +3,7 @@ class Pool < ActiveRecord::Base
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"
belongs_to :creator, :class_name => "User"
belongs_to :updater, :class_name => "User"
has_many :versions, :class_name => "PoolVersion", :dependent => :destroy
has_many :versions, :class_name => "PoolVersion", :dependent => :destroy, :order => "pool_versions.id ASC"
before_validation :normalize_name
before_validation :initialize_creator, :on => :create
after_save :create_version

View File

@@ -16,7 +16,7 @@ class Post < ActiveRecord::Base
belongs_to :parent, :class_name => "Post"
has_one :unapproval, :dependent => :destroy
has_one :upload, :dependent => :destroy
has_many :versions, :class_name => "PostVersion", :dependent => :destroy
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.id ASC"
has_many :votes, :class_name => "PostVote", :dependent => :destroy
has_many :notes, :dependent => :destroy
has_many :comments

View File

@@ -2,6 +2,7 @@ class Unapproval < ActiveRecord::Base
class Error < Exception ; end
belongs_to :unapprover, :class_name => "User"
belongs_to :post
validates_presence_of :reason, :unapprover_id, :unapprover_ip_addr
before_validation :initialize_unapprover, :on => :create

View File

@@ -9,7 +9,7 @@ class WikiPage < ActiveRecord::Base
scope :titled, lambda {|title| where(["title = ?", title.downcase.tr(" ", "_")])}
has_one :tag, :foreign_key => "name", :primary_key => "title"
has_one :artist, :foreign_key => "name", :primary_key => "title"
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy
has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC"
def self.build_relation(options = {})
relation = where()

View File

@@ -1,4 +1,4 @@
<% form_tag(posts_path, :method => "get") do %>
<%= form_tag(posts_path, :method => "get") do %>
<%= text_field_tag("tags", params[:tags], :size => 15) %>
<%= submit_tag "Go" %>
<% end %>

View File

@@ -32,9 +32,8 @@
<h2>Help</h2>
<ul>
<li><%= link_to "I don't have an account", new_user_path %></li>
<li><%= link_to "I forgot my password", reset_password_info_path %></li>
<li><%= link_to "I forgot my login", login_reminder_info_path %></li>
<li><%= link_to "I want to delete my account", delete_account_info_path %></li>
<li><%= link_to "I forgot my password", reset_password_path %></li>
<li><%= link_to "I forgot my login", login_reminder_path %></li>
</ul>
</aside>
</div>

View File

@@ -1,4 +1,4 @@
<% form_for @user do |f| %>
<%= form_for @user do |f| %>
<p>Hover over the labels to see a brief explanation of the setting. Required fields are marked in red.</p>
<fieldset>

View File

@@ -75,8 +75,8 @@ Danbooru::Application.routes.draw do
match '/dtext/preview' => 'dtext#preview', :via => :post
match "/site_map" => "static#site_map", :as => "site_map"
match "/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
match "/user_maintenance/login_reminder" => "user_maintenance#login_reminder"
match "/user_maintenance/reset_password" => "user_maintenance#reset_password"
match "/user_maintenance/login_reminder" => "user_maintenance#login_reminder", :as => "login_reminder"
match "/user_maintenance/reset_password" => "user_maintenance#reset_password", :as => "reset_password"
root :to => "posts#index"
end

View File

@@ -1,3 +1,4 @@
Factory.define(:unapproval) do |f|
f.post {|x| x.association(:post)}
f.reason "xxx"
end

View File

@@ -6,7 +6,8 @@ class PostsControllerTest < ActionController::TestCase
@user = Factory.create(:user)
CurrentUser.user = @user
CurrentUser.ip_addr = "127.0.0.1"
@post = Factory.create(:post, :uploader_id => @user.id, :tag_string => "aaa")
@post = Factory.create(:post, :uploader_id => @user.id, :tag_string => "aaaa")
MEMCACHE.flush_all
end
teardown do
@@ -22,7 +23,7 @@ class PostsControllerTest < ActionController::TestCase
context "with a search" do
should "render" do
get :index, {:tags => "aaa"}
get :index, {:tags => "aaaa"}
assert_response :success
end
end
@@ -52,11 +53,11 @@ class PostsControllerTest < ActionController::TestCase
should "work" do
@version = @post.versions(true).first
assert_equal("aaa", @version.add_tags)
assert_equal("aaaa", @version.add_tags)
post :revert, {:id => @post.id, :version_id => @version.id}, {:user_id => @user.id}
assert_redirected_to post_path(@post)
@post.reload
assert_equal("aaa", @post.tag_string)
assert_equal("aaaa", @post.tag_string)
end
end
end

View File

@@ -45,7 +45,9 @@ class UnapprovalsControllerTest < ActionController::TestCase
should "create a new unapproval" do
assert_difference("Unapproval.count", 1) do
post :create, {:post_id => @post.id, :reason => "xxx"}, {:user_id => @user.id}
post :create, {:unapproval => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id}
assert_not_nil(assigns(:unapproval))
assert_equal([], assigns(:unapproval).errors.full_messages)
end
end
end

View File

@@ -80,7 +80,7 @@ class WikiPagesControllerTest < ActionController::TestCase
end
should "revert to a previous version" do
version = @wiki_page.versions(true).last
version = @wiki_page.versions(true).first
assert_equal("1", version.body)
post :revert, {:id => @wiki_page.id, :version_id => version.id}
@wiki_page.reload

View File

@@ -2,7 +2,7 @@ require_relative '../test_helper'
class TagSubscriptionTest < ActiveSupport::TestCase
setup do
user = Factory.create(:owner)
user = Factory.create(:user)
CurrentUser.user = user
CurrentUser.ip_addr = "127.0.0.1"
MEMCACHE.flush_all
@@ -16,7 +16,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
context "A tag subscription" do
should "find the union of all posts for each tag in its tag query" do
posts = []
user = Factory.create(:owner)
user = Factory.create(:user)
posts << Factory.create(:post, :tag_string => "aaa")
posts << Factory.create(:post, :tag_string => "bbb")
posts << Factory.create(:post, :tag_string => "ccc")
@@ -29,7 +29,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
should "cache its tag query results" do
posts = []
user = Factory.create(:owner)
user = Factory.create(:user)
posts << Factory.create(:post, :tag_string => "aaa")
posts << Factory.create(:post, :tag_string => "bbb")
posts << Factory.create(:post, :tag_string => "ccc")
@@ -38,7 +38,7 @@ class TagSubscriptionTest < ActiveSupport::TestCase
end
should "find posts based on its cached post ids" do
user = Factory.create(:owner)
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")
@@ -59,8 +59,8 @@ class TagSubscriptionTest < ActiveSupport::TestCase
context "A tag subscription manager" do
should "process all active tag subscriptions" do
users = []
users << Factory.create(:owner)
users << Factory.create(:owner)
users << Factory.create(:user)
users << Factory.create(:user)
posts = []
posts << Factory.create(:post, :tag_string => "aaa")
posts << Factory.create(:post, :tag_string => "bbb")