diff --git a/Gemfile b/Gemfile index 20ea1f1bf..3ab8a7dc1 100644 --- a/Gemfile +++ b/Gemfile @@ -14,13 +14,14 @@ group :assets do gem "therubyracer" end -gem "rails", "3.1.3" +gem "rails", "3.2.0" gem "pg" gem "memcache-client", :require => "memcache" gem "delayed_job" +gem "delayed_job_active_record" gem "super_exception_notifier" gem "simple_form" -gem "mechanize" +gem "mechanize", git: 'git://github.com/caribio/mechanize.git' gem "nokogiri" gem "meta_search", :git => "git://github.com/ernie/meta_search.git" gem "silent-postgres" diff --git a/Gemfile.lock b/Gemfile.lock index f97f92b86..c368891b3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,23 @@ +GIT + remote: git://github.com/caribio/mechanize.git + revision: 602a453f25c376681317e1f1af7229d39ccfff3d + specs: + mechanize (2.1.1) + domain_name (~> 0.5, >= 0.5.1) + net-http-digest_auth (~> 1.1, >= 1.1.1) + net-http-persistent (~> 2.3, >= 2.3.2) + nokogiri (~> 1.4) + ntlm-http (~> 0.1, >= 0.1.1) + webrobots (~> 0.0, >= 0.0.9) + GIT remote: git://github.com/ernie/meta_search.git - revision: 1b8522a4129b5771c920898cb05badbe119c2f35 + revision: 5bfe8322ac3c56ed8c714c1892aebf1390e7db5e specs: - meta_search (1.1.1) - actionpack (~> 3.1.0) - activerecord (~> 3.1.0) - activesupport (~> 3.1.0) + meta_search (1.1.2) + actionpack (~> 3.1) + activerecord (~> 3.1) + activesupport (~> 3.1) polyamorous (~> 0.5.0) GIT @@ -17,120 +29,112 @@ GIT GIT remote: http://github.com/EmmanuelOga/ffaker.git - revision: f95ce5645d706d865990184ff83d40fe8ccc5e49 + revision: 0a281092f4ed985b7f7ae6eb2d03677fbcfc722d specs: - ffaker (1.10.1) + ffaker (1.12.1) GEM remote: http://gemcutter.org/ specs: - actionmailer (3.1.3) - actionpack (= 3.1.3) - mail (~> 2.3.0) - actionpack (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) + actionmailer (3.2.0) + actionpack (= 3.2.0) + mail (~> 2.4.0) + actionpack (3.2.0) + activemodel (= 3.2.0) + activesupport (= 3.2.0) builder (~> 3.0.0) erubis (~> 2.7.0) - i18n (~> 0.6) - rack (~> 1.3.5) + journey (~> 1.0.0) + rack (~> 1.4.0) rack-cache (~> 1.1) - rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.3) - activemodel (3.1.3) - activesupport (= 3.1.3) + sprockets (~> 2.1.2) + activemodel (3.2.0) + activesupport (= 3.2.0) builder (~> 3.0.0) - i18n (~> 0.6) - activerecord (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - arel (~> 2.2.1) + activerecord (3.2.0) + activemodel (= 3.2.0) + activesupport (= 3.2.0) + arel (~> 3.0.0) tzinfo (~> 0.3.29) - activeresource (3.1.3) - activemodel (= 3.1.3) - activesupport (= 3.1.3) - activesupport (3.1.3) + activeresource (3.2.0) + activemodel (= 3.2.0) + activesupport (= 3.2.0) + activesupport (3.2.0) + i18n (~> 0.6) multi_json (~> 1.0) - arel (2.2.1) - awesome_print (0.4.0) + arel (3.0.0) + awesome_print (1.0.2) builder (3.0.0) chronic (0.6.6) - coderay (0.9.8) - daemons (1.1.4) - delayed_job (2.1.4) + coderay (1.0.5) + delayed_job (3.0.1) activesupport (~> 3.0) - daemons + delayed_job_active_record (0.3.1) + activerecord (> 2.1.0) + delayed_job (~> 3.0.0) + domain_name (0.5.2) + unf (~> 0.0.3) erubis (2.7.0) - execjs (1.2.9) + execjs (1.3.0) multi_json (~> 1.0) - factory_girl (2.3.2) + factory_girl (2.5.0) activesupport hike (1.2.1) i18n (0.6.0) - json (1.6.2) + journey (1.0.1) + json (1.6.5) libv8 (3.3.10.4) - mail (2.3.0) + mail (2.4.1) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mechanize (2.0.1) - net-http-digest_auth (~> 1.1, >= 1.1.1) - net-http-persistent (~> 1.8) - nokogiri (~> 1.4) - webrobots (~> 0.0, >= 0.0.9) memcache-client (1.8.5) metaclass (0.0.1) - method_source (0.6.7) - ruby_parser (>= 2.3.1) + method_source (0.7.0) mime-types (1.17.2) - mocha (0.10.0) + mocha (0.10.3) metaclass (~> 0.0.1) multi_json (1.0.4) net-http-digest_auth (1.2) - net-http-persistent (1.9) + net-http-persistent (2.3.3) nokogiri (1.5.0) - pg (0.11.0) + ntlm-http (0.1.1) + pg (0.12.2) polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) - pry (0.9.7.4) - coderay (~> 0.9.8) - method_source (~> 0.6.7) - ruby_parser (>= 2.3.1) - slop (~> 2.1.0) - rack (1.3.5) + pry (0.9.8) + coderay (~> 1.0.5) + method_source (~> 0.7) + slop (>= 2.4.3, < 3) + rack (1.4.1) rack-cache (1.1) rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) rack-ssl (1.3.2) rack rack-test (0.6.1) rack (>= 1.0) - rails (3.1.3) - actionmailer (= 3.1.3) - actionpack (= 3.1.3) - activerecord (= 3.1.3) - activeresource (= 3.1.3) - activesupport (= 3.1.3) + rails (3.2.0) + actionmailer (= 3.2.0) + actionpack (= 3.2.0) + activerecord (= 3.2.0) + activeresource (= 3.2.0) + activesupport (= 3.2.0) bundler (~> 1.0) - railties (= 3.1.3) - railties (3.1.3) - actionpack (= 3.1.3) - activesupport (= 3.1.3) + railties (= 3.2.0) + railties (3.2.0) + actionpack (= 3.2.0) + activesupport (= 3.2.0) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) - rdoc (3.11) + rdoc (3.12) json (~> 1.4) rmagick (2.13.1) - ruby_parser (2.3.1) - sexp_processor (~> 3.0) - sass (3.1.11) - sexp_processor (3.0.8) + sass (3.1.12) shoulda (2.11.3) silent-postgres (0.1.1) simple_form (1.5.2) @@ -140,8 +144,8 @@ GEM multi_json (~> 1.0.3) simplecov-html (~> 0.5.3) simplecov-html (0.5.3) - slop (2.1.0) - sprockets (2.0.3) + slop (2.4.3) + sprockets (2.1.2) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) @@ -156,12 +160,14 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.31) - uglifier (1.1.0) + uglifier (1.2.2) execjs (>= 0.3.0) multi_json (>= 1.0.2) - webrobots (0.0.12) - nokogiri (>= 1.4.4) - whenever (0.7.0) + unf (0.0.4) + unf_ext + unf_ext (0.0.4) + webrobots (0.0.13) + whenever (0.7.2) activesupport (>= 2.3.4) chronic (~> 0.6.3) @@ -171,16 +177,17 @@ PLATFORMS DEPENDENCIES awesome_print delayed_job + delayed_job_active_record factory_girl ffaker! - mechanize + mechanize! memcache-client meta_search! mocha nokogiri pg pry - rails (= 3.1.3) + rails (= 3.2.0) rmagick sanitize! sass diff --git a/app/models/artist.rb b/app/models/artist.rb index 493723ca1..0b1a302c2 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -12,7 +12,7 @@ class Artist < ActiveRecord::Base 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 - attr_accessible :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :default, :admin] + attr_accessible :body, :name, :url_string, :other_names, :group_name, :wiki_page_attributes, :notes, :is_active, :as => [:member, :privileged, :contributor, :janitor, :moderator, :default, :admin] attr_accessible :is_banned, :as => :admin scope :url_match, lambda {|string| where(["id in (?)", Artist.find_all_by_url(string).map(&:id)])} scope :other_names_match, lambda {|string| where(["other_names_index @@ to_tsquery('danbooru', ?)", Artist.normalize_name(string)])} diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index ada74f13b..465409afa 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -1,5 +1,5 @@ class UserFeedback < ActiveRecord::Base - set_table_name "user_feedback" + self.table_name = "user_feedback" belongs_to :user belongs_to :creator, :class_name => "User" before_validation :initialize_creator, :on => :create diff --git a/config/application.rb b/config/application.rb index 655d64665..cd0b0fa80 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,10 +2,9 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' -# If you have a Gemfile, require the default gems, the ones in the -# current environment and also include :assets gems if in development -# or test environments. -Bundler.require *Rails.groups(:assets) if defined?(Bundler) +if defined?(Bundler) + Bundler.require(*Rails.groups(:assets => %w(development test))) +end module Danbooru class Application < Rails::Application @@ -13,6 +12,7 @@ module Danbooru config.encoding = "utf-8" config.filter_parameters += [:password] config.assets.enabled = true + config.assets.version = '1.0' config.autoload_paths += %W(#{config.root}/app/presenters #{config.root}/app/logical #{config.root}/app/mailers) config.plugins = [:all] config.time_zone = 'Eastern Time (US & Canada)' diff --git a/config/environment.rb b/config/environment.rb index 00be728e9..11b966c09 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,8 @@ # Load the rails application require File.expand_path('../application', __FILE__) +Encoding.default_external = Encoding::UTF_8 +Encoding.default_internal = Encoding::UTF_8 + # Initialize the rails application Danbooru::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 384fe56c6..953608bb1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -2,7 +2,7 @@ Danbooru::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false @@ -22,6 +22,16 @@ Danbooru::Application.configure do # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Do not compress assets config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 597b4909f..e30978073 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,9 +14,18 @@ Danbooru::Application.configure do # Compress JavaScripts and CSS config.assets.compress = true + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files - # (comment out if your front-end server doesn't support this) - config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -24,8 +33,11 @@ Danbooru::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store @@ -48,4 +60,8 @@ Danbooru::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 end diff --git a/config/environments/test.rb b/config/environments/test.rb index 959da24b9..c86c60b9e 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -2,9 +2,9 @@ Danbooru::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that + # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance @@ -29,10 +29,8 @@ Danbooru::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict # Print deprecation notices to the stderr config.active_support.deprecation = :stderr diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 9e8b0131f..5d8d9be23 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -8,3 +8,8 @@ # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end +# +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 71b88b0b4..999df2018 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -4,9 +4,11 @@ # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. -ActionController::Base.wrap_parameters :format => [:json] +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end # Disable root element in JSON by default. -if defined?(ActiveRecord) - ActiveRecord::Base.include_root_in_json = false +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false end diff --git a/test/factories/artist.rb b/test/factories/artist.rb index 28eff6564..bcad070da 100644 --- a/test/factories/artist.rb +++ b/test/factories/artist.rb @@ -1,5 +1,4 @@ Factory.define(:artist) do |f| f.name {rand(1_000_000).to_s} - f.creator {|x| x.association(:user)} f.is_active true end diff --git a/test/factories/comment.rb b/test/factories/comment.rb index 173ed472e..a3e080a58 100644 --- a/test/factories/comment.rb +++ b/test/factories/comment.rb @@ -1,5 +1,4 @@ Factory.define(:comment) do |f| f.post {|x| x.association(:post)} f.body {Faker::Lorem.sentences.join(" ")} - f.score 0 end diff --git a/test/factories/dmail.rb b/test/factories/dmail.rb index 71f480029..76e55bf25 100644 --- a/test/factories/dmail.rb +++ b/test/factories/dmail.rb @@ -2,5 +2,4 @@ Factory.define(:dmail) do |f| f.to {|x| x.association(:user)} f.title {Faker::Lorem.words.join(" ")} f.body {Faker::Lorem.sentences.join(" ")} - f.is_read false end diff --git a/test/functional/dmails_controller_test.rb b/test/functional/dmails_controller_test.rb index 59ce3c2eb..ad5e212c2 100644 --- a/test/functional/dmails_controller_test.rb +++ b/test/functional/dmails_controller_test.rb @@ -78,7 +78,7 @@ class DmailsControllerTest < ActionController::TestCase should "create two messages, one for the sender and one for the recipient" do assert_difference("Dmail.count", 2) do - dmail_attribs = {:to_id => @user_2.id, :title => "abc", :body => "abc", :is_read => false} + dmail_attribs = {:to_id => @user_2.id, :title => "abc", :body => "abc"} post :create, {:dmail => dmail_attribs}, {:user_id => @user.id} assert_redirected_to dmail_path(Dmail.last) end diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 208ec71d2..a2a5104ef 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -117,12 +117,14 @@ class ArtistTest < ActiveSupport::TestCase should "have an associated wiki" do user = Factory.create(:user) + CurrentUser.user = user artist = Factory.create(:artist, :name => "max", :wiki_page_attributes => {:title => "xxx", :body => "this is max"}) assert_not_nil(artist.wiki_page) assert_equal("this is max", artist.wiki_page.body) - artist.update_attributes(:wiki_page_attributes => {:id => artist.wiki_page.id, :body => "this is hoge mark ii", :creator_id => user.id}) + artist.update_attributes({:wiki_page_attributes => {:id => artist.wiki_page.id, :body => "this is hoge mark ii"}}) assert_equal("this is hoge mark ii", artist.wiki_page(true).body) + CurrentUser.user = nil end should "revert to prior versions" do