diff --git a/app/models/artist.rb b/app/models/artist.rb index 2048af396..83ec6553a 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -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 diff --git a/app/models/pool.rb b/app/models/pool.rb index 0e588cd2f..cd74ef42c 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index bf87624a8..2a61fe666 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/unapproval.rb b/app/models/unapproval.rb index 0153cafcb..f37cb6fdf 100644 --- a/app/models/unapproval.rb +++ b/app/models/unapproval.rb @@ -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 diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 8a0e65116..b3396a105 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -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() diff --git a/app/views/posts/partials/common/_search.html.erb b/app/views/posts/partials/common/_search.html.erb index c203da4d2..afbb66a07 100644 --- a/app/views/posts/partials/common/_search.html.erb +++ b/app/views/posts/partials/common/_search.html.erb @@ -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 %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index e142d279e..4299196b1 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -32,9 +32,8 @@

Help

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 343ccb968..7799e3021 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,4 +1,4 @@ -<% form_for @user do |f| %> +<%= form_for @user do |f| %>

Hover over the labels to see a brief explanation of the setting. Required fields are marked in red.

diff --git a/config/routes.rb b/config/routes.rb index 50ec27b17..ad110e57e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/test/factories/unapproval.rb b/test/factories/unapproval.rb index 17483a0c0..93c42d048 100644 --- a/test/factories/unapproval.rb +++ b/test/factories/unapproval.rb @@ -1,3 +1,4 @@ Factory.define(:unapproval) do |f| f.post {|x| x.association(:post)} + f.reason "xxx" end diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index d37951afd..3dffe25cf 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -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 diff --git a/test/functional/unapprovals_controller_test.rb b/test/functional/unapprovals_controller_test.rb index f0a4c6a7a..c18616908 100644 --- a/test/functional/unapprovals_controller_test.rb +++ b/test/functional/unapprovals_controller_test.rb @@ -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 diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index af2caa1fb..88911709a 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -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 diff --git a/test/unit/tag_subscription_test.rb b/test/unit/tag_subscription_test.rb index fcfea82a1..52dffd43f 100644 --- a/test/unit/tag_subscription_test.rb +++ b/test/unit/tag_subscription_test.rb @@ -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")