diff --git a/Gemfile b/Gemfile index a0fc953cc..d5e517d7d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,13 +2,12 @@ source 'https://rubygems.org/' gem 'dotenv-rails', :require => "dotenv/rails-now" -gem 'protected_attributes' gem "sass-rails" gem "sprockets-rails", :require => "sprockets/railtie" gem "uglifier" gem "therubyracer", :platforms => :ruby -gem "rails", "~> 4.2.0" -gem "pg", "0.21.0" +gem "rails", "~> 5.1" +gem "pg" gem "dalli", :platforms => :ruby gem "memcache-client", :platforms => [:mswin, :mingw, :x64_mingw] gem "tzinfo-data", :platforms => [:mswin, :mingw, :x64_mingw] @@ -22,9 +21,9 @@ gem 'ruby-vips' gem 'net-sftp' gem 'term-ansicolor', :require => "term/ansicolor" gem 'diff-lcs', :require => "diff/lcs/array" -gem 'bcrypt-ruby', :require => "bcrypt" +gem 'bcrypt', :require => "bcrypt" gem 'statistics2' -gem 'capistrano', '~> 3.4.0' +gem 'capistrano', '~> 3.10' gem 'capistrano-rails' gem 'capistrano-rbenv' gem 'radix62', '~> 1.0.1' @@ -48,6 +47,8 @@ gem 'addressable' gem 'httparty' gem 'rakismet' gem 'recaptcha', require: "recaptcha/rails" +gem 'activemodel-serializers-xml' +gem 'ptools' # needed for looser jpeg header compat gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes" @@ -68,16 +69,16 @@ group :development, :test do gem 'pry-byebug' gem 'ruby-prof' gem 'foreman' + gem 'listen' end group :test do gem "shoulda-context" gem "shoulda-matchers" - gem "factory_girl" + gem "factory_bot" gem "mocha", :require => "mocha/setup" gem "ffaker" gem "simplecov", :require => false gem "timecop" gem "webmock" - gem "test_after_commit" # XXX remove me after upgrading to rails 5. end diff --git a/Gemfile.lock b/Gemfile.lock index 5ac7139ed..872393739 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ GIT GIT remote: https://github.com/r888888888/dtext_rb.git - revision: e343c4572e7a72666123984679e6cf90badd473d + revision: 47f238ec378be0933fcd7eccf1904fbd1f8d8613 specs: dtext_rb (1.7.0) nokogiri (~> 1.8) @@ -24,76 +24,82 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) + actioncable (5.1.6) + actionpack (= 5.1.6) + nio4r (~> 2.0) + websocket-driver (~> 0.6.1) + actionmailer (5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.8) - actionview (= 4.2.8) - activesupport (= 4.2.8) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.1.6) + actionview (= 5.1.6) + activesupport (= 5.1.6) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.8) - activesupport (= 4.2.8) + actionview (5.1.6) + activesupport (= 5.1.6) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.8) - activesupport (= 4.2.8) - globalid (>= 0.3.0) - activemodel (4.2.8) - activesupport (= 4.2.8) + activejob (5.1.6) + activesupport (= 5.1.6) + globalid (>= 0.3.6) + activemodel (5.1.6) + activesupport (= 5.1.6) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) builder (~> 3.1) - activerecord (4.2.8) - activemodel (= 4.2.8) - activesupport (= 4.2.8) - arel (~> 6.0) - activesupport (4.2.8) - i18n (~> 0.7) + activerecord (5.1.6) + activemodel (= 5.1.6) + activesupport (= 5.1.6) + arel (~> 8.0) + activesupport (5.1.6) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) - arel (6.0.4) + airbrussh (1.3.0) + sshkit (>= 1.6.1, != 1.7.0) + arel (8.0.0) awesome_print (1.8.0) - aws-sdk (2.10.122) - aws-sdk-resources (= 2.10.122) - aws-sdk-core (2.10.122) + aws-sdk (2.10.125) + aws-sdk-resources (= 2.10.125) + aws-sdk-core (2.10.125) aws-sigv4 (~> 1.0) jmespath (~> 1.0) - aws-sdk-resources (2.10.122) - aws-sdk-core (= 2.10.122) + aws-sdk-resources (2.10.125) + aws-sdk-core (= 2.10.125) aws-sigv4 (1.0.2) bcrypt (3.1.11) bcrypt (3.1.11-x64-mingw32) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) - bcrypt-ruby (3.1.5-x64-mingw32) - bcrypt (>= 3.1.3) bootsnap (1.1.8) msgpack (~> 1.0) buftok (0.2.0) builder (3.2.3) - byebug (9.1.0) - capistrano (3.4.0) + byebug (10.0.2) + capistrano (3.10.1) + airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) - sshkit (~> 1.3) - capistrano-bundler (1.1.4) + sshkit (>= 1.9.0) + capistrano-bundler (1.3.0) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-deploytags (1.0.4) - capistrano (>= 3.2.0) - capistrano-rails (1.1.3) + capistrano-deploytags (1.0.7) + capistrano (>= 3.7.0) + capistrano-rails (1.3.1) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.0.3) + capistrano-rbenv (2.1.3) capistrano (~> 3.1) sshkit (~> 1.3) capistrano3-unicorn (0.2.1) @@ -121,15 +127,17 @@ GEM dotenv (= 2.2.1) railties (>= 3.2, < 5.2) equalizer (0.0.11) - erubis (2.7.0) + erubi (1.7.1) execjs (2.7.0) - factory_girl (4.8.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) - faraday (0.10.1) + faraday (0.12.2) multipart-post (>= 1.2, < 3) ffaker (2.8.1) ffi (1.9.18) ffi (1.9.18-x64-mingw32) + ffi-win32-extensions (1.0.3) + ffi foreman (0.63.0) dotenv (>= 0.7) thor (>= 0.13.6) @@ -149,8 +157,8 @@ GEM mime-types (>= 1.6) representable (~> 2.3.0) retriable (~> 2.0) - googleauth (0.5.1) - faraday (~> 0.9) + googleauth (0.5.3) + faraday (~> 0.12) jwt (~> 1.4) logging (~> 2.0) memoist (~> 0.12) @@ -159,32 +167,35 @@ GEM signet (~> 0.7) hashdiff (0.3.7) highline (1.7.10) - hike (1.2.3) - http (2.2.2) + http (3.0.0) addressable (~> 2.3) http-cookie (~> 1.0) - http-form_data (~> 1.0.1) + http-form_data (>= 2.0.0.pre.pre2, < 3) http_parser.rb (~> 0.6.0) http-cookie (1.0.3) domain_name (~> 0.5) - http-form_data (1.0.3) + http-form_data (2.0.0) http_parser.rb (0.6.0) httparty (0.15.6) multi_xml (>= 0.5.2) httpclient (2.8.3) hurley (0.2) - i18n (0.9.1) + i18n (1.0.0) concurrent-ruby (~> 1.0) jmespath (1.3.1) - json (1.8.6) + json (2.1.0) jwt (1.5.6) - kgio (2.11.1) + kgio (2.11.2) libv8 (3.16.14.19) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) little-plugger (1.1.4) logging (2.2.2) little-plugger (~> 1.1) multi_json (~> 1.10) - loofah (2.1.1) + loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.0) @@ -205,10 +216,12 @@ GEM thread_safe (~> 0.3, >= 0.3.1) metaclass (0.0.4) method_source (0.9.0) - mime-types (2.99.3) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.11.1) + minitest (5.11.3) mocha (1.3.0) metaclass (~> 0.0.1) msgpack (1.2.2) @@ -224,13 +237,13 @@ GEM net-sftp (2.1.2) net-ssh (>= 2.6.5) net-ssh (4.2.0) - netrc (0.11.0) - newrelic_rpm (4.7.1.340) - nokogiri (1.8.1) + newrelic_rpm (4.8.0.341) + nio4r (2.3.0) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) - nokogiri (1.8.1-x64-mingw32) + nokogiri (1.8.2-x64-mingw32) mini_portile2 (~> 2.3.0) - nokogumbo (1.4.13) + nokogumbo (1.5.0) nokogiri ntlm-http (0.1.1) oauth2 (1.4.0) @@ -242,50 +255,50 @@ GEM os (0.9.6) pg (0.21.0) pg (0.21.0-x64-mingw32) - protected_attributes (1.1.4) - activemodel (>= 4.0.1, < 5.0) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) - pry-byebug (3.5.1) - byebug (~> 9.1) + pry-byebug (3.6.0) + byebug (~> 10.0) pry (~> 0.10) + ptools (1.3.5) + ptools (1.3.5-universal-mingw32) + win32-file (>= 0.7.0) public_suffix (3.0.1) - rack (1.6.8) - rack-test (0.6.3) - rack (>= 1.0) + rack (2.0.4) + rack-test (1.0.0) + rack (>= 1.0, < 3) radix62 (1.0.1) - rails (4.2.8) - actionmailer (= 4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) - activemodel (= 4.2.8) - activerecord (= 4.2.8) - activesupport (= 4.2.8) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.8) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - railties (4.2.8) - actionpack (= 4.2.8) - activesupport (= 4.2.8) + rails (5.1.6) + actioncable (= 5.1.6) + actionmailer (= 5.1.6) + actionpack (= 5.1.6) + actionview (= 5.1.6) + activejob (= 5.1.6) + activemodel (= 5.1.6) + activerecord (= 5.1.6) + activesupport (= 5.1.6) + bundler (>= 1.3.0) + railties (= 5.1.6) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.1.6) + actionpack (= 5.1.6) + activesupport (= 5.1.6) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.19.0) - rake (12.3.0) + rake (12.3.1) rakismet (1.5.4) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - recaptcha (4.6.3) + recaptcha (4.6.4) json ref (2.0.0) representable (2.3.0) @@ -293,25 +306,17 @@ GEM responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rest-client (1.8.0-x64-mingw32) - ffi (~> 1.9) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) retriable (2.1.0) ruby-prof (0.17.0) ruby-vips (2.0.9) ffi (~> 1.9) + ruby_dep (1.5.0) rubyzip (1.2.1) safe_yaml (1.0.4) - sanitize (4.5.0) + sanitize (4.6.0) crass (~> 1.0.2) nokogiri (>= 1.4.4) - nokogumbo (~> 1.4.1) + nokogumbo (~> 1.4) sass (3.5.5) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -340,52 +345,48 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sprockets (2.12.4) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) sshkit (1.15.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) statistics2 (0.54) streamio-ffmpeg (3.0.2) multi_json (~> 1.8) - stripe (1.25.0) - json (~> 1.8.1) - rest-client (~> 1.4) + stripe (3.9.1) + faraday (~> 0.10) term-ansicolor (1.6.0) tins (~> 1.0) - test_after_commit (1.1.0) - activerecord (>= 3.2) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref thor (0.20.0) thread_safe (0.3.6) - tilt (1.4.1) + tilt (2.0.8) timecop (0.9.1) tins (1.16.3) - twitter (6.0.0) - addressable (~> 2.5) + twitter (6.2.0) + addressable (~> 2.3) buftok (~> 0.2.0) - equalizer (= 0.0.11) - faraday (~> 0.10.0) - http (~> 2.1) + equalizer (~> 0.0.11) + http (~> 3.0) + http-form_data (~> 2.0) http_parser.rb (~> 0.6.0) - memoizable (~> 0.4.2) - naught (~> 1.1) - simple_oauth (~> 0.3.1) - tzinfo (1.2.4) + memoizable (~> 0.4.0) + multipart-post (~> 2.0) + naught (~> 1.0) + simple_oauth (~> 0.3.0) + tzinfo (1.2.5) thread_safe (~> 0.1) - tzinfo-data (1.2017.3) + tzinfo-data (1.2018.3) tzinfo (>= 1.0.0) uber (0.0.15) - uglifier (4.1.3) + uglifier (4.1.5) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext @@ -402,8 +403,18 @@ GEM crack (>= 0.3.2) hashdiff webrobots (0.1.2) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) whenever (0.10.0) chronic (>= 0.6.3) + win32-file (0.8.1) + ffi + ffi-win32-extensions + win32-file-stat (>= 1.4.0) + win32-file-stat (1.5.5) + ffi + ffi-win32-extensions win32console (1.3.2) PLATFORMS @@ -411,13 +422,14 @@ PLATFORMS x64-mingw32 DEPENDENCIES + activemodel-serializers-xml addressable awesome_print aws-sdk (~> 2) - bcrypt-ruby + bcrypt bigquery! bootsnap - capistrano (~> 3.4.0) + capistrano (~> 3.10) capistrano-deploytags (~> 1.0.0) capistrano-rails capistrano-rbenv @@ -430,12 +442,13 @@ DEPENDENCIES diff-lcs dotenv-rails dtext_rb! - factory_girl + factory_bot ffaker foreman google-api-client highline httparty + listen mechanize memcache-client memcache_mock @@ -444,11 +457,11 @@ DEPENDENCIES net-sftp newrelic_rpm oauth2 - pg (= 0.21.0) - protected_attributes + pg pry-byebug + ptools radix62 (~> 1.0.1) - rails (~> 4.2.0) + rails (~> 5.1) rakismet recaptcha responders @@ -467,7 +480,6 @@ DEPENDENCIES streamio-ffmpeg stripe term-ansicolor - test_after_commit therubyracer timecop twitter diff --git a/app/assets/javascripts/mod_queue.js b/app/assets/javascripts/mod_queue.js index de168331f..7ab0420b1 100644 --- a/app/assets/javascripts/mod_queue.js +++ b/app/assets/javascripts/mod_queue.js @@ -56,23 +56,17 @@ } Danbooru.ModQueue.detailed_rejection_dialog = function() { - $("#post_id").val($(this).data("post-id")); + $("#post_disapproval_post_id").val($(this).data("post-id")); $("#detailed-rejection-dialog").dialog({ width: 500, buttons: { "Submit": function() { - var data = $("#detailed-rejection-form").serialize(); - $.ajax({ - type: "POST", - url: $("#detailed-rejection-form").attr("action"), - data: data, - dataType: "script" - }); - $("#detailed-rejection-dialog").dialog("close"); + $(this).find("form").submit(); + $(this).dialog("close"); }, "Cancel": function() { - $("#detailed-rejection-dialog").dialog("close"); + $(this).dialog("close"); } } }); diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index e4d3ccdf7..03f7dac7b 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -628,6 +628,8 @@ }); $("#save-search").click(function(e) { + $("#save-search-dialog #saved_search_query").val($("#tags").val()); + if (Danbooru.meta("disable-labeled-saved-searches") === "false") { $("#save-search-dialog").dialog("open"); } else { diff --git a/app/controllers/admin/alias_and_implication_imports_controller.rb b/app/controllers/admin/alias_and_implication_imports_controller.rb index 215594ead..ad4998e06 100644 --- a/app/controllers/admin/alias_and_implication_imports_controller.rb +++ b/app/controllers/admin/alias_and_implication_imports_controller.rb @@ -1,6 +1,6 @@ module Admin class AliasAndImplicationImportsController < ApplicationController - before_filter :admin_only + before_action :admin_only def new end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 748c8fad9..0cf7a2fd3 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,6 +1,6 @@ module Admin class UsersController < ApplicationController - before_filter :moderator_only + before_action :moderator_only def edit @user = User.find(params[:id]) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1dfeccf39..ab4b50a5f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,25 +1,26 @@ class ApplicationController < ActionController::Base protect_from_forgery helper :pagination - before_filter :reset_current_user - before_filter :set_current_user - after_filter :reset_current_user - before_filter :set_title - before_filter :normalize_search - before_filter :set_started_at_session - before_filter :api_check - before_filter :set_safe_mode - # before_filter :secure_cookies_check + before_action :reset_current_user + before_action :set_current_user + after_action :reset_current_user + before_action :set_title + before_action :normalize_search + before_action :set_started_at_session + before_action :api_check + before_action :set_safe_mode + # before_action :secure_cookies_check layout "default" force_ssl :if => :ssl_login? helper_method :show_moderation_notice? - before_filter :enable_cors + before_action :enable_cors rescue_from Exception, :with => :rescue_exception rescue_from User::PrivilegeError, :with => :access_denied rescue_from SessionLoader::AuthenticationFailure, :with => :authentication_failed rescue_from Danbooru::Paginator::PaginationError, :with => :render_pagination_limit rescue_from PG::ConnectionBad, with: :bad_db_connection + rescue_from ActionController::UnpermittedParameters, :with => :access_denied # This is raised on requests to `/blah.js`. Rails has already rendered StaticController#not_found # here, so calling `rescue_exception` would cause a double render error. @@ -93,6 +94,13 @@ class ApplicationController < ActionController::Base def rescue_exception(exception) @exception = exception + if Rails.env.test? && ENV["DEBUG"] + puts "---" + STDERR.puts("#{exception.class} exception thrown: #{exception.message}") + exception.backtrace.each {|x| STDERR.puts(x)} + puts "---" + end + if exception.is_a?(::ActiveRecord::StatementInvalid) && exception.to_s =~ /statement timeout/ if Rails.env.production? NewRelic::Agent.notice_error(exception, :uri => request.original_url, :referer => request.referer, :request_params => params, :custom_params => {:user_id => CurrentUser.user.id, :user_ip_addr => CurrentUser.ip_addr}) @@ -159,7 +167,7 @@ class ApplicationController < ActionController::Base render :json => {:success => false, :reason => "access denied"}.to_json, :status => 403 end fmt.js do - render :nothing => true, :status => 403 + render js: "", :status => 403 end end end @@ -212,6 +220,10 @@ class ApplicationController < ActionController::Base end end + def search_params + params.fetch(:search, {}).permit! + end + def set_safe_mode CurrentUser.set_safe_mode(request) end diff --git a/app/controllers/artist_commentaries_controller.rb b/app/controllers/artist_commentaries_controller.rb index 2d91919dc..ddcfd912d 100644 --- a/app/controllers/artist_commentaries_controller.rb +++ b/app/controllers/artist_commentaries_controller.rb @@ -1,9 +1,9 @@ class ArtistCommentariesController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show] + before_action :member_only, :except => [:index, :show] def index - @commentaries = ArtistCommentary.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @commentaries = ArtistCommentary.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@commentaries) do |format| format.xml do render :xml => @commentaries.to_xml(:root => "artist-commentaries") @@ -24,14 +24,8 @@ class ArtistCommentariesController < ApplicationController end def create_or_update - @artist_commentary = ArtistCommentary.find_by_post_id(params[:artist_commentary][:post_id]) - - if @artist_commentary - @artist_commentary.update_attributes(params[:artist_commentary]) - else - @artist_commentary = ArtistCommentary.create(params[:artist_commentary]) - end - + @artist_commentary = ArtistCommentary.find_or_initialize_by(post_id: params.dig(:artist_commentary, :post_id)) + @artist_commentary.update(commentary_params) respond_with(@artist_commentary) end @@ -39,6 +33,15 @@ class ArtistCommentariesController < ApplicationController @artist_commentary = ArtistCommentary.find_by_post_id!(params[:id]) @version = @artist_commentary.versions.find(params[:version_id]) @artist_commentary.revert_to!(@version) - respond_with(@artist_commentary) + end + +private + + def commentary_params + params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[ + original_description original_title translated_description translated_title + remove_commentary_tag remove_commentary_request_tag remove_commentary_check_tag + add_commentary_tag add_commentary_request_tag add_commentary_check_tag + ]) end end diff --git a/app/controllers/artist_commentary_versions_controller.rb b/app/controllers/artist_commentary_versions_controller.rb index c64bea080..68c8f8640 100644 --- a/app/controllers/artist_commentary_versions_controller.rb +++ b/app/controllers/artist_commentary_versions_controller.rb @@ -2,7 +2,7 @@ class ArtistCommentaryVersionsController < ApplicationController respond_to :html, :xml, :json def index - @commentary_versions = ArtistCommentaryVersion.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @commentary_versions = ArtistCommentaryVersion.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@commentary_versions) do |format| format.xml do render :xml => @commentary_versions.to_xml(:root => "artist-commentary-versions") diff --git a/app/controllers/artist_versions_controller.rb b/app/controllers/artist_versions_controller.rb index 88197e292..eaa279ea0 100644 --- a/app/controllers/artist_versions_controller.rb +++ b/app/controllers/artist_versions_controller.rb @@ -1,13 +1,14 @@ class ArtistVersionsController < ApplicationController - before_filter :member_only + before_action :member_only respond_to :html, :xml, :json def index - @artist_versions = ArtistVersion.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @artist_versions = ArtistVersion.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@artist_versions) do |format| format.xml do render :xml => @artist_versions.to_xml(:root => "artist-versions") end end end + end diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index ef121fc54..d95d8aeb1 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,12 +1,12 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, :except => [:index, :show, :show_or_new, :banned] - before_filter :builder_only, :only => [:destroy] - before_filter :admin_only, :only => [:ban, :unban] - before_filter :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete] + before_action :member_only, :except => [:index, :show, :show_or_new, :banned] + before_action :builder_only, :only => [:destroy] + before_action :admin_only, :only => [:ban, :unban] + before_action :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete] def new - @artist = Artist.new_with_defaults(params) + @artist = Artist.new_with_defaults(artist_params) respond_with(@artist) end @@ -37,7 +37,6 @@ class ArtistsController < ApplicationController end def index - search_params = params[:search].present? ? params[:search] : params @artists = Artist.includes(:urls).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@artists) do |format| format.xml do @@ -56,12 +55,12 @@ class ArtistsController < ApplicationController end def create - @artist = Artist.create(params[:artist], :as => CurrentUser.role) + @artist = Artist.create(artist_params) respond_with(@artist) end def update - @artist.update(params[:artist], :as => CurrentUser.role) + @artist.update(artist_params) flash[:notice] = @artist.valid? ? "Artist updated" : @artist.errors.full_messages.join("; ") respond_with(@artist) end @@ -118,4 +117,17 @@ private def load_artist @artist = Artist.find(params[:id]) end + + def search_params + sp = params.fetch(:search, {}) + sp[:name] = params[:name] if params[:name] + sp.permit! + end + + def artist_params + permitted_params = %i[name other_names other_names_comma group_name url_string notes] + permitted_params << :is_active if CurrentUser.is_builder? + + params.fetch(:artist, {}).permit(permitted_params) + end end diff --git a/app/controllers/bans_controller.rb b/app/controllers/bans_controller.rb index 9ce26ebba..1f5da2242 100644 --- a/app/controllers/bans_controller.rb +++ b/app/controllers/bans_controller.rb @@ -1,6 +1,7 @@ class BansController < ApplicationController - before_filter :moderator_only, :except => [:show, :index] + before_action :moderator_only, :except => [:show, :index] respond_to :html, :xml, :json + helper_method :search_params def new @ban = Ban.new(params[:ban]) @@ -11,7 +12,7 @@ class BansController < ApplicationController end def index - @bans = Ban.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @bans = Ban.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@bans) do |fmt| fmt.html { @bans = @bans.includes(:user, :banner) } end @@ -23,7 +24,7 @@ class BansController < ApplicationController end def create - @ban = Ban.create(params[:ban]) + @ban = Ban.create(ban_params(:create)) if @ban.errors.any? render :action => "new" @@ -34,7 +35,7 @@ class BansController < ApplicationController def update @ban = Ban.find(params[:id]) - if @ban.update_attributes(params[:ban]) + if @ban.update(ban_params(:update)) redirect_to ban_path(@ban), :notice => "Ban updated" else render :action => "edit" @@ -46,4 +47,13 @@ class BansController < ApplicationController @ban.destroy redirect_to bans_path, :notice => "Ban destroyed" end + + private + + def ban_params(context) + permitted_params = %i[reason duration expires_at] + permitted_params += %i[user_id user_name] if context == :create + + params.require(:ban).permit(permitted_params) + end end diff --git a/app/controllers/bulk_update_requests_controller.rb b/app/controllers/bulk_update_requests_controller.rb index 9da1f65fa..bac8a2a92 100644 --- a/app/controllers/bulk_update_requests_controller.rb +++ b/app/controllers/bulk_update_requests_controller.rb @@ -1,8 +1,8 @@ class BulkUpdateRequestsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show] - before_filter :admin_only, :only => [:approve] - before_filter :load_bulk_update_request, :except => [:new, :create, :index] + before_action :member_only, :except => [:index, :show] + before_action :admin_only, :only => [:approve] + before_action :load_bulk_update_request, :except => [:new, :create, :index] def new @bulk_update_request = BulkUpdateRequest.new @@ -47,7 +47,7 @@ class BulkUpdateRequestsController < ApplicationController end def index - @bulk_update_requests = BulkUpdateRequest.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @bulk_update_requests = BulkUpdateRequest.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@bulk_update_requests) end diff --git a/app/controllers/comment_votes_controller.rb b/app/controllers/comment_votes_controller.rb index 1cd22afd1..bea09d334 100644 --- a/app/controllers/comment_votes_controller.rb +++ b/app/controllers/comment_votes_controller.rb @@ -1,7 +1,7 @@ class CommentVotesController < ApplicationController respond_to :js, :json, :xml - before_filter :member_only - skip_before_filter :api_check + before_action :member_only + skip_before_action :api_check def create @comment = Comment.find(params[:comment_id]) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 32b6af649..43ac0cbf9 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,12 +1,12 @@ class CommentsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, :except => [:index, :search, :show] - skip_before_filter :api_check + before_action :member_only, :except => [:index, :search, :show] + skip_before_action :api_check def index - if params[:group_by] == "comment" || request.format == Mime::ATOM + if params[:group_by] == "comment" || request.format == Mime::Type.lookup("application/atom+xml") index_by_comment - elsif request.format == Mime::JS + elsif request.format == Mime::Type.lookup("text/javascript") index_for_post else index_by_post @@ -23,15 +23,17 @@ class CommentsController < ApplicationController def update @comment = Comment.find(params[:id]) check_privilege(@comment) - @comment.update(update_params, :as => CurrentUser.role) + @comment.update(comment_params(:update)) respond_with(@comment, :location => post_path(@comment.post_id)) end def create - @comment = Comment.create(create_params, :as => CurrentUser.role) + @comment = Comment.create(comment_params(:create)) respond_with(@comment) do |format| format.html do - if @comment.errors.any? + if @comment.post.nil? + redirect_to comments_path, notice: @comment.errors.full_messages.join("; ") + elsif @comment.errors.any? redirect_to post_path(@comment.post), :notice => @comment.errors.full_messages.join("; ") else redirect_to post_path(@comment.post), :notice => "Comment posted" @@ -88,7 +90,7 @@ private end def index_by_comment - @comments = Comment.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @comments = Comment.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@comments) do |format| format.atom do @comments = @comments.includes(:post, :creator).load @@ -105,11 +107,12 @@ private end end - def create_params - params.require(:comment).permit(:post_id, :body, :do_not_bump_post, :is_sticky) - end + def comment_params(context) + permitted_params = %i[body] + permitted_params += %i[post_id do_not_bump_post] if context == :create + permitted_params += %i[is_deleted] if context == :update + permitted_params += %i[is_sticky] if CurrentUser.is_moderator? - def update_params - params.require(:comment).permit(:body, :is_deleted, :is_sticky) + params.require(:comment).permit(permitted_params) end end diff --git a/app/controllers/delayed_jobs_controller.rb b/app/controllers/delayed_jobs_controller.rb index 4b4fa5b1b..b3c2d1025 100644 --- a/app/controllers/delayed_jobs_controller.rb +++ b/app/controllers/delayed_jobs_controller.rb @@ -1,6 +1,6 @@ class DelayedJobsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :admin_only, except: [:index] + before_action :admin_only, except: [:index] def index @delayed_jobs = Delayed::Job.order("run_at asc").paginate(params[:page], :limit => params[:limit]) @@ -18,7 +18,7 @@ class DelayedJobsController < ApplicationController def retry @job = Delayed::Job.find(params[:id]) if !@job.locked_at? - @job.update({failed_at: nil, attempts: 0}, without_protection: true) + @job.update(failed_at: nil, attempts: 0) end respond_with(@job) end diff --git a/app/controllers/dmails_controller.rb b/app/controllers/dmails_controller.rb index 3724d7611..50830ac37 100644 --- a/app/controllers/dmails_controller.rb +++ b/app/controllers/dmails_controller.rb @@ -1,7 +1,7 @@ class DmailsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, except: [:index, :show, :destroy, :mark_all_as_read] - before_filter :gold_only, only: [:ham, :spam] + before_action :member_only, except: [:index, :show, :destroy, :mark_all_as_read] + before_action :gold_only, only: [:ham, :spam] def new if params[:respond_to_id] @@ -19,7 +19,7 @@ class DmailsController < ApplicationController if params[:folder] && params[:set_default_folder] cookies.permanent[:dmail_folder] = params[:folder] end - @query = Dmail.active.visible.search(params[:search]) + @query = Dmail.active.visible.search(search_params) @dmails = @query.paginate(params[:page], :limit => params[:limit]) respond_with(@dmails) do |format| format.xml do diff --git a/app/controllers/explore/posts_controller.rb b/app/controllers/explore/posts_controller.rb index 35a396ce2..006df5e98 100644 --- a/app/controllers/explore/posts_controller.rb +++ b/app/controllers/explore/posts_controller.rb @@ -1,7 +1,7 @@ module Explore class PostsController < ApplicationController respond_to :html, :xml, :json - before_filter :set_date, only: [:searches, :viewed] + before_action :set_date, only: [:searches, :viewed] def popular @post_set = PostSets::Popular.new(params[:date], params[:scale]) diff --git a/app/controllers/favorite_group_orders_controller.rb b/app/controllers/favorite_group_orders_controller.rb index 2ad325c22..7e24f7e04 100644 --- a/app/controllers/favorite_group_orders_controller.rb +++ b/app/controllers/favorite_group_orders_controller.rb @@ -1,6 +1,6 @@ class FavoriteGroupOrdersController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only + before_action :member_only def edit @favorite_group = FavoriteGroup.find(params[:favorite_group_id]) diff --git a/app/controllers/favorite_groups_controller.rb b/app/controllers/favorite_groups_controller.rb index 972b56558..b98e13d93 100644 --- a/app/controllers/favorite_groups_controller.rb +++ b/app/controllers/favorite_groups_controller.rb @@ -1,9 +1,9 @@ class FavoriteGroupsController < ApplicationController - before_filter :member_only, :except => [:index, :show] + before_action :member_only, :except => [:index, :show] respond_to :html, :xml, :json, :js def index - @favorite_groups = FavoriteGroup.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @favorite_groups = FavoriteGroup.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@favorite_groups) do |format| format.xml do render :xml => @favorite_groups.to_xml(:root => "favorite-groups") @@ -24,7 +24,7 @@ class FavoriteGroupsController < ApplicationController end def create - @favorite_group = FavoriteGroup.create(params[:favorite_group]) + @favorite_group = FavoriteGroup.create(favgroup_params) respond_with(@favorite_group) do |format| format.html do if @favorite_group.errors.any? @@ -45,7 +45,7 @@ class FavoriteGroupsController < ApplicationController def update @favorite_group = FavoriteGroup.find(params[:id]) check_write_privilege(@favorite_group) - @favorite_group.update_attributes(params[:favorite_group]) + @favorite_group.update(favgroup_params) unless @favorite_group.errors.any? flash[:notice] = "Favorite group updated" end @@ -67,7 +67,8 @@ class FavoriteGroupsController < ApplicationController @favorite_group.add!(@post.id) end -private + private + def check_write_privilege(favgroup) raise User::PrivilegeError unless favgroup.editable_by?(CurrentUser.user) end @@ -75,4 +76,8 @@ private def check_read_privilege(favgroup) raise User::PrivilegeError unless favgroup.viewable_by?(CurrentUser.user) end + + def favgroup_params + params.fetch(:favorite_group, {}).permit(%i[name post_ids is_public]) + end end diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index 564a5a11f..75e481e14 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -1,7 +1,7 @@ class FavoritesController < ApplicationController - before_filter :member_only, except: [:index] + before_action :member_only, except: [:index] respond_to :html, :xml, :json - skip_before_filter :api_check + skip_before_action :api_check def index if params[:tags] diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index 7c28f4b59..fd9a48f35 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -1,9 +1,9 @@ class ForumPostsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show, :search] - before_filter :load_post, :only => [:edit, :show, :update, :destroy, :undelete] - before_filter :check_min_level, :only => [:edit, :show, :update, :destroy, :undelete] - skip_before_filter :api_check + before_action :member_only, :except => [:index, :show, :search] + before_action :load_post, :only => [:edit, :show, :update, :destroy, :undelete] + before_action :check_min_level, :only => [:edit, :show, :update, :destroy, :undelete] + skip_before_action :api_check def new if params[:topic_id] @@ -24,7 +24,7 @@ class ForumPostsController < ApplicationController end def index - @query = ForumPost.search(params[:search]) + @query = ForumPost.search(search_params) @forum_posts = @query.includes(:topic).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@forum_posts) do |format| format.xml do @@ -45,14 +45,14 @@ class ForumPostsController < ApplicationController end def create - @forum_post = ForumPost.create(params[:forum_post]) + @forum_post = ForumPost.create(forum_post_params(:create)) page = @forum_post.topic.last_page if @forum_post.topic.last_page > 1 respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => page)) end def update check_privilege(@forum_post) - @forum_post.update_attributes(params[:forum_post]) + @forum_post.update(forum_post_params(:update)) page = @forum_post.forum_topic_page if @forum_post.forum_topic_page > 1 respond_with(@forum_post, :location => forum_topic_path(@forum_post.topic, :page => page, :anchor => "forum_post_#{@forum_post.id}")) end @@ -84,11 +84,11 @@ private end fmt.json do - render :nothing => true, :status => 403 + render json: nil, :status => 403 end fmt.xml do - render :nothing => true, :status => 403 + render xml: nil, :status => 403 end end @@ -101,4 +101,11 @@ private raise User::PrivilegeError end end + + def forum_post_params(context) + permitted_params = [:body] + permitted_params += [:topic_id] if context == :create + + params.require(:forum_post).permit(permitted_params) + end end diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 9f40958b8..015e73f7e 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -1,11 +1,11 @@ class ForumTopicsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, :except => [:index, :show] - before_filter :moderator_only, :only => [:new_merge, :create_merge] - before_filter :normalize_search, :only => :index - before_filter :load_topic, :only => [:edit, :show, :update, :destroy, :undelete, :new_merge, :create_merge, :subscribe, :unsubscribe] - before_filter :check_min_level, :only => [:show, :edit, :update, :new_merge, :create_merge, :destroy, :undelete, :subscribe, :unsubscribe] - skip_before_filter :api_check + before_action :member_only, :except => [:index, :show] + before_action :moderator_only, :only => [:new_merge, :create_merge] + before_action :normalize_search, :only => :index + before_action :load_topic, :only => [:edit, :show, :update, :destroy, :undelete, :new_merge, :create_merge, :subscribe, :unsubscribe] + before_action :check_min_level, :only => [:show, :edit, :update, :new_merge, :create_merge, :destroy, :undelete, :subscribe, :unsubscribe] + skip_before_action :api_check def new @forum_topic = ForumTopic.new @@ -20,9 +20,9 @@ class ForumTopicsController < ApplicationController def index params[:search] ||= {} - params[:search][:order] ||= "sticky" if request.format == Mime::HTML + params[:search][:order] ||= "sticky" if request.format == Mime::Type.lookup("text/html") - @query = ForumTopic.active.search(params[:search]) + @query = ForumTopic.active.search(search_params) @forum_topics = @query.paginate(params[:page], :limit => per_page, :search_count => params[:search]) respond_with(@forum_topics) do |format| @@ -42,7 +42,7 @@ class ForumTopicsController < ApplicationController end def show - if request.format == Mime::HTML + if request.format == Mime::Type.lookup("text/html") @forum_topic.mark_as_read!(CurrentUser.user) end @forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page]) @@ -54,13 +54,13 @@ class ForumTopicsController < ApplicationController end def create - @forum_topic = ForumTopic.create(params[:forum_topic], :as => CurrentUser.role) + @forum_topic = ForumTopic.create(forum_topic_params(:create)) respond_with(@forum_topic) end def update check_privilege(@forum_topic) - @forum_topic.update_attributes(params[:forum_topic], :as => CurrentUser.role) + @forum_topic.update(forum_topic_params(:update)) respond_with(@forum_topic) end @@ -147,15 +147,22 @@ private end fmt.json do - render :nothing => true, :status => 403 + render json: nil, :status => 403 end fmt.xml do - render :nothing => true, :status => 403 + render xml: nil, :status => 403 end end return false end end + + def forum_topic_params(context) + permitted_params = [:title, :category_id, { original_post_attributes: %i[id body] }] + permitted_params += %i[is_sticky is_locked min_level] if CurrentUser.is_moderator? + + params.require(:forum_topic).permit(permitted_params) + end end diff --git a/app/controllers/ip_bans_controller.rb b/app/controllers/ip_bans_controller.rb index e7687e99e..16d309c33 100644 --- a/app/controllers/ip_bans_controller.rb +++ b/app/controllers/ip_bans_controller.rb @@ -1,18 +1,18 @@ class IpBansController < ApplicationController - respond_to :html, :xml, :json - before_filter :moderator_only + respond_to :html, :xml, :json, :js + before_action :moderator_only def new @ip_ban = IpBan.new end def create - @ip_ban = IpBan.create(params[:ip_ban]) + @ip_ban = IpBan.create(ip_ban_params) respond_with(@ip_ban, :location => ip_bans_path) end def index - @search = IpBan.search(params[:search]) + @search = IpBan.search(search_params) @ip_bans = @search.paginate(params[:page], :limit => params[:limit]) respond_with(@ip_bans) end @@ -22,4 +22,14 @@ class IpBansController < ApplicationController @ip_ban.destroy respond_with(@ip_ban) end + + private + + def ip_ban_params + params.fetch(:ip_ban, {}).permit(%i[ip_addr reason]) + end + + def search_params + params.fetch(:search, {}).permit(%i[ip_addr order]) + end end diff --git a/app/controllers/iqdb_queries_controller.rb b/app/controllers/iqdb_queries_controller.rb index 62a9b93a5..9b34e97b9 100644 --- a/app/controllers/iqdb_queries_controller.rb +++ b/app/controllers/iqdb_queries_controller.rb @@ -15,7 +15,7 @@ class IqdbQueriesController < ApplicationController fmt.js { render :layout => false, :action => "create_by_post" } end else - render :nothing => true, :status => 422 + render plain: "", :status => 422 end end diff --git a/app/controllers/janitor_trials_controller.rb b/app/controllers/janitor_trials_controller.rb index d9235415e..0341ff9c9 100644 --- a/app/controllers/janitor_trials_controller.rb +++ b/app/controllers/janitor_trials_controller.rb @@ -1,6 +1,6 @@ class JanitorTrialsController < ApplicationController respond_to :html, :xml, :json - before_filter :moderator_only, :only => [:create, :promote, :demote] + before_action :moderator_only, :only => [:create, :promote, :demote] def new @janitor_trial = JanitorTrial.new @@ -13,12 +13,12 @@ class JanitorTrialsController < ApplicationController end def index - @janitor_trials = JanitorTrial.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @janitor_trials = JanitorTrial.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@janitor_trials) end def create - @janitor_trial = JanitorTrial.create(params[:janitor_trial]) + @janitor_trial = JanitorTrial.create(janitor_trial_params) respond_with(@janitor_trial, :location => janitor_trials_path) end @@ -41,4 +41,10 @@ class JanitorTrialsController < ApplicationController def test @tester = JanitorTrialTester.new(params[:janitor_trial][:user_name]) end + + private + + def janitor_trial_params + params.require(:janitor_trial).permit(%i[user_id user_name]) + end end diff --git a/app/controllers/legacy_controller.rb b/app/controllers/legacy_controller.rb index 8a17ff46a..efb39abea 100644 --- a/app/controllers/legacy_controller.rb +++ b/app/controllers/legacy_controller.rb @@ -1,5 +1,5 @@ class LegacyController < ApplicationController - before_filter :member_only, :only => [:create_post] + before_action :member_only, :only => [:create_post] respond_to :json, :xml def posts @@ -40,7 +40,7 @@ class LegacyController < ApplicationController end def artists - @artists = Artist.limit(100).search(params[:search]).paginate(params[:page]) + @artists = Artist.limit(100).search(search_params).paginate(params[:page]) end def unavailable diff --git a/app/controllers/maintenance/user/api_keys_controller.rb b/app/controllers/maintenance/user/api_keys_controller.rb index e29330524..2b2b64064 100644 --- a/app/controllers/maintenance/user/api_keys_controller.rb +++ b/app/controllers/maintenance/user/api_keys_controller.rb @@ -1,8 +1,8 @@ module Maintenance module User class ApiKeysController < ApplicationController - before_filter :check_privilege - before_filter :authenticate!, :except => [:show] + before_action :check_privilege + before_action :authenticate!, :except => [:show] rescue_from ::SessionLoader::AuthenticationFailure, :with => :authentication_failed respond_to :html, :json, :xml diff --git a/app/controllers/maintenance/user/dmail_filters_controller.rb b/app/controllers/maintenance/user/dmail_filters_controller.rb index 040d5e532..395b56f81 100644 --- a/app/controllers/maintenance/user/dmail_filters_controller.rb +++ b/app/controllers/maintenance/user/dmail_filters_controller.rb @@ -1,7 +1,7 @@ module Maintenance module User class DmailFiltersController < ApplicationController - before_filter :ensure_ownership + before_action :ensure_ownership respond_to :html, :json, :xml def edit @@ -10,12 +10,12 @@ module Maintenance def update @dmail_filter = CurrentUser.dmail_filter || DmailFilter.new - @dmail_filter.update(params.require(:dmail_filter).permit(:words), :as => CurrentUser.role) + @dmail_filter.update(dmail_filter_params) flash[:notice] = "Filter updated" respond_with(@dmail) end - private + private def ensure_ownership @dmail = Dmail.find(params[:dmail_id]) @@ -24,6 +24,10 @@ module Maintenance raise User::PrivilegeError.new end end + + def dmail_filter_params + params.require(:dmail_filter).permit(:words) + end end end end diff --git a/app/controllers/maintenance/user/email_notifications_controller.rb b/app/controllers/maintenance/user/email_notifications_controller.rb index 0452a8706..e2f00a53b 100644 --- a/app/controllers/maintenance/user/email_notifications_controller.rb +++ b/app/controllers/maintenance/user/email_notifications_controller.rb @@ -3,7 +3,7 @@ module Maintenance class EmailNotificationsController < ApplicationController class VerificationError < Exception ; end - before_filter :validate_sig, :only => [:destroy] + before_action :validate_sig, :only => [:destroy] rescue_from VerificationError, :with => :render_403 def show @@ -18,7 +18,7 @@ module Maintenance private def render_403 - render :nothing => true, :status => 403 + render plain: "", :status => 403 end def validate_sig diff --git a/app/controllers/maintenance/user/password_resets_controller.rb b/app/controllers/maintenance/user/password_resets_controller.rb index d11110714..79b7ca5fc 100644 --- a/app/controllers/maintenance/user/password_resets_controller.rb +++ b/app/controllers/maintenance/user/password_resets_controller.rb @@ -6,7 +6,7 @@ module Maintenance end def create - @nonce = UserPasswordResetNonce.create(params[:nonce]) + @nonce = UserPasswordResetNonce.create(nonce_params) if @nonce.errors.any? redirect_to new_maintenance_user_password_reset_path, :notice => @nonce.errors.full_messages.join("; ") else @@ -29,6 +29,10 @@ module Maintenance redirect_to new_maintenance_user_password_reset_path, :notice => "Invalid key" end end + + def nonce_params + params.fetch(:nonce, {}).permit([:email]) + end end end end diff --git a/app/controllers/mod_actions_controller.rb b/app/controllers/mod_actions_controller.rb index 97831be8b..d48071189 100644 --- a/app/controllers/mod_actions_controller.rb +++ b/app/controllers/mod_actions_controller.rb @@ -2,7 +2,7 @@ class ModActionsController < ApplicationController respond_to :html, :xml, :json def index - @mod_actions = ModAction.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @mod_actions = ModAction.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@mod_actions) end end diff --git a/app/controllers/moderator/bulk_reverts_controller.rb b/app/controllers/moderator/bulk_reverts_controller.rb index 2e8568618..78629b7fa 100644 --- a/app/controllers/moderator/bulk_reverts_controller.rb +++ b/app/controllers/moderator/bulk_reverts_controller.rb @@ -1,7 +1,7 @@ module Moderator class BulkRevertsController < ApplicationController - before_filter :moderator_only - before_filter :init_constraints + before_action :moderator_only + before_action :init_constraints helper PostVersionsHelper rescue_from BulkRevert::ConstraintTooGeneralError, :with => :tag_constraint_too_general diff --git a/app/controllers/moderator/dashboards_controller.rb b/app/controllers/moderator/dashboards_controller.rb index b7d7dcb3f..06bc255e9 100644 --- a/app/controllers/moderator/dashboards_controller.rb +++ b/app/controllers/moderator/dashboards_controller.rb @@ -1,6 +1,6 @@ module Moderator class DashboardsController < ApplicationController - before_filter :member_only + before_action :member_only helper :post_flags, :post_appeals def show diff --git a/app/controllers/moderator/invitations_controller.rb b/app/controllers/moderator/invitations_controller.rb index c0caf36e1..e76af41d5 100644 --- a/app/controllers/moderator/invitations_controller.rb +++ b/app/controllers/moderator/invitations_controller.rb @@ -1,6 +1,6 @@ module Moderator class InvitationsController < ApplicationController - before_filter :moderator_only + before_action :moderator_only def new end diff --git a/app/controllers/moderator/ip_addrs_controller.rb b/app/controllers/moderator/ip_addrs_controller.rb index 82085a56e..2add8f756 100644 --- a/app/controllers/moderator/ip_addrs_controller.rb +++ b/app/controllers/moderator/ip_addrs_controller.rb @@ -1,6 +1,6 @@ module Moderator class IpAddrsController < ApplicationController - before_filter :moderator_only + before_action :moderator_only def index @search = IpAddrSearch.new(params[:search]) diff --git a/app/controllers/moderator/post/approvals_controller.rb b/app/controllers/moderator/post/approvals_controller.rb index c0e18b644..3d24a5446 100644 --- a/app/controllers/moderator/post/approvals_controller.rb +++ b/app/controllers/moderator/post/approvals_controller.rb @@ -1,8 +1,8 @@ module Moderator module Post class ApprovalsController < ApplicationController - before_filter :approver_only - skip_before_filter :api_check + before_action :approver_only + skip_before_action :api_check respond_to :json, :xml, :js def create diff --git a/app/controllers/moderator/post/disapprovals_controller.rb b/app/controllers/moderator/post/disapprovals_controller.rb index dafdafb27..9795bea50 100644 --- a/app/controllers/moderator/post/disapprovals_controller.rb +++ b/app/controllers/moderator/post/disapprovals_controller.rb @@ -1,13 +1,20 @@ module Moderator module Post class DisapprovalsController < ApplicationController - before_filter :approver_only - skip_before_filter :api_check + before_action :approver_only + skip_before_action :api_check + respond_to :js, :json, :xml def create cookies.permanent[:moderated] = Time.now.to_i - @post = ::Post.find(params[:post_id]) - @post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user, :reason => params[:reason] || "disinterest", :message => params[:message]) + @post_disapproval = PostDisapproval.create(post_disapproval_params) + respond_with(@post_disapproval) + end + + private + + def post_disapproval_params + params.require(:post_disapproval).permit(%i[post_id reason message]) end end end diff --git a/app/controllers/moderator/post/posts_controller.rb b/app/controllers/moderator/post/posts_controller.rb index df660785d..09b3b95a0 100644 --- a/app/controllers/moderator/post/posts_controller.rb +++ b/app/controllers/moderator/post/posts_controller.rb @@ -1,9 +1,9 @@ module Moderator module Post class PostsController < ApplicationController - before_filter :approver_only, :only => [:delete, :undelete, :move_favorites, :ban, :unban, :confirm_delete, :confirm_move_favorites, :confirm_ban] - before_filter :admin_only, :only => [:expunge] - skip_before_filter :api_check + before_action :approver_only, :only => [:delete, :undelete, :move_favorites, :ban, :unban, :confirm_delete, :confirm_move_favorites, :confirm_ban] + before_action :admin_only, :only => [:expunge] + skip_before_action :api_check respond_to :html, :json, :xml diff --git a/app/controllers/moderator/post/queues_controller.rb b/app/controllers/moderator/post/queues_controller.rb index e274c19fb..c1d7d4254 100644 --- a/app/controllers/moderator/post/queues_controller.rb +++ b/app/controllers/moderator/post/queues_controller.rb @@ -4,8 +4,8 @@ module Moderator RANDOM_COUNT = 12 respond_to :html, :json - before_filter :approver_only - skip_before_filter :api_check + before_action :approver_only + skip_before_action :api_check def show cookies.permanent[:moderated] = Time.now.to_i diff --git a/app/controllers/moderator/tags_controller.rb b/app/controllers/moderator/tags_controller.rb index c5361acbc..68cc562d7 100644 --- a/app/controllers/moderator/tags_controller.rb +++ b/app/controllers/moderator/tags_controller.rb @@ -1,6 +1,6 @@ module Moderator class TagsController < ApplicationController - before_filter :moderator_only + before_action :moderator_only rescue_from TagBatchChange::Error, :with => :error def edit diff --git a/app/controllers/news_updates_controller.rb b/app/controllers/news_updates_controller.rb index f9a85fb30..a00389ea3 100644 --- a/app/controllers/news_updates_controller.rb +++ b/app/controllers/news_updates_controller.rb @@ -1,5 +1,5 @@ class NewsUpdatesController < ApplicationController - before_filter :admin_only + before_action :admin_only respond_to :html def index @@ -14,7 +14,7 @@ class NewsUpdatesController < ApplicationController def update @news_update = NewsUpdate.find(params[:id]) - @news_update.update_attributes(params[:news_update]) + @news_update.update(news_update_params) respond_with(@news_update, :location => news_updates_path) end @@ -24,7 +24,7 @@ class NewsUpdatesController < ApplicationController end def create - @news_update = NewsUpdate.create(params[:news_update]) + @news_update = NewsUpdate.create(news_update_params) respond_with(@news_update, :location => news_updates_path) end @@ -35,4 +35,10 @@ class NewsUpdatesController < ApplicationController format.js end end + + private + + def news_update_params + params.require(:news_update).permit([:message]) + end end diff --git a/app/controllers/note_versions_controller.rb b/app/controllers/note_versions_controller.rb index 148884fce..76ee6e28b 100644 --- a/app/controllers/note_versions_controller.rb +++ b/app/controllers/note_versions_controller.rb @@ -2,7 +2,7 @@ class NoteVersionsController < ApplicationController respond_to :html, :xml, :json def index - @note_versions = NoteVersion.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @note_versions = NoteVersion.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@note_versions) do |format| format.html { @note_versions = @note_versions.includes(:updater) } format.xml do diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 56eded3c7..3db3e6a99 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,12 +1,12 @@ class NotesController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show, :search] + before_action :member_only, :except => [:index, :show, :search] def search end def index - @notes = Note.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @notes = Note.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@notes) do |format| format.html { @notes = @notes.includes(:creator) } format.xml do @@ -23,7 +23,7 @@ class NotesController < ApplicationController end def create - @note = Note.create(create_params) + @note = Note.create(note_params(:create)) respond_with(@note) do |fmt| fmt.json do if @note.errors.any? @@ -37,7 +37,7 @@ class NotesController < ApplicationController def update @note = Note.find(params[:id]) - @note.update_attributes(update_params) + @note.update(note_params(:update)) respond_with(@note) do |format| format.json do if @note.errors.any? @@ -62,12 +62,12 @@ class NotesController < ApplicationController respond_with(@note) end -private - def update_params - params.require(:note).permit(:x, :y, :width, :height, :body) - end + private - def create_params - params.require(:note).permit(:x, :y, :width, :height, :body, :post_id, :html_id) + def note_params(context) + permitted_params = %i[x y width height body] + permitted_params += %i[post_id html_id] if context == :create + + params.require(:note).permit(permitted_params) end end diff --git a/app/controllers/pool_elements_controller.rb b/app/controllers/pool_elements_controller.rb index 28d56c940..464d83df9 100644 --- a/app/controllers/pool_elements_controller.rb +++ b/app/controllers/pool_elements_controller.rb @@ -1,6 +1,6 @@ class PoolElementsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only + before_action :member_only def create @pool = Pool.find_by_name(params[:pool_name]) || Pool.find_by_id(params[:pool_id]) diff --git a/app/controllers/pool_orders_controller.rb b/app/controllers/pool_orders_controller.rb index f4352d2da..10b5b6a8c 100644 --- a/app/controllers/pool_orders_controller.rb +++ b/app/controllers/pool_orders_controller.rb @@ -1,6 +1,6 @@ class PoolOrdersController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only + before_action :member_only def edit @pool = Pool.find(params[:pool_id]) diff --git a/app/controllers/pool_versions_controller.rb b/app/controllers/pool_versions_controller.rb index 3013cdd16..3b59f7679 100644 --- a/app/controllers/pool_versions_controller.rb +++ b/app/controllers/pool_versions_controller.rb @@ -1,13 +1,13 @@ class PoolVersionsController < ApplicationController respond_to :html, :xml, :json - before_filter :check_availabililty + before_action :check_availabililty def index if params[:search] && params[:search][:pool_id].present? @pool = Pool.find(params[:search][:pool_id]) end - @pool_versions = PoolArchive.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @pool_versions = PoolArchive.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@pool_versions) do |format| format.xml do render :xml => @pool_versions.to_xml(:root => "pool-versions") diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index 7d7ced9c0..1d5466b7e 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -1,7 +1,7 @@ class PoolsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show, :gallery] - before_filter :builder_only, :only => [:destroy] + before_action :member_only, :except => [:index, :show, :gallery] + before_action :builder_only, :only => [:destroy] def new @pool = Pool.new @@ -17,7 +17,7 @@ class PoolsController < ApplicationController end def index - @pools = Pool.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @pools = Pool.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@pools) do |format| format.xml do render :xml => @pools.to_xml(:root => "pools") @@ -27,7 +27,7 @@ class PoolsController < ApplicationController def gallery limit = params[:limit] || CurrentUser.user.per_page - @pools = Pool.series.search(params[:search]).reorder("updated_at desc").paginate(params[:page], :limit => limit, :search_count => params[:search]) + @pools = Pool.series.search(search_params).reorder("updated_at desc").paginate(params[:page], :limit => limit, :search_count => params[:search]) @post_set = PostSets::PoolGallery.new(@pools) end @@ -38,7 +38,7 @@ class PoolsController < ApplicationController end def create - @pool = Pool.create(params[:pool]) + @pool = Pool.create(pool_params) flash[:notice] = @pool.valid? ? "Pool created" : @pool.errors.full_messages.join("; ") respond_with(@pool) end @@ -46,7 +46,7 @@ class PoolsController < ApplicationController def update # need to do this in order for synchronize! to work correctly @pool = Pool.find(params[:id]) - @pool.attributes = params[:pool] + @pool.attributes = pool_params @pool.synchronize @pool.save unless @pool.errors.any? @@ -86,4 +86,11 @@ class PoolsController < ApplicationController format.js end end + + private + + def pool_params + permitted_params = %i[name description category is_active post_ids] + params.require(:pool).permit(permitted_params) + end end diff --git a/app/controllers/post_appeals_controller.rb b/app/controllers/post_appeals_controller.rb index 0ccb4dd65..18a14494b 100644 --- a/app/controllers/post_appeals_controller.rb +++ b/app/controllers/post_appeals_controller.rb @@ -1,5 +1,5 @@ class PostAppealsController < ApplicationController - before_filter :member_only, :except => [:index, :show] + before_action :member_only, :except => [:index, :show] respond_to :html, :xml, :json, :js def new @@ -8,7 +8,7 @@ class PostAppealsController < ApplicationController end def index - @post_appeals = PostAppeal.includes(:creator).search(params[:search]).includes(post: [:appeals, :uploader, :approver]) + @post_appeals = PostAppeal.includes(:creator).search(search_params).includes(post: [:appeals, :uploader, :approver]) @post_appeals = @post_appeals.paginate(params[:page], limit: params[:limit]) respond_with(@post_appeals) do |format| format.xml do @@ -18,7 +18,7 @@ class PostAppealsController < ApplicationController end def create - @post_appeal = PostAppeal.create(params[:post_appeal]) + @post_appeal = PostAppeal.create(post_appeal_params) respond_with(@post_appeal) end @@ -26,4 +26,10 @@ class PostAppealsController < ApplicationController @post_appeal = PostAppeal.find(params[:id]) respond_with(@post_appeal) end + + private + + def post_appeal_params + params.fetch(:post_appeal, {}).permit(%i[post_id reason]) + end end diff --git a/app/controllers/post_flags_controller.rb b/app/controllers/post_flags_controller.rb index 7793419b8..b80bad83b 100644 --- a/app/controllers/post_flags_controller.rb +++ b/app/controllers/post_flags_controller.rb @@ -1,5 +1,5 @@ class PostFlagsController < ApplicationController - before_filter :member_only, :except => [:index, :show] + before_action :member_only, :except => [:index, :show] respond_to :html, :xml, :json, :js def new @@ -8,7 +8,7 @@ class PostFlagsController < ApplicationController end def index - @post_flags = PostFlag.search(params[:search]).includes(:creator, post: [:flags, :uploader, :approver]) + @post_flags = PostFlag.search(search_params).includes(:creator, post: [:flags, :uploader, :approver]) @post_flags = @post_flags.paginate(params[:page], limit: params[:limit]) respond_with(@post_flags) do |format| format.xml do @@ -18,7 +18,7 @@ class PostFlagsController < ApplicationController end def create - @post_flag = PostFlag.create(params[:post_flag].merge(:is_resolved => false)) + @post_flag = PostFlag.create(post_flag_params) respond_with(@post_flag) end @@ -26,4 +26,10 @@ class PostFlagsController < ApplicationController @post_flag = PostFlag.find(params[:id]) respond_with(@post_flag) end + + private + + def post_flag_params + params.require(:post_flag).permit(%i[post_id reason]) + end end diff --git a/app/controllers/post_replacements_controller.rb b/app/controllers/post_replacements_controller.rb index eebbedd81..c83fd7c8b 100644 --- a/app/controllers/post_replacements_controller.rb +++ b/app/controllers/post_replacements_controller.rb @@ -1,6 +1,6 @@ class PostReplacementsController < ApplicationController respond_to :html, :xml, :json - before_filter :moderator_only, except: [:index] + before_action :moderator_only, except: [:index] def new @post = Post.find(params[:post_id]) @@ -23,7 +23,7 @@ class PostReplacementsController < ApplicationController def index params[:search][:post_id] = params.delete(:post_id) if params.has_key?(:post_id) - @post_replacements = PostReplacement.search(params[:search]).paginate(params[:page], limit: params[:limit]) + @post_replacements = PostReplacement.search(search_params).paginate(params[:page], limit: params[:limit]) respond_with(@post_replacements) end diff --git a/app/controllers/post_versions_controller.rb b/app/controllers/post_versions_controller.rb index f1ba6a38c..0bcce0418 100644 --- a/app/controllers/post_versions_controller.rb +++ b/app/controllers/post_versions_controller.rb @@ -1,10 +1,10 @@ class PostVersionsController < ApplicationController - before_filter :member_only - before_filter :check_availabililty + before_action :member_only + before_action :check_availabililty respond_to :html, :xml, :json def index - @post_versions = PostArchive.includes(:updater, post: [:versions]).search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @post_versions = PostArchive.includes(:updater, post: [:versions]).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@post_versions) do |format| format.xml do render :xml => @post_versions.to_xml(:root => "post-versions") diff --git a/app/controllers/post_votes_controller.rb b/app/controllers/post_votes_controller.rb index 07c2dd0c4..b90577460 100644 --- a/app/controllers/post_votes_controller.rb +++ b/app/controllers/post_votes_controller.rb @@ -1,6 +1,6 @@ class PostVotesController < ApplicationController - before_filter :voter_only - skip_before_filter :api_check + before_action :voter_only + skip_before_action :api_check def create @post = Post.find(params[:post_id]) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index e11c8c36d..7bf2dd475 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,6 +1,6 @@ class PostsController < ApplicationController - before_filter :member_only, :except => [:show, :show_seq, :index, :home, :random] - before_filter :builder_only, :only => [:copy_notes] + before_action :member_only, :except => [:show, :show_seq, :index, :home, :random] + before_action :builder_only, :only => [:copy_notes] respond_to :html, :xml, :json def index @@ -46,10 +46,7 @@ class PostsController < ApplicationController def update @post = Post.find(params[:id]) - if @post.visible? - @post.update_attributes(params[:post], :as => CurrentUser.role) - end - + @post.update(post_params) if @post.visible? save_recent_tags respond_with_post_after_update(@post) end @@ -131,4 +128,18 @@ private end end end + + def post_params + permitted_params = %i[ + tag_string old_tag_string + parent_id old_parent_id + source old_source + rating old_rating + has_embedded_notes + ] + permitted_params += %i[is_rating_locked is_note_locked] if CurrentUser.is_builder? + permitted_params += %i[is_status_locked] if CurrentUser.is_admin? + + params.require(:post).permit(permitted_params) + end end diff --git a/app/controllers/related_tags_controller.rb b/app/controllers/related_tags_controller.rb index 16cf5dea6..4a1cff36b 100644 --- a/app/controllers/related_tags_controller.rb +++ b/app/controllers/related_tags_controller.rb @@ -1,7 +1,7 @@ class RelatedTagsController < ApplicationController respond_to :json respond_to :html, :only=>[:show] - before_filter :require_reportbooru_key, only: [:update] + before_action :require_reportbooru_key, only: [:update] def show @query = RelatedTagQuery.new(params[:query].to_s.downcase, params[:category]) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 1749178af..e3fdb95d8 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,7 +1,7 @@ class ReportsController < ApplicationController - before_filter :member_only, :except => [:upload_tags] - before_filter :gold_only, :only => [:similar_users] - before_filter :moderator_only, :only => [:post_versions, :post_versions_create, :down_voting_post_report, :down_voting_post_report_create] + before_action :member_only, :except => [:upload_tags] + before_action :gold_only, :only => [:similar_users] + before_action :moderator_only, :only => [:post_versions, :post_versions_create, :down_voting_post_report, :down_voting_post_report_create] def uploads @report = Reports::Uploads.new(params[:min_date], params[:max_date], params[:queries]) diff --git a/app/controllers/saved_searches_controller.rb b/app/controllers/saved_searches_controller.rb index 8da52410a..ea80b5be8 100644 --- a/app/controllers/saved_searches_controller.rb +++ b/app/controllers/saved_searches_controller.rb @@ -1,5 +1,5 @@ class SavedSearchesController < ApplicationController - before_filter :check_availability + before_action :check_availability respond_to :html, :xml, :json, :js def index @@ -22,11 +22,7 @@ class SavedSearchesController < ApplicationController end def create - @saved_search = saved_searches.create!(:query => params[:saved_search_tags], :label_string => params[:saved_search_labels]) - if params[:saved_search_disable_labels] - CurrentUser.disable_categorized_saved_searches = true - CurrentUser.save - end + @saved_search = saved_searches.create(saved_search_params) respond_with(@saved_search) end @@ -42,11 +38,12 @@ class SavedSearchesController < ApplicationController def update @saved_search = saved_searches.find(params[:id]) - @saved_search.update_attributes(params[:saved_search]) + @saved_search.update(saved_search_params) respond_with(@saved_search, :location => saved_searches_path) end -private + private + def saved_searches CurrentUser.user.saved_searches end @@ -56,4 +53,8 @@ private raise NotImplementedError.new("Listbooru service is not configured. Saved searches are not available.") end end + + def saved_search_params + params.require(:saved_search).permit(%i[query label_string disable_labels]) + end end diff --git a/app/controllers/tag_alias_corrections_controller.rb b/app/controllers/tag_alias_corrections_controller.rb index fdfb294c0..e61f9448b 100644 --- a/app/controllers/tag_alias_corrections_controller.rb +++ b/app/controllers/tag_alias_corrections_controller.rb @@ -1,5 +1,5 @@ class TagAliasCorrectionsController < ApplicationController - before_filter :builder_only + before_action :builder_only def create @correction = TagAliasCorrection.new(params[:tag_alias_id]) diff --git a/app/controllers/tag_alias_requests_controller.rb b/app/controllers/tag_alias_requests_controller.rb index 7073d0c15..e776c3fd4 100644 --- a/app/controllers/tag_alias_requests_controller.rb +++ b/app/controllers/tag_alias_requests_controller.rb @@ -1,11 +1,11 @@ class TagAliasRequestsController < ApplicationController - before_filter :member_only + before_action :member_only def new end def create - @tag_alias_request = TagAliasRequest.new(params[:tag_alias_request]) + @tag_alias_request = TagAliasRequest.new(tar_params) @tag_alias_request.create if @tag_alias_request.invalid? @@ -14,4 +14,10 @@ class TagAliasRequestsController < ApplicationController redirect_to forum_topic_path(@tag_alias_request.forum_topic) end end + +private + + def tar_params + params.require(:tag_alias_request).permit(:antecedent_name, :consequent_name, :reason, :skip_secondary_validations) + end end diff --git a/app/controllers/tag_aliases_controller.rb b/app/controllers/tag_aliases_controller.rb index 8913a806b..ab8c5be0c 100644 --- a/app/controllers/tag_aliases_controller.rb +++ b/app/controllers/tag_aliases_controller.rb @@ -1,5 +1,5 @@ class TagAliasesController < ApplicationController - before_filter :admin_only, :only => [:approve, :new, :create] + before_action :admin_only, :only => [:approve, :new, :create] respond_to :html, :xml, :json, :js def show @@ -15,14 +15,14 @@ class TagAliasesController < ApplicationController @tag_alias = TagAlias.find(params[:id]) if @tag_alias.is_pending? && @tag_alias.editable_by?(CurrentUser.user) - @tag_alias.update_attributes(update_params) + @tag_alias.update(tag_alias_params) end respond_with(@tag_alias) end def index - @tag_aliases = TagAlias.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @tag_aliases = TagAlias.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@tag_aliases) do |format| format.xml do render :xml => @tag_aliases.to_xml(:root => "tag-aliases") @@ -48,7 +48,7 @@ class TagAliasesController < ApplicationController private - def update_params - params.require(:tag_alias).permit(:antecedent_name, :consequent_name, :forum_topic_id) + def tag_alias_params + params.require(:tag_alias).permit(%i[antecedent_name consequent_name forum_topic_id skip_secondary_validations]) end end diff --git a/app/controllers/tag_corrections_controller.rb b/app/controllers/tag_corrections_controller.rb index 2f6303937..7bda603c6 100644 --- a/app/controllers/tag_corrections_controller.rb +++ b/app/controllers/tag_corrections_controller.rb @@ -1,5 +1,5 @@ class TagCorrectionsController < ApplicationController - before_filter :builder_only + before_action :builder_only def new @correction = TagCorrection.new(params[:tag_id]) diff --git a/app/controllers/tag_implication_requests_controller.rb b/app/controllers/tag_implication_requests_controller.rb index 281001c44..a395b4ad7 100644 --- a/app/controllers/tag_implication_requests_controller.rb +++ b/app/controllers/tag_implication_requests_controller.rb @@ -1,11 +1,11 @@ class TagImplicationRequestsController < ApplicationController - before_filter :member_only + before_action :member_only def new end def create - @tag_implication_request = TagImplicationRequest.new(params[:tag_implication_request]) + @tag_implication_request = TagImplicationRequest.new(tir_params) @tag_implication_request.create if @tag_implication_request.invalid? @@ -14,4 +14,10 @@ class TagImplicationRequestsController < ApplicationController redirect_to forum_topic_path(@tag_implication_request.forum_topic) end end + +private + + def tir_params + params.require(:tag_implication_request).permit(:antecedent_name, :consequent_name, :reason, :skip_secondary_validations) + end end diff --git a/app/controllers/tag_implications_controller.rb b/app/controllers/tag_implications_controller.rb index 387d984de..0c530a068 100644 --- a/app/controllers/tag_implications_controller.rb +++ b/app/controllers/tag_implications_controller.rb @@ -1,5 +1,5 @@ class TagImplicationsController < ApplicationController - before_filter :admin_only, :only => [:new, :create, :approve] + before_action :admin_only, :only => [:new, :create, :approve] respond_to :html, :xml, :json, :js def show @@ -15,14 +15,14 @@ class TagImplicationsController < ApplicationController @tag_implication = TagImplication.find(params[:id]) if @tag_implication.is_pending? && @tag_implication.editable_by?(CurrentUser.user) - @tag_implication.update_attributes(update_params) + @tag_implication.update(tag_implication_params) end respond_with(@tag_implication) end def index - @tag_implications = TagImplication.search(params[:search]).paginate(params[:page], :limit => params[:limit]) + @tag_implications = TagImplication.search(search_params).paginate(params[:page], :limit => params[:limit]) respond_with(@tag_implications) do |format| format.xml do render :xml => @tag_implications.to_xml(:root => "tag-implications") @@ -53,7 +53,7 @@ class TagImplicationsController < ApplicationController private - def update_params - params.require(:tag_implication).permit(:antecedent_name, :consequent_name, :forum_topic_id) + def tag_implication_params + params.require(:tag_implication).permit(%i[antecedent_name consequent_name forum_topic_id skip_secondary_validations]) end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index ee2136d93..65a951e93 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,5 @@ class TagsController < ApplicationController - before_filter :member_only, :only => [:edit, :update] + before_action :member_only, :only => [:edit, :update] respond_to :html, :xml, :json def edit @@ -9,7 +9,7 @@ class TagsController < ApplicationController end def index - @tags = Tag.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@tags) do |format| format.xml do render :xml => @tags.to_xml(:root => "tags") @@ -35,7 +35,7 @@ class TagsController < ApplicationController def update @tag = Tag.find(params[:id]) check_privilege(@tag) - @tag.update_attributes(params[:tag], :as => CurrentUser.role) + @tag.update(tag_params) respond_with(@tag) end @@ -43,4 +43,11 @@ private def check_privilege(tag) raise User::PrivilegeError unless tag.editable_by?(CurrentUser.user) end + + def tag_params + permitted_params = [:category] + permitted_params << :is_locked if CurrentUser.is_moderator? + + params.require(:tag).permit(permitted_params) + end end diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 55ace2f4e..dd55d2ad6 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -1,5 +1,5 @@ class UploadsController < ApplicationController - before_filter :member_only, except: [:index, :show] + before_action :member_only, except: [:index, :show] respond_to :html, :xml, :json, :js def new @@ -31,7 +31,7 @@ class UploadsController < ApplicationController end def index - @search = Upload.search(params[:search]) + @search = Upload.search(search_params) @uploads = @search.paginate(params[:page], :limit => params[:limit]) respond_with(@uploads) do |format| format.xml do @@ -52,7 +52,7 @@ class UploadsController < ApplicationController end def create - @upload = Upload.create(params[:upload].merge(:server => Socket.gethostname)) + @upload = Upload.create(upload_params) if @upload.errors.empty? post = @upload.process! @@ -72,7 +72,8 @@ class UploadsController < ApplicationController respond_with(@upload) end -protected + private + def find_post_by_url(normalized_url) if normalized_url.nil? Post.where("SourcePattern(lower(posts.source)) = ?", params[:url]).first @@ -89,4 +90,14 @@ protected cookies[:recent_tags_with_categories] = Tag.categories_for(tags).to_a.flatten.join(" ") end end + + def upload_params + permitted_params = %i[ + file source tag_string rating status parent_id artist_commentary_title + artist_commentary_desc include_artist_commentary referer_url + md5_confirmation as_pending + ] + + params.require(:upload).permit(permitted_params) + end end diff --git a/app/controllers/user_feedbacks_controller.rb b/app/controllers/user_feedbacks_controller.rb index a953fb66c..e62a4fdf6 100644 --- a/app/controllers/user_feedbacks_controller.rb +++ b/app/controllers/user_feedbacks_controller.rb @@ -1,9 +1,9 @@ class UserFeedbacksController < ApplicationController - before_filter :gold_only, :only => [:new, :edit, :create, :update, :destroy] + before_action :gold_only, :only => [:new, :edit, :create, :update, :destroy] respond_to :html, :xml, :json def new - @user_feedback = UserFeedback.new(params[:user_feedback]) + @user_feedback = UserFeedback.new(user_feedback_params(:create)) respond_with(@user_feedback) end @@ -19,7 +19,7 @@ class UserFeedbacksController < ApplicationController end def index - @search = UserFeedback.visible.search(params[:search]) + @search = UserFeedback.visible.search(search_params) @user_feedbacks = @search.paginate(params[:page], :limit => params[:limit]) respond_with(@user_feedbacks) do |format| format.xml do @@ -29,14 +29,14 @@ class UserFeedbacksController < ApplicationController end def create - @user_feedback = UserFeedback.create(params[:user_feedback]) + @user_feedback = UserFeedback.create(user_feedback_params(:create)) respond_with(@user_feedback) end def update @user_feedback = UserFeedback.visible.find(params[:id]) check_privilege(@user_feedback) - @user_feedback.update_attributes(params[:user_feedback]) + @user_feedback.update(user_feedback_params(:update)) respond_with(@user_feedback) end @@ -47,8 +47,16 @@ class UserFeedbacksController < ApplicationController respond_with(@user_feedback) end -private + private + def check_privilege(user_feedback) raise User::PrivilegeError unless user_feedback.editable_by?(CurrentUser.user) end + + def user_feedback_params(context) + permitted_params = %i[body category] + permitted_params += %i[user_id user_name] if context == :create + + params.require(:user_feedback).permit(permitted_params) + end end diff --git a/app/controllers/user_name_change_requests_controller.rb b/app/controllers/user_name_change_requests_controller.rb index 7c5c79378..6e1f290cd 100644 --- a/app/controllers/user_name_change_requests_controller.rb +++ b/app/controllers/user_name_change_requests_controller.rb @@ -1,20 +1,16 @@ class UserNameChangeRequestsController < ApplicationController - before_filter :member_only, :only => [:index, :show] - before_filter :gold_only, :only => [:new, :create] - before_filter :admin_only, :only => [:approve, :reject] + before_action :member_only, :only => [:index, :show] + before_action :gold_only, :only => [:new, :create] + before_action :admin_only, :only => [:approve, :reject] respond_to :html, :json, :xml def new + @change_request = UserNameChangeRequest.new(change_request_params) + respond_with(@change_request) end def create - @change_request = UserNameChangeRequest.create( - :user_id => CurrentUser.user.id, - :original_name => CurrentUser.user.name, - :status => "pending", - :change_reason => params[:reason], - :desired_name => params[:desired_name] - ) + @change_request = UserNameChangeRequest.create(change_request_params) if @change_request.errors.any? render :action => "new" @@ -47,9 +43,14 @@ class UserNameChangeRequestsController < ApplicationController redirect_to user_name_change_request_path(@change_request), :notice => "Name change request rejected" end -private + private + def check_privileges!(change_request) return if CurrentUser.is_admin? raise User::PrivilegeError if change_request.user_id != CurrentUser.user.id end + + def change_request_params + params.fetch(:user_name_change_request, {}).permit(%i[desired_name change_reason]) + end end diff --git a/app/controllers/user_reverts_controller.rb b/app/controllers/user_reverts_controller.rb index 6f1513426..a4bc94015 100644 --- a/app/controllers/user_reverts_controller.rb +++ b/app/controllers/user_reverts_controller.rb @@ -1,5 +1,5 @@ class UserRevertsController < ApplicationController - before_filter :moderator_only + before_action :moderator_only def new @user = User.find(params[:user_id]) diff --git a/app/controllers/user_upgrades_controller.rb b/app/controllers/user_upgrades_controller.rb index 987e8890d..b126d2aee 100644 --- a/app/controllers/user_upgrades_controller.rb +++ b/app/controllers/user_upgrades_controller.rb @@ -1,5 +1,5 @@ class UserUpgradesController < ApplicationController - before_filter :member_only, :only => [:new, :show] + before_action :member_only, :only => [:new, :show] helper_method :user force_ssl :if => :ssl_enabled? skip_before_action :verify_authenticity_token, only: [:create] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 598e0d870..9e6dc0317 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController respond_to :html, :xml, :json - skip_before_filter :api_check + skip_before_action :api_check def new @user = User.new @@ -22,7 +22,7 @@ class UsersController < ApplicationController redirect_to user_path(@user) end else - @users = User.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @users = User.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@users) do |format| format.xml do render :xml => @users.to_xml(:root => "users") @@ -41,8 +41,7 @@ class UsersController < ApplicationController end def create - @user = User.new(params[:user], :as => CurrentUser.role) - @user.last_ip_addr = request.remote_ip + @user = User.new(user_params(:create)) if !Danbooru.config.enable_recaptcha? || verify_recaptcha(model: @user) @user.save if @user.errors.empty? @@ -61,7 +60,7 @@ class UsersController < ApplicationController def update @user = User.find(params[:id]) check_privilege(@user) - @user.update_attributes(params[:user].except(:name), :as => CurrentUser.role) + @user.update(user_params(:update)) cookies.delete(:favorite_tags) cookies.delete(:favorite_tags_with_categories) if @user.errors.any? @@ -75,12 +74,34 @@ class UsersController < ApplicationController def cache @user = User.find(params[:id]) @user.update_cache - render :nothing => true + render plain: "" end -private + private def check_privilege(user) raise User::PrivilegeError unless (user.id == CurrentUser.id || CurrentUser.is_admin?) end + + def user_params(context) + permitted_params = %i[ + password old_password password_confirmation email + comment_threshold default_image_size favorite_tags blacklisted_tags + time_zone per_page custom_style + + receive_email_notifications always_resize_images enable_post_navigation + new_post_navigation_layout enable_privacy_mode + enable_sequential_post_navigation hide_deleted_posts style_usernames + enable_auto_complete show_deleted_children + disable_categorized_saved_searches disable_tagged_filenames + enable_recent_searches disable_cropped_thumbnails disable_mobile_gestures + enable_safe_mode disable_responsive_mode + ] + + permitted_params += [dmail_filter_attributes: %i[id words]] + permitted_params << :name if context == :create + permitted_params << :level if CurrentUser.is_admin? + + params.require(:user).permit(permitted_params) + end end diff --git a/app/controllers/wiki_page_versions_controller.rb b/app/controllers/wiki_page_versions_controller.rb index 125f4f7e7..34398adb9 100644 --- a/app/controllers/wiki_page_versions_controller.rb +++ b/app/controllers/wiki_page_versions_controller.rb @@ -2,7 +2,7 @@ class WikiPageVersionsController < ApplicationController respond_to :html, :xml, :json def index - @wiki_page_versions = WikiPageVersion.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @wiki_page_versions = WikiPageVersion.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@wiki_page_versions) do |format| format.xml do render :xml => @wiki_page_versions.to_xml(:root => "wiki-page-versions") diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index ae707acc9..9220e4412 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -1,11 +1,11 @@ class WikiPagesController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :search, :show, :show_or_new] - before_filter :builder_only, :only => [:destroy] - before_filter :normalize_search_params, :only => [:index] + before_action :member_only, :except => [:index, :search, :show, :show_or_new] + before_action :builder_only, :only => [:destroy] + before_action :normalize_search_params, :only => [:index] def new - @wiki_page = WikiPage.new(params[:wiki_page]) + @wiki_page = WikiPage.new(wiki_page_params) respond_with(@wiki_page) end @@ -15,7 +15,7 @@ class WikiPagesController < ApplicationController end def index - @wiki_pages = WikiPage.search(params[:search]).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) + @wiki_pages = WikiPage.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search]) respond_with(@wiki_pages) do |format| format.html do if params[:page].nil? || params[:page].to_i == 1 @@ -50,13 +50,13 @@ class WikiPagesController < ApplicationController end def create - @wiki_page = WikiPage.create(params[:wiki_page]) + @wiki_page = WikiPage.create(wiki_page_params) respond_with(@wiki_page) end def update @wiki_page = WikiPage.find(params[:id]) - @wiki_page.update_attributes(params[:wiki_page]) + @wiki_page.update(wiki_page_params) respond_with(@wiki_page) end @@ -85,11 +85,19 @@ class WikiPagesController < ApplicationController end end -private + private + def normalize_search_params if params[:title] params[:search] ||= {} params[:search][:title] = params.delete(:title) end end + + def wiki_page_params + permitted_params = %i[title body other_names skip_secondary_validations] + permitted_params += %i[is_locked is_deleted] if CurrentUser.is_builder? + + params.require(:wiki_page).permit(permitted_params) + end end diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index c1412cb90..ff31e8db3 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -230,7 +230,7 @@ class AnonymousUser end def saved_searches - [] + SavedSearch.where(false) end def has_saved_searches? diff --git a/app/logical/current_user.rb b/app/logical/current_user.rb index 194a721b3..fdc3a7138 100644 --- a/app/logical/current_user.rb +++ b/app/logical/current_user.rb @@ -14,6 +14,10 @@ class CurrentUser end end + def self.as(user, &block) + scoped(user, &block) + end + def self.as_admin(&block) if block_given? scoped(User.admins.first, "127.0.0.1", &block) @@ -83,10 +87,6 @@ class CurrentUser end def self.method_missing(method, *params, &block) - if user.respond_to?(method) - user.__send__(method, *params, &block) - else - super - end + user.__send__(method, *params, &block) end end diff --git a/app/logical/forum_updater.rb b/app/logical/forum_updater.rb index 036a7f0b9..6ac8c8f35 100644 --- a/app/logical/forum_updater.rb +++ b/app/logical/forum_updater.rb @@ -21,10 +21,7 @@ class ForumUpdater end def create_response(body) - forum_topic.posts.create({ - :body => body, - :skip_mention_notifications => true - }, :without_protection => true) + forum_topic.posts.create(body: body, skip_mention_notifications: true) end def update_title(title_tag) @@ -34,6 +31,6 @@ class ForumUpdater end def update_post(body) - forum_post.update({:body => "#{forum_post.body}\n\nEDIT: #{body}", :skip_mention_notifications => true }, :without_protection => true) + forum_post.update(body: "#{forum_post.body}\n\nEDIT: #{body}", skip_mention_notifications: true) end end diff --git a/app/logical/mentionable.rb b/app/logical/mentionable.rb index 9a2c9613d..f6dda15e9 100644 --- a/app/logical/mentionable.rb +++ b/app/logical/mentionable.rb @@ -23,11 +23,11 @@ module Mentionable def queue_mention_messages message_field = self.class.mentionable_option(:message_field) - return if !send("#{message_field}_changed?") + return if !send(:saved_change_to_attribute?, message_field) return if self.skip_mention_notifications text = send(message_field) - text_was = send("#{message_field}_was") + text_was = send(:attribute_before_last_save, message_field) names = DText.parse_mentions(text) - DText.parse_mentions(text_was) diff --git a/app/logical/post_pruner.rb b/app/logical/post_pruner.rb index 18c8053f8..f80fdb401 100644 --- a/app/logical/post_pruner.rb +++ b/app/logical/post_pruner.rb @@ -36,6 +36,6 @@ protected end def prune_mod_actions! - ModAction.destroy_all(["creator_id = ? and description like ?", User.system.id, "deleted post %"]) + ModAction.where(["creator_id = ? and description like ?", User.system.id, "deleted post %"]).destroy_all end end diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index ff7ae1c80..1bf302a1c 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -291,13 +291,13 @@ class PostQueryBuilder if q[:note_updater_ids] q[:note_updater_ids].each do |note_updater_id| - relation = relation.where("posts.id IN (?)", NoteVersion.unscoped.where("updater_id = ?", note_updater_id).select("post_id").uniq) + relation = relation.where("posts.id IN (?)", NoteVersion.unscoped.where("updater_id = ?", note_updater_id).select("post_id").distinct) end end if q[:artcomm_ids] q[:artcomm_ids].each do |artcomm_id| - relation = relation.where("posts.id IN (?)", ArtistCommentaryVersion.unscoped.where("updater_id = ?", artcomm_id).select("post_id").uniq) + relation = relation.where("posts.id IN (?)", ArtistCommentaryVersion.unscoped.where("updater_id = ?", artcomm_id).select("post_id").distinct) end end diff --git a/app/logical/session_loader.rb b/app/logical/session_loader.rb index 583055577..ce449d858 100644 --- a/app/logical/session_loader.rb +++ b/app/logical/session_loader.rb @@ -14,7 +14,9 @@ class SessionLoader CurrentUser.user = AnonymousUser.new CurrentUser.ip_addr = request.remote_ip - if session[:user_id] + if Rails.env.test? && Thread.current[:test_user_id] + load_for_test(Thread.current[:test_user_id]) + elsif session[:user_id] load_session_user elsif cookie_password_hash_valid? load_cookie_user @@ -31,6 +33,11 @@ class SessionLoader end private + + def load_for_test(user_id) + CurrentUser.user = User.find(user_id) + CurrentUser.ip_addr = "127.0.0.1" + end def set_statement_timeout timeout = CurrentUser.user.statement_timeout diff --git a/app/logical/sources/strategies/twitter.rb b/app/logical/sources/strategies/twitter.rb index 090d8736b..da146c97b 100644 --- a/app/logical/sources/strategies/twitter.rb +++ b/app/logical/sources/strategies/twitter.rb @@ -69,7 +69,7 @@ module Sources::Strategies # https://twitter.com/motty08111213/status/943446161586733056 def self.status_id_from_url(url) if url =~ %r{\Ahttps?://(?:mobile\.)?twitter\.com/(?:i/web|\w+)/status/(\d+)}i - $1.to_i + $1 else nil end diff --git a/app/logical/tag_alias_request.rb b/app/logical/tag_alias_request.rb index 6c37f7063..394c79c8c 100644 --- a/app/logical/tag_alias_request.rb +++ b/app/logical/tag_alias_request.rb @@ -75,7 +75,7 @@ class TagAliasRequest end def skip_secondary_validations=(v) - if v == "1" or v == true + if v == "1" or v == true or v =~ /t/ @skip_secondary_validations = true else @skip_secondary_validations = false diff --git a/app/logical/tag_implication_request.rb b/app/logical/tag_implication_request.rb index 1d2b44de7..6262a85c0 100644 --- a/app/logical/tag_implication_request.rb +++ b/app/logical/tag_implication_request.rb @@ -75,7 +75,7 @@ class TagImplicationRequest end def skip_secondary_validations=(v) - if v == "1" or v == true + if v == "1" or v == true or v =~ /t/ @skip_secondary_validations = true else @skip_secondary_validations = false diff --git a/app/logical/twitter_service.rb b/app/logical/twitter_service.rb index 2cfa5288c..c57096db3 100644 --- a/app/logical/twitter_service.rb +++ b/app/logical/twitter_service.rb @@ -3,7 +3,7 @@ class TwitterService raise "Twitter API keys not set" if Danbooru.config.twitter_api_key.nil? @client ||= begin - rest_client = Twitter::REST::Client.new do |config| + rest_client = ::Twitter::REST::Client.new do |config| config.consumer_key = Danbooru.config.twitter_api_key config.consumer_secret = Danbooru.config.twitter_api_secret if bearer_token = Cache.get("twitter-api-token") diff --git a/app/models/amazon_backup.rb b/app/models/amazon_backup.rb index 3ee7fcda2..fb0a72960 100644 --- a/app/models/amazon_backup.rb +++ b/app/models/amazon_backup.rb @@ -4,8 +4,6 @@ require 'base64' require 'digest/md5' class AmazonBackup < ApplicationRecord - attr_accessible :last_id - def self.last_id first.last_id end diff --git a/app/models/api_key.rb b/app/models/api_key.rb index b80088efa..aca02f54d 100644 --- a/app/models/api_key.rb +++ b/app/models/api_key.rb @@ -2,7 +2,6 @@ class ApiKey < ApplicationRecord belongs_to :user validates_uniqueness_of :user_id validates_uniqueness_of :key - attr_accessible :user_id, :key def self.generate!(user) create(:user_id => user.id, :key => SecureRandom.urlsafe_base64(32)) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 3b61dcff4..fb16fc3c0 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -141,6 +141,41 @@ class ApplicationRecord < ActiveRecord::Base end end + concerning :UserMethods do + class_methods do + def belongs_to_creator(options = {}) + class_eval do + belongs_to :creator, options.merge(class_name: "User") + before_validation(on: :create) do |rec| + if rec.creator_id.nil? + rec.creator_id = CurrentUser.id + rec.creator_ip_addr = CurrentUser.ip_addr if rec.respond_to?(:creator_ip_addr=) + rec.ip_addr = CurrentUser.ip_addr if rec.respond_to?(:ip_addr=) + end + end + + define_method :creator_name do + User.id_to_name(creator_id) + end + end + end + + def belongs_to_updater(options = {}) + class_eval do + belongs_to :updater, options.merge(class_name: "User") + before_validation do |rec| + rec.updater_id = CurrentUser.id + rec.updater_ip_addr = CurrentUser.ip_addr if rec.respond_to?(:updater_ip_addr=) + end + + define_method :updater_name do + User.id_to_name(updater_id) + end + end + end + end + end + def warnings @warnings ||= ActiveModel::Errors.new(self) end diff --git a/app/models/artist.rb b/app/models/artist.rb index 1d5f4a4c9..c59cfe4ba 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -2,25 +2,25 @@ class Artist < ApplicationRecord extend Memoist class RevertError < Exception ; end - before_create :initialize_creator + attribute :url_string, :string, default: "" before_validation :normalize_name after_save :create_version after_save :categorize_tag after_save :update_wiki + after_save :save_urls validates_uniqueness_of :name + validates_associated :urls validates :name, tag_name: true validate :validate_wiki, :on => :create after_validation :merge_validation_errors - belongs_to :creator, :class_name => "User" + belongs_to_creator has_many :members, :class_name => "Artist", :foreign_key => "group_name", :primary_key => "name" has_many :urls, :dependent => :destroy, :class_name => "ArtistUrl" has_many :versions, lambda {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" has_one :tag, :foreign_key => "name", :primary_key => "name" - attr_accessible :body, :notes, :name, :url_string, :other_names, :other_names_comma, :group_name, :notes, :as => [:member, :gold, :builder, :platinum, :moderator, :default, :admin] - attr_accessible :is_active, :as => [:builder, :moderator, :default, :admin] - attr_accessible :is_banned, :as => :admin + attribute :notes, :string scope :active, lambda { where(is_active: true) } scope :deleted, lambda { where(is_active: false) } @@ -178,22 +178,12 @@ class Artist < ApplicationRecord urls.map(&:url) end - def url_string=(string) - @url_string_was = url_string - - self.urls = string.scan(/[^[:space:]]+/).uniq.map do |url| - self.urls.find_or_initialize_by(url: url) + def save_urls + self.urls = url_string.scan(/[^[:space:]]+/).uniq.map do |url| + self.urls.find_or_create_by(url: url) end end - def url_string - url_array.join("\n") - end - - def url_string_changed? - @url_string_was != url_string - end - def map_domain(x) case x when "pximg.net" @@ -258,7 +248,7 @@ class Artist < ApplicationRecord module VersionMethods def create_version(force=false) - if name_changed? || url_string_changed? || is_active_changed? || is_banned_changed? || other_names_changed? || group_name_changed? || notes_changed? || force + if saved_change_to_name? || saved_change_to_url_string? || saved_change_to_is_active? || saved_change_to_is_banned? || saved_change_to_other_names? || saved_change_to_group_name? || saved_change_to_notes? || force if merge_version? merge_version else @@ -271,7 +261,7 @@ class Artist < ApplicationRecord ArtistVersion.create( :artist_id => id, :name => name, - :updater_id => CurrentUser.user.id, + :updater_id => CurrentUser.id, :updater_ip_addr => CurrentUser.ip_addr, :url_string => url_string, :is_active => is_active, @@ -369,9 +359,9 @@ class Artist < ApplicationRecord end def update_wiki - if persisted? && name_changed? && name_was.present? && WikiPage.titled(name_was).exists? + if persisted? && saved_change_to_name? && attribute_before_last_save("name").present? && WikiPage.titled(attribute_before_last_save("name")).exists? # we're renaming the artist, so rename the corresponding wiki page - old_page = WikiPage.titled(name_was).first + old_page = WikiPage.titled(name_before_last_save).first if wiki_page.present? # a wiki page with the new name already exists, so update the content @@ -383,7 +373,7 @@ class Artist < ApplicationRecord elsif wiki_page.nil? # if there are any notes, we need to create a new wiki page if @notes.present? - create_wiki_page(body: @notes, title: name) + wp = create_wiki_page(body: @notes, title: name) end elsif (!@notes.nil? && (wiki_page.body != @notes)) || wiki_page.title != name # if anything changed, we need to update the wiki page @@ -415,7 +405,7 @@ class Artist < ApplicationRecord end def categorize_tag - if new_record? || name_changed? + if new_record? || saved_change_to_name? Tag.find_or_create_by_name("artist:#{name}") end end @@ -666,10 +656,6 @@ class Artist < ApplicationRecord end end - def initialize_creator - self.creator_id = CurrentUser.user.id - end - def deletable_by?(user) user.is_builder? end diff --git a/app/models/artist_commentary.rb b/app/models/artist_commentary.rb index 4d882535d..ed952bff4 100644 --- a/app/models/artist_commentary.rb +++ b/app/models/artist_commentary.rb @@ -3,10 +3,9 @@ class ArtistCommentary < ApplicationRecord attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag - attr_accessible :post_id, :original_description, :original_title, :translated_description, :translated_title, :remove_commentary_tag, :remove_commentary_request_tag, :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag, :remove_commentary_check_tag before_validation :trim_whitespace validates_uniqueness_of :post_id - belongs_to :post + belongs_to :post, required: true has_many :versions, lambda {order("artist_commentary_versions.id ASC")}, :class_name => "ArtistCommentaryVersion", :dependent => :destroy, :foreign_key => :post_id, :primary_key => :post_id has_one :previous_version, lambda {order(id: :desc)}, :class_name => "ArtistCommentaryVersion", :foreign_key => :post_id, :primary_key => :post_id after_save :create_version @@ -109,12 +108,12 @@ class ArtistCommentary < ApplicationRecord post.add_tag("check_commentary") end - post.save if post.tag_string_changed? + post.save if post.saved_change_to_tag_string? end module VersionMethods def create_version - return unless changed? + return unless saved_changes? if merge_version? merge_version diff --git a/app/models/artist_commentary_version.rb b/app/models/artist_commentary_version.rb index c01cfecfc..d8a9ab6ad 100644 --- a/app/models/artist_commentary_version.rb +++ b/app/models/artist_commentary_version.rb @@ -1,9 +1,7 @@ class ArtistCommentaryVersion < ApplicationRecord - before_validation :initialize_updater belongs_to :post - belongs_to :updater, :class_name => "User" + belongs_to_updater scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} - attr_accessible :post_id, :original_title, :original_description, :translated_title, :translated_description def self.search(params) q = super @@ -18,13 +16,4 @@ class ArtistCommentaryVersion < ApplicationRecord q.apply_default_order(params) end - - def initialize_updater - self.updater_id = CurrentUser.id - self.updater_ip_addr = CurrentUser.ip_addr - end - - def updater_name - User.id_to_name(updater_id) - end end diff --git a/app/models/artist_url.rb b/app/models/artist_url.rb index d1f1ce797..f76c48198 100644 --- a/app/models/artist_url.rb +++ b/app/models/artist_url.rb @@ -4,7 +4,6 @@ class ArtistUrl < ApplicationRecord validates_presence_of :url validate :validate_url_format belongs_to :artist, :touch => true - attr_accessible :url, :artist_id, :normalized_url def self.normalize(url) if url.nil? @@ -93,8 +92,8 @@ class ArtistUrl < ApplicationRecord def validate_url_format uri = Addressable::URI.parse(url) - errors[:base] << "'#{url}' must begin with http:// or https://" if !uri.scheme.in?(%w[http https]) + errors[:url] << "must begin with http:// or https://" if !uri.scheme.in?(%w[http https]) rescue Addressable::URI::InvalidURIError => error - errors[:base] << "'#{url}' is malformed: #{error}" + errors[:url] << "is malformed: #{error}" end end diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 61b4a6f29..97589614f 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -1,7 +1,6 @@ class ArtistVersion < ApplicationRecord - belongs_to :updater, :class_name => "User" + belongs_to_updater belongs_to :artist - attr_accessible :artist_id, :name, :is_active, :other_names, :group_name, :url_string, :is_banned, :updater_id, :updater_ip_addr delegate :visible?, :to => :artist module SearchMethods @@ -106,8 +105,4 @@ class ArtistVersion < ApplicationRecord def previous ArtistVersion.where("artist_id = ? and created_at < ?", artist_id, created_at).order("created_at desc").first end - - def updater_name - User.id_to_name(updater_id) - end end diff --git a/app/models/ban.rb b/app/models/ban.rb index 3cec1dd9d..fc141a479 100644 --- a/app/models/ban.rb +++ b/app/models/ban.rb @@ -5,7 +5,6 @@ class Ban < ApplicationRecord after_destroy :update_user_on_destroy belongs_to :user belongs_to :banner, :class_name => "User" - attr_accessible :reason, :duration, :user_id, :user_name validate :user_is_inferior validates_presence_of :user_id, :reason, :duration before_validation :initialize_banner_id, :on => :create diff --git a/app/models/bulk_update_request.rb b/app/models/bulk_update_request.rb index 2cfcd50bc..c349538c9 100644 --- a/app/models/bulk_update_request.rb +++ b/app/models/bulk_update_request.rb @@ -2,9 +2,9 @@ class BulkUpdateRequest < ApplicationRecord attr_accessor :reason, :skip_secondary_validations belongs_to :user - belongs_to :forum_topic - belongs_to :forum_post - belongs_to :approver, :class_name => "User" + belongs_to :forum_topic, optional: true + belongs_to :forum_post, optional: true + belongs_to :approver, optional: true, class_name: "User" validates_presence_of :user validates_presence_of :script @@ -112,10 +112,12 @@ class BulkUpdateRequest < ApplicationRecord def create_forum_topic if forum_topic_id forum_post = forum_topic.posts.create(body: reason_with_link) - update_attributes(:forum_post_id => forum_post.id) + update(forum_post_id: forum_post.id) else - forum_topic = ForumTopic.create(:title => title, :category_id => 1, :original_post_attributes => {:body => reason_with_link}) - update_attributes(:forum_topic_id => forum_topic.id, :forum_post_id => forum_topic.posts.first.id) + forum_topic = ForumTopic.create(title: title, category_id: 1, original_post_attributes: {body: reason_with_link}) + puts forum_topic.errors.full_messages + puts forum_topic.original_post.errors.full_messages + update(forum_topic_id: forum_topic.id, forum_post_id: forum_topic.posts.first.id) end end @@ -136,13 +138,13 @@ class BulkUpdateRequest < ApplicationRecord AliasAndImplicationImporter.tokenize(script) return true rescue StandardError => e - errors.add(:base, e.message) + errors[:base] << e.message return false end def forum_topic_id_not_invalid if forum_topic_id && !forum_topic - errors.add(:base, "Forum topic ID is invalid") + errors[:base] << "Forum topic ID is invalid" end end @@ -150,7 +152,7 @@ class BulkUpdateRequest < ApplicationRecord begin AliasAndImplicationImporter.new(script, forum_topic_id, "1", skip_secondary_validations).validate! rescue RuntimeError => e - self.errors[:base] = e.message + self.errors[:base] << e.message return false end diff --git a/app/models/comment.rb b/app/models/comment.rb index eb9c23cef..40ee980fb 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -5,21 +5,17 @@ class Comment < ApplicationRecord validate :validate_creator_is_not_limited, :on => :create validates_format_of :body, :with => /\S/, :message => 'has no content' belongs_to :post - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater has_many :votes, :class_name => "CommentVote", :dependent => :destroy - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater after_create :update_last_commented_at_on_create - after_update(:if => lambda {|rec| (!rec.is_deleted? || !rec.is_deleted_changed?) && CurrentUser.id != rec.creator_id}) do |rec| + after_update(:if => lambda {|rec| (!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |rec| ModAction.log("comment ##{rec.id} updated by #{CurrentUser.name}",:comment_update) end - after_save :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed?} - after_save(:if => lambda {|rec| rec.is_deleted? && rec.is_deleted_changed? && CurrentUser.id != rec.creator_id}) do |rec| + after_save :update_last_commented_at_on_destroy, :if => lambda {|rec| rec.is_deleted? && rec.saved_change_to_is_deleted?} + after_save(:if => lambda {|rec| rec.is_deleted? && rec.saved_change_to_is_deleted? && CurrentUser.id != rec.creator_id}) do |rec| ModAction.log("comment ##{rec.id} deleted by #{CurrentUser.name}",:comment_delete) end - attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted, :as => [:member, :gold, :platinum, :builder, :moderator, :admin] - attr_accessible :is_sticky, :as => [:moderator, :admin] mentionable( :message_field => :body, :title => lambda {|user_name| "#{creator_name} mentioned you in a comment on post ##{post_id}"}, @@ -172,24 +168,6 @@ class Comment < ApplicationRecord extend SearchMethods include VoteMethods - def initialize_creator - self.creator_id ||= CurrentUser.user.id - self.ip_addr ||= CurrentUser.ip_addr - end - - def initialize_updater - self.updater_id = CurrentUser.user.id - self.updater_ip_addr = CurrentUser.ip_addr - end - - def creator_name - User.id_to_name(creator_id) - end - - def updater_name - User.id_to_name(updater_id) - end - def validate_post_exists errors.add(:post, "must exist") unless Post.exists?(post_id) end @@ -245,11 +223,11 @@ class Comment < ApplicationRecord end def delete! - update({ :is_deleted => true }, :as => CurrentUser.role) + update(is_deleted: true) end def undelete! - update({ :is_deleted => false }, :as => CurrentUser.role) + update(is_deleted: false) end def quoted_response diff --git a/app/models/comment_vote.rb b/app/models/comment_vote.rb index c337e67f0..4ed666095 100644 --- a/app/models/comment_vote.rb +++ b/app/models/comment_vote.rb @@ -9,7 +9,6 @@ class CommentVote < ApplicationRecord validate :validate_user_can_vote validate :validate_comment_can_be_down_voted validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1" - attr_accessible :comment_id, :user_id, :score def self.prune! where("created_at < ?", 14.days.ago).delete_all diff --git a/app/models/dmail.rb b/app/models/dmail.rb index 688e22461..bc0d36683 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -235,7 +235,7 @@ class Dmail < ApplicationRecord def validate_sender_is_not_banned if from.is_banned? - errors[:base] = "Sender is banned and cannot send messages" + errors[:base] << "Sender is banned and cannot send messages" return false else return true diff --git a/app/models/dmail_filter.rb b/app/models/dmail_filter.rb index 019fadb9f..eec9ea005 100644 --- a/app/models/dmail_filter.rb +++ b/app/models/dmail_filter.rb @@ -1,6 +1,5 @@ class DmailFilter < ApplicationRecord belongs_to :user - attr_accessible :words, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin] validates_presence_of :user before_validation :initialize_user diff --git a/app/models/favorite.rb b/app/models/favorite.rb index 3b95696c7..bc713882b 100644 --- a/app/models/favorite.rb +++ b/app/models/favorite.rb @@ -2,7 +2,6 @@ class Favorite < ApplicationRecord belongs_to :post belongs_to :user scope :for_user, lambda {|user_id| where("user_id % 100 = #{user_id.to_i % 100} and user_id = #{user_id.to_i}")} - attr_accessible :user_id, :post_id def self.add(post:, user:) Favorite.transaction do @@ -26,7 +25,7 @@ class Favorite < ApplicationRecord User.where(:id => user.id).select("id").lock("FOR UPDATE NOWAIT").first return unless Favorite.for_user(user.id).where(:user_id => user.id, :post_id => post_id).exists? - Favorite.for_user(user.id).delete_all(post_id: post_id) + Favorite.for_user(user.id).where(post_id: post_id).delete_all Post.where(:id => post_id).update_all("fav_count = fav_count - 1") post.delete_user_from_fav_string(user.id) if post User.where(:id => user.id).update_all("favorite_count = favorite_count - 1") diff --git a/app/models/favorite_group.rb b/app/models/favorite_group.rb index 5bc8aac33..d6a09f630 100644 --- a/app/models/favorite_group.rb +++ b/app/models/favorite_group.rb @@ -3,15 +3,13 @@ require 'ostruct' class FavoriteGroup < ApplicationRecord validates_uniqueness_of :name, :case_sensitive => false, :scope => :creator_id validates_format_of :name, :with => /\A[^,]+\Z/, :message => "cannot have commas" - belongs_to :creator, :class_name => "User" + belongs_to_creator before_validation :normalize_post_ids before_validation :normalize_name - before_validation :initialize_creator, :on => :create before_validation :strip_name validate :creator_can_create_favorite_groups, :on => :create validate :validate_number_of_posts before_save :update_post_count - attr_accessible :name, :post_ids, :post_id_array, :is_public, :as => [:member, :gold, :platinum, :builder, :moderator, :admin, :default] module SearchMethods def for_creator(user_id) @@ -125,10 +123,6 @@ class FavoriteGroup < ApplicationRecord end end - def initialize_creator - self.creator_id ||= CurrentUser.id - end - def strip_name self.name = name.to_s.strip end diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index c963632a6..0866d8767 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -1,14 +1,10 @@ class ForumPost < ApplicationRecord include Mentionable - attr_accessible :body, :topic_id, :as => [:member, :builder, :gold, :platinum, :admin, :moderator, :default] - attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator] attr_readonly :topic_id - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater belongs_to :topic, :class_name => "ForumTopic" - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater before_validation :initialize_is_deleted, :on => :create after_create :update_topic_updated_at_on_create after_update :update_topic_updated_at_on_update_for_original_posts @@ -137,22 +133,22 @@ class ForumPost < ApplicationRecord return if topic.nil? if topic.is_locked? - errors.add(:topic, "is locked") - return false - else - return true + errors[:topic] << "is locked" + throw :abort end end def topic_id_not_invalid if topic_id && !topic - errors.add(:base, "Topic ID is invalid") + errors[:base] << "Topic ID is invalid" + return false end end def topic_is_not_restricted if topic && !topic.visible?(creator) - errors.add(:topic, "restricted") + errors[:topic] << "is restricted" + return false end end @@ -179,12 +175,12 @@ class ForumPost < ApplicationRecord end def delete! - update_attributes({:is_deleted => true}, :as => CurrentUser.role) + update(is_deleted: true) update_topic_updated_at_on_delete end def undelete! - update_attributes({:is_deleted => false}, :as => CurrentUser.role) + update(is_deleted: false) update_topic_updated_at_on_undelete end @@ -212,14 +208,6 @@ class ForumPost < ApplicationRecord end end - def initialize_creator - self.creator_id = CurrentUser.id - end - - def initialize_updater - self.updater_id = CurrentUser.id - end - def initialize_is_deleted self.is_deleted = false if is_deleted.nil? end diff --git a/app/models/forum_subscription.rb b/app/models/forum_subscription.rb index a2f007186..07fd1d17f 100644 --- a/app/models/forum_subscription.rb +++ b/app/models/forum_subscription.rb @@ -1,7 +1,6 @@ class ForumSubscription < ApplicationRecord belongs_to :user belongs_to :forum_topic - attr_accessible :user, :forum_topic, :user_id, :forum_topic_id, :last_read_at, :delete_key def self.prune! where("last_read_at < ?", 3.months.ago).delete_all diff --git a/app/models/forum_topic.rb b/app/models/forum_topic.rb index 3dd19c86a..4106abec7 100644 --- a/app/models/forum_topic.rb +++ b/app/models/forum_topic.rb @@ -11,15 +11,11 @@ class ForumTopic < ApplicationRecord Admin: User::Levels::ADMIN, } - attr_accessible :title, :original_post_attributes, :category_id, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default] - attr_accessible :is_sticky, :is_locked, :is_deleted, :min_level, :as => [:admin, :moderator] - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater has_many :posts, lambda {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id", :dependent => :destroy - has_one :original_post, lambda {order("forum_posts.id asc")}, :class_name => "ForumPost", :foreign_key => "topic_id" + has_one :original_post, lambda {order("forum_posts.id asc")}, class_name: "ForumPost", foreign_key: "topic_id", inverse_of: :topic has_many :subscriptions, :class_name => "ForumSubscription" - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater before_validation :initialize_is_deleted, :on => :create validates_presence_of :title, :creator_id validates_associated :original_post @@ -28,7 +24,7 @@ class ForumTopic < ApplicationRecord validates :title, :length => {:maximum => 255} accepts_nested_attributes_for :original_post after_update :update_orignal_post - after_save(:if => lambda {|rec| rec.is_locked? && rec.is_locked_changed?}) do |rec| + after_save(:if => lambda {|rec| rec.is_locked? && rec.saved_change_to_is_locked?}) do |rec| ModAction.log("locked forum topic ##{id} (title: #{title})",:forum_topic_lock) end @@ -173,14 +169,6 @@ class ForumTopic < ApplicationRecord self.is_deleted = false if is_deleted.nil? end - def initialize_creator - self.creator_id = CurrentUser.id - end - - def initialize_updater - self.updater_id = CurrentUser.id - end - def page_for(post_id) (posts.where("id < ?", post_id).count / Danbooru.config.posts_per_page.to_f).ceil end @@ -216,11 +204,11 @@ class ForumTopic < ApplicationRecord end def delete! - update_attributes({:is_deleted => true}, :as => CurrentUser.role) + update(is_deleted: true) end def undelete! - update_attributes({:is_deleted => false}, :as => CurrentUser.role) + update(is_deleted: false) end def update_orignal_post diff --git a/app/models/forum_topic_visit.rb b/app/models/forum_topic_visit.rb index a824bcdd4..71f237125 100644 --- a/app/models/forum_topic_visit.rb +++ b/app/models/forum_topic_visit.rb @@ -1,7 +1,6 @@ class ForumTopicVisit < ApplicationRecord belongs_to :user belongs_to :forum_topic - attr_accessible :user_id, :user, :forum_topic_id, :forum_topic, :last_read_at def self.prune!(user) where("user_id = ? and last_read_at < ?", user.id, user.last_forum_read_at).delete_all diff --git a/app/models/ip_ban.rb b/app/models/ip_ban.rb index c60b76bd9..dac2d0190 100644 --- a/app/models/ip_ban.rb +++ b/app/models/ip_ban.rb @@ -1,11 +1,9 @@ class IpBan < ApplicationRecord IP_ADDR_REGEX = /\A(?:[0-9]{1,3}\.){3}[0-9]{1,3}\Z/ - belongs_to :creator, :class_name => "User" - before_validation :initialize_creator, :on => :create + belongs_to_creator validates_presence_of :reason, :creator, :ip_addr validates_format_of :ip_addr, :with => IP_ADDR_REGEX validates_uniqueness_of :ip_addr, :if => lambda {|rec| rec.ip_addr =~ IP_ADDR_REGEX} - attr_accessible :ip_addr, :reason after_create do |rec| ModAction.log("#{CurrentUser.name} created ip ban for #{rec.ip_addr}",:ip_ban_create) end @@ -44,8 +42,4 @@ class IpBan < ApplicationRecord def self.count_by_ip_addr(table, user_ids, user_id_field = "user_id", ip_addr_field = "ip_addr") select_all_sql("SELECT #{ip_addr_field}, count(*) FROM #{table} WHERE #{user_id_field} IN (?) GROUP BY #{ip_addr_field} ORDER BY count(*) DESC", user_ids).to_hash end - - def initialize_creator - self.creator_id = CurrentUser.id - end end diff --git a/app/models/janitor_trial.rb b/app/models/janitor_trial.rb index 053a082c9..85755ad35 100644 --- a/app/models/janitor_trial.rb +++ b/app/models/janitor_trial.rb @@ -3,8 +3,7 @@ class JanitorTrial < ApplicationRecord after_create :send_dmail after_create :promote_user validates_presence_of :user - before_validation :initialize_creator - attr_accessible :user_id, :user_name + belongs_to_creator validates_inclusion_of :status, :in => %w(active inactive) before_validation :initialize_status validates_uniqueness_of :user_id @@ -57,10 +56,6 @@ class JanitorTrial < ApplicationRecord self.status = "active" end - def initialize_creator - self.creator_id = CurrentUser.id - end - def user_name user.try(:name) end diff --git a/app/models/mod_action.rb b/app/models/mod_action.rb index 72a113f6e..3557fa2c2 100644 --- a/app/models/mod_action.rb +++ b/app/models/mod_action.rb @@ -2,7 +2,6 @@ class ModAction < ApplicationRecord belongs_to :creator, :class_name => "User" before_validation :initialize_creator, :on => :create validates_presence_of :creator_id - attr_accessible :description, :category #####DIVISIONS##### #Groups: 0-999 diff --git a/app/models/news_update.rb b/app/models/news_update.rb index 686068638..fcf5e514a 100644 --- a/app/models/news_update.rb +++ b/app/models/news_update.rb @@ -1,16 +1,5 @@ class NewsUpdate < ApplicationRecord - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater scope :recent, lambda {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)} - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater - attr_accessible :message - - def initialize_creator - self.creator_id = CurrentUser.id - end - - def initialize_updater - self.updater_id = CurrentUser.id - end end diff --git a/app/models/note.rb b/app/models/note.rb index aac5a1b88..ea7733483 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -1,20 +1,19 @@ class Note < ApplicationRecord class RevertError < Exception ; end - attr_accessor :updater_id, :updater_ip_addr, :html_id + attribute :updater_id, :integer + attribute :updater_ip_addr, :inet + attr_accessor :html_id belongs_to :post - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater has_many :versions, lambda {order("note_versions.id ASC")}, :class_name => "NoteVersion", :dependent => :destroy - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height, :body validate :post_must_exist validate :note_within_image after_save :update_post after_save :create_version validate :post_must_not_be_note_locked - attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :post, :html_id module SearchMethods def active @@ -87,15 +86,6 @@ class Note < ApplicationRecord extend SearchMethods include ApiMethods - def initialize_creator - self.creator_id ||= CurrentUser.id - end - - def initialize_updater - self.updater_id = CurrentUser.id - self.updater_ip_addr = CurrentUser.ip_addr - end - def post_must_exist if !Post.exists?(post_id) errors.add :post, "must exist" @@ -122,10 +112,6 @@ class Note < ApplicationRecord Post.exists?(["id = ? AND is_note_locked = ?", post_id, true]) end - def creator_name - User.id_to_name(creator_id) - end - def rescale!(x_scale, y_scale) self.x *= x_scale self.y *= y_scale @@ -135,7 +121,7 @@ class Note < ApplicationRecord end def update_post - if self.changed? + if self.saved_changes? if Note.where(:is_active => true, :post_id => post_id).exists? execute_sql("UPDATE posts SET last_noted_at = ? WHERE id = ?", updated_at, post_id) else @@ -145,7 +131,7 @@ class Note < ApplicationRecord end def create_version - return unless versioned_attributes_changed? + return unless saved_change_to_versioned_attributes? if merge_version? merge_version @@ -156,8 +142,8 @@ class Note < ApplicationRecord end end - def versioned_attributes_changed? - new_record? || x_changed? || y_changed? || width_changed? || height_changed? || is_active_changed? || body_changed? + def saved_change_to_versioned_attributes? + new_record? || saved_change_to_x? || saved_change_to_y? || saved_change_to_width? || saved_change_to_height? || saved_change_to_is_active? || saved_change_to_body? end def create_new_version @@ -189,7 +175,7 @@ class Note < ApplicationRecord def merge_version? prev = versions.last - prev && prev.updater_id == CurrentUser.user.id && prev.updated_at > 1.hour.ago && !is_active_changed? + prev && prev.updater_id == CurrentUser.user.id && prev.updated_at > 1.hour.ago && !saved_change_to_is_active? end def revert_to(version) diff --git a/app/models/note_version.rb b/app/models/note_version.rb index a2a048da9..469e2ced0 100644 --- a/app/models/note_version.rb +++ b/app/models/note_version.rb @@ -1,8 +1,6 @@ class NoteVersion < ApplicationRecord - before_validation :initialize_updater - belongs_to :updater, :class_name => "User", :counter_cache => "note_update_count" + belongs_to_updater :counter_cache => "note_update_count" scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)} - attr_accessible :note_id, :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id, :html_id, :version def self.search(params) q = super @@ -22,16 +20,7 @@ class NoteVersion < ApplicationRecord q.apply_default_order(params) end - def initialize_updater - self.updater_id = CurrentUser.id - self.updater_ip_addr = CurrentUser.ip_addr - end - def previous NoteVersion.where("note_id = ? and updated_at < ?", note_id, updated_at).order("updated_at desc").first end - - def updater_name - User.id_to_name(updater_id) - end end diff --git a/app/models/pixiv_ugoira_frame_data.rb b/app/models/pixiv_ugoira_frame_data.rb index dc5ca5d85..84b8660c5 100644 --- a/app/models/pixiv_ugoira_frame_data.rb +++ b/app/models/pixiv_ugoira_frame_data.rb @@ -1,4 +1,3 @@ class PixivUgoiraFrameData < ApplicationRecord - attr_accessible :post_id, :data, :content_type serialize :data end diff --git a/app/models/pool.rb b/app/models/pool.rb index c1760f5cd..95c55d447 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -3,24 +3,22 @@ require 'ostruct' class Pool < ApplicationRecord class RevertError < Exception ; end - validates_uniqueness_of :name, :case_sensitive => false, :if => :name_changed? - validate :validate_name, :if => :name_changed? + attribute :updater_id, :integer + validates_uniqueness_of :name, :case_sensitive => false, :if => :saved_change_to_name? + validate :validate_name, :if => :saved_change_to_name? validates_inclusion_of :category, :in => %w(series collection) validate :updater_can_change_category validate :updater_can_remove_posts validate :updater_can_edit_deleted - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater before_validation :normalize_post_ids before_validation :normalize_name before_validation :initialize_is_active, :on => :create - before_validation :initialize_creator, :on => :create after_save :update_category_pseudo_tags_for_posts_async after_save :create_version after_create :synchronize! before_destroy :create_mod_action_for_destroy - attr_accessible :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :as => [:member, :gold, :platinum, :moderator, :admin, :default] - attr_accessible :is_deleted, :as => [:builder, :moderator, :admin] module SearchMethods def deleted @@ -163,10 +161,6 @@ class Pool < ApplicationRecord self.is_active = true if is_active.nil? end - def initialize_creator - self.creator_id = CurrentUser.id - end - def normalize_name self.name = Pool.normalize_name(name) end @@ -195,7 +189,6 @@ class Pool < ApplicationRecord self.post_ids = version.post_ids.join(" ") self.name = version.name self.description = version.description - synchronize! end @@ -244,6 +237,7 @@ class Pool < ApplicationRecord return unless CurrentUser.user.can_remove_from_pools? with_lock do + reload update_attributes(:post_ids => remove_number_from_string(post.id, post_ids), :post_count => post_count - 1) post.remove_pool!(self) clear_post_id_array @@ -296,7 +290,7 @@ class Pool < ApplicationRecord def synchronize! synchronize - save if post_ids_changed? + save if will_save_change_to_post_ids? end def post_id_array @@ -306,15 +300,18 @@ class Pool < ApplicationRecord def post_id_array=(array) self.post_ids = array.join(" ") clear_post_id_array + self end def post_id_array_was - @post_id_array_was ||= post_ids_was.scan(/\d+/).map(&:to_i) + old_post_ids = post_ids_before_last_save || post_ids_was + @post_id_array_was ||= old_post_ids.to_s.scan(/\d+/).map(&:to_i) end def clear_post_id_array @post_id_array = nil @post_id_array_was = nil + self end def neighbors(post) @@ -353,6 +350,7 @@ class Pool < ApplicationRecord super @neighbor_posts = nil clear_post_id_array + self end def method_attributes @@ -360,7 +358,7 @@ class Pool < ApplicationRecord end def update_category_pseudo_tags_for_posts_async - if category_changed? + if saved_change_to_category? delay(:queue => "default").update_category_pseudo_tags_for_posts end end @@ -378,7 +376,7 @@ class Pool < ApplicationRecord end def updater_can_change_category - if category_changed? && !category_changeable_by?(CurrentUser.user) + if saved_change_to_category? && !category_changeable_by?(CurrentUser.user) errors[:base] << "You cannot change the category of pools with greater than 100 posts" false else diff --git a/app/models/pool_version.rb b/app/models/pool_version.rb index 6a1f2413b..ac2f20dae 100644 --- a/app/models/pool_version.rb +++ b/app/models/pool_version.rb @@ -1,11 +1,8 @@ class PoolVersion < ApplicationRecord class Error < Exception ; end - validates_presence_of :updater_id, :updater_ip_addr belongs_to :pool - belongs_to :updater, :class_name => "User" - before_validation :initialize_updater - attr_accessible :pool_id, :is_deleted, :name, :description, :post_ids, :post_id_array, :post_count, :is_active, :category, :updater_id, :updater_ip_addr + belongs_to_updater module SearchMethods def for_user(user_id) @@ -73,19 +70,10 @@ class PoolVersion < ApplicationRecord puts "last version id: #{last_version_id}" end - def updater_name - User.id_to_name(updater_id) - end - def pretty_name name.tr("_", " ") end - def initialize_updater - self.updater_id = CurrentUser.id - self.updater_ip_addr = CurrentUser.ip_addr - end - def post_id_array @post_id_array ||= post_ids.scan(/\d+/).map(&:to_i) end diff --git a/app/models/post.rb b/app/models/post.rb index d445030a1..551ee2493 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -41,10 +41,10 @@ class Post < ApplicationRecord after_commit :update_iqdb_async, :on => :create after_commit :notify_pubsub - belongs_to :updater, :class_name => "User" - belongs_to :approver, :class_name => "User" + belongs_to :updater, :class_name => "User", optional: true # this is handled in versions + belongs_to :approver, class_name: "User", optional: true belongs_to :uploader, :class_name => "User", :counter_cache => "post_upload_count" - belongs_to :parent, :class_name => "Post" + belongs_to :parent, class_name: "Post", optional: true has_one :upload, :dependent => :destroy has_one :artist_commentary, :dependent => :destroy has_one :pixiv_ugoira_frame_data, :class_name => "PixivUgoiraFrameData", :dependent => :destroy @@ -60,14 +60,6 @@ class Post < ApplicationRecord has_many :replacements, class_name: "PostReplacement", :dependent => :destroy serialize :keeper_data, JSON - - if PostArchive.enabled? - has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy - end - - attr_accessible :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :parent_id, :has_embedded_notes, :as => [:member, :builder, :gold, :platinum, :moderator, :admin, :default] - attr_accessible :is_rating_locked, :is_note_locked, :has_cropped, :keeper_data, :as => [:builder, :moderator, :admin] - attr_accessible :is_status_locked, :keeper_data, :as => [:admin] attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning, :view_count concerning :KeeperMethods do @@ -82,7 +74,7 @@ class Post < ApplicationRecord uploader_id end end - + def keeper User.find(keeper_id) end @@ -92,6 +84,12 @@ class Post < ApplicationRecord end end + if PostArchive.enabled? + has_many :versions, lambda {order("post_versions.updated_at ASC")}, :class_name => "PostArchive", :dependent => :destroy + end + + attr_accessor :old_tag_string, :old_parent_id, :old_source, :old_rating, :has_constraints, :disable_versioning, :view_count + module FileMethods extend ActiveSupport::Concern @@ -521,7 +519,7 @@ class Post < ApplicationRecord end def tag_array_was - @tag_array_was ||= Tag.scan_tags(tag_string_was) + @tag_array_was ||= Tag.scan_tags(tag_string_before_last_save || tag_string_was) end def tags @@ -606,15 +604,15 @@ class Post < ApplicationRecord old_parent_id = old_parent_id.to_i end if old_parent_id == parent_id - self.parent_id = parent_id_was + self.parent_id = parent_id_before_last_save || parent_id_was end if old_source == source.to_s - self.source = source_was + self.source = source_before_last_save || source_was end if old_rating == rating - self.rating = rating_was + self.rating = rating_before_last_save || rating_was end end @@ -838,13 +836,13 @@ class Post < ApplicationRecord self.rating = $1 when /^(-?)locked:notes?$/i - assign_attributes({ is_note_locked: $1 != "-" }, as: CurrentUser.role) + self.is_note_locked = ($1 != "-" ) if CurrentUser.is_builder? when /^(-?)locked:rating$/i - assign_attributes({ is_rating_locked: $1 != "-" }, as: CurrentUser.role) + self.is_rating_locked = ($1 != "-" ) if CurrentUser.is_builder? when /^(-?)locked:status$/i - assign_attributes({ is_status_locked: $1 != "-" }, as: CurrentUser.role) + self.is_status_locked = ($1 != "-" ) if CurrentUser.is_admin? end end @@ -977,7 +975,7 @@ class Post < ApplicationRecord end def remove_from_favorites - Favorite.delete_all(post_id: id) + Favorite.where(post_id: id).delete_all user_ids = fav_string.scan(/\d+/) User.where(:id => user_ids).update_all("favorite_count = favorite_count - 1") PostVote.where(post_id: id).delete_all @@ -1175,7 +1173,7 @@ class Post < ApplicationRecord def fix_post_counts(post) post.set_tag_counts(false) - if post.changed? + if post.changes_saved? args = Hash[TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}].update(:tag_count => post.tag_count) post.update_columns(args) end @@ -1220,7 +1218,7 @@ class Post < ApplicationRecord # - Reparent all children to the first child. def update_has_children_flag - update({has_children: children.exists?, has_active_children: children.undeleted.exists?}, without_protection: true) + update(has_children: children.exists?, has_active_children: children.undeleted.exists?) end def blank_out_nonexistent_parents @@ -1252,10 +1250,10 @@ class Post < ApplicationRecord end def update_parent_on_save - return unless parent_id_changed? || is_deleted_changed? + return unless saved_change_to_parent_id? || saved_change_to_is_deleted? parent.update_has_children_flag if parent.present? - Post.find(parent_id_was).update_has_children_flag if parent_id_was.present? + Post.find(parent_id_before_last_save).update_has_children_flag if parent_id_before_last_save.present? end def give_favorites_to_parent(options = {}) @@ -1337,12 +1335,12 @@ class Post < ApplicationRecord Post.transaction do flag!(reason, is_deletion: true) - update({ + update( is_deleted: true, is_pending: false, is_flagged: false, is_banned: is_banned || options[:ban] || has_tag?("banned_artist") - }, without_protection: true) + ) # XXX This must happen *after* the `is_deleted` flag is set to true (issue #3419). give_favorites_to_parent(options) if options[:move_favorites] @@ -1385,11 +1383,15 @@ class Post < ApplicationRecord module VersionMethods def create_version(force = false) - if new_record? || rating_changed? || source_changed? || parent_id_changed? || tag_string_changed? || force + if new_record? || saved_change_to_watched_attributes? || force create_new_version end end + def saved_change_to_watched_attributes? + saved_change_to_rating? || saved_change_to_source? || saved_change_to_parent_id? || saved_change_to_tag_string? + end + def merge_version? prev = versions.last prev && prev.updater_id == CurrentUser.user.id && prev.updated_at > 1.hour.ago diff --git a/app/models/post_appeal.rb b/app/models/post_appeal.rb index c5abd0a11..13a1eb1c1 100644 --- a/app/models/post_appeal.rb +++ b/app/models/post_appeal.rb @@ -8,7 +8,6 @@ class PostAppeal < ApplicationRecord validate :validate_creator_is_not_limited before_validation :initialize_creator, :on => :create validates_uniqueness_of :creator_id, :scope => :post_id, :message => "have already appealed this post" - attr_accessible :post_id, :post, :reason module SearchMethods def reason_matches(query) diff --git a/app/models/post_approval.rb b/app/models/post_approval.rb index 8ac4a015b..e93c99077 100644 --- a/app/models/post_approval.rb +++ b/app/models/post_approval.rb @@ -31,6 +31,6 @@ class PostApproval < ApplicationRecord ModAction.log("undeleted post ##{post_id}",:post_undelete) if post.is_deleted post.flags.each(&:resolve!) - post.update({ approver: user, is_flagged: false, is_pending: false, is_deleted: false }, without_protection: true) + post.update(approver: user, is_flagged: false, is_pending: false, is_deleted: false) end end diff --git a/app/models/post_disapproval.rb b/app/models/post_disapproval.rb index 632ee6bc5..776508c76 100644 --- a/app/models/post_disapproval.rb +++ b/app/models/post_disapproval.rb @@ -1,10 +1,10 @@ class PostDisapproval < ApplicationRecord DELETION_THRESHOLD = 1.month - belongs_to :post + belongs_to :post, required: true belongs_to :user + after_initialize :initialize_attributes, if: :new_record? validates_uniqueness_of :post_id, :scope => [:user_id], :message => "have already hidden this post" - attr_accessible :post_id, :post, :user_id, :user, :reason, :message validates_inclusion_of :reason, :in => %w(legacy breaks_rules poor_quality disinterest) scope :with_message, lambda {where("message is not null and message <> ''")} @@ -12,6 +12,14 @@ class PostDisapproval < ApplicationRecord scope :poor_quality, lambda {where(:reason => "poor_quality")} scope :disinterest, lambda {where(:reason => ["disinterest", "legacy"])} + def initialize_attributes + self.user_id ||= CurrentUser.user.id + end + + def initialize_attributes + self.user_id ||= CurrentUser.user.id + end + def self.prune! PostDisapproval.where("post_id in (select _.post_id from post_disapprovals _ where _.created_at < ?)", DELETION_THRESHOLD.ago).delete_all end diff --git a/app/models/post_flag.rb b/app/models/post_flag.rb index 1040e316d..349ef579f 100644 --- a/app/models/post_flag.rb +++ b/app/models/post_flag.rb @@ -17,7 +17,6 @@ class PostFlag < ApplicationRecord before_validation :initialize_creator, :on => :create validates_uniqueness_of :creator_id, :scope => :post_id, :on => :create, :unless => :is_deletion, :message => "have already flagged this post" before_save :update_post - attr_accessible :post, :post_id, :reason, :is_resolved, :is_deletion attr_accessor :is_deletion scope :by_users, lambda { where.not(creator: User.system) } diff --git a/app/models/post_replacement.rb b/app/models/post_replacement.rb index e709942fb..507737d25 100644 --- a/app/models/post_replacement.rb +++ b/app/models/post_replacement.rb @@ -70,7 +70,11 @@ class PostReplacement < ApplicationRecord update_ugoira_frame_data(upload) if md5_changed - post.comments.create!({creator: User.system, body: comment_replacement_message, do_not_bump_post: true}, without_protection: true) + CurrentUser.as(User.system) do + post.comments.create!(body: comment_replacement_message, do_not_bump_post: true) + end + else + post.queue_backup end save! diff --git a/app/models/post_version.rb b/app/models/post_version.rb index 604f608a6..718b660e0 100644 --- a/app/models/post_version.rb +++ b/app/models/post_version.rb @@ -2,7 +2,6 @@ class PostVersion < ApplicationRecord belongs_to :post belongs_to :updater, :class_name => "User" before_validation :initialize_updater - attr_accessible :post_id, :is_status_locked, :is_rating_locked, :is_note_locked, :source, :rating, :tag_string, :old_tag_string, :old_parent_id, :old_source, :old_rating, :last_noted_at, :parent_id, :tags module SearchMethods def for_user(user_id) diff --git a/app/models/post_vote.rb b/app/models/post_vote.rb index 4e872c99e..80c00aa0e 100644 --- a/app/models/post_vote.rb +++ b/app/models/post_vote.rb @@ -4,7 +4,6 @@ class PostVote < ApplicationRecord belongs_to :post belongs_to :user attr_accessor :vote - attr_accessible :post, :post_id, :user, :user_id, :score, :vote after_initialize :initialize_attributes, if: :new_record? validates_presence_of :post_id, :user_id, :score diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb index 2a0077454..d57951a05 100644 --- a/app/models/saved_search.rb +++ b/app/models/saved_search.rb @@ -43,10 +43,10 @@ class SavedSearch < ApplicationRecord include ListbooruMethods + attr_accessor :disable_labels belongs_to :user validates :query, :presence => true validate :validate_count - attr_accessible :query, :label_string before_create :update_user_on_create after_destroy :update_user_on_destroy after_save {|rec| Cache.delete(SavedSearch.cache_key(rec.user_id))} @@ -128,4 +128,12 @@ class SavedSearch < ApplicationRecord labels = labels.map { |label| SavedSearch.normalize_label(label) } super(labels) end + + def disable_labels=(value) + CurrentUser.update(disable_categorized_saved_searches: true) if value == "1" + end + + def disable_labels=(value) + CurrentUser.update(disable_categorized_saved_searches: true) if value == "1" + end end diff --git a/app/models/tag.rb b/app/models/tag.rb index 6b628c8b8..7b8d41af5 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -3,8 +3,6 @@ class Tag < ApplicationRecord METATAGS = "-user|user|-approver|approver|commenter|comm|noter|noteupdater|artcomm|-pool|pool|ordpool|-favgroup|favgroup|-fav|fav|ordfav|md5|-rating|rating|-locked|locked|width|height|mpixels|ratio|score|favcount|filesize|source|-source|id|-id|date|age|order|limit|-status|status|tagcount|parent|-parent|child|pixiv_id|pixiv|search|upvote|downvote|filetype|-filetype|flagger|-flagger|appealer|-appealer|" + TagCategory.short_name_list.map {|x| "#{x}tags"}.join("|") SUBQUERY_METATAGS = "commenter|comm|noter|noteupdater|artcomm|flagger|-flagger|appealer|-appealer" - attr_accessible :category, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin] - attr_accessible :is_locked, :as => [:moderator, :admin] has_one :wiki_page, :foreign_key => "title", :primary_key => "name" has_one :artist, :foreign_key => "name", :primary_key => "name" has_one :antecedent_alias, lambda {active}, :class_name => "TagAlias", :foreign_key => "antecedent_name", :primary_key => "name" @@ -15,7 +13,7 @@ class Tag < ApplicationRecord validates :name, uniqueness: true, tag_name: true, on: :create validates_inclusion_of :category, in: TagCategory.category_ids - after_save :update_category_cache_for_all, if: :category_changed? + after_save :update_category_cache_for_all, if: lambda {|rec| rec.saved_change_to_attribute?(:category)} module ApiMethods def to_legacy_json diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index d289837b5..9491b458f 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -8,12 +8,6 @@ class TagAlias < TagRelationship validate :antecedent_and_consequent_are_different validate :consequent_has_wiki_page, :on => :create validate :mininum_antecedent_count, :on => :create - belongs_to :creator, :class_name => "User" - belongs_to :approver, :class_name => "User" - belongs_to :forum_topic - belongs_to :forum_post - attr_accessible :antecedent_name, :consequent_name, :forum_topic_id, :skip_secondary_validations - attr_accessible :status, :approver_id, :as => [:admin] module CacheMethods extend ActiveSupport::Concern @@ -38,7 +32,7 @@ class TagAlias < TagRelationship module ApprovalMethods def approve!(update_topic: true, approver: CurrentUser.user) CurrentUser.scoped(approver) do - update({ :status => "queued", :approver_id => approver.id }, :as => CurrentUser.role) + update(status: "queued", approver_id: approver.id) delay(:queue => "default").process!(update_topic: update_topic) end end @@ -80,7 +74,7 @@ class TagAlias < TagRelationship begin CurrentUser.scoped(approver) do - update({ :status => "processing" }, :as => CurrentUser.role) + update(status: "processing") move_aliases_and_implications move_saved_searches clear_all_cache @@ -88,7 +82,7 @@ class TagAlias < TagRelationship update_posts forum_updater.update(approval_message(approver), "APPROVED") if update_topic rename_wiki_and_artist - update({ :status => "active", :post_count => consequent_tag.post_count }, :as => CurrentUser.role) + update(status: "active", post_count: consequent_tag.post_count) end rescue Exception => e if tries < 5 @@ -99,7 +93,7 @@ class TagAlias < TagRelationship CurrentUser.scoped(approver) do forum_updater.update(failure_message(e), "FAILED") if update_topic - update({ :status => "error: #{e}" }, :as => CurrentUser.role) + update(status: "error: #{e}") end if Rails.env.production? @@ -220,7 +214,7 @@ class TagAlias < TagRelationship end def reject! - update({ :status => "deleted" }, :as => CurrentUser.role) + update(status: "deleted") clear_all_cache forum_updater.update(reject_message(CurrentUser.user), "REJECTED") destroy @@ -230,7 +224,7 @@ class TagAlias < TagRelationship return if skip_secondary_validations unless WikiPage.titled(consequent_name).exists? - self.errors[:base] = "The #{consequent_name} tag needs a corresponding wiki page" + self.errors[:base] << "The #{consequent_name} tag needs a corresponding wiki page" return false end end @@ -239,7 +233,7 @@ class TagAlias < TagRelationship return if skip_secondary_validations unless Post.fast_count(antecedent_name) >= 50 - self.errors[:base] = "The #{antecedent_name} tag must have at least 50 posts for an alias to be created" + self.errors[:base] << "The #{antecedent_name} tag must have at least 50 posts for an alias to be created" end end @@ -252,11 +246,11 @@ class TagAlias < TagRelationship def create_mod_action alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]]) - if id_changed? + if saved_change_to_id? ModAction.log("created #{status} #{alias_desc}",:tag_alias_create) else # format the changes hash more nicely. - change_desc = changes.except(:updated_at).map do |attribute, values| + change_desc = saved_changes.except(:updated_at).map do |attribute, values| old, new = values[0], values[1] if old.nil? %Q(set #{attribute} to "#{new}") diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index 4863a7551..25097fd9d 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -123,12 +123,12 @@ class TagImplication < TagRelationship return if skip_secondary_validations unless WikiPage.titled(consequent_name).exists? - self.errors[:base] = "The #{consequent_name} tag needs a corresponding wiki page" + self.errors[:base] << "The #{consequent_name} tag needs a corresponding wiki page" return false end unless WikiPage.titled(antecedent_name).exists? - self.errors[:base] = "The #{antecedent_name} tag needs a corresponding wiki page" + self.errors[:base] << "The #{antecedent_name} tag needs a corresponding wiki page" return false end end @@ -144,9 +144,9 @@ class TagImplication < TagRelationship begin CurrentUser.scoped(approver) do - update({ :status => "processing" }, :as => CurrentUser.role) + update(status: "processing") update_posts - update({ :status => "active" }, :as => CurrentUser.role) + update(status: "active") update_descendant_names_for_parents forum_updater.update(approval_message(approver), "APPROVED") if update_topic end @@ -158,7 +158,7 @@ class TagImplication < TagRelationship end forum_updater.update(failure_message(e), "FAILED") if update_topic - update({ :status => "error: #{e}" }, :as => CurrentUser.role) + update(status: "error: #{e}") if Rails.env.production? NewRelic::Agent.notice_error(e, :custom_params => {:tag_implication_id => id, :antecedent_name => antecedent_name, :consequent_name => consequent_name}) @@ -180,12 +180,12 @@ class TagImplication < TagRelationship end def approve!(approver: CurrentUser.user, update_topic: true) - update({ :status => "queued", :approver_id => approver.id }, :as => approver.role) + update(status: "queued", approver_id: approver.id) delay(:queue => "default").process!(update_topic: update_topic) end def reject! - update({ :status => "deleted", }, :as => CurrentUser.role) + update(status: "deleted") forum_updater.update(reject_message(CurrentUser.user), "REJECTED") destroy end @@ -193,11 +193,11 @@ class TagImplication < TagRelationship def create_mod_action implication = %Q("tag implication ##{id}":[#{Rails.application.routes.url_helpers.tag_implication_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]]) - if id_changed? + if saved_change_to_id? ModAction.log("created #{status} #{implication}",:tag_implication_create) else # format the changes hash more nicely. - change_desc = changes.except(:updated_at).map do |attribute, values| + change_desc = saved_changes.except(:updated_at).map do |attribute, values| old, new = values[0], values[1] if old.nil? %Q(set #{attribute} to "#{new}") diff --git a/app/models/tag_relationship.rb b/app/models/tag_relationship.rb index c7a43cd16..66ff817be 100644 --- a/app/models/tag_relationship.rb +++ b/app/models/tag_relationship.rb @@ -2,13 +2,11 @@ class TagRelationship < ApplicationRecord self.abstract_class = true attr_accessor :skip_secondary_validations - attr_accessible :antecedent_name, :consequent_name, :forum_topic_id, :skip_secondary_validations - attr_accessible :status, :approver_id, :as => [:admin] - belongs_to :creator, :class_name => "User" - belongs_to :approver, :class_name => "User" - belongs_to :forum_post - belongs_to :forum_topic + belongs_to_creator + belongs_to :approver, class_name: "User", optional: true + belongs_to :forum_post, optional: true + belongs_to :forum_topic, optional: true has_one :antecedent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "antecedent_name" has_one :consequent_tag, :class_name => "Tag", :foreign_key => "name", :primary_key => "consequent_name" diff --git a/app/models/tag_subscription.rb b/app/models/tag_subscription.rb index 434e067af..d00c59d18 100644 --- a/app/models/tag_subscription.rb +++ b/app/models/tag_subscription.rb @@ -1,11 +1,10 @@ class TagSubscription < ApplicationRecord belongs_to :creator, :class_name => "User" - attr_accessible :name, :tag_query, :post_ids, :is_public, :is_visible_on_profile validates_presence_of :name, :tag_query, :creator_id def migrate_to_saved_searches tag_query.split(/\r\n|\r|\n/).each do |query| - creator.saved_searches.create({query: query, labels: [name]}, without_protection: true) + creator.saved_searches.create(query: query, labels: [name]) end end diff --git a/app/models/upload.rb b/app/models/upload.rb index 7a20fbdcb..756554415 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -8,17 +8,19 @@ class Upload < ApplicationRecord :artist_commentary_desc, :include_artist_commentary, :referer_url, :downloaded_source, :replaced_post belongs_to :uploader, :class_name => "User" - belongs_to :post - before_validation :initialize_uploader, :on => :create + + belongs_to :post, optional: true + + before_validation :initialize_attributes validate :uploader_is_not_limited, :on => :create validate :file_or_source_is_present, :on => :create validate :rating_given - attr_accessible :file, :image_width, :image_height, :file_ext, :md5, - :file_size, :as_pending, :source, :rating, - :tag_string, :status, :backtrace, :post_id, :md5_confirmation, - :parent_id, :server, :artist_commentary_title, - :artist_commentary_desc, :include_artist_commentary, - :referer_url, :replaced_post + + def initialize_attributes + self.uploader_id = CurrentUser.user.id + self.uploader_ip_addr = CurrentUser.ip_addr + self.server = Danbooru.config.server_host + end module ValidationMethods def uploader_is_not_limited @@ -117,7 +119,7 @@ class Upload < ApplicationRecord self.source = source.to_s.strip if is_downloadable? self.downloaded_source, self.source, self.file = download_from_source(source, referer_url) - else + elsif self.file.respond_to?(:tempfile) self.file = self.file.tempfile end @@ -245,7 +247,7 @@ class Upload < ApplicationRecord result = Vips::Image.gifload(file.path, page: 1) rescue $ERROR_INFO if result.is_a?(Vips::Image) true - elsif result.is_a?(Vips::Error) && result.message.match?(/too few frames in GIF file/) + elsif result.is_a?(Vips::Error) && result.message =~ /too few frames in GIF file/ false else raise result @@ -337,7 +339,7 @@ class Upload < ApplicationRecord source =~ /^https?:\/\// && file.blank? end - def download_from_source(source, referer_url) + def download_from_source(source, referer_url = nil) download = Downloads::File.new(source, referer_url: referer_url) file = download.download! ugoira_service.load(download.data) @@ -369,11 +371,6 @@ class Upload < ApplicationRecord end module UploaderMethods - def initialize_uploader - self.uploader_id = CurrentUser.user.id - self.uploader_ip_addr = CurrentUser.ip_addr - end - def uploader_name User.id_to_name(uploader_id) end diff --git a/app/models/user.rb b/app/models/user.rb index 611fbd71d..5b504ea1c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,7 +15,7 @@ class User < ApplicationRecord ADMIN = 50 end - # Used for `before_filter :_only`. Must have a corresponding `is_?` method. + # Used for `before_action :_only`. Must have a corresponding `is_?` method. Roles = Levels.constants.map(&:downcase) + [ :anonymous, :banned, @@ -64,11 +64,10 @@ class User < ApplicationRecord has_bit_flags BOOLEAN_ATTRIBUTES, :field => "bit_prefs" attr_accessor :password, :old_password - attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :disable_categorized_saved_searches, :disable_tagged_filenames, :enable_recent_searches, :disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode, :disable_responsive_mode, :as => [:moderator, :gold, :platinum, :member, :anonymous, :default, :builder, :admin] - attr_accessible :level, :as => :admin + after_initialize :initialize_attributes, if: :new_record? validates :name, user_name: true, on: :create - validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present? && rec.email_changed? } + validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present? && rec.saved_change_to_email? } validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || rec.password.present?} validates_inclusion_of :default_image_size, :in => %w(large original) validates_inclusion_of :per_page, :in => 1..100 @@ -82,7 +81,6 @@ class User < ApplicationRecord before_validation :normalize_email before_create :encrypt_password_on_create before_update :encrypt_password_on_update - before_create :initialize_default_boolean_attributes after_save :update_cache after_update :update_remote_cache before_create :promote_to_admin_if_first_user @@ -105,7 +103,7 @@ class User < ApplicationRecord has_many :saved_searches has_many :forum_posts, lambda {order("forum_posts.created_at, forum_posts.id")}, :foreign_key => "creator_id" has_many :user_name_change_requests, lambda {visible.order("user_name_change_requests.created_at desc")} - belongs_to :inviter, :class_name => "User" + belongs_to :inviter, class_name: "User", optional: true after_update :create_mod_action accepts_nested_attributes_for :dmail_filter @@ -191,7 +189,7 @@ class User < ApplicationRecord end def update_remote_cache - if name_changed? + if saved_change_to_name? Danbooru.config.other_server_hosts.each do |server| HTTParty.delete("http://#{server}/users/#{id}/cache", Danbooru.config.httparty_options) end @@ -223,7 +221,7 @@ class User < ApplicationRecord self.bcrypt_password_hash = User.bcrypt(password) return true else - errors[:old_password] = "is incorrect" + errors[:old_password] << "is incorrect" return false end end @@ -385,6 +383,10 @@ class User < ApplicationRecord level_string.downcase.to_sym end + def level_string_before_last_save + level_string(level_before_last_save) + end + def level_string_was level_string(level_was) end @@ -438,8 +440,8 @@ class User < ApplicationRecord end def create_mod_action - if level_changed? - ModAction.log(%{"#{name}":/users/#{id} level changed #{level_string_was} -> #{level_string}},:user_level) + if saved_change_to_level? + ModAction.log(%{"#{name}":/users/#{id} level changed #{level_string_before_last_save} -> #{level_string}},:user_level) end end @@ -916,8 +918,8 @@ class User < ApplicationRecord extend SearchMethods include StatisticsMethods - def initialize_default_image_size - self.default_image_size = "large" + def as_current(&block) + CurrentUser.as(self, &block) end def can_update?(object, foreign_key = :user_id) @@ -936,7 +938,8 @@ class User < ApplicationRecord !CurrentUser.is_admin? && enable_privacy_mode? && CurrentUser.user.id != id end - def initialize_default_boolean_attributes + def initialize_attributes + self.last_ip_addr ||= CurrentUser.ip_addr self.enable_post_navigation = true self.new_post_navigation_layout = true self.enable_sequential_post_navigation = true diff --git a/app/models/user_feedback.rb b/app/models/user_feedback.rb index 6ed70cdb5..d80751590 100644 --- a/app/models/user_feedback.rb +++ b/app/models/user_feedback.rb @@ -1,10 +1,8 @@ class UserFeedback < ApplicationRecord self.table_name = "user_feedback" belongs_to :user - belongs_to :creator, :class_name => "User" - before_validation :initialize_creator, :on => :create - attr_accessor :disable_dmail_notification - attr_accessible :body, :user_id, :category, :user_name, :disable_dmail_notification + belongs_to_creator + attribute :disable_dmail_notification, :boolean validates_presence_of :user, :creator, :body, :category validates_inclusion_of :category, :in => %w(positive negative neutral) validate :creator_is_gold @@ -76,18 +74,10 @@ class UserFeedback < ApplicationRecord extend SearchMethods - def initialize_creator - self.creator_id ||= CurrentUser.id - end - def user_name User.id_to_name(user_id) end - def creator_name - User.id_to_name(creator_id) - end - def user_name=(name) self.user_id = User.name_to_id(name) end diff --git a/app/models/user_name_change_request.rb b/app/models/user_name_change_request.rb index 3c2ac923d..ba862e820 100644 --- a/app/models/user_name_change_request.rb +++ b/app/models/user_name_change_request.rb @@ -1,11 +1,16 @@ class UserNameChangeRequest < ApplicationRecord + after_initialize :initialize_attributes, if: :new_record? validates_presence_of :user_id, :original_name, :desired_name validates_inclusion_of :status, :in => %w(pending approved rejected) belongs_to :user - belongs_to :approver, :class_name => "User" + belongs_to :approver, :class_name => "User", optional: true validate :not_limited, :on => :create validates :desired_name, user_name: true - attr_accessible :status, :user_id, :original_name, :desired_name, :change_reason, :rejection_reason, :approver_id + + def initialize_attributes + self.user_id ||= CurrentUser.user.id + self.original_name ||= CurrentUser.user.name + end def self.pending where(:status => "pending") diff --git a/app/models/user_password_reset_nonce.rb b/app/models/user_password_reset_nonce.rb index dba29444e..fbdc0e151 100644 --- a/app/models/user_password_reset_nonce.rb +++ b/app/models/user_password_reset_nonce.rb @@ -3,7 +3,6 @@ class UserPasswordResetNonce < ApplicationRecord validate :validate_existence_of_email before_validation :initialize_key, :on => :create after_create :deliver_notice - attr_accessible :key, :nonce, :email def self.prune! destroy_all(["created_at < ?", 1.week.ago]) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 8b772e962..016d4d70a 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -3,19 +3,15 @@ class WikiPage < ApplicationRecord before_save :normalize_title before_save :normalize_other_names - before_validation :initialize_creator, :on => :create - before_validation :initialize_updater after_save :create_version - belongs_to :creator, :class_name => "User" - belongs_to :updater, :class_name => "User" + belongs_to_creator + belongs_to_updater validates_uniqueness_of :title, :case_sensitive => false validates_presence_of :title validates_presence_of :body, :unless => -> { is_deleted? || other_names.present? } validate :validate_rename - validate :validate_locker_is_builder validate :validate_not_locked attr_accessor :skip_secondary_validations - attr_accessible :title, :body, :is_locked, :is_deleted, :other_names, :skip_secondary_validations has_one :tag, :foreign_key => "name", :primary_key => "title" has_one :artist, lambda {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title" has_many :versions, lambda {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy @@ -127,13 +123,6 @@ class WikiPage < ApplicationRecord titled(title).select("title, id").first end - def validate_locker_is_builder - if is_locked_changed? && !CurrentUser.is_builder? - errors.add(:is_locked, "can be modified by builders only") - return false - end - end - def validate_not_locked if is_locked? && !CurrentUser.is_builder? errors.add(:is_locked, "and cannot be updated") @@ -142,7 +131,7 @@ class WikiPage < ApplicationRecord end def validate_rename - return if !title_changed? || skip_secondary_validations + return if !will_save_change_to_title? || skip_secondary_validations tag_was = Tag.find_by_name(Tag.normalize_name(title_was)) if tag_was.present? && tag_was.post_count > 0 @@ -179,10 +168,6 @@ class WikiPage < ApplicationRecord @skip_secondary_validations = (value == true || value == "1") end - def creator_name - User.id_to_name(creator_id) - end - def category_name Tag.category_for(title) end @@ -192,7 +177,7 @@ class WikiPage < ApplicationRecord end def wiki_page_changed? - title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed? + saved_change_to_title? || saved_change_to_body? || saved_change_to_is_locked? || saved_change_to_is_deleted? || saved_change_to_other_names? end def merge_version @@ -232,20 +217,6 @@ class WikiPage < ApplicationRecord end end end - - def updater_name - User.id_to_name(updater_id) - end - - def initialize_creator - self.creator_id = CurrentUser.user.id - end - - def initialize_updater - if wiki_page_changed? - self.updater_id = CurrentUser.user.id - end - end def post_set @post_set ||= PostSets::WikiPage.new(title, 1, 4) diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index e939c0b84..b91aaed4f 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -1,8 +1,7 @@ class WikiPageVersion < ApplicationRecord belongs_to :wiki_page - belongs_to :updater, :class_name => "User" - belongs_to :artist - attr_accessible :wiki_page_id, :title, :body, :is_locked, :is_deleted, :updater_id, :updater_ip_addr, :version, :other_names + belongs_to_updater + belongs_to :artist, optional: true delegate :visible?, :to => :wiki_page module SearchMethods @@ -27,10 +26,6 @@ class WikiPageVersion < ApplicationRecord extend SearchMethods - def updater_name - User.id_to_name(updater_id) - end - def pretty_title title.tr("_", " ") end diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 4d72d2517..e1e69f325 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -58,7 +58,7 @@ class PostPresenter < Presenter if options[:size] html << %{

} - html << post.file_size.to_formatted_s(:human_size) + html << post.file_size.to_s(:human_size) html << " (#{post.image_width}x#{post.image_height})" html << %{

} end diff --git a/app/presenters/post_set_presenters/post.rb b/app/presenters/post_set_presenters/post.rb index 1d0e43106..27a81bd3b 100644 --- a/app/presenters/post_set_presenters/post.rb +++ b/app/presenters/post_set_presenters/post.rb @@ -22,8 +22,6 @@ module PostSetPresenters related_tags_for_single(post_set.unordered_tag_array.first) elsif post_set.tag_string =~ /(?:^|\s)(?:#{Tag::SUBQUERY_METATAGS}):\S+/ calculate_related_tags_from_post_set - elsif post_set.tag_string =~ /search:/ - saved_search_tags elsif post_set.is_empty_tag? popular_tags else diff --git a/app/views/bans/edit.html.erb b/app/views/bans/edit.html.erb index 6af6bcf31..213413430 100644 --- a/app/views/bans/edit.html.erb +++ b/app/views/bans/edit.html.erb @@ -1,7 +1,14 @@

Edit Ban

- <%= render "form", :ban => @ban %> + + <%= simple_form_for(@ban) do |f| %> + <%= error_messages_for("ban") %> + + <%= f.input :duration, :hint => "in days" %> + <%= f.input :reason %> + <%= f.button :submit, :value => "Ban" %> + <% end %>
diff --git a/app/views/bans/index.html.erb b/app/views/bans/index.html.erb index be02630f0..e5be766a3 100644 --- a/app/views/bans/index.html.erb +++ b/app/views/bans/index.html.erb @@ -20,11 +20,11 @@ <%= link_to_user(ban.user) %> - <%= link_to "»", bans_path(search: params[:search].merge(user_name: ban.user.name)) %> + <%= link_to "»", bans_path(search: search_params.merge(user_name: ban.user.name)) %> <%= link_to_user(ban.banner) %> - <%= link_to "»", bans_path(search: params[:search].merge(banner_name: ban.banner.name)) %> + <%= link_to "»", bans_path(search: search_params.merge(banner_name: ban.banner.name)) %> <%= time_ago_in_words_tagged(ban.created_at) %> <%= humanized_duration(ban.created_at, ban.expires_at) %> diff --git a/app/views/comments/_index_by_comment.html.erb b/app/views/comments/_index_by_comment.html.erb index 13da58138..01ebabe3f 100644 --- a/app/views/comments/_index_by_comment.html.erb +++ b/app/views/comments/_index_by_comment.html.erb @@ -18,4 +18,4 @@ <%= numbered_paginator(@comments) %> -<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(:atom, search: params[:search]), title: "Comments")) %> +<% content_for(:html_header, auto_discovery_link_tag(:atom, comments_url(format: "atom"), title: "Comments")) %> diff --git a/app/views/forum_posts/partials/edit/_form.html.erb b/app/views/forum_posts/partials/edit/_form.html.erb index 2117b78fc..5cc5f49b2 100644 --- a/app/views/forum_posts/partials/edit/_form.html.erb +++ b/app/views/forum_posts/partials/edit/_form.html.erb @@ -1,7 +1,6 @@ <%= error_messages_for("forum_post") %> <%= simple_form_for(forum_post) do |f| %> - <%= f.input :topic_id, :as => :hidden %> <%= dtext_field "forum_post", "body", :value => forum_post.body, :classes => "autocomplete-mentions", :input_id => "forum_post_body_for_#{forum_post.id}", :preview_id => "dtext-preview-for-#{forum_post.id}" %> <%= f.button :submit, "Submit" %> diff --git a/app/views/forum_topics/_form.html.erb b/app/views/forum_topics/_form.html.erb index c5ff6df7f..e19c12128 100644 --- a/app/views/forum_topics/_form.html.erb +++ b/app/views/forum_topics/_form.html.erb @@ -10,10 +10,6 @@ <%= f.simple_fields_for :original_post do |pf| %> - <% if !forum_topic.new_record? %> - <%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", forum_topic.id %> - <% end %> - <%= dtext_field "forum_post", "body", :classes => "autocomplete-mentions", :input_name => "forum_topic[original_post_attributes][body]", :value => forum_topic.original_post.body, :input_id => "forum_post_body_for_#{forum_topic.original_post.id}", :preview_id => "dtext-preview-for-#{forum_topic.original_post.id}" %> <% end %> diff --git a/app/views/forum_topics/_listing.html.erb b/app/views/forum_topics/_listing.html.erb index 874cd0b04..bf0850176 100644 --- a/app/views/forum_topics/_listing.html.erb +++ b/app/views/forum_topics/_listing.html.erb @@ -20,7 +20,7 @@ NEW <% end %> - <%= link_to topic.title, forum_topic_path(topic) %> + <%= link_to topic.title, forum_topic_path(topic), class: "forum-post-link" %> <% if topic.response_count > Danbooru.config.posts_per_page %> <%= link_to "page #{topic.last_page}", forum_topic_path(topic, :page => topic.last_page), :class => "last-page" %> diff --git a/app/views/moderator/post/disapprovals/create.js.erb b/app/views/moderator/post/disapprovals/create.js.erb index 946be5a5e..33275491e 100644 --- a/app/views/moderator/post/disapprovals/create.js.erb +++ b/app/views/moderator/post/disapprovals/create.js.erb @@ -9,4 +9,4 @@ $("#c-posts #approve").hide(); $("#c-posts #disapprove").hide(); $("#pending-approval-notice, .notice-flagged, .notice-appealed").hide(); -$("#c-moderator-post-queues #post-<%= @post.id %>").hide(); +$("#c-moderator-post-queues #post-<%= @post_disapproval.post.id %>").hide(); diff --git a/app/views/moderator/post/queues/_post.html.erb b/app/views/moderator/post/queues/_post.html.erb index 3369e8045..f9fb8d2b1 100644 --- a/app/views/moderator/post/queues/_post.html.erb +++ b/app/views/moderator/post/queues/_post.html.erb @@ -6,13 +6,7 @@
  • -

    - <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :class => "approve-link" %> - | <%= link_to "Breaks Rules", moderator_post_disapproval_path(:post_id => post.id, :reason => "breaks_rules"), :remote => true, :method => :post, :class => "disapprove-link" %> - | <%= link_to "Poor Quality", moderator_post_disapproval_path(:post_id => post.id, :reason => "poor_quality"), :remote => true, :method => :post, :class => "disapprove-link" %> - | <%= link_to "No Interest", moderator_post_disapproval_path(:post_id => post.id, :reason => "disinterest"), :remote => true, :method => :post, :class => "disapprove-link" %> - | <%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, :class => "detailed-rejection-link" %> -

    +

    <%= render "moderator/post/queues/quick_mod", post: post %>

  • Rating: <%= post.pretty_rating %>
  • Score: <%= post.score %>
  • diff --git a/app/views/moderator/post/queues/_quick_mod.html.erb b/app/views/moderator/post/queues/_quick_mod.html.erb new file mode 100644 index 000000000..f0a043f13 --- /dev/null +++ b/app/views/moderator/post/queues/_quick_mod.html.erb @@ -0,0 +1,7 @@ +
    + <%= link_to_if post.is_approvable?, "Approve", moderator_post_approval_path(post_id: post.id), id: "quick-mod-approve", method: :post, remote: true, class: "btn" %> | + <%= link_to "Breaks Rules", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "breaks_rules" }), method: :post, remote: true, class: "btn" %> | + <%= link_to "Poor Quality", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "poor_quality" }), method: :post, remote: true, class: "btn" %> | + <%= link_to "No Interest", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), method: :post, remote: true, class: "btn" %> | + <%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, class: "detailed-rejection-link btn" %> +
    diff --git a/app/views/note_versions/_standard_listing.html.erb b/app/views/note_versions/_standard_listing.html.erb index 33cc9a770..64399f0cc 100644 --- a/app/views/note_versions/_standard_listing.html.erb +++ b/app/views/note_versions/_standard_listing.html.erb @@ -16,7 +16,7 @@ <% @note_versions.each do |note_version| %> - + <%= link_to note_version.post_id, post_path(note_version.post_id) %> diff --git a/app/views/pool_versions/_standard_listing.html.erb b/app/views/pool_versions/_standard_listing.html.erb index 209449dd4..38a518c81 100644 --- a/app/views/pool_versions/_standard_listing.html.erb +++ b/app/views/pool_versions/_standard_listing.html.erb @@ -15,7 +15,7 @@ <% @pool_versions.each do |pool_version| %> - + <%= link_to pool_version.pretty_name, pool_path(pool_version.pool_id), :class => "pool-category-#{pool_version.pool.category}" %> <%= link_to pool_version.post_ids.size, pool_versions_path(:search => {:pool_id => pool_version.pool_id}) %> <%= pool_version_diff(pool_version) %> diff --git a/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb b/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb index 09b95feac..1529032b0 100644 --- a/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb +++ b/app/views/post_disapprovals/_detailed_rejection_dialog.html.erb @@ -1,17 +1,9 @@ diff --git a/app/views/post_votes/create.js.erb b/app/views/post_votes/create.js.erb index 4ed12dbad..c61179241 100644 --- a/app/views/post_votes/create.js.erb +++ b/app/views/post_votes/create.js.erb @@ -3,7 +3,6 @@ <% else %> Danbooru.notice("Vote saved"); $("#score-for-post-<%= @post.id %>").html(<%= @post.score %>); + $("#vote-links-for-post-<%= @post.id %>").hide(); + $("#unvote-link-for-post-<%= @post.id %>").show(); <% end %> - -$("#vote-links-for-post-<%= @post.id %>").hide(); -$("#unvote-link-for-post-<%= @post.id %>").show(); diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 9d424b9da..86b9f795d 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -41,16 +41,7 @@ <%= render "post_disapprovals/counts", :disapprovals => post.disapprovals, :post => post %> <% if CurrentUser.can_approve_posts? && !post.disapproved_by?(CurrentUser.user) %> -
    - <% unless post.is_status_locked? %> - <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :id => "quick-mod-approve", :method => :post, :remote => true, :class => "btn" %> | - <% end %> - <%= link_to "Breaks Rules", moderator_post_disapproval_path(:post_id => post.id, :reason => "breaks_rules"), :method => :post, :remote => true, :class => "btn" %> | - <%= link_to "Poor Quality", moderator_post_disapproval_path(:post_id => post.id, :reason => "poor_quality"), :method => :post, :remote => true, :class => "btn" %> | - <%= link_to "No Interest", moderator_post_disapproval_path(:post_id => post.id, :reason => "disinterest"), :method => :post, :remote => true, :class => "btn" %> | - <%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, :class => "detailed-rejection-link btn" %> - -
    + <%= render "moderator/post/queues/quick_mod", post: post %> <% end %> <% end %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 130bf434d..1bc8815b3 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -42,7 +42,7 @@ <% if post.is_flagged? || post.is_pending? %>
  • <%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :id => "approve", :data => { :confirm => "Are you sure you want to approve this post?" } %>
  • <% else %> -
  • <%= link_to "Hide from queue", moderator_post_disapproval_path(:post_id => post.id), :remote => true, :method => :post, :id => "disapprove" %>
  • +
  • <%= link_to "Hide from queue", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %>
  • <% end %> <% if post.is_banned? %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 6d3ac195b..691da1ae0 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -144,10 +144,6 @@ - -
    - <%= render "saved_searches/interface" %> -
    <%= post_view_count_js %> diff --git a/app/views/saved_searches/_interface.html.erb b/app/views/saved_searches/_interface.html.erb index 28f618fbb..8d735839a 100644 --- a/app/views/saved_searches/_interface.html.erb +++ b/app/views/saved_searches/_interface.html.erb @@ -1,14 +1,10 @@ <% if SavedSearch.enabled? %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/saved_searches/edit.html.erb b/app/views/saved_searches/edit.html.erb index 1005282a0..71f496f30 100644 --- a/app/views/saved_searches/edit.html.erb +++ b/app/views/saved_searches/edit.html.erb @@ -5,7 +5,7 @@ <%= error_messages_for :saved_search %> <%= simple_form_for(@saved_search) do |f| %> - <%= f.input :query %> + <%= f.input :query, :as => :string %> <%= f.input :label_string, :label => "Labels", :hint => "A list of tags to help categorize this search. Space delimited." %> <%= f.button :submit, :value => "Submit", :data => { :disable_with => "Submitting..." } %> <% end %> diff --git a/app/views/uploads/batch.html.erb b/app/views/uploads/batch.html.erb index 77551a2e9..1cd12a528 100644 --- a/app/views/uploads/batch.html.erb +++ b/app/views/uploads/batch.html.erb @@ -12,8 +12,10 @@ <%= link_to new_upload_path(url: url, ref: params[:url]), target: "_blank" do %> <% if ImageProxy.needs_proxy?(url) %> <%= image_tag(image_proxy_uploads_path(url: url)) %> - <% else %> + <% elsif url.is_a?(String) %> <%= image_tag url %> + <% else %> + Direct Link <% end %> <% end %> diff --git a/app/views/user_name_change_requests/new.html.erb b/app/views/user_name_change_requests/new.html.erb index 2f54f4e5f..af81b58dc 100644 --- a/app/views/user_name_change_requests/new.html.erb +++ b/app/views/user_name_change_requests/new.html.erb @@ -8,15 +8,9 @@ <%= error_messages_for "change_request" %> - <%= form_tag(user_name_change_requests_path, :class => "simple_form") do %> -
    - - <%= text_field_tag "desired_name" %> -
    - -
    - <%= submit_tag "Submit", :data => { :disable_with => "Submitting..." } %> -
    + <%= simple_form_for(@change_request) do |f| %> + <%= f.input :desired_name %> + <%= f.submit "Submit", data: { disable_with: "Submitting..." } %> <% end %> diff --git a/bin/rails b/bin/rails index 5191e6927..073966023 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup index acdb2c138..78c4e861d 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,38 @@ #!/usr/bin/env ruby require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! 'bin/rails restart' end diff --git a/bin/update b/bin/update new file mode 100755 index 000000000..a8e4462f2 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..c2bacef83 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +VENDOR_PATH = File.expand_path('..', __dir__) +Dir.chdir(VENDOR_PATH) do + begin + exec "yarnpkg #{ARGV.join(" ")}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index b5627814a..92d06bc4b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,13 +1,16 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' if defined?(Bundler) Bundler.require(:default, Rails.env) end +Bundler.require(*Rails.groups) module Danbooru class Application < Rails::Application - + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.1 + config.active_record.schema_format = :sql config.encoding = "utf-8" config.filter_parameters += [:password] @@ -20,7 +23,7 @@ module Danbooru config.action_mailer.smtp_settings = {:enable_starttls_auto => false} config.action_mailer.perform_deliveries = true config.log_tags = [lambda {|req| "PID:#{Process.pid}"}] - config.active_record.raise_in_transactional_callbacks = true + config.action_controller.action_on_unpermitted_parameters = :raise if File.exists?("#{config.root}/REVISION") config.x.git_hash = File.read("#{config.root}/REVISION").strip diff --git a/config/boot.rb b/config/boot.rb index 0fe553980..3455ce0c0 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile. require 'bootsnap' diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 000000000..d923d9731 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 + channel_prefix: danbooru_production diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc6..426333bb4 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 10f04e7ec..b8a0406b1 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -10,12 +10,24 @@ Rails.application.configure do config.eager_load = false # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + config.consider_all_requests_local = true + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" + } + else + config.action_controller.perform_caching = false + config.cache_store = :null_store + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -25,12 +37,10 @@ Rails.application.configure do # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = false + config.assets.debug = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = false - config.assets.compress = false + # Suppress logger output for asset requests. + config.assets.quiet = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. @@ -41,4 +51,8 @@ Rails.application.configure do # config.action_view.raise_on_missing_translations = true config.eager_load = false + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index dde8016ca..798cb1d32 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,33 +14,36 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Attempt to read encrypted secrets from `config/secrets.yml.enc`. + # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or + # `config/secrets.yml.key`. + config.read_encrypted_secrets = false # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = true - - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true + config.assets.compile = false # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -49,16 +52,15 @@ Rails.application.configure do config.log_level = :error # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "danbooru_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -74,8 +76,16 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - - config.eager_load = true end diff --git a/config/environments/test.rb b/config/environments/test.rb index 41c02c0d4..8e5cbde53 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ Rails.application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -25,20 +27,16 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Randomize the order test cases are executed. - config.active_support.test_order = :random - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - - config.eager_load = false end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..89d2efab2 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 07bbd08c4..ac075a7bf 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -# Add additional assets to the asset load path +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# application.js, application.css, and all non-JS/CSS in the app/assets Rails.application.config.assets.precompile += %w( *.png *.jpg *.gif ) diff --git a/config/initializers/new_framework_defaults_5_1.rb b/config/initializers/new_framework_defaults_5_1.rb new file mode 100644 index 000000000..9010abd5c --- /dev/null +++ b/config/initializers/new_framework_defaults_5_1.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Make `form_with` generate non-remote forms. +Rails.application.config.action_view.form_with_generates_remote_forms = false + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 007c0deff..bffab6c85 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,7 +5,7 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 000000000..1e19380dc --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..c9119b40c --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/migrate/20171106075030_add_tag_count_meta_to_posts.rb b/db/migrate/20171106075030_add_tag_count_meta_to_posts.rb index c82afaf66..b941571dc 100644 --- a/db/migrate/20171106075030_add_tag_count_meta_to_posts.rb +++ b/db/migrate/20171106075030_add_tag_count_meta_to_posts.rb @@ -1,4 +1,4 @@ -class AddTagCountMetaToPosts < ActiveRecord::Migration +class AddTagCountMetaToPosts < ActiveRecord::Migration[4.2] def change Post.without_timeout do add_column :posts, :tag_count_meta, :integer, default: 0, null: false diff --git a/db/migrate/20171127195124_add_trigram_index_to_tags.rb b/db/migrate/20171127195124_add_trigram_index_to_tags.rb index adcc47be5..6b468a4fc 100644 --- a/db/migrate/20171127195124_add_trigram_index_to_tags.rb +++ b/db/migrate/20171127195124_add_trigram_index_to_tags.rb @@ -1,4 +1,4 @@ -class AddTrigramIndexToTags < ActiveRecord::Migration +class AddTrigramIndexToTags < ActiveRecord::Migration[4.2] def up Tag.without_timeout do execute "create index index_tags_on_name_trgm on tags using gin (name gin_trgm_ops)" diff --git a/db/migrate/20171218213037_add_metadata_to_post_replacements.rb b/db/migrate/20171218213037_add_metadata_to_post_replacements.rb index 1a2e9becd..aaae5bc20 100644 --- a/db/migrate/20171218213037_add_metadata_to_post_replacements.rb +++ b/db/migrate/20171218213037_add_metadata_to_post_replacements.rb @@ -1,4 +1,4 @@ -class AddMetadataToPostReplacements < ActiveRecord::Migration +class AddMetadataToPostReplacements < ActiveRecord::Migration[4.2] def change PostReplacement.without_timeout do add_column :post_replacements, :file_ext_was, :string diff --git a/db/migrate/20171219001521_add_is_public_to_favorite_groups.rb b/db/migrate/20171219001521_add_is_public_to_favorite_groups.rb index fb99e21cf..3333ab019 100644 --- a/db/migrate/20171219001521_add_is_public_to_favorite_groups.rb +++ b/db/migrate/20171219001521_add_is_public_to_favorite_groups.rb @@ -1,4 +1,4 @@ -class AddIsPublicToFavoriteGroups < ActiveRecord::Migration +class AddIsPublicToFavoriteGroups < ActiveRecord::Migration[4.2] def change FavoriteGroup.without_timeout do add_column :favorite_groups, :is_public, :boolean, default: false, null: false diff --git a/db/migrate/20171230220225_change_timestamps_to_non_null_on_tags.rb b/db/migrate/20171230220225_change_timestamps_to_non_null_on_tags.rb index 9caf220cb..8a570015f 100644 --- a/db/migrate/20171230220225_change_timestamps_to_non_null_on_tags.rb +++ b/db/migrate/20171230220225_change_timestamps_to_non_null_on_tags.rb @@ -1,4 +1,4 @@ -class ChangeTimestampsToNonNullOnTags < ActiveRecord::Migration +class ChangeTimestampsToNonNullOnTags < ActiveRecord::Migration[4.2] def change Post.without_timeout do change_column_null :tags, :created_at, false diff --git a/db/migrate/20180113211343_add_category_to_mod_actions.rb b/db/migrate/20180113211343_add_category_to_mod_actions.rb index 36534abc2..aa39731de 100644 --- a/db/migrate/20180113211343_add_category_to_mod_actions.rb +++ b/db/migrate/20180113211343_add_category_to_mod_actions.rb @@ -1,4 +1,4 @@ -class AddCategoryToModActions < ActiveRecord::Migration +class AddCategoryToModActions < ActiveRecord::Migration[4.2] def change ModAction.without_timeout do add_column :mod_actions, :category, :integer diff --git a/db/migrate/20180116001101_add_keeper_data_to_posts.rb b/db/migrate/20180116001101_add_keeper_data_to_posts.rb deleted file mode 100644 index e7edcd1e6..000000000 --- a/db/migrate/20180116001101_add_keeper_data_to_posts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddKeeperDataToPosts < ActiveRecord::Migration - def change - add_column :posts, :keeper_data, :text - end -end diff --git a/db/migrate/20180403231351_change_post_flags_reason_type.rb b/db/migrate/20180403231351_change_post_flags_reason_type.rb index 991135a8f..7f7c6ebae 100644 --- a/db/migrate/20180403231351_change_post_flags_reason_type.rb +++ b/db/migrate/20180403231351_change_post_flags_reason_type.rb @@ -1,4 +1,4 @@ -class ChangePostFlagsReasonType < ActiveRecord::Migration +class ChangePostFlagsReasonType < ActiveRecord::Migration[4.2] def change change_column :post_flags, :reason, :text change_column :post_appeals, :reason, :text diff --git a/db/structure.sql b/db/structure.sql index d7f212ab0..764ad9659 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,15 +1,9 @@ --- --- PostgreSQL database dump --- - --- Dumped from database version 9.6.6 --- Dumped by pg_dump version 9.6.6 - SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET client_min_messages = warning; SET row_security = off; @@ -42,13 +36,11 @@ CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public; COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams'; -SET search_path = public, pg_catalog; - -- -- Name: favorites_insert_trigger(); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION favorites_insert_trigger() RETURNS trigger +CREATE FUNCTION public.favorites_insert_trigger() RETURNS trigger LANGUAGE plpgsql AS $$ begin @@ -361,7 +353,7 @@ CREATE FUNCTION favorites_insert_trigger() RETURNS trigger -- Name: sourcepattern(text); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION sourcepattern(src text) RETURNS text +CREATE FUNCTION public.sourcepattern(src text) RETURNS text LANGUAGE plpgsql IMMUTABLE STRICT AS $_$ BEGIN @@ -374,7 +366,7 @@ CREATE FUNCTION sourcepattern(src text) RETURNS text -- Name: testprs_end(internal); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION testprs_end(internal) RETURNS void +CREATE FUNCTION public.testprs_end(internal) RETURNS void LANGUAGE c STRICT AS '$libdir/test_parser', 'testprs_end'; @@ -383,7 +375,7 @@ CREATE FUNCTION testprs_end(internal) RETURNS void -- Name: testprs_getlexeme(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION testprs_getlexeme(internal, internal, internal) RETURNS internal +CREATE FUNCTION public.testprs_getlexeme(internal, internal, internal) RETURNS internal LANGUAGE c STRICT AS '$libdir/test_parser', 'testprs_getlexeme'; @@ -392,7 +384,7 @@ CREATE FUNCTION testprs_getlexeme(internal, internal, internal) RETURNS internal -- Name: testprs_lextype(internal); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION testprs_lextype(internal) RETURNS internal +CREATE FUNCTION public.testprs_lextype(internal) RETURNS internal LANGUAGE c STRICT AS '$libdir/test_parser', 'testprs_lextype'; @@ -401,7 +393,7 @@ CREATE FUNCTION testprs_lextype(internal) RETURNS internal -- Name: testprs_start(internal, integer); Type: FUNCTION; Schema: public; Owner: - -- -CREATE FUNCTION testprs_start(internal, integer) RETURNS internal +CREATE FUNCTION public.testprs_start(internal, integer) RETURNS internal LANGUAGE c STRICT AS '$libdir/test_parser', 'testprs_start'; @@ -410,22 +402,22 @@ CREATE FUNCTION testprs_start(internal, integer) RETURNS internal -- Name: testparser; Type: TEXT SEARCH PARSER; Schema: public; Owner: - -- -CREATE TEXT SEARCH PARSER testparser ( - START = testprs_start, - GETTOKEN = testprs_getlexeme, - END = testprs_end, +CREATE TEXT SEARCH PARSER public.testparser ( + START = public.testprs_start, + GETTOKEN = public.testprs_getlexeme, + END = public.testprs_end, HEADLINE = prsd_headline, - LEXTYPES = testprs_lextype ); + LEXTYPES = public.testprs_lextype ); -- -- Name: danbooru; Type: TEXT SEARCH CONFIGURATION; Schema: public; Owner: - -- -CREATE TEXT SEARCH CONFIGURATION danbooru ( - PARSER = testparser ); +CREATE TEXT SEARCH CONFIGURATION public.danbooru ( + PARSER = public.testparser ); -ALTER TEXT SEARCH CONFIGURATION danbooru +ALTER TEXT SEARCH CONFIGURATION public.danbooru ADD MAPPING FOR word WITH simple; @@ -437,7 +429,7 @@ SET default_with_oids = false; -- Name: advertisement_hits; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE advertisement_hits ( +CREATE TABLE public.advertisement_hits ( id integer NOT NULL, advertisement_id integer NOT NULL, ip_addr inet NOT NULL, @@ -450,7 +442,7 @@ CREATE TABLE advertisement_hits ( -- Name: advertisement_hits_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE advertisement_hits_id_seq +CREATE SEQUENCE public.advertisement_hits_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -462,14 +454,14 @@ CREATE SEQUENCE advertisement_hits_id_seq -- Name: advertisement_hits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE advertisement_hits_id_seq OWNED BY advertisement_hits.id; +ALTER SEQUENCE public.advertisement_hits_id_seq OWNED BY public.advertisement_hits.id; -- -- Name: advertisements; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE advertisements ( +CREATE TABLE public.advertisements ( id integer NOT NULL, referral_url text NOT NULL, ad_type character varying NOT NULL, @@ -488,7 +480,7 @@ CREATE TABLE advertisements ( -- Name: advertisements_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE advertisements_id_seq +CREATE SEQUENCE public.advertisements_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -500,14 +492,14 @@ CREATE SEQUENCE advertisements_id_seq -- Name: advertisements_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE advertisements_id_seq OWNED BY advertisements.id; +ALTER SEQUENCE public.advertisements_id_seq OWNED BY public.advertisements.id; -- -- Name: amazon_backups; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE amazon_backups ( +CREATE TABLE public.amazon_backups ( id integer NOT NULL, last_id integer, created_at timestamp without time zone, @@ -519,7 +511,7 @@ CREATE TABLE amazon_backups ( -- Name: amazon_backups_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE amazon_backups_id_seq +CREATE SEQUENCE public.amazon_backups_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -531,14 +523,14 @@ CREATE SEQUENCE amazon_backups_id_seq -- Name: amazon_backups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE amazon_backups_id_seq OWNED BY amazon_backups.id; +ALTER SEQUENCE public.amazon_backups_id_seq OWNED BY public.amazon_backups.id; -- -- Name: anti_voters; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE anti_voters ( +CREATE TABLE public.anti_voters ( id integer NOT NULL, user_id integer, created_at timestamp without time zone NOT NULL, @@ -550,7 +542,7 @@ CREATE TABLE anti_voters ( -- Name: anti_voters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE anti_voters_id_seq +CREATE SEQUENCE public.anti_voters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -562,14 +554,14 @@ CREATE SEQUENCE anti_voters_id_seq -- Name: anti_voters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE anti_voters_id_seq OWNED BY anti_voters.id; +ALTER SEQUENCE public.anti_voters_id_seq OWNED BY public.anti_voters.id; -- -- Name: api_keys; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE api_keys ( +CREATE TABLE public.api_keys ( id integer NOT NULL, user_id integer NOT NULL, key character varying NOT NULL, @@ -582,7 +574,7 @@ CREATE TABLE api_keys ( -- Name: api_keys_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE api_keys_id_seq +CREATE SEQUENCE public.api_keys_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -594,14 +586,26 @@ CREATE SEQUENCE api_keys_id_seq -- Name: api_keys_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE api_keys_id_seq OWNED BY api_keys.id; +ALTER SEQUENCE public.api_keys_id_seq OWNED BY public.api_keys.id; + + +-- +-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.ar_internal_metadata ( + key character varying NOT NULL, + value character varying, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); -- -- Name: artist_commentaries; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE artist_commentaries ( +CREATE TABLE public.artist_commentaries ( id integer NOT NULL, post_id integer NOT NULL, original_title text DEFAULT ''::text NOT NULL, @@ -617,7 +621,7 @@ CREATE TABLE artist_commentaries ( -- Name: artist_commentaries_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE artist_commentaries_id_seq +CREATE SEQUENCE public.artist_commentaries_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -629,14 +633,14 @@ CREATE SEQUENCE artist_commentaries_id_seq -- Name: artist_commentaries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE artist_commentaries_id_seq OWNED BY artist_commentaries.id; +ALTER SEQUENCE public.artist_commentaries_id_seq OWNED BY public.artist_commentaries.id; -- -- Name: artist_commentary_versions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE artist_commentary_versions ( +CREATE TABLE public.artist_commentary_versions ( id integer NOT NULL, post_id integer NOT NULL, updater_id integer NOT NULL, @@ -654,7 +658,7 @@ CREATE TABLE artist_commentary_versions ( -- Name: artist_commentary_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE artist_commentary_versions_id_seq +CREATE SEQUENCE public.artist_commentary_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -666,14 +670,14 @@ CREATE SEQUENCE artist_commentary_versions_id_seq -- Name: artist_commentary_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE artist_commentary_versions_id_seq OWNED BY artist_commentary_versions.id; +ALTER SEQUENCE public.artist_commentary_versions_id_seq OWNED BY public.artist_commentary_versions.id; -- -- Name: artist_urls; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE artist_urls ( +CREATE TABLE public.artist_urls ( id integer NOT NULL, artist_id integer NOT NULL, url text NOT NULL, @@ -687,7 +691,7 @@ CREATE TABLE artist_urls ( -- Name: artist_urls_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE artist_urls_id_seq +CREATE SEQUENCE public.artist_urls_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -699,14 +703,14 @@ CREATE SEQUENCE artist_urls_id_seq -- Name: artist_urls_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE artist_urls_id_seq OWNED BY artist_urls.id; +ALTER SEQUENCE public.artist_urls_id_seq OWNED BY public.artist_urls.id; -- -- Name: artist_versions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE artist_versions ( +CREATE TABLE public.artist_versions ( id integer NOT NULL, artist_id integer NOT NULL, name character varying NOT NULL, @@ -726,7 +730,7 @@ CREATE TABLE artist_versions ( -- Name: artist_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE artist_versions_id_seq +CREATE SEQUENCE public.artist_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -738,14 +742,14 @@ CREATE SEQUENCE artist_versions_id_seq -- Name: artist_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE artist_versions_id_seq OWNED BY artist_versions.id; +ALTER SEQUENCE public.artist_versions_id_seq OWNED BY public.artist_versions.id; -- -- Name: artists; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE artists ( +CREATE TABLE public.artists ( id integer NOT NULL, name character varying NOT NULL, creator_id integer NOT NULL, @@ -763,7 +767,7 @@ CREATE TABLE artists ( -- Name: artists_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE artists_id_seq +CREATE SEQUENCE public.artists_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -775,14 +779,14 @@ CREATE SEQUENCE artists_id_seq -- Name: artists_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE artists_id_seq OWNED BY artists.id; +ALTER SEQUENCE public.artists_id_seq OWNED BY public.artists.id; -- -- Name: bans; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE bans ( +CREATE TABLE public.bans ( id integer NOT NULL, user_id integer, reason text NOT NULL, @@ -797,7 +801,7 @@ CREATE TABLE bans ( -- Name: bans_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE bans_id_seq +CREATE SEQUENCE public.bans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -809,14 +813,14 @@ CREATE SEQUENCE bans_id_seq -- Name: bans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE bans_id_seq OWNED BY bans.id; +ALTER SEQUENCE public.bans_id_seq OWNED BY public.bans.id; -- -- Name: bulk_update_requests; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE bulk_update_requests ( +CREATE TABLE public.bulk_update_requests ( id integer NOT NULL, user_id integer NOT NULL, forum_topic_id integer, @@ -834,7 +838,7 @@ CREATE TABLE bulk_update_requests ( -- Name: bulk_update_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE bulk_update_requests_id_seq +CREATE SEQUENCE public.bulk_update_requests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -846,14 +850,14 @@ CREATE SEQUENCE bulk_update_requests_id_seq -- Name: bulk_update_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE bulk_update_requests_id_seq OWNED BY bulk_update_requests.id; +ALTER SEQUENCE public.bulk_update_requests_id_seq OWNED BY public.bulk_update_requests.id; -- -- Name: comment_votes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE comment_votes ( +CREATE TABLE public.comment_votes ( id integer NOT NULL, comment_id integer NOT NULL, user_id integer NOT NULL, @@ -867,7 +871,7 @@ CREATE TABLE comment_votes ( -- Name: comment_votes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE comment_votes_id_seq +CREATE SEQUENCE public.comment_votes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -879,14 +883,14 @@ CREATE SEQUENCE comment_votes_id_seq -- Name: comment_votes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE comment_votes_id_seq OWNED BY comment_votes.id; +ALTER SEQUENCE public.comment_votes_id_seq OWNED BY public.comment_votes.id; -- -- Name: comments; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE comments ( +CREATE TABLE public.comments ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, @@ -908,7 +912,7 @@ CREATE TABLE comments ( -- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE comments_id_seq +CREATE SEQUENCE public.comments_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -920,14 +924,14 @@ CREATE SEQUENCE comments_id_seq -- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE comments_id_seq OWNED BY comments.id; +ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id; -- -- Name: delayed_jobs; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE delayed_jobs ( +CREATE TABLE public.delayed_jobs ( id integer NOT NULL, priority integer DEFAULT 0, attempts integer DEFAULT 0, @@ -947,7 +951,7 @@ CREATE TABLE delayed_jobs ( -- Name: delayed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE delayed_jobs_id_seq +CREATE SEQUENCE public.delayed_jobs_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -959,14 +963,14 @@ CREATE SEQUENCE delayed_jobs_id_seq -- Name: delayed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE delayed_jobs_id_seq OWNED BY delayed_jobs.id; +ALTER SEQUENCE public.delayed_jobs_id_seq OWNED BY public.delayed_jobs.id; -- -- Name: dmail_filters; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE dmail_filters ( +CREATE TABLE public.dmail_filters ( id integer NOT NULL, user_id integer NOT NULL, words text NOT NULL, @@ -979,7 +983,7 @@ CREATE TABLE dmail_filters ( -- Name: dmail_filters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE dmail_filters_id_seq +CREATE SEQUENCE public.dmail_filters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -991,14 +995,14 @@ CREATE SEQUENCE dmail_filters_id_seq -- Name: dmail_filters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE dmail_filters_id_seq OWNED BY dmail_filters.id; +ALTER SEQUENCE public.dmail_filters_id_seq OWNED BY public.dmail_filters.id; -- -- Name: dmails; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE dmails ( +CREATE TABLE public.dmails ( id integer NOT NULL, owner_id integer NOT NULL, from_id integer NOT NULL, @@ -1019,7 +1023,7 @@ CREATE TABLE dmails ( -- Name: dmails_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE dmails_id_seq +CREATE SEQUENCE public.dmails_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -1031,14 +1035,14 @@ CREATE SEQUENCE dmails_id_seq -- Name: dmails_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE dmails_id_seq OWNED BY dmails.id; +ALTER SEQUENCE public.dmails_id_seq OWNED BY public.dmails.id; -- -- Name: favorite_groups; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorite_groups ( +CREATE TABLE public.favorite_groups ( id integer NOT NULL, name text NOT NULL, creator_id integer NOT NULL, @@ -1054,7 +1058,7 @@ CREATE TABLE favorite_groups ( -- Name: favorite_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE favorite_groups_id_seq +CREATE SEQUENCE public.favorite_groups_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -1066,14 +1070,14 @@ CREATE SEQUENCE favorite_groups_id_seq -- Name: favorite_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE favorite_groups_id_seq OWNED BY favorite_groups.id; +ALTER SEQUENCE public.favorite_groups_id_seq OWNED BY public.favorite_groups.id; -- -- Name: favorites; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites ( +CREATE TABLE public.favorites ( id integer NOT NULL, user_id integer, post_id integer @@ -1084,1007 +1088,1007 @@ CREATE TABLE favorites ( -- Name: favorites_0; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_0 ( +CREATE TABLE public.favorites_0 ( CONSTRAINT favorites_0_user_id_check CHECK (((user_id % 100) = 0)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_1; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_1 ( +CREATE TABLE public.favorites_1 ( CONSTRAINT favorites_1_user_id_check CHECK (((user_id % 100) = 1)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_10; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_10 ( +CREATE TABLE public.favorites_10 ( CONSTRAINT favorites_10_user_id_check CHECK (((user_id % 100) = 10)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_11; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_11 ( +CREATE TABLE public.favorites_11 ( CONSTRAINT favorites_11_user_id_check CHECK (((user_id % 100) = 11)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_12; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_12 ( +CREATE TABLE public.favorites_12 ( CONSTRAINT favorites_12_user_id_check CHECK (((user_id % 100) = 12)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_13; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_13 ( +CREATE TABLE public.favorites_13 ( CONSTRAINT favorites_13_user_id_check CHECK (((user_id % 100) = 13)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_14; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_14 ( +CREATE TABLE public.favorites_14 ( CONSTRAINT favorites_14_user_id_check CHECK (((user_id % 100) = 14)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_15; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_15 ( +CREATE TABLE public.favorites_15 ( CONSTRAINT favorites_15_user_id_check CHECK (((user_id % 100) = 15)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_16; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_16 ( +CREATE TABLE public.favorites_16 ( CONSTRAINT favorites_16_user_id_check CHECK (((user_id % 100) = 16)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_17; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_17 ( +CREATE TABLE public.favorites_17 ( CONSTRAINT favorites_17_user_id_check CHECK (((user_id % 100) = 17)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_18; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_18 ( +CREATE TABLE public.favorites_18 ( CONSTRAINT favorites_18_user_id_check CHECK (((user_id % 100) = 18)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_19; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_19 ( +CREATE TABLE public.favorites_19 ( CONSTRAINT favorites_19_user_id_check CHECK (((user_id % 100) = 19)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_2; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_2 ( +CREATE TABLE public.favorites_2 ( CONSTRAINT favorites_2_user_id_check CHECK (((user_id % 100) = 2)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_20; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_20 ( +CREATE TABLE public.favorites_20 ( CONSTRAINT favorites_20_user_id_check CHECK (((user_id % 100) = 20)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_21; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_21 ( +CREATE TABLE public.favorites_21 ( CONSTRAINT favorites_21_user_id_check CHECK (((user_id % 100) = 21)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_22; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_22 ( +CREATE TABLE public.favorites_22 ( CONSTRAINT favorites_22_user_id_check CHECK (((user_id % 100) = 22)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_23; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_23 ( +CREATE TABLE public.favorites_23 ( CONSTRAINT favorites_23_user_id_check CHECK (((user_id % 100) = 23)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_24; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_24 ( +CREATE TABLE public.favorites_24 ( CONSTRAINT favorites_24_user_id_check CHECK (((user_id % 100) = 24)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_25; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_25 ( +CREATE TABLE public.favorites_25 ( CONSTRAINT favorites_25_user_id_check CHECK (((user_id % 100) = 25)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_26; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_26 ( +CREATE TABLE public.favorites_26 ( CONSTRAINT favorites_26_user_id_check CHECK (((user_id % 100) = 26)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_27; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_27 ( +CREATE TABLE public.favorites_27 ( CONSTRAINT favorites_27_user_id_check CHECK (((user_id % 100) = 27)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_28; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_28 ( +CREATE TABLE public.favorites_28 ( CONSTRAINT favorites_28_user_id_check CHECK (((user_id % 100) = 28)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_29; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_29 ( +CREATE TABLE public.favorites_29 ( CONSTRAINT favorites_29_user_id_check CHECK (((user_id % 100) = 29)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_3; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_3 ( +CREATE TABLE public.favorites_3 ( CONSTRAINT favorites_3_user_id_check CHECK (((user_id % 100) = 3)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_30; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_30 ( +CREATE TABLE public.favorites_30 ( CONSTRAINT favorites_30_user_id_check CHECK (((user_id % 100) = 30)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_31; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_31 ( +CREATE TABLE public.favorites_31 ( CONSTRAINT favorites_31_user_id_check CHECK (((user_id % 100) = 31)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_32; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_32 ( +CREATE TABLE public.favorites_32 ( CONSTRAINT favorites_32_user_id_check CHECK (((user_id % 100) = 32)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_33; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_33 ( +CREATE TABLE public.favorites_33 ( CONSTRAINT favorites_33_user_id_check CHECK (((user_id % 100) = 33)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_34; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_34 ( +CREATE TABLE public.favorites_34 ( CONSTRAINT favorites_34_user_id_check CHECK (((user_id % 100) = 34)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_35; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_35 ( +CREATE TABLE public.favorites_35 ( CONSTRAINT favorites_35_user_id_check CHECK (((user_id % 100) = 35)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_36; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_36 ( +CREATE TABLE public.favorites_36 ( CONSTRAINT favorites_36_user_id_check CHECK (((user_id % 100) = 36)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_37; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_37 ( +CREATE TABLE public.favorites_37 ( CONSTRAINT favorites_37_user_id_check CHECK (((user_id % 100) = 37)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_38; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_38 ( +CREATE TABLE public.favorites_38 ( CONSTRAINT favorites_38_user_id_check CHECK (((user_id % 100) = 38)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_39; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_39 ( +CREATE TABLE public.favorites_39 ( CONSTRAINT favorites_39_user_id_check CHECK (((user_id % 100) = 39)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_4; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_4 ( +CREATE TABLE public.favorites_4 ( CONSTRAINT favorites_4_user_id_check CHECK (((user_id % 100) = 4)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_40; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_40 ( +CREATE TABLE public.favorites_40 ( CONSTRAINT favorites_40_user_id_check CHECK (((user_id % 100) = 40)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_41; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_41 ( +CREATE TABLE public.favorites_41 ( CONSTRAINT favorites_41_user_id_check CHECK (((user_id % 100) = 41)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_42; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_42 ( +CREATE TABLE public.favorites_42 ( CONSTRAINT favorites_42_user_id_check CHECK (((user_id % 100) = 42)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_43; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_43 ( +CREATE TABLE public.favorites_43 ( CONSTRAINT favorites_43_user_id_check CHECK (((user_id % 100) = 43)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_44; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_44 ( +CREATE TABLE public.favorites_44 ( CONSTRAINT favorites_44_user_id_check CHECK (((user_id % 100) = 44)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_45; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_45 ( +CREATE TABLE public.favorites_45 ( CONSTRAINT favorites_45_user_id_check CHECK (((user_id % 100) = 45)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_46; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_46 ( +CREATE TABLE public.favorites_46 ( CONSTRAINT favorites_46_user_id_check CHECK (((user_id % 100) = 46)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_47; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_47 ( +CREATE TABLE public.favorites_47 ( CONSTRAINT favorites_47_user_id_check CHECK (((user_id % 100) = 47)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_48; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_48 ( +CREATE TABLE public.favorites_48 ( CONSTRAINT favorites_48_user_id_check CHECK (((user_id % 100) = 48)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_49; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_49 ( +CREATE TABLE public.favorites_49 ( CONSTRAINT favorites_49_user_id_check CHECK (((user_id % 100) = 49)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_5; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_5 ( +CREATE TABLE public.favorites_5 ( CONSTRAINT favorites_5_user_id_check CHECK (((user_id % 100) = 5)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_50; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_50 ( +CREATE TABLE public.favorites_50 ( CONSTRAINT favorites_50_user_id_check CHECK (((user_id % 100) = 50)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_51; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_51 ( +CREATE TABLE public.favorites_51 ( CONSTRAINT favorites_51_user_id_check CHECK (((user_id % 100) = 51)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_52; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_52 ( +CREATE TABLE public.favorites_52 ( CONSTRAINT favorites_52_user_id_check CHECK (((user_id % 100) = 52)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_53; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_53 ( +CREATE TABLE public.favorites_53 ( CONSTRAINT favorites_53_user_id_check CHECK (((user_id % 100) = 53)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_54; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_54 ( +CREATE TABLE public.favorites_54 ( CONSTRAINT favorites_54_user_id_check CHECK (((user_id % 100) = 54)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_55; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_55 ( +CREATE TABLE public.favorites_55 ( CONSTRAINT favorites_55_user_id_check CHECK (((user_id % 100) = 55)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_56; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_56 ( +CREATE TABLE public.favorites_56 ( CONSTRAINT favorites_56_user_id_check CHECK (((user_id % 100) = 56)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_57; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_57 ( +CREATE TABLE public.favorites_57 ( CONSTRAINT favorites_57_user_id_check CHECK (((user_id % 100) = 57)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_58; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_58 ( +CREATE TABLE public.favorites_58 ( CONSTRAINT favorites_58_user_id_check CHECK (((user_id % 100) = 58)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_59; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_59 ( +CREATE TABLE public.favorites_59 ( CONSTRAINT favorites_59_user_id_check CHECK (((user_id % 100) = 59)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_6; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_6 ( +CREATE TABLE public.favorites_6 ( CONSTRAINT favorites_6_user_id_check CHECK (((user_id % 100) = 6)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_60; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_60 ( +CREATE TABLE public.favorites_60 ( CONSTRAINT favorites_60_user_id_check CHECK (((user_id % 100) = 60)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_61; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_61 ( +CREATE TABLE public.favorites_61 ( CONSTRAINT favorites_61_user_id_check CHECK (((user_id % 100) = 61)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_62; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_62 ( +CREATE TABLE public.favorites_62 ( CONSTRAINT favorites_62_user_id_check CHECK (((user_id % 100) = 62)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_63; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_63 ( +CREATE TABLE public.favorites_63 ( CONSTRAINT favorites_63_user_id_check CHECK (((user_id % 100) = 63)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_64; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_64 ( +CREATE TABLE public.favorites_64 ( CONSTRAINT favorites_64_user_id_check CHECK (((user_id % 100) = 64)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_65; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_65 ( +CREATE TABLE public.favorites_65 ( CONSTRAINT favorites_65_user_id_check CHECK (((user_id % 100) = 65)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_66; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_66 ( +CREATE TABLE public.favorites_66 ( CONSTRAINT favorites_66_user_id_check CHECK (((user_id % 100) = 66)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_67; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_67 ( +CREATE TABLE public.favorites_67 ( CONSTRAINT favorites_67_user_id_check CHECK (((user_id % 100) = 67)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_68; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_68 ( +CREATE TABLE public.favorites_68 ( CONSTRAINT favorites_68_user_id_check CHECK (((user_id % 100) = 68)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_69; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_69 ( +CREATE TABLE public.favorites_69 ( CONSTRAINT favorites_69_user_id_check CHECK (((user_id % 100) = 69)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_7; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_7 ( +CREATE TABLE public.favorites_7 ( CONSTRAINT favorites_7_user_id_check CHECK (((user_id % 100) = 7)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_70; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_70 ( +CREATE TABLE public.favorites_70 ( CONSTRAINT favorites_70_user_id_check CHECK (((user_id % 100) = 70)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_71; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_71 ( +CREATE TABLE public.favorites_71 ( CONSTRAINT favorites_71_user_id_check CHECK (((user_id % 100) = 71)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_72; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_72 ( +CREATE TABLE public.favorites_72 ( CONSTRAINT favorites_72_user_id_check CHECK (((user_id % 100) = 72)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_73; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_73 ( +CREATE TABLE public.favorites_73 ( CONSTRAINT favorites_73_user_id_check CHECK (((user_id % 100) = 73)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_74; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_74 ( +CREATE TABLE public.favorites_74 ( CONSTRAINT favorites_74_user_id_check CHECK (((user_id % 100) = 74)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_75; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_75 ( +CREATE TABLE public.favorites_75 ( CONSTRAINT favorites_75_user_id_check CHECK (((user_id % 100) = 75)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_76; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_76 ( +CREATE TABLE public.favorites_76 ( CONSTRAINT favorites_76_user_id_check CHECK (((user_id % 100) = 76)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_77; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_77 ( +CREATE TABLE public.favorites_77 ( CONSTRAINT favorites_77_user_id_check CHECK (((user_id % 100) = 77)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_78; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_78 ( +CREATE TABLE public.favorites_78 ( CONSTRAINT favorites_78_user_id_check CHECK (((user_id % 100) = 78)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_79; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_79 ( +CREATE TABLE public.favorites_79 ( CONSTRAINT favorites_79_user_id_check CHECK (((user_id % 100) = 79)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_8; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_8 ( +CREATE TABLE public.favorites_8 ( CONSTRAINT favorites_8_user_id_check CHECK (((user_id % 100) = 8)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_80; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_80 ( +CREATE TABLE public.favorites_80 ( CONSTRAINT favorites_80_user_id_check CHECK (((user_id % 100) = 80)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_81; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_81 ( +CREATE TABLE public.favorites_81 ( CONSTRAINT favorites_81_user_id_check CHECK (((user_id % 100) = 81)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_82; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_82 ( +CREATE TABLE public.favorites_82 ( CONSTRAINT favorites_82_user_id_check CHECK (((user_id % 100) = 82)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_83; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_83 ( +CREATE TABLE public.favorites_83 ( CONSTRAINT favorites_83_user_id_check CHECK (((user_id % 100) = 83)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_84; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_84 ( +CREATE TABLE public.favorites_84 ( CONSTRAINT favorites_84_user_id_check CHECK (((user_id % 100) = 84)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_85; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_85 ( +CREATE TABLE public.favorites_85 ( CONSTRAINT favorites_85_user_id_check CHECK (((user_id % 100) = 85)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_86; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_86 ( +CREATE TABLE public.favorites_86 ( CONSTRAINT favorites_86_user_id_check CHECK (((user_id % 100) = 86)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_87; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_87 ( +CREATE TABLE public.favorites_87 ( CONSTRAINT favorites_87_user_id_check CHECK (((user_id % 100) = 87)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_88; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_88 ( +CREATE TABLE public.favorites_88 ( CONSTRAINT favorites_88_user_id_check CHECK (((user_id % 100) = 88)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_89; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_89 ( +CREATE TABLE public.favorites_89 ( CONSTRAINT favorites_89_user_id_check CHECK (((user_id % 100) = 89)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_9; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_9 ( +CREATE TABLE public.favorites_9 ( CONSTRAINT favorites_9_user_id_check CHECK (((user_id % 100) = 9)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_90; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_90 ( +CREATE TABLE public.favorites_90 ( CONSTRAINT favorites_90_user_id_check CHECK (((user_id % 100) = 90)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_91; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_91 ( +CREATE TABLE public.favorites_91 ( CONSTRAINT favorites_91_user_id_check CHECK (((user_id % 100) = 91)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_92; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_92 ( +CREATE TABLE public.favorites_92 ( CONSTRAINT favorites_92_user_id_check CHECK (((user_id % 100) = 92)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_93; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_93 ( +CREATE TABLE public.favorites_93 ( CONSTRAINT favorites_93_user_id_check CHECK (((user_id % 100) = 93)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_94; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_94 ( +CREATE TABLE public.favorites_94 ( CONSTRAINT favorites_94_user_id_check CHECK (((user_id % 100) = 94)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_95; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_95 ( +CREATE TABLE public.favorites_95 ( CONSTRAINT favorites_95_user_id_check CHECK (((user_id % 100) = 95)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_96; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_96 ( +CREATE TABLE public.favorites_96 ( CONSTRAINT favorites_96_user_id_check CHECK (((user_id % 100) = 96)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_97; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_97 ( +CREATE TABLE public.favorites_97 ( CONSTRAINT favorites_97_user_id_check CHECK (((user_id % 100) = 97)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_98; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_98 ( +CREATE TABLE public.favorites_98 ( CONSTRAINT favorites_98_user_id_check CHECK (((user_id % 100) = 98)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_99; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE favorites_99 ( +CREATE TABLE public.favorites_99 ( CONSTRAINT favorites_99_user_id_check CHECK (((user_id % 100) = 99)) ) -INHERITS (favorites); +INHERITS (public.favorites); -- -- Name: favorites_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE favorites_id_seq +CREATE SEQUENCE public.favorites_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2096,14 +2100,14 @@ CREATE SEQUENCE favorites_id_seq -- Name: favorites_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE favorites_id_seq OWNED BY favorites.id; +ALTER SEQUENCE public.favorites_id_seq OWNED BY public.favorites.id; -- -- Name: forum_posts; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE forum_posts ( +CREATE TABLE public.forum_posts ( id integer NOT NULL, topic_id integer NOT NULL, creator_id integer NOT NULL, @@ -2120,7 +2124,7 @@ CREATE TABLE forum_posts ( -- Name: forum_posts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE forum_posts_id_seq +CREATE SEQUENCE public.forum_posts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2132,14 +2136,14 @@ CREATE SEQUENCE forum_posts_id_seq -- Name: forum_posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE forum_posts_id_seq OWNED BY forum_posts.id; +ALTER SEQUENCE public.forum_posts_id_seq OWNED BY public.forum_posts.id; -- -- Name: forum_subscriptions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE forum_subscriptions ( +CREATE TABLE public.forum_subscriptions ( id integer NOT NULL, user_id integer, forum_topic_id integer, @@ -2152,7 +2156,7 @@ CREATE TABLE forum_subscriptions ( -- Name: forum_subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE forum_subscriptions_id_seq +CREATE SEQUENCE public.forum_subscriptions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2164,14 +2168,14 @@ CREATE SEQUENCE forum_subscriptions_id_seq -- Name: forum_subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE forum_subscriptions_id_seq OWNED BY forum_subscriptions.id; +ALTER SEQUENCE public.forum_subscriptions_id_seq OWNED BY public.forum_subscriptions.id; -- -- Name: forum_topic_visits; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE forum_topic_visits ( +CREATE TABLE public.forum_topic_visits ( id integer NOT NULL, user_id integer, forum_topic_id integer, @@ -2185,7 +2189,7 @@ CREATE TABLE forum_topic_visits ( -- Name: forum_topic_visits_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE forum_topic_visits_id_seq +CREATE SEQUENCE public.forum_topic_visits_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2197,14 +2201,14 @@ CREATE SEQUENCE forum_topic_visits_id_seq -- Name: forum_topic_visits_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE forum_topic_visits_id_seq OWNED BY forum_topic_visits.id; +ALTER SEQUENCE public.forum_topic_visits_id_seq OWNED BY public.forum_topic_visits.id; -- -- Name: forum_topics; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE forum_topics ( +CREATE TABLE public.forum_topics ( id integer NOT NULL, creator_id integer NOT NULL, updater_id integer NOT NULL, @@ -2225,7 +2229,7 @@ CREATE TABLE forum_topics ( -- Name: forum_topics_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE forum_topics_id_seq +CREATE SEQUENCE public.forum_topics_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2237,14 +2241,14 @@ CREATE SEQUENCE forum_topics_id_seq -- Name: forum_topics_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE forum_topics_id_seq OWNED BY forum_topics.id; +ALTER SEQUENCE public.forum_topics_id_seq OWNED BY public.forum_topics.id; -- -- Name: ip_bans; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE ip_bans ( +CREATE TABLE public.ip_bans ( id integer NOT NULL, creator_id integer NOT NULL, ip_addr inet NOT NULL, @@ -2258,7 +2262,7 @@ CREATE TABLE ip_bans ( -- Name: ip_bans_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE ip_bans_id_seq +CREATE SEQUENCE public.ip_bans_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2270,14 +2274,14 @@ CREATE SEQUENCE ip_bans_id_seq -- Name: ip_bans_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE ip_bans_id_seq OWNED BY ip_bans.id; +ALTER SEQUENCE public.ip_bans_id_seq OWNED BY public.ip_bans.id; -- -- Name: janitor_trials; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE janitor_trials ( +CREATE TABLE public.janitor_trials ( id integer NOT NULL, creator_id integer NOT NULL, user_id integer NOT NULL, @@ -2292,7 +2296,7 @@ CREATE TABLE janitor_trials ( -- Name: janitor_trials_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE janitor_trials_id_seq +CREATE SEQUENCE public.janitor_trials_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2304,14 +2308,14 @@ CREATE SEQUENCE janitor_trials_id_seq -- Name: janitor_trials_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE janitor_trials_id_seq OWNED BY janitor_trials.id; +ALTER SEQUENCE public.janitor_trials_id_seq OWNED BY public.janitor_trials.id; -- -- Name: mod_actions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE mod_actions ( +CREATE TABLE public.mod_actions ( id integer NOT NULL, creator_id integer NOT NULL, description text NOT NULL, @@ -2325,7 +2329,7 @@ CREATE TABLE mod_actions ( -- Name: mod_actions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE mod_actions_id_seq +CREATE SEQUENCE public.mod_actions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2337,14 +2341,14 @@ CREATE SEQUENCE mod_actions_id_seq -- Name: mod_actions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE mod_actions_id_seq OWNED BY mod_actions.id; +ALTER SEQUENCE public.mod_actions_id_seq OWNED BY public.mod_actions.id; -- -- Name: news_updates; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE news_updates ( +CREATE TABLE public.news_updates ( id integer NOT NULL, message text NOT NULL, creator_id integer NOT NULL, @@ -2358,7 +2362,7 @@ CREATE TABLE news_updates ( -- Name: news_updates_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE news_updates_id_seq +CREATE SEQUENCE public.news_updates_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2370,14 +2374,14 @@ CREATE SEQUENCE news_updates_id_seq -- Name: news_updates_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE news_updates_id_seq OWNED BY news_updates.id; +ALTER SEQUENCE public.news_updates_id_seq OWNED BY public.news_updates.id; -- -- Name: note_versions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE note_versions ( +CREATE TABLE public.note_versions ( id integer NOT NULL, note_id integer NOT NULL, post_id integer NOT NULL, @@ -2399,7 +2403,7 @@ CREATE TABLE note_versions ( -- Name: note_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE note_versions_id_seq +CREATE SEQUENCE public.note_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2411,14 +2415,14 @@ CREATE SEQUENCE note_versions_id_seq -- Name: note_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE note_versions_id_seq OWNED BY note_versions.id; +ALTER SEQUENCE public.note_versions_id_seq OWNED BY public.note_versions.id; -- -- Name: notes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE notes ( +CREATE TABLE public.notes ( id integer NOT NULL, creator_id integer NOT NULL, post_id integer NOT NULL, @@ -2439,7 +2443,7 @@ CREATE TABLE notes ( -- Name: notes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE notes_id_seq +CREATE SEQUENCE public.notes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2451,14 +2455,14 @@ CREATE SEQUENCE notes_id_seq -- Name: notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE notes_id_seq OWNED BY notes.id; +ALTER SEQUENCE public.notes_id_seq OWNED BY public.notes.id; -- -- Name: pixiv_ugoira_frame_data; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE pixiv_ugoira_frame_data ( +CREATE TABLE public.pixiv_ugoira_frame_data ( id integer NOT NULL, post_id integer, data text NOT NULL, @@ -2470,7 +2474,7 @@ CREATE TABLE pixiv_ugoira_frame_data ( -- Name: pixiv_ugoira_frame_data_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE pixiv_ugoira_frame_data_id_seq +CREATE SEQUENCE public.pixiv_ugoira_frame_data_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2482,14 +2486,14 @@ CREATE SEQUENCE pixiv_ugoira_frame_data_id_seq -- Name: pixiv_ugoira_frame_data_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE pixiv_ugoira_frame_data_id_seq OWNED BY pixiv_ugoira_frame_data.id; +ALTER SEQUENCE public.pixiv_ugoira_frame_data_id_seq OWNED BY public.pixiv_ugoira_frame_data.id; -- -- Name: pools; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE pools ( +CREATE TABLE public.pools ( id integer NOT NULL, name character varying, creator_id integer NOT NULL, @@ -2508,7 +2512,7 @@ CREATE TABLE pools ( -- Name: pools_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE pools_id_seq +CREATE SEQUENCE public.pools_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2520,14 +2524,14 @@ CREATE SEQUENCE pools_id_seq -- Name: pools_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE pools_id_seq OWNED BY pools.id; +ALTER SEQUENCE public.pools_id_seq OWNED BY public.pools.id; -- -- Name: post_appeals; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_appeals ( +CREATE TABLE public.post_appeals ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, @@ -2542,7 +2546,7 @@ CREATE TABLE post_appeals ( -- Name: post_appeals_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_appeals_id_seq +CREATE SEQUENCE public.post_appeals_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2554,14 +2558,14 @@ CREATE SEQUENCE post_appeals_id_seq -- Name: post_appeals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_appeals_id_seq OWNED BY post_appeals.id; +ALTER SEQUENCE public.post_appeals_id_seq OWNED BY public.post_appeals.id; -- -- Name: post_approvals; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_approvals ( +CREATE TABLE public.post_approvals ( id integer NOT NULL, user_id integer NOT NULL, post_id integer NOT NULL, @@ -2574,7 +2578,7 @@ CREATE TABLE post_approvals ( -- Name: post_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_approvals_id_seq +CREATE SEQUENCE public.post_approvals_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2586,14 +2590,14 @@ CREATE SEQUENCE post_approvals_id_seq -- Name: post_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_approvals_id_seq OWNED BY post_approvals.id; +ALTER SEQUENCE public.post_approvals_id_seq OWNED BY public.post_approvals.id; -- -- Name: post_disapprovals; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_disapprovals ( +CREATE TABLE public.post_disapprovals ( id integer NOT NULL, user_id integer NOT NULL, post_id integer NOT NULL, @@ -2608,7 +2612,7 @@ CREATE TABLE post_disapprovals ( -- Name: post_disapprovals_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_disapprovals_id_seq +CREATE SEQUENCE public.post_disapprovals_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2620,14 +2624,14 @@ CREATE SEQUENCE post_disapprovals_id_seq -- Name: post_disapprovals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_disapprovals_id_seq OWNED BY post_disapprovals.id; +ALTER SEQUENCE public.post_disapprovals_id_seq OWNED BY public.post_disapprovals.id; -- -- Name: post_flags; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_flags ( +CREATE TABLE public.post_flags ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, @@ -2643,7 +2647,7 @@ CREATE TABLE post_flags ( -- Name: post_flags_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_flags_id_seq +CREATE SEQUENCE public.post_flags_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2655,14 +2659,14 @@ CREATE SEQUENCE post_flags_id_seq -- Name: post_flags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_flags_id_seq OWNED BY post_flags.id; +ALTER SEQUENCE public.post_flags_id_seq OWNED BY public.post_flags.id; -- -- Name: post_replacements; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_replacements ( +CREATE TABLE public.post_replacements ( id integer NOT NULL, post_id integer NOT NULL, creator_id integer NOT NULL, @@ -2687,7 +2691,7 @@ CREATE TABLE post_replacements ( -- Name: post_replacements_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_replacements_id_seq +CREATE SEQUENCE public.post_replacements_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2699,14 +2703,14 @@ CREATE SEQUENCE post_replacements_id_seq -- Name: post_replacements_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_replacements_id_seq OWNED BY post_replacements.id; +ALTER SEQUENCE public.post_replacements_id_seq OWNED BY public.post_replacements.id; -- -- Name: post_updates; Type: TABLE; Schema: public; Owner: - -- -CREATE UNLOGGED TABLE post_updates ( +CREATE UNLOGGED TABLE public.post_updates ( post_id integer ); @@ -2715,7 +2719,7 @@ CREATE UNLOGGED TABLE post_updates ( -- Name: post_votes; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE post_votes ( +CREATE TABLE public.post_votes ( id integer NOT NULL, post_id integer NOT NULL, user_id integer NOT NULL, @@ -2729,7 +2733,7 @@ CREATE TABLE post_votes ( -- Name: post_votes_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE post_votes_id_seq +CREATE SEQUENCE public.post_votes_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2741,14 +2745,14 @@ CREATE SEQUENCE post_votes_id_seq -- Name: post_votes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE post_votes_id_seq OWNED BY post_votes.id; +ALTER SEQUENCE public.post_votes_id_seq OWNED BY public.post_votes.id; -- -- Name: posts; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE posts ( +CREATE TABLE public.posts ( id integer NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, @@ -2799,7 +2803,7 @@ CREATE TABLE posts ( -- Name: posts_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE posts_id_seq +CREATE SEQUENCE public.posts_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2811,14 +2815,14 @@ CREATE SEQUENCE posts_id_seq -- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE posts_id_seq OWNED BY posts.id; +ALTER SEQUENCE public.posts_id_seq OWNED BY public.posts.id; -- -- Name: saved_searches; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE saved_searches ( +CREATE TABLE public.saved_searches ( id integer NOT NULL, user_id integer, query text, @@ -2832,7 +2836,7 @@ CREATE TABLE saved_searches ( -- Name: saved_searches_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE saved_searches_id_seq +CREATE SEQUENCE public.saved_searches_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2844,14 +2848,14 @@ CREATE SEQUENCE saved_searches_id_seq -- Name: saved_searches_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE saved_searches_id_seq OWNED BY saved_searches.id; +ALTER SEQUENCE public.saved_searches_id_seq OWNED BY public.saved_searches.id; -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE schema_migrations ( +CREATE TABLE public.schema_migrations ( version character varying NOT NULL ); @@ -2860,7 +2864,7 @@ CREATE TABLE schema_migrations ( -- Name: super_voters; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE super_voters ( +CREATE TABLE public.super_voters ( id integer NOT NULL, user_id integer, created_at timestamp without time zone NOT NULL, @@ -2872,7 +2876,7 @@ CREATE TABLE super_voters ( -- Name: super_voters_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE super_voters_id_seq +CREATE SEQUENCE public.super_voters_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2884,14 +2888,14 @@ CREATE SEQUENCE super_voters_id_seq -- Name: super_voters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE super_voters_id_seq OWNED BY super_voters.id; +ALTER SEQUENCE public.super_voters_id_seq OWNED BY public.super_voters.id; -- -- Name: tag_aliases; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE tag_aliases ( +CREATE TABLE public.tag_aliases ( id integer NOT NULL, antecedent_name character varying NOT NULL, consequent_name character varying NOT NULL, @@ -2911,7 +2915,7 @@ CREATE TABLE tag_aliases ( -- Name: tag_aliases_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE tag_aliases_id_seq +CREATE SEQUENCE public.tag_aliases_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2923,14 +2927,14 @@ CREATE SEQUENCE tag_aliases_id_seq -- Name: tag_aliases_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE tag_aliases_id_seq OWNED BY tag_aliases.id; +ALTER SEQUENCE public.tag_aliases_id_seq OWNED BY public.tag_aliases.id; -- -- Name: tag_implications; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE tag_implications ( +CREATE TABLE public.tag_implications ( id integer NOT NULL, antecedent_name character varying NOT NULL, consequent_name character varying NOT NULL, @@ -2950,7 +2954,7 @@ CREATE TABLE tag_implications ( -- Name: tag_implications_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE tag_implications_id_seq +CREATE SEQUENCE public.tag_implications_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2962,14 +2966,14 @@ CREATE SEQUENCE tag_implications_id_seq -- Name: tag_implications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE tag_implications_id_seq OWNED BY tag_implications.id; +ALTER SEQUENCE public.tag_implications_id_seq OWNED BY public.tag_implications.id; -- -- Name: tag_subscriptions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE tag_subscriptions ( +CREATE TABLE public.tag_subscriptions ( id integer NOT NULL, creator_id integer NOT NULL, name character varying NOT NULL, @@ -2987,7 +2991,7 @@ CREATE TABLE tag_subscriptions ( -- Name: tag_subscriptions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE tag_subscriptions_id_seq +CREATE SEQUENCE public.tag_subscriptions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -2999,14 +3003,14 @@ CREATE SEQUENCE tag_subscriptions_id_seq -- Name: tag_subscriptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE tag_subscriptions_id_seq OWNED BY tag_subscriptions.id; +ALTER SEQUENCE public.tag_subscriptions_id_seq OWNED BY public.tag_subscriptions.id; -- -- Name: tags; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE tags ( +CREATE TABLE public.tags ( id integer NOT NULL, name character varying NOT NULL, post_count integer DEFAULT 0 NOT NULL, @@ -3023,7 +3027,7 @@ CREATE TABLE tags ( -- Name: tags_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE tags_id_seq +CREATE SEQUENCE public.tags_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3035,14 +3039,14 @@ CREATE SEQUENCE tags_id_seq -- Name: tags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE tags_id_seq OWNED BY tags.id; +ALTER SEQUENCE public.tags_id_seq OWNED BY public.tags.id; -- -- Name: token_buckets; Type: TABLE; Schema: public; Owner: - -- -CREATE UNLOGGED TABLE token_buckets ( +CREATE UNLOGGED TABLE public.token_buckets ( user_id integer, last_touched_at timestamp without time zone NOT NULL, token_count real NOT NULL @@ -3053,7 +3057,7 @@ CREATE UNLOGGED TABLE token_buckets ( -- Name: uploads; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE uploads ( +CREATE TABLE public.uploads ( id integer NOT NULL, source text, file_path character varying, @@ -3077,7 +3081,7 @@ CREATE TABLE uploads ( -- Name: uploads_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE uploads_id_seq +CREATE SEQUENCE public.uploads_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3089,14 +3093,14 @@ CREATE SEQUENCE uploads_id_seq -- Name: uploads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE uploads_id_seq OWNED BY uploads.id; +ALTER SEQUENCE public.uploads_id_seq OWNED BY public.uploads.id; -- -- Name: user_feedback; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE user_feedback ( +CREATE TABLE public.user_feedback ( id integer NOT NULL, user_id integer NOT NULL, creator_id integer NOT NULL, @@ -3111,7 +3115,7 @@ CREATE TABLE user_feedback ( -- Name: user_feedback_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE user_feedback_id_seq +CREATE SEQUENCE public.user_feedback_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3123,14 +3127,14 @@ CREATE SEQUENCE user_feedback_id_seq -- Name: user_feedback_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE user_feedback_id_seq OWNED BY user_feedback.id; +ALTER SEQUENCE public.user_feedback_id_seq OWNED BY public.user_feedback.id; -- -- Name: user_name_change_requests; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE user_name_change_requests ( +CREATE TABLE public.user_name_change_requests ( id integer NOT NULL, status character varying DEFAULT 'pending'::character varying NOT NULL, user_id integer NOT NULL, @@ -3148,7 +3152,7 @@ CREATE TABLE user_name_change_requests ( -- Name: user_name_change_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE user_name_change_requests_id_seq +CREATE SEQUENCE public.user_name_change_requests_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3160,14 +3164,14 @@ CREATE SEQUENCE user_name_change_requests_id_seq -- Name: user_name_change_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE user_name_change_requests_id_seq OWNED BY user_name_change_requests.id; +ALTER SEQUENCE public.user_name_change_requests_id_seq OWNED BY public.user_name_change_requests.id; -- -- Name: user_password_reset_nonces; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE user_password_reset_nonces ( +CREATE TABLE public.user_password_reset_nonces ( id integer NOT NULL, key character varying NOT NULL, email character varying NOT NULL, @@ -3180,7 +3184,7 @@ CREATE TABLE user_password_reset_nonces ( -- Name: user_password_reset_nonces_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE user_password_reset_nonces_id_seq +CREATE SEQUENCE public.user_password_reset_nonces_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3192,14 +3196,14 @@ CREATE SEQUENCE user_password_reset_nonces_id_seq -- Name: user_password_reset_nonces_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE user_password_reset_nonces_id_seq OWNED BY user_password_reset_nonces.id; +ALTER SEQUENCE public.user_password_reset_nonces_id_seq OWNED BY public.user_password_reset_nonces.id; -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE users ( +CREATE TABLE public.users ( id integer NOT NULL, created_at timestamp without time zone, updated_at timestamp without time zone, @@ -3237,7 +3241,7 @@ furry -rating:s'::text, -- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE users_id_seq +CREATE SEQUENCE public.users_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3249,14 +3253,14 @@ CREATE SEQUENCE users_id_seq -- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE users_id_seq OWNED BY users.id; +ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; -- -- Name: wiki_page_versions; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE wiki_page_versions ( +CREATE TABLE public.wiki_page_versions ( id integer NOT NULL, wiki_page_id integer NOT NULL, updater_id integer NOT NULL, @@ -3275,7 +3279,7 @@ CREATE TABLE wiki_page_versions ( -- Name: wiki_page_versions_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE wiki_page_versions_id_seq +CREATE SEQUENCE public.wiki_page_versions_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3287,14 +3291,14 @@ CREATE SEQUENCE wiki_page_versions_id_seq -- Name: wiki_page_versions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE wiki_page_versions_id_seq OWNED BY wiki_page_versions.id; +ALTER SEQUENCE public.wiki_page_versions_id_seq OWNED BY public.wiki_page_versions.id; -- -- Name: wiki_pages; Type: TABLE; Schema: public; Owner: - -- -CREATE TABLE wiki_pages ( +CREATE TABLE public.wiki_pages ( id integer NOT NULL, creator_id integer NOT NULL, title character varying NOT NULL, @@ -3314,7 +3318,7 @@ CREATE TABLE wiki_pages ( -- Name: wiki_pages_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- -CREATE SEQUENCE wiki_pages_id_seq +CREATE SEQUENCE public.wiki_pages_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE @@ -3326,1071 +3330,1071 @@ CREATE SEQUENCE wiki_pages_id_seq -- Name: wiki_pages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - -- -ALTER SEQUENCE wiki_pages_id_seq OWNED BY wiki_pages.id; +ALTER SEQUENCE public.wiki_pages_id_seq OWNED BY public.wiki_pages.id; -- -- Name: advertisement_hits id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY advertisement_hits ALTER COLUMN id SET DEFAULT nextval('advertisement_hits_id_seq'::regclass); +ALTER TABLE ONLY public.advertisement_hits ALTER COLUMN id SET DEFAULT nextval('public.advertisement_hits_id_seq'::regclass); -- -- Name: advertisements id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY advertisements ALTER COLUMN id SET DEFAULT nextval('advertisements_id_seq'::regclass); +ALTER TABLE ONLY public.advertisements ALTER COLUMN id SET DEFAULT nextval('public.advertisements_id_seq'::regclass); -- -- Name: amazon_backups id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY amazon_backups ALTER COLUMN id SET DEFAULT nextval('amazon_backups_id_seq'::regclass); +ALTER TABLE ONLY public.amazon_backups ALTER COLUMN id SET DEFAULT nextval('public.amazon_backups_id_seq'::regclass); -- -- Name: anti_voters id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY anti_voters ALTER COLUMN id SET DEFAULT nextval('anti_voters_id_seq'::regclass); +ALTER TABLE ONLY public.anti_voters ALTER COLUMN id SET DEFAULT nextval('public.anti_voters_id_seq'::regclass); -- -- Name: api_keys id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY api_keys ALTER COLUMN id SET DEFAULT nextval('api_keys_id_seq'::regclass); +ALTER TABLE ONLY public.api_keys ALTER COLUMN id SET DEFAULT nextval('public.api_keys_id_seq'::regclass); -- -- Name: artist_commentaries id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_commentaries ALTER COLUMN id SET DEFAULT nextval('artist_commentaries_id_seq'::regclass); +ALTER TABLE ONLY public.artist_commentaries ALTER COLUMN id SET DEFAULT nextval('public.artist_commentaries_id_seq'::regclass); -- -- Name: artist_commentary_versions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_commentary_versions ALTER COLUMN id SET DEFAULT nextval('artist_commentary_versions_id_seq'::regclass); +ALTER TABLE ONLY public.artist_commentary_versions ALTER COLUMN id SET DEFAULT nextval('public.artist_commentary_versions_id_seq'::regclass); -- -- Name: artist_urls id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_urls ALTER COLUMN id SET DEFAULT nextval('artist_urls_id_seq'::regclass); +ALTER TABLE ONLY public.artist_urls ALTER COLUMN id SET DEFAULT nextval('public.artist_urls_id_seq'::regclass); -- -- Name: artist_versions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_versions ALTER COLUMN id SET DEFAULT nextval('artist_versions_id_seq'::regclass); +ALTER TABLE ONLY public.artist_versions ALTER COLUMN id SET DEFAULT nextval('public.artist_versions_id_seq'::regclass); -- -- Name: artists id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY artists ALTER COLUMN id SET DEFAULT nextval('artists_id_seq'::regclass); +ALTER TABLE ONLY public.artists ALTER COLUMN id SET DEFAULT nextval('public.artists_id_seq'::regclass); -- -- Name: bans id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY bans ALTER COLUMN id SET DEFAULT nextval('bans_id_seq'::regclass); +ALTER TABLE ONLY public.bans ALTER COLUMN id SET DEFAULT nextval('public.bans_id_seq'::regclass); -- -- Name: bulk_update_requests id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY bulk_update_requests ALTER COLUMN id SET DEFAULT nextval('bulk_update_requests_id_seq'::regclass); +ALTER TABLE ONLY public.bulk_update_requests ALTER COLUMN id SET DEFAULT nextval('public.bulk_update_requests_id_seq'::regclass); -- -- Name: comment_votes id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY comment_votes ALTER COLUMN id SET DEFAULT nextval('comment_votes_id_seq'::regclass); +ALTER TABLE ONLY public.comment_votes ALTER COLUMN id SET DEFAULT nextval('public.comment_votes_id_seq'::regclass); -- -- Name: comments id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq'::regclass); +ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass); -- -- Name: delayed_jobs id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY delayed_jobs ALTER COLUMN id SET DEFAULT nextval('delayed_jobs_id_seq'::regclass); +ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public.delayed_jobs_id_seq'::regclass); -- -- Name: dmail_filters id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY dmail_filters ALTER COLUMN id SET DEFAULT nextval('dmail_filters_id_seq'::regclass); +ALTER TABLE ONLY public.dmail_filters ALTER COLUMN id SET DEFAULT nextval('public.dmail_filters_id_seq'::regclass); -- -- Name: dmails id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY dmails ALTER COLUMN id SET DEFAULT nextval('dmails_id_seq'::regclass); +ALTER TABLE ONLY public.dmails ALTER COLUMN id SET DEFAULT nextval('public.dmails_id_seq'::regclass); -- -- Name: favorite_groups id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorite_groups ALTER COLUMN id SET DEFAULT nextval('favorite_groups_id_seq'::regclass); +ALTER TABLE ONLY public.favorite_groups ALTER COLUMN id SET DEFAULT nextval('public.favorite_groups_id_seq'::regclass); -- -- Name: favorites id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_0 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_0 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_0 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_1 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_1 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_1 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_10 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_10 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_10 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_11 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_11 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_11 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_12 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_12 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_12 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_13 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_13 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_13 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_14 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_14 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_14 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_15 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_15 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_15 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_16 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_16 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_16 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_17 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_17 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_17 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_18 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_18 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_18 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_19 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_19 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_19 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_2 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_2 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_2 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_20 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_20 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_20 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_21 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_21 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_21 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_22 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_22 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_22 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_23 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_23 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_23 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_24 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_24 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_24 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_25 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_25 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_25 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_26 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_26 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_26 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_27 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_27 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_27 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_28 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_28 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_28 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_29 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_29 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_29 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_3 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_3 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_3 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_30 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_30 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_30 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_31 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_31 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_31 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_32 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_32 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_32 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_33 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_33 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_33 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_34 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_34 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_34 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_35 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_35 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_35 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_36 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_36 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_36 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_37 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_37 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_37 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_38 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_38 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_38 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_39 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_39 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_39 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_4 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_4 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_4 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_40 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_40 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_40 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_41 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_41 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_41 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_42 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_42 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_42 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_43 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_43 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_43 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_44 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_44 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_44 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_45 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_45 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_45 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_46 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_46 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_46 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_47 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_47 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_47 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_48 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_48 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_48 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_49 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_49 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_49 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_5 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_5 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_5 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_50 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_50 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_50 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_51 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_51 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_51 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_52 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_52 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_52 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_53 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_53 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_53 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_54 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_54 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_54 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_55 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_55 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_55 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_56 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_56 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_56 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_57 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_57 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_57 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_58 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_58 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_58 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_59 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_59 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_59 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_6 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_6 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_6 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_60 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_60 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_60 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_61 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_61 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_61 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_62 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_62 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_62 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_63 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_63 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_63 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_64 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_64 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_64 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_65 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_65 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_65 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_66 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_66 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_66 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_67 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_67 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_67 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_68 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_68 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_68 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_69 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_69 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_69 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_7 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_7 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_7 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_70 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_70 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_70 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_71 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_71 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_71 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_72 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_72 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_72 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_73 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_73 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_73 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_74 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_74 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_74 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_75 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_75 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_75 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_76 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_76 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_76 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_77 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_77 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_77 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_78 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_78 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_78 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_79 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_79 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_79 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_8 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_8 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_8 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_80 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_80 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_80 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_81 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_81 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_81 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_82 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_82 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_82 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_83 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_83 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_83 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_84 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_84 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_84 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_85 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_85 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_85 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_86 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_86 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_86 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_87 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_87 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_87 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_88 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_88 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_88 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_89 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_89 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_89 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_9 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_9 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_9 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_90 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_90 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_90 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_91 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_91 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_91 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_92 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_92 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_92 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_93 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_93 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_93 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_94 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_94 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_94 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_95 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_95 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_95 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_96 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_96 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_96 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_97 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_97 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_97 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_98 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_98 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_98 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: favorites_99 id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites_99 ALTER COLUMN id SET DEFAULT nextval('favorites_id_seq'::regclass); +ALTER TABLE ONLY public.favorites_99 ALTER COLUMN id SET DEFAULT nextval('public.favorites_id_seq'::regclass); -- -- Name: forum_posts id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_posts ALTER COLUMN id SET DEFAULT nextval('forum_posts_id_seq'::regclass); +ALTER TABLE ONLY public.forum_posts ALTER COLUMN id SET DEFAULT nextval('public.forum_posts_id_seq'::regclass); -- -- Name: forum_subscriptions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_subscriptions ALTER COLUMN id SET DEFAULT nextval('forum_subscriptions_id_seq'::regclass); +ALTER TABLE ONLY public.forum_subscriptions ALTER COLUMN id SET DEFAULT nextval('public.forum_subscriptions_id_seq'::regclass); -- -- Name: forum_topic_visits id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_topic_visits ALTER COLUMN id SET DEFAULT nextval('forum_topic_visits_id_seq'::regclass); +ALTER TABLE ONLY public.forum_topic_visits ALTER COLUMN id SET DEFAULT nextval('public.forum_topic_visits_id_seq'::regclass); -- -- Name: forum_topics id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_topics ALTER COLUMN id SET DEFAULT nextval('forum_topics_id_seq'::regclass); +ALTER TABLE ONLY public.forum_topics ALTER COLUMN id SET DEFAULT nextval('public.forum_topics_id_seq'::regclass); -- -- Name: ip_bans id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY ip_bans ALTER COLUMN id SET DEFAULT nextval('ip_bans_id_seq'::regclass); +ALTER TABLE ONLY public.ip_bans ALTER COLUMN id SET DEFAULT nextval('public.ip_bans_id_seq'::regclass); -- -- Name: janitor_trials id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY janitor_trials ALTER COLUMN id SET DEFAULT nextval('janitor_trials_id_seq'::regclass); +ALTER TABLE ONLY public.janitor_trials ALTER COLUMN id SET DEFAULT nextval('public.janitor_trials_id_seq'::regclass); -- -- Name: mod_actions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY mod_actions ALTER COLUMN id SET DEFAULT nextval('mod_actions_id_seq'::regclass); +ALTER TABLE ONLY public.mod_actions ALTER COLUMN id SET DEFAULT nextval('public.mod_actions_id_seq'::regclass); -- -- Name: news_updates id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY news_updates ALTER COLUMN id SET DEFAULT nextval('news_updates_id_seq'::regclass); +ALTER TABLE ONLY public.news_updates ALTER COLUMN id SET DEFAULT nextval('public.news_updates_id_seq'::regclass); -- -- Name: note_versions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY note_versions ALTER COLUMN id SET DEFAULT nextval('note_versions_id_seq'::regclass); +ALTER TABLE ONLY public.note_versions ALTER COLUMN id SET DEFAULT nextval('public.note_versions_id_seq'::regclass); -- -- Name: notes id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY notes ALTER COLUMN id SET DEFAULT nextval('notes_id_seq'::regclass); +ALTER TABLE ONLY public.notes ALTER COLUMN id SET DEFAULT nextval('public.notes_id_seq'::regclass); -- -- Name: pixiv_ugoira_frame_data id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY pixiv_ugoira_frame_data ALTER COLUMN id SET DEFAULT nextval('pixiv_ugoira_frame_data_id_seq'::regclass); +ALTER TABLE ONLY public.pixiv_ugoira_frame_data ALTER COLUMN id SET DEFAULT nextval('public.pixiv_ugoira_frame_data_id_seq'::regclass); -- -- Name: pools id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY pools ALTER COLUMN id SET DEFAULT nextval('pools_id_seq'::regclass); +ALTER TABLE ONLY public.pools ALTER COLUMN id SET DEFAULT nextval('public.pools_id_seq'::regclass); -- -- Name: post_appeals id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_appeals ALTER COLUMN id SET DEFAULT nextval('post_appeals_id_seq'::regclass); +ALTER TABLE ONLY public.post_appeals ALTER COLUMN id SET DEFAULT nextval('public.post_appeals_id_seq'::regclass); -- -- Name: post_approvals id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_approvals ALTER COLUMN id SET DEFAULT nextval('post_approvals_id_seq'::regclass); +ALTER TABLE ONLY public.post_approvals ALTER COLUMN id SET DEFAULT nextval('public.post_approvals_id_seq'::regclass); -- -- Name: post_disapprovals id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_disapprovals ALTER COLUMN id SET DEFAULT nextval('post_disapprovals_id_seq'::regclass); +ALTER TABLE ONLY public.post_disapprovals ALTER COLUMN id SET DEFAULT nextval('public.post_disapprovals_id_seq'::regclass); -- -- Name: post_flags id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_flags ALTER COLUMN id SET DEFAULT nextval('post_flags_id_seq'::regclass); +ALTER TABLE ONLY public.post_flags ALTER COLUMN id SET DEFAULT nextval('public.post_flags_id_seq'::regclass); -- -- Name: post_replacements id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_replacements ALTER COLUMN id SET DEFAULT nextval('post_replacements_id_seq'::regclass); +ALTER TABLE ONLY public.post_replacements ALTER COLUMN id SET DEFAULT nextval('public.post_replacements_id_seq'::regclass); -- -- Name: post_votes id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_votes ALTER COLUMN id SET DEFAULT nextval('post_votes_id_seq'::regclass); +ALTER TABLE ONLY public.post_votes ALTER COLUMN id SET DEFAULT nextval('public.post_votes_id_seq'::regclass); -- -- Name: posts id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY posts ALTER COLUMN id SET DEFAULT nextval('posts_id_seq'::regclass); +ALTER TABLE ONLY public.posts ALTER COLUMN id SET DEFAULT nextval('public.posts_id_seq'::regclass); -- -- Name: saved_searches id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY saved_searches ALTER COLUMN id SET DEFAULT nextval('saved_searches_id_seq'::regclass); +ALTER TABLE ONLY public.saved_searches ALTER COLUMN id SET DEFAULT nextval('public.saved_searches_id_seq'::regclass); -- -- Name: super_voters id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY super_voters ALTER COLUMN id SET DEFAULT nextval('super_voters_id_seq'::regclass); +ALTER TABLE ONLY public.super_voters ALTER COLUMN id SET DEFAULT nextval('public.super_voters_id_seq'::regclass); -- -- Name: tag_aliases id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_aliases ALTER COLUMN id SET DEFAULT nextval('tag_aliases_id_seq'::regclass); +ALTER TABLE ONLY public.tag_aliases ALTER COLUMN id SET DEFAULT nextval('public.tag_aliases_id_seq'::regclass); -- -- Name: tag_implications id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_implications ALTER COLUMN id SET DEFAULT nextval('tag_implications_id_seq'::regclass); +ALTER TABLE ONLY public.tag_implications ALTER COLUMN id SET DEFAULT nextval('public.tag_implications_id_seq'::regclass); -- -- Name: tag_subscriptions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_subscriptions ALTER COLUMN id SET DEFAULT nextval('tag_subscriptions_id_seq'::regclass); +ALTER TABLE ONLY public.tag_subscriptions ALTER COLUMN id SET DEFAULT nextval('public.tag_subscriptions_id_seq'::regclass); -- -- Name: tags id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY tags ALTER COLUMN id SET DEFAULT nextval('tags_id_seq'::regclass); +ALTER TABLE ONLY public.tags ALTER COLUMN id SET DEFAULT nextval('public.tags_id_seq'::regclass); -- -- Name: uploads id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY uploads ALTER COLUMN id SET DEFAULT nextval('uploads_id_seq'::regclass); +ALTER TABLE ONLY public.uploads ALTER COLUMN id SET DEFAULT nextval('public.uploads_id_seq'::regclass); -- -- Name: user_feedback id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_feedback ALTER COLUMN id SET DEFAULT nextval('user_feedback_id_seq'::regclass); +ALTER TABLE ONLY public.user_feedback ALTER COLUMN id SET DEFAULT nextval('public.user_feedback_id_seq'::regclass); -- -- Name: user_name_change_requests id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_name_change_requests ALTER COLUMN id SET DEFAULT nextval('user_name_change_requests_id_seq'::regclass); +ALTER TABLE ONLY public.user_name_change_requests ALTER COLUMN id SET DEFAULT nextval('public.user_name_change_requests_id_seq'::regclass); -- -- Name: user_password_reset_nonces id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_password_reset_nonces ALTER COLUMN id SET DEFAULT nextval('user_password_reset_nonces_id_seq'::regclass); +ALTER TABLE ONLY public.user_password_reset_nonces ALTER COLUMN id SET DEFAULT nextval('public.user_password_reset_nonces_id_seq'::regclass); -- -- Name: users id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass); +ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass); -- -- Name: wiki_page_versions id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY wiki_page_versions ALTER COLUMN id SET DEFAULT nextval('wiki_page_versions_id_seq'::regclass); +ALTER TABLE ONLY public.wiki_page_versions ALTER COLUMN id SET DEFAULT nextval('public.wiki_page_versions_id_seq'::regclass); -- -- Name: wiki_pages id; Type: DEFAULT; Schema: public; Owner: - -- -ALTER TABLE ONLY wiki_pages ALTER COLUMN id SET DEFAULT nextval('wiki_pages_id_seq'::regclass); +ALTER TABLE ONLY public.wiki_pages ALTER COLUMN id SET DEFAULT nextval('public.wiki_pages_id_seq'::regclass); -- -- Name: advertisement_hits advertisement_hits_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY advertisement_hits +ALTER TABLE ONLY public.advertisement_hits ADD CONSTRAINT advertisement_hits_pkey PRIMARY KEY (id); @@ -4398,7 +4402,7 @@ ALTER TABLE ONLY advertisement_hits -- Name: advertisements advertisements_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY advertisements +ALTER TABLE ONLY public.advertisements ADD CONSTRAINT advertisements_pkey PRIMARY KEY (id); @@ -4406,7 +4410,7 @@ ALTER TABLE ONLY advertisements -- Name: amazon_backups amazon_backups_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY amazon_backups +ALTER TABLE ONLY public.amazon_backups ADD CONSTRAINT amazon_backups_pkey PRIMARY KEY (id); @@ -4414,7 +4418,7 @@ ALTER TABLE ONLY amazon_backups -- Name: anti_voters anti_voters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY anti_voters +ALTER TABLE ONLY public.anti_voters ADD CONSTRAINT anti_voters_pkey PRIMARY KEY (id); @@ -4422,15 +4426,23 @@ ALTER TABLE ONLY anti_voters -- Name: api_keys api_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY api_keys +ALTER TABLE ONLY public.api_keys ADD CONSTRAINT api_keys_pkey PRIMARY KEY (id); +-- +-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.ar_internal_metadata + ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key); + + -- -- Name: artist_commentaries artist_commentaries_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_commentaries +ALTER TABLE ONLY public.artist_commentaries ADD CONSTRAINT artist_commentaries_pkey PRIMARY KEY (id); @@ -4438,7 +4450,7 @@ ALTER TABLE ONLY artist_commentaries -- Name: artist_commentary_versions artist_commentary_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_commentary_versions +ALTER TABLE ONLY public.artist_commentary_versions ADD CONSTRAINT artist_commentary_versions_pkey PRIMARY KEY (id); @@ -4446,7 +4458,7 @@ ALTER TABLE ONLY artist_commentary_versions -- Name: artist_urls artist_urls_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_urls +ALTER TABLE ONLY public.artist_urls ADD CONSTRAINT artist_urls_pkey PRIMARY KEY (id); @@ -4454,7 +4466,7 @@ ALTER TABLE ONLY artist_urls -- Name: artist_versions artist_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY artist_versions +ALTER TABLE ONLY public.artist_versions ADD CONSTRAINT artist_versions_pkey PRIMARY KEY (id); @@ -4462,7 +4474,7 @@ ALTER TABLE ONLY artist_versions -- Name: artists artists_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY artists +ALTER TABLE ONLY public.artists ADD CONSTRAINT artists_pkey PRIMARY KEY (id); @@ -4470,7 +4482,7 @@ ALTER TABLE ONLY artists -- Name: bans bans_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY bans +ALTER TABLE ONLY public.bans ADD CONSTRAINT bans_pkey PRIMARY KEY (id); @@ -4478,7 +4490,7 @@ ALTER TABLE ONLY bans -- Name: bulk_update_requests bulk_update_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY bulk_update_requests +ALTER TABLE ONLY public.bulk_update_requests ADD CONSTRAINT bulk_update_requests_pkey PRIMARY KEY (id); @@ -4486,7 +4498,7 @@ ALTER TABLE ONLY bulk_update_requests -- Name: comment_votes comment_votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY comment_votes +ALTER TABLE ONLY public.comment_votes ADD CONSTRAINT comment_votes_pkey PRIMARY KEY (id); @@ -4494,7 +4506,7 @@ ALTER TABLE ONLY comment_votes -- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY comments +ALTER TABLE ONLY public.comments ADD CONSTRAINT comments_pkey PRIMARY KEY (id); @@ -4502,7 +4514,7 @@ ALTER TABLE ONLY comments -- Name: delayed_jobs delayed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY delayed_jobs +ALTER TABLE ONLY public.delayed_jobs ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id); @@ -4510,7 +4522,7 @@ ALTER TABLE ONLY delayed_jobs -- Name: dmail_filters dmail_filters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY dmail_filters +ALTER TABLE ONLY public.dmail_filters ADD CONSTRAINT dmail_filters_pkey PRIMARY KEY (id); @@ -4518,7 +4530,7 @@ ALTER TABLE ONLY dmail_filters -- Name: dmails dmails_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY dmails +ALTER TABLE ONLY public.dmails ADD CONSTRAINT dmails_pkey PRIMARY KEY (id); @@ -4526,7 +4538,7 @@ ALTER TABLE ONLY dmails -- Name: favorite_groups favorite_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorite_groups +ALTER TABLE ONLY public.favorite_groups ADD CONSTRAINT favorite_groups_pkey PRIMARY KEY (id); @@ -4534,7 +4546,7 @@ ALTER TABLE ONLY favorite_groups -- Name: favorites favorites_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY favorites +ALTER TABLE ONLY public.favorites ADD CONSTRAINT favorites_pkey PRIMARY KEY (id); @@ -4542,7 +4554,7 @@ ALTER TABLE ONLY favorites -- Name: forum_posts forum_posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_posts +ALTER TABLE ONLY public.forum_posts ADD CONSTRAINT forum_posts_pkey PRIMARY KEY (id); @@ -4550,7 +4562,7 @@ ALTER TABLE ONLY forum_posts -- Name: forum_subscriptions forum_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_subscriptions +ALTER TABLE ONLY public.forum_subscriptions ADD CONSTRAINT forum_subscriptions_pkey PRIMARY KEY (id); @@ -4558,7 +4570,7 @@ ALTER TABLE ONLY forum_subscriptions -- Name: forum_topic_visits forum_topic_visits_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_topic_visits +ALTER TABLE ONLY public.forum_topic_visits ADD CONSTRAINT forum_topic_visits_pkey PRIMARY KEY (id); @@ -4566,7 +4578,7 @@ ALTER TABLE ONLY forum_topic_visits -- Name: forum_topics forum_topics_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY forum_topics +ALTER TABLE ONLY public.forum_topics ADD CONSTRAINT forum_topics_pkey PRIMARY KEY (id); @@ -4574,7 +4586,7 @@ ALTER TABLE ONLY forum_topics -- Name: ip_bans ip_bans_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY ip_bans +ALTER TABLE ONLY public.ip_bans ADD CONSTRAINT ip_bans_pkey PRIMARY KEY (id); @@ -4582,7 +4594,7 @@ ALTER TABLE ONLY ip_bans -- Name: janitor_trials janitor_trials_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY janitor_trials +ALTER TABLE ONLY public.janitor_trials ADD CONSTRAINT janitor_trials_pkey PRIMARY KEY (id); @@ -4590,7 +4602,7 @@ ALTER TABLE ONLY janitor_trials -- Name: mod_actions mod_actions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY mod_actions +ALTER TABLE ONLY public.mod_actions ADD CONSTRAINT mod_actions_pkey PRIMARY KEY (id); @@ -4598,7 +4610,7 @@ ALTER TABLE ONLY mod_actions -- Name: news_updates news_updates_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY news_updates +ALTER TABLE ONLY public.news_updates ADD CONSTRAINT news_updates_pkey PRIMARY KEY (id); @@ -4606,7 +4618,7 @@ ALTER TABLE ONLY news_updates -- Name: note_versions note_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY note_versions +ALTER TABLE ONLY public.note_versions ADD CONSTRAINT note_versions_pkey PRIMARY KEY (id); @@ -4614,7 +4626,7 @@ ALTER TABLE ONLY note_versions -- Name: notes notes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY notes +ALTER TABLE ONLY public.notes ADD CONSTRAINT notes_pkey PRIMARY KEY (id); @@ -4622,7 +4634,7 @@ ALTER TABLE ONLY notes -- Name: pixiv_ugoira_frame_data pixiv_ugoira_frame_data_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY pixiv_ugoira_frame_data +ALTER TABLE ONLY public.pixiv_ugoira_frame_data ADD CONSTRAINT pixiv_ugoira_frame_data_pkey PRIMARY KEY (id); @@ -4630,7 +4642,7 @@ ALTER TABLE ONLY pixiv_ugoira_frame_data -- Name: pools pools_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY pools +ALTER TABLE ONLY public.pools ADD CONSTRAINT pools_pkey PRIMARY KEY (id); @@ -4638,7 +4650,7 @@ ALTER TABLE ONLY pools -- Name: post_appeals post_appeals_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_appeals +ALTER TABLE ONLY public.post_appeals ADD CONSTRAINT post_appeals_pkey PRIMARY KEY (id); @@ -4646,7 +4658,7 @@ ALTER TABLE ONLY post_appeals -- Name: post_approvals post_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_approvals +ALTER TABLE ONLY public.post_approvals ADD CONSTRAINT post_approvals_pkey PRIMARY KEY (id); @@ -4654,7 +4666,7 @@ ALTER TABLE ONLY post_approvals -- Name: post_disapprovals post_disapprovals_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_disapprovals +ALTER TABLE ONLY public.post_disapprovals ADD CONSTRAINT post_disapprovals_pkey PRIMARY KEY (id); @@ -4662,7 +4674,7 @@ ALTER TABLE ONLY post_disapprovals -- Name: post_flags post_flags_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_flags +ALTER TABLE ONLY public.post_flags ADD CONSTRAINT post_flags_pkey PRIMARY KEY (id); @@ -4670,7 +4682,7 @@ ALTER TABLE ONLY post_flags -- Name: post_replacements post_replacements_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_replacements +ALTER TABLE ONLY public.post_replacements ADD CONSTRAINT post_replacements_pkey PRIMARY KEY (id); @@ -4678,7 +4690,7 @@ ALTER TABLE ONLY post_replacements -- Name: post_votes post_votes_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY post_votes +ALTER TABLE ONLY public.post_votes ADD CONSTRAINT post_votes_pkey PRIMARY KEY (id); @@ -4686,7 +4698,7 @@ ALTER TABLE ONLY post_votes -- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY posts +ALTER TABLE ONLY public.posts ADD CONSTRAINT posts_pkey PRIMARY KEY (id); @@ -4694,7 +4706,7 @@ ALTER TABLE ONLY posts -- Name: saved_searches saved_searches_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY saved_searches +ALTER TABLE ONLY public.saved_searches ADD CONSTRAINT saved_searches_pkey PRIMARY KEY (id); @@ -4702,7 +4714,7 @@ ALTER TABLE ONLY saved_searches -- Name: super_voters super_voters_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY super_voters +ALTER TABLE ONLY public.super_voters ADD CONSTRAINT super_voters_pkey PRIMARY KEY (id); @@ -4710,7 +4722,7 @@ ALTER TABLE ONLY super_voters -- Name: tag_aliases tag_aliases_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_aliases +ALTER TABLE ONLY public.tag_aliases ADD CONSTRAINT tag_aliases_pkey PRIMARY KEY (id); @@ -4718,7 +4730,7 @@ ALTER TABLE ONLY tag_aliases -- Name: tag_implications tag_implications_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_implications +ALTER TABLE ONLY public.tag_implications ADD CONSTRAINT tag_implications_pkey PRIMARY KEY (id); @@ -4726,7 +4738,7 @@ ALTER TABLE ONLY tag_implications -- Name: tag_subscriptions tag_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY tag_subscriptions +ALTER TABLE ONLY public.tag_subscriptions ADD CONSTRAINT tag_subscriptions_pkey PRIMARY KEY (id); @@ -4734,7 +4746,7 @@ ALTER TABLE ONLY tag_subscriptions -- Name: tags tags_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY tags +ALTER TABLE ONLY public.tags ADD CONSTRAINT tags_pkey PRIMARY KEY (id); @@ -4742,7 +4754,7 @@ ALTER TABLE ONLY tags -- Name: uploads uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY uploads +ALTER TABLE ONLY public.uploads ADD CONSTRAINT uploads_pkey PRIMARY KEY (id); @@ -4750,7 +4762,7 @@ ALTER TABLE ONLY uploads -- Name: user_feedback user_feedback_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_feedback +ALTER TABLE ONLY public.user_feedback ADD CONSTRAINT user_feedback_pkey PRIMARY KEY (id); @@ -4758,7 +4770,7 @@ ALTER TABLE ONLY user_feedback -- Name: user_name_change_requests user_name_change_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_name_change_requests +ALTER TABLE ONLY public.user_name_change_requests ADD CONSTRAINT user_name_change_requests_pkey PRIMARY KEY (id); @@ -4766,7 +4778,7 @@ ALTER TABLE ONLY user_name_change_requests -- Name: user_password_reset_nonces user_password_reset_nonces_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY user_password_reset_nonces +ALTER TABLE ONLY public.user_password_reset_nonces ADD CONSTRAINT user_password_reset_nonces_pkey PRIMARY KEY (id); @@ -4774,7 +4786,7 @@ ALTER TABLE ONLY user_password_reset_nonces -- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY users +ALTER TABLE ONLY public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id); @@ -4782,7 +4794,7 @@ ALTER TABLE ONLY users -- Name: wiki_page_versions wiki_page_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY wiki_page_versions +ALTER TABLE ONLY public.wiki_page_versions ADD CONSTRAINT wiki_page_versions_pkey PRIMARY KEY (id); @@ -4790,7 +4802,7 @@ ALTER TABLE ONLY wiki_page_versions -- Name: wiki_pages wiki_pages_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY wiki_pages +ALTER TABLE ONLY public.wiki_pages ADD CONSTRAINT wiki_pages_pkey PRIMARY KEY (id); @@ -4798,2464 +4810,2464 @@ ALTER TABLE ONLY wiki_pages -- Name: index_advertisement_hits_on_advertisement_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_advertisement_hits_on_advertisement_id ON advertisement_hits USING btree (advertisement_id); +CREATE INDEX index_advertisement_hits_on_advertisement_id ON public.advertisement_hits USING btree (advertisement_id); -- -- Name: index_advertisement_hits_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_advertisement_hits_on_created_at ON advertisement_hits USING btree (created_at); +CREATE INDEX index_advertisement_hits_on_created_at ON public.advertisement_hits USING btree (created_at); -- -- Name: index_advertisements_on_ad_type; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_advertisements_on_ad_type ON advertisements USING btree (ad_type); +CREATE INDEX index_advertisements_on_ad_type ON public.advertisements USING btree (ad_type); -- -- Name: index_api_keys_on_key; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_api_keys_on_key ON api_keys USING btree (key); +CREATE UNIQUE INDEX index_api_keys_on_key ON public.api_keys USING btree (key); -- -- Name: index_api_keys_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_api_keys_on_user_id ON api_keys USING btree (user_id); +CREATE UNIQUE INDEX index_api_keys_on_user_id ON public.api_keys USING btree (user_id); -- -- Name: index_artist_commentaries_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_artist_commentaries_on_post_id ON artist_commentaries USING btree (post_id); +CREATE UNIQUE INDEX index_artist_commentaries_on_post_id ON public.artist_commentaries USING btree (post_id); -- -- Name: index_artist_commentary_versions_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_commentary_versions_on_post_id ON artist_commentary_versions USING btree (post_id); +CREATE INDEX index_artist_commentary_versions_on_post_id ON public.artist_commentary_versions USING btree (post_id); -- -- Name: index_artist_commentary_versions_on_updater_id_and_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_commentary_versions_on_updater_id_and_post_id ON artist_commentary_versions USING btree (updater_id, post_id); +CREATE INDEX index_artist_commentary_versions_on_updater_id_and_post_id ON public.artist_commentary_versions USING btree (updater_id, post_id); -- -- Name: index_artist_commentary_versions_on_updater_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_commentary_versions_on_updater_ip_addr ON artist_commentary_versions USING btree (updater_ip_addr); +CREATE INDEX index_artist_commentary_versions_on_updater_ip_addr ON public.artist_commentary_versions USING btree (updater_ip_addr); -- -- Name: index_artist_urls_on_artist_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_artist_id ON artist_urls USING btree (artist_id); +CREATE INDEX index_artist_urls_on_artist_id ON public.artist_urls USING btree (artist_id); -- -- Name: index_artist_urls_on_normalized_url; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_normalized_url ON artist_urls USING btree (normalized_url); +CREATE INDEX index_artist_urls_on_normalized_url ON public.artist_urls USING btree (normalized_url); -- -- Name: index_artist_urls_on_normalized_url_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_normalized_url_pattern ON artist_urls USING btree (normalized_url text_pattern_ops); +CREATE INDEX index_artist_urls_on_normalized_url_pattern ON public.artist_urls USING btree (normalized_url text_pattern_ops); -- -- Name: index_artist_urls_on_url; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_url ON artist_urls USING btree (url); +CREATE INDEX index_artist_urls_on_url ON public.artist_urls USING btree (url); -- -- Name: index_artist_urls_on_url_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_url_pattern ON artist_urls USING btree (url text_pattern_ops); +CREATE INDEX index_artist_urls_on_url_pattern ON public.artist_urls USING btree (url text_pattern_ops); -- -- Name: index_artist_versions_on_artist_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_versions_on_artist_id ON artist_versions USING btree (artist_id); +CREATE INDEX index_artist_versions_on_artist_id ON public.artist_versions USING btree (artist_id); -- -- Name: index_artist_versions_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_versions_on_created_at ON artist_versions USING btree (created_at); +CREATE INDEX index_artist_versions_on_created_at ON public.artist_versions USING btree (created_at); -- -- Name: index_artist_versions_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_versions_on_name ON artist_versions USING btree (name); +CREATE INDEX index_artist_versions_on_name ON public.artist_versions USING btree (name); -- -- Name: index_artist_versions_on_updater_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_versions_on_updater_id ON artist_versions USING btree (updater_id); +CREATE INDEX index_artist_versions_on_updater_id ON public.artist_versions USING btree (updater_id); -- -- Name: index_artist_versions_on_updater_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_versions_on_updater_ip_addr ON artist_versions USING btree (updater_ip_addr); +CREATE INDEX index_artist_versions_on_updater_ip_addr ON public.artist_versions USING btree (updater_ip_addr); -- -- Name: index_artists_on_group_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artists_on_group_name ON artists USING btree (group_name); +CREATE INDEX index_artists_on_group_name ON public.artists USING btree (group_name); -- -- Name: index_artists_on_group_name_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artists_on_group_name_trgm ON artists USING gin (group_name gin_trgm_ops); +CREATE INDEX index_artists_on_group_name_trgm ON public.artists USING gin (group_name public.gin_trgm_ops); -- -- Name: index_artists_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_artists_on_name ON artists USING btree (name); +CREATE UNIQUE INDEX index_artists_on_name ON public.artists USING btree (name); -- -- Name: index_artists_on_name_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artists_on_name_trgm ON artists USING gin (name gin_trgm_ops); +CREATE INDEX index_artists_on_name_trgm ON public.artists USING gin (name public.gin_trgm_ops); -- -- Name: index_artists_on_other_names_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artists_on_other_names_index ON artists USING gin (other_names_index); +CREATE INDEX index_artists_on_other_names_index ON public.artists USING gin (other_names_index); -- -- Name: index_artists_on_other_names_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artists_on_other_names_trgm ON artists USING gin (other_names gin_trgm_ops); +CREATE INDEX index_artists_on_other_names_trgm ON public.artists USING gin (other_names public.gin_trgm_ops); -- -- Name: index_bans_on_banner_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_bans_on_banner_id ON bans USING btree (banner_id); +CREATE INDEX index_bans_on_banner_id ON public.bans USING btree (banner_id); -- -- Name: index_bans_on_expires_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_bans_on_expires_at ON bans USING btree (expires_at); +CREATE INDEX index_bans_on_expires_at ON public.bans USING btree (expires_at); -- -- Name: index_bans_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_bans_on_user_id ON bans USING btree (user_id); +CREATE INDEX index_bans_on_user_id ON public.bans USING btree (user_id); -- -- Name: index_comment_votes_on_comment_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comment_votes_on_comment_id ON comment_votes USING btree (comment_id); +CREATE INDEX index_comment_votes_on_comment_id ON public.comment_votes USING btree (comment_id); -- -- Name: index_comment_votes_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comment_votes_on_created_at ON comment_votes USING btree (created_at); +CREATE INDEX index_comment_votes_on_created_at ON public.comment_votes USING btree (created_at); -- -- Name: index_comment_votes_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comment_votes_on_user_id ON comment_votes USING btree (user_id); +CREATE INDEX index_comment_votes_on_user_id ON public.comment_votes USING btree (user_id); -- -- Name: index_comments_on_body_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comments_on_body_index ON comments USING gin (body_index); +CREATE INDEX index_comments_on_body_index ON public.comments USING gin (body_index); -- -- Name: index_comments_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comments_on_creator_id_and_post_id ON comments USING btree (creator_id, post_id); +CREATE INDEX index_comments_on_creator_id_and_post_id ON public.comments USING btree (creator_id, post_id); -- -- Name: index_comments_on_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comments_on_ip_addr ON comments USING btree (ip_addr); +CREATE INDEX index_comments_on_ip_addr ON public.comments USING btree (ip_addr); -- -- Name: index_comments_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_comments_on_post_id ON comments USING btree (post_id); +CREATE INDEX index_comments_on_post_id ON public.comments USING btree (post_id); -- -- Name: index_delayed_jobs_on_locked_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_delayed_jobs_on_locked_at ON delayed_jobs USING btree (locked_at); +CREATE INDEX index_delayed_jobs_on_locked_at ON public.delayed_jobs USING btree (locked_at); -- -- Name: index_delayed_jobs_on_locked_by; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_delayed_jobs_on_locked_by ON delayed_jobs USING btree (locked_by); +CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree (locked_by); -- -- Name: index_delayed_jobs_on_run_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_delayed_jobs_on_run_at ON delayed_jobs USING btree (run_at); +CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at); -- -- Name: index_dmail_filters_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_dmail_filters_on_user_id ON dmail_filters USING btree (user_id); +CREATE UNIQUE INDEX index_dmail_filters_on_user_id ON public.dmail_filters USING btree (user_id); -- -- Name: index_dmails_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_dmails_on_creator_ip_addr ON dmails USING btree (creator_ip_addr); +CREATE INDEX index_dmails_on_creator_ip_addr ON public.dmails USING btree (creator_ip_addr); -- -- Name: index_dmails_on_is_deleted; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_dmails_on_is_deleted ON dmails USING btree (is_deleted); +CREATE INDEX index_dmails_on_is_deleted ON public.dmails USING btree (is_deleted); -- -- Name: index_dmails_on_is_read; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_dmails_on_is_read ON dmails USING btree (is_read); +CREATE INDEX index_dmails_on_is_read ON public.dmails USING btree (is_read); -- -- Name: index_dmails_on_message_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_dmails_on_message_index ON dmails USING gin (message_index); +CREATE INDEX index_dmails_on_message_index ON public.dmails USING gin (message_index); -- -- Name: index_dmails_on_owner_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_dmails_on_owner_id ON dmails USING btree (owner_id); +CREATE INDEX index_dmails_on_owner_id ON public.dmails USING btree (owner_id); -- -- Name: index_favorite_groups_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorite_groups_on_creator_id ON favorite_groups USING btree (creator_id); +CREATE INDEX index_favorite_groups_on_creator_id ON public.favorite_groups USING btree (creator_id); -- -- Name: index_favorite_groups_on_lower_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorite_groups_on_lower_name ON favorite_groups USING btree (lower(name)); +CREATE INDEX index_favorite_groups_on_lower_name ON public.favorite_groups USING btree (lower(name)); -- -- Name: index_favorites_0_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_0_on_post_id ON favorites_0 USING btree (post_id); +CREATE INDEX index_favorites_0_on_post_id ON public.favorites_0 USING btree (post_id); -- -- Name: index_favorites_0_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_0_on_user_id ON favorites_0 USING btree (user_id); +CREATE INDEX index_favorites_0_on_user_id ON public.favorites_0 USING btree (user_id); -- -- Name: index_favorites_10_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_10_on_post_id ON favorites_10 USING btree (post_id); +CREATE INDEX index_favorites_10_on_post_id ON public.favorites_10 USING btree (post_id); -- -- Name: index_favorites_10_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_10_on_user_id ON favorites_10 USING btree (user_id); +CREATE INDEX index_favorites_10_on_user_id ON public.favorites_10 USING btree (user_id); -- -- Name: index_favorites_11_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_11_on_post_id ON favorites_11 USING btree (post_id); +CREATE INDEX index_favorites_11_on_post_id ON public.favorites_11 USING btree (post_id); -- -- Name: index_favorites_11_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_11_on_user_id ON favorites_11 USING btree (user_id); +CREATE INDEX index_favorites_11_on_user_id ON public.favorites_11 USING btree (user_id); -- -- Name: index_favorites_12_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_12_on_post_id ON favorites_12 USING btree (post_id); +CREATE INDEX index_favorites_12_on_post_id ON public.favorites_12 USING btree (post_id); -- -- Name: index_favorites_12_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_12_on_user_id ON favorites_12 USING btree (user_id); +CREATE INDEX index_favorites_12_on_user_id ON public.favorites_12 USING btree (user_id); -- -- Name: index_favorites_13_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_13_on_post_id ON favorites_13 USING btree (post_id); +CREATE INDEX index_favorites_13_on_post_id ON public.favorites_13 USING btree (post_id); -- -- Name: index_favorites_13_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_13_on_user_id ON favorites_13 USING btree (user_id); +CREATE INDEX index_favorites_13_on_user_id ON public.favorites_13 USING btree (user_id); -- -- Name: index_favorites_14_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_14_on_post_id ON favorites_14 USING btree (post_id); +CREATE INDEX index_favorites_14_on_post_id ON public.favorites_14 USING btree (post_id); -- -- Name: index_favorites_14_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_14_on_user_id ON favorites_14 USING btree (user_id); +CREATE INDEX index_favorites_14_on_user_id ON public.favorites_14 USING btree (user_id); -- -- Name: index_favorites_15_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_15_on_post_id ON favorites_15 USING btree (post_id); +CREATE INDEX index_favorites_15_on_post_id ON public.favorites_15 USING btree (post_id); -- -- Name: index_favorites_15_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_15_on_user_id ON favorites_15 USING btree (user_id); +CREATE INDEX index_favorites_15_on_user_id ON public.favorites_15 USING btree (user_id); -- -- Name: index_favorites_16_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_16_on_post_id ON favorites_16 USING btree (post_id); +CREATE INDEX index_favorites_16_on_post_id ON public.favorites_16 USING btree (post_id); -- -- Name: index_favorites_16_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_16_on_user_id ON favorites_16 USING btree (user_id); +CREATE INDEX index_favorites_16_on_user_id ON public.favorites_16 USING btree (user_id); -- -- Name: index_favorites_17_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_17_on_post_id ON favorites_17 USING btree (post_id); +CREATE INDEX index_favorites_17_on_post_id ON public.favorites_17 USING btree (post_id); -- -- Name: index_favorites_17_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_17_on_user_id ON favorites_17 USING btree (user_id); +CREATE INDEX index_favorites_17_on_user_id ON public.favorites_17 USING btree (user_id); -- -- Name: index_favorites_18_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_18_on_post_id ON favorites_18 USING btree (post_id); +CREATE INDEX index_favorites_18_on_post_id ON public.favorites_18 USING btree (post_id); -- -- Name: index_favorites_18_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_18_on_user_id ON favorites_18 USING btree (user_id); +CREATE INDEX index_favorites_18_on_user_id ON public.favorites_18 USING btree (user_id); -- -- Name: index_favorites_19_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_19_on_post_id ON favorites_19 USING btree (post_id); +CREATE INDEX index_favorites_19_on_post_id ON public.favorites_19 USING btree (post_id); -- -- Name: index_favorites_19_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_19_on_user_id ON favorites_19 USING btree (user_id); +CREATE INDEX index_favorites_19_on_user_id ON public.favorites_19 USING btree (user_id); -- -- Name: index_favorites_1_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_1_on_post_id ON favorites_1 USING btree (post_id); +CREATE INDEX index_favorites_1_on_post_id ON public.favorites_1 USING btree (post_id); -- -- Name: index_favorites_1_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_1_on_user_id ON favorites_1 USING btree (user_id); +CREATE INDEX index_favorites_1_on_user_id ON public.favorites_1 USING btree (user_id); -- -- Name: index_favorites_20_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_20_on_post_id ON favorites_20 USING btree (post_id); +CREATE INDEX index_favorites_20_on_post_id ON public.favorites_20 USING btree (post_id); -- -- Name: index_favorites_20_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_20_on_user_id ON favorites_20 USING btree (user_id); +CREATE INDEX index_favorites_20_on_user_id ON public.favorites_20 USING btree (user_id); -- -- Name: index_favorites_21_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_21_on_post_id ON favorites_21 USING btree (post_id); +CREATE INDEX index_favorites_21_on_post_id ON public.favorites_21 USING btree (post_id); -- -- Name: index_favorites_21_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_21_on_user_id ON favorites_21 USING btree (user_id); +CREATE INDEX index_favorites_21_on_user_id ON public.favorites_21 USING btree (user_id); -- -- Name: index_favorites_22_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_22_on_post_id ON favorites_22 USING btree (post_id); +CREATE INDEX index_favorites_22_on_post_id ON public.favorites_22 USING btree (post_id); -- -- Name: index_favorites_22_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_22_on_user_id ON favorites_22 USING btree (user_id); +CREATE INDEX index_favorites_22_on_user_id ON public.favorites_22 USING btree (user_id); -- -- Name: index_favorites_23_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_23_on_post_id ON favorites_23 USING btree (post_id); +CREATE INDEX index_favorites_23_on_post_id ON public.favorites_23 USING btree (post_id); -- -- Name: index_favorites_23_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_23_on_user_id ON favorites_23 USING btree (user_id); +CREATE INDEX index_favorites_23_on_user_id ON public.favorites_23 USING btree (user_id); -- -- Name: index_favorites_24_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_24_on_post_id ON favorites_24 USING btree (post_id); +CREATE INDEX index_favorites_24_on_post_id ON public.favorites_24 USING btree (post_id); -- -- Name: index_favorites_24_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_24_on_user_id ON favorites_24 USING btree (user_id); +CREATE INDEX index_favorites_24_on_user_id ON public.favorites_24 USING btree (user_id); -- -- Name: index_favorites_25_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_25_on_post_id ON favorites_25 USING btree (post_id); +CREATE INDEX index_favorites_25_on_post_id ON public.favorites_25 USING btree (post_id); -- -- Name: index_favorites_25_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_25_on_user_id ON favorites_25 USING btree (user_id); +CREATE INDEX index_favorites_25_on_user_id ON public.favorites_25 USING btree (user_id); -- -- Name: index_favorites_26_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_26_on_post_id ON favorites_26 USING btree (post_id); +CREATE INDEX index_favorites_26_on_post_id ON public.favorites_26 USING btree (post_id); -- -- Name: index_favorites_26_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_26_on_user_id ON favorites_26 USING btree (user_id); +CREATE INDEX index_favorites_26_on_user_id ON public.favorites_26 USING btree (user_id); -- -- Name: index_favorites_27_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_27_on_post_id ON favorites_27 USING btree (post_id); +CREATE INDEX index_favorites_27_on_post_id ON public.favorites_27 USING btree (post_id); -- -- Name: index_favorites_27_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_27_on_user_id ON favorites_27 USING btree (user_id); +CREATE INDEX index_favorites_27_on_user_id ON public.favorites_27 USING btree (user_id); -- -- Name: index_favorites_28_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_28_on_post_id ON favorites_28 USING btree (post_id); +CREATE INDEX index_favorites_28_on_post_id ON public.favorites_28 USING btree (post_id); -- -- Name: index_favorites_28_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_28_on_user_id ON favorites_28 USING btree (user_id); +CREATE INDEX index_favorites_28_on_user_id ON public.favorites_28 USING btree (user_id); -- -- Name: index_favorites_29_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_29_on_post_id ON favorites_29 USING btree (post_id); +CREATE INDEX index_favorites_29_on_post_id ON public.favorites_29 USING btree (post_id); -- -- Name: index_favorites_29_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_29_on_user_id ON favorites_29 USING btree (user_id); +CREATE INDEX index_favorites_29_on_user_id ON public.favorites_29 USING btree (user_id); -- -- Name: index_favorites_2_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_2_on_post_id ON favorites_2 USING btree (post_id); +CREATE INDEX index_favorites_2_on_post_id ON public.favorites_2 USING btree (post_id); -- -- Name: index_favorites_2_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_2_on_user_id ON favorites_2 USING btree (user_id); +CREATE INDEX index_favorites_2_on_user_id ON public.favorites_2 USING btree (user_id); -- -- Name: index_favorites_30_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_30_on_post_id ON favorites_30 USING btree (post_id); +CREATE INDEX index_favorites_30_on_post_id ON public.favorites_30 USING btree (post_id); -- -- Name: index_favorites_30_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_30_on_user_id ON favorites_30 USING btree (user_id); +CREATE INDEX index_favorites_30_on_user_id ON public.favorites_30 USING btree (user_id); -- -- Name: index_favorites_31_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_31_on_post_id ON favorites_31 USING btree (post_id); +CREATE INDEX index_favorites_31_on_post_id ON public.favorites_31 USING btree (post_id); -- -- Name: index_favorites_31_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_31_on_user_id ON favorites_31 USING btree (user_id); +CREATE INDEX index_favorites_31_on_user_id ON public.favorites_31 USING btree (user_id); -- -- Name: index_favorites_32_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_32_on_post_id ON favorites_32 USING btree (post_id); +CREATE INDEX index_favorites_32_on_post_id ON public.favorites_32 USING btree (post_id); -- -- Name: index_favorites_32_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_32_on_user_id ON favorites_32 USING btree (user_id); +CREATE INDEX index_favorites_32_on_user_id ON public.favorites_32 USING btree (user_id); -- -- Name: index_favorites_33_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_33_on_post_id ON favorites_33 USING btree (post_id); +CREATE INDEX index_favorites_33_on_post_id ON public.favorites_33 USING btree (post_id); -- -- Name: index_favorites_33_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_33_on_user_id ON favorites_33 USING btree (user_id); +CREATE INDEX index_favorites_33_on_user_id ON public.favorites_33 USING btree (user_id); -- -- Name: index_favorites_34_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_34_on_post_id ON favorites_34 USING btree (post_id); +CREATE INDEX index_favorites_34_on_post_id ON public.favorites_34 USING btree (post_id); -- -- Name: index_favorites_34_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_34_on_user_id ON favorites_34 USING btree (user_id); +CREATE INDEX index_favorites_34_on_user_id ON public.favorites_34 USING btree (user_id); -- -- Name: index_favorites_35_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_35_on_post_id ON favorites_35 USING btree (post_id); +CREATE INDEX index_favorites_35_on_post_id ON public.favorites_35 USING btree (post_id); -- -- Name: index_favorites_35_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_35_on_user_id ON favorites_35 USING btree (user_id); +CREATE INDEX index_favorites_35_on_user_id ON public.favorites_35 USING btree (user_id); -- -- Name: index_favorites_36_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_36_on_post_id ON favorites_36 USING btree (post_id); +CREATE INDEX index_favorites_36_on_post_id ON public.favorites_36 USING btree (post_id); -- -- Name: index_favorites_36_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_36_on_user_id ON favorites_36 USING btree (user_id); +CREATE INDEX index_favorites_36_on_user_id ON public.favorites_36 USING btree (user_id); -- -- Name: index_favorites_37_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_37_on_post_id ON favorites_37 USING btree (post_id); +CREATE INDEX index_favorites_37_on_post_id ON public.favorites_37 USING btree (post_id); -- -- Name: index_favorites_37_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_37_on_user_id ON favorites_37 USING btree (user_id); +CREATE INDEX index_favorites_37_on_user_id ON public.favorites_37 USING btree (user_id); -- -- Name: index_favorites_38_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_38_on_post_id ON favorites_38 USING btree (post_id); +CREATE INDEX index_favorites_38_on_post_id ON public.favorites_38 USING btree (post_id); -- -- Name: index_favorites_38_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_38_on_user_id ON favorites_38 USING btree (user_id); +CREATE INDEX index_favorites_38_on_user_id ON public.favorites_38 USING btree (user_id); -- -- Name: index_favorites_39_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_39_on_post_id ON favorites_39 USING btree (post_id); +CREATE INDEX index_favorites_39_on_post_id ON public.favorites_39 USING btree (post_id); -- -- Name: index_favorites_39_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_39_on_user_id ON favorites_39 USING btree (user_id); +CREATE INDEX index_favorites_39_on_user_id ON public.favorites_39 USING btree (user_id); -- -- Name: index_favorites_3_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_3_on_post_id ON favorites_3 USING btree (post_id); +CREATE INDEX index_favorites_3_on_post_id ON public.favorites_3 USING btree (post_id); -- -- Name: index_favorites_3_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_3_on_user_id ON favorites_3 USING btree (user_id); +CREATE INDEX index_favorites_3_on_user_id ON public.favorites_3 USING btree (user_id); -- -- Name: index_favorites_40_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_40_on_post_id ON favorites_40 USING btree (post_id); +CREATE INDEX index_favorites_40_on_post_id ON public.favorites_40 USING btree (post_id); -- -- Name: index_favorites_40_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_40_on_user_id ON favorites_40 USING btree (user_id); +CREATE INDEX index_favorites_40_on_user_id ON public.favorites_40 USING btree (user_id); -- -- Name: index_favorites_41_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_41_on_post_id ON favorites_41 USING btree (post_id); +CREATE INDEX index_favorites_41_on_post_id ON public.favorites_41 USING btree (post_id); -- -- Name: index_favorites_41_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_41_on_user_id ON favorites_41 USING btree (user_id); +CREATE INDEX index_favorites_41_on_user_id ON public.favorites_41 USING btree (user_id); -- -- Name: index_favorites_42_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_42_on_post_id ON favorites_42 USING btree (post_id); +CREATE INDEX index_favorites_42_on_post_id ON public.favorites_42 USING btree (post_id); -- -- Name: index_favorites_42_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_42_on_user_id ON favorites_42 USING btree (user_id); +CREATE INDEX index_favorites_42_on_user_id ON public.favorites_42 USING btree (user_id); -- -- Name: index_favorites_43_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_43_on_post_id ON favorites_43 USING btree (post_id); +CREATE INDEX index_favorites_43_on_post_id ON public.favorites_43 USING btree (post_id); -- -- Name: index_favorites_43_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_43_on_user_id ON favorites_43 USING btree (user_id); +CREATE INDEX index_favorites_43_on_user_id ON public.favorites_43 USING btree (user_id); -- -- Name: index_favorites_44_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_44_on_post_id ON favorites_44 USING btree (post_id); +CREATE INDEX index_favorites_44_on_post_id ON public.favorites_44 USING btree (post_id); -- -- Name: index_favorites_44_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_44_on_user_id ON favorites_44 USING btree (user_id); +CREATE INDEX index_favorites_44_on_user_id ON public.favorites_44 USING btree (user_id); -- -- Name: index_favorites_45_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_45_on_post_id ON favorites_45 USING btree (post_id); +CREATE INDEX index_favorites_45_on_post_id ON public.favorites_45 USING btree (post_id); -- -- Name: index_favorites_45_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_45_on_user_id ON favorites_45 USING btree (user_id); +CREATE INDEX index_favorites_45_on_user_id ON public.favorites_45 USING btree (user_id); -- -- Name: index_favorites_46_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_46_on_post_id ON favorites_46 USING btree (post_id); +CREATE INDEX index_favorites_46_on_post_id ON public.favorites_46 USING btree (post_id); -- -- Name: index_favorites_46_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_46_on_user_id ON favorites_46 USING btree (user_id); +CREATE INDEX index_favorites_46_on_user_id ON public.favorites_46 USING btree (user_id); -- -- Name: index_favorites_47_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_47_on_post_id ON favorites_47 USING btree (post_id); +CREATE INDEX index_favorites_47_on_post_id ON public.favorites_47 USING btree (post_id); -- -- Name: index_favorites_47_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_47_on_user_id ON favorites_47 USING btree (user_id); +CREATE INDEX index_favorites_47_on_user_id ON public.favorites_47 USING btree (user_id); -- -- Name: index_favorites_48_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_48_on_post_id ON favorites_48 USING btree (post_id); +CREATE INDEX index_favorites_48_on_post_id ON public.favorites_48 USING btree (post_id); -- -- Name: index_favorites_48_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_48_on_user_id ON favorites_48 USING btree (user_id); +CREATE INDEX index_favorites_48_on_user_id ON public.favorites_48 USING btree (user_id); -- -- Name: index_favorites_49_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_49_on_post_id ON favorites_49 USING btree (post_id); +CREATE INDEX index_favorites_49_on_post_id ON public.favorites_49 USING btree (post_id); -- -- Name: index_favorites_49_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_49_on_user_id ON favorites_49 USING btree (user_id); +CREATE INDEX index_favorites_49_on_user_id ON public.favorites_49 USING btree (user_id); -- -- Name: index_favorites_4_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_4_on_post_id ON favorites_4 USING btree (post_id); +CREATE INDEX index_favorites_4_on_post_id ON public.favorites_4 USING btree (post_id); -- -- Name: index_favorites_4_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_4_on_user_id ON favorites_4 USING btree (user_id); +CREATE INDEX index_favorites_4_on_user_id ON public.favorites_4 USING btree (user_id); -- -- Name: index_favorites_50_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_50_on_post_id ON favorites_50 USING btree (post_id); +CREATE INDEX index_favorites_50_on_post_id ON public.favorites_50 USING btree (post_id); -- -- Name: index_favorites_50_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_50_on_user_id ON favorites_50 USING btree (user_id); +CREATE INDEX index_favorites_50_on_user_id ON public.favorites_50 USING btree (user_id); -- -- Name: index_favorites_51_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_51_on_post_id ON favorites_51 USING btree (post_id); +CREATE INDEX index_favorites_51_on_post_id ON public.favorites_51 USING btree (post_id); -- -- Name: index_favorites_51_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_51_on_user_id ON favorites_51 USING btree (user_id); +CREATE INDEX index_favorites_51_on_user_id ON public.favorites_51 USING btree (user_id); -- -- Name: index_favorites_52_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_52_on_post_id ON favorites_52 USING btree (post_id); +CREATE INDEX index_favorites_52_on_post_id ON public.favorites_52 USING btree (post_id); -- -- Name: index_favorites_52_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_52_on_user_id ON favorites_52 USING btree (user_id); +CREATE INDEX index_favorites_52_on_user_id ON public.favorites_52 USING btree (user_id); -- -- Name: index_favorites_53_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_53_on_post_id ON favorites_53 USING btree (post_id); +CREATE INDEX index_favorites_53_on_post_id ON public.favorites_53 USING btree (post_id); -- -- Name: index_favorites_53_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_53_on_user_id ON favorites_53 USING btree (user_id); +CREATE INDEX index_favorites_53_on_user_id ON public.favorites_53 USING btree (user_id); -- -- Name: index_favorites_54_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_54_on_post_id ON favorites_54 USING btree (post_id); +CREATE INDEX index_favorites_54_on_post_id ON public.favorites_54 USING btree (post_id); -- -- Name: index_favorites_54_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_54_on_user_id ON favorites_54 USING btree (user_id); +CREATE INDEX index_favorites_54_on_user_id ON public.favorites_54 USING btree (user_id); -- -- Name: index_favorites_55_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_55_on_post_id ON favorites_55 USING btree (post_id); +CREATE INDEX index_favorites_55_on_post_id ON public.favorites_55 USING btree (post_id); -- -- Name: index_favorites_55_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_55_on_user_id ON favorites_55 USING btree (user_id); +CREATE INDEX index_favorites_55_on_user_id ON public.favorites_55 USING btree (user_id); -- -- Name: index_favorites_56_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_56_on_post_id ON favorites_56 USING btree (post_id); +CREATE INDEX index_favorites_56_on_post_id ON public.favorites_56 USING btree (post_id); -- -- Name: index_favorites_56_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_56_on_user_id ON favorites_56 USING btree (user_id); +CREATE INDEX index_favorites_56_on_user_id ON public.favorites_56 USING btree (user_id); -- -- Name: index_favorites_57_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_57_on_post_id ON favorites_57 USING btree (post_id); +CREATE INDEX index_favorites_57_on_post_id ON public.favorites_57 USING btree (post_id); -- -- Name: index_favorites_57_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_57_on_user_id ON favorites_57 USING btree (user_id); +CREATE INDEX index_favorites_57_on_user_id ON public.favorites_57 USING btree (user_id); -- -- Name: index_favorites_58_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_58_on_post_id ON favorites_58 USING btree (post_id); +CREATE INDEX index_favorites_58_on_post_id ON public.favorites_58 USING btree (post_id); -- -- Name: index_favorites_58_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_58_on_user_id ON favorites_58 USING btree (user_id); +CREATE INDEX index_favorites_58_on_user_id ON public.favorites_58 USING btree (user_id); -- -- Name: index_favorites_59_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_59_on_post_id ON favorites_59 USING btree (post_id); +CREATE INDEX index_favorites_59_on_post_id ON public.favorites_59 USING btree (post_id); -- -- Name: index_favorites_59_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_59_on_user_id ON favorites_59 USING btree (user_id); +CREATE INDEX index_favorites_59_on_user_id ON public.favorites_59 USING btree (user_id); -- -- Name: index_favorites_5_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_5_on_post_id ON favorites_5 USING btree (post_id); +CREATE INDEX index_favorites_5_on_post_id ON public.favorites_5 USING btree (post_id); -- -- Name: index_favorites_5_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_5_on_user_id ON favorites_5 USING btree (user_id); +CREATE INDEX index_favorites_5_on_user_id ON public.favorites_5 USING btree (user_id); -- -- Name: index_favorites_60_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_60_on_post_id ON favorites_60 USING btree (post_id); +CREATE INDEX index_favorites_60_on_post_id ON public.favorites_60 USING btree (post_id); -- -- Name: index_favorites_60_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_60_on_user_id ON favorites_60 USING btree (user_id); +CREATE INDEX index_favorites_60_on_user_id ON public.favorites_60 USING btree (user_id); -- -- Name: index_favorites_61_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_61_on_post_id ON favorites_61 USING btree (post_id); +CREATE INDEX index_favorites_61_on_post_id ON public.favorites_61 USING btree (post_id); -- -- Name: index_favorites_61_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_61_on_user_id ON favorites_61 USING btree (user_id); +CREATE INDEX index_favorites_61_on_user_id ON public.favorites_61 USING btree (user_id); -- -- Name: index_favorites_62_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_62_on_post_id ON favorites_62 USING btree (post_id); +CREATE INDEX index_favorites_62_on_post_id ON public.favorites_62 USING btree (post_id); -- -- Name: index_favorites_62_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_62_on_user_id ON favorites_62 USING btree (user_id); +CREATE INDEX index_favorites_62_on_user_id ON public.favorites_62 USING btree (user_id); -- -- Name: index_favorites_63_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_63_on_post_id ON favorites_63 USING btree (post_id); +CREATE INDEX index_favorites_63_on_post_id ON public.favorites_63 USING btree (post_id); -- -- Name: index_favorites_63_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_63_on_user_id ON favorites_63 USING btree (user_id); +CREATE INDEX index_favorites_63_on_user_id ON public.favorites_63 USING btree (user_id); -- -- Name: index_favorites_64_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_64_on_post_id ON favorites_64 USING btree (post_id); +CREATE INDEX index_favorites_64_on_post_id ON public.favorites_64 USING btree (post_id); -- -- Name: index_favorites_64_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_64_on_user_id ON favorites_64 USING btree (user_id); +CREATE INDEX index_favorites_64_on_user_id ON public.favorites_64 USING btree (user_id); -- -- Name: index_favorites_65_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_65_on_post_id ON favorites_65 USING btree (post_id); +CREATE INDEX index_favorites_65_on_post_id ON public.favorites_65 USING btree (post_id); -- -- Name: index_favorites_65_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_65_on_user_id ON favorites_65 USING btree (user_id); +CREATE INDEX index_favorites_65_on_user_id ON public.favorites_65 USING btree (user_id); -- -- Name: index_favorites_66_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_66_on_post_id ON favorites_66 USING btree (post_id); +CREATE INDEX index_favorites_66_on_post_id ON public.favorites_66 USING btree (post_id); -- -- Name: index_favorites_66_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_66_on_user_id ON favorites_66 USING btree (user_id); +CREATE INDEX index_favorites_66_on_user_id ON public.favorites_66 USING btree (user_id); -- -- Name: index_favorites_67_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_67_on_post_id ON favorites_67 USING btree (post_id); +CREATE INDEX index_favorites_67_on_post_id ON public.favorites_67 USING btree (post_id); -- -- Name: index_favorites_67_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_67_on_user_id ON favorites_67 USING btree (user_id); +CREATE INDEX index_favorites_67_on_user_id ON public.favorites_67 USING btree (user_id); -- -- Name: index_favorites_68_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_68_on_post_id ON favorites_68 USING btree (post_id); +CREATE INDEX index_favorites_68_on_post_id ON public.favorites_68 USING btree (post_id); -- -- Name: index_favorites_68_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_68_on_user_id ON favorites_68 USING btree (user_id); +CREATE INDEX index_favorites_68_on_user_id ON public.favorites_68 USING btree (user_id); -- -- Name: index_favorites_69_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_69_on_post_id ON favorites_69 USING btree (post_id); +CREATE INDEX index_favorites_69_on_post_id ON public.favorites_69 USING btree (post_id); -- -- Name: index_favorites_69_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_69_on_user_id ON favorites_69 USING btree (user_id); +CREATE INDEX index_favorites_69_on_user_id ON public.favorites_69 USING btree (user_id); -- -- Name: index_favorites_6_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_6_on_post_id ON favorites_6 USING btree (post_id); +CREATE INDEX index_favorites_6_on_post_id ON public.favorites_6 USING btree (post_id); -- -- Name: index_favorites_6_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_6_on_user_id ON favorites_6 USING btree (user_id); +CREATE INDEX index_favorites_6_on_user_id ON public.favorites_6 USING btree (user_id); -- -- Name: index_favorites_70_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_70_on_post_id ON favorites_70 USING btree (post_id); +CREATE INDEX index_favorites_70_on_post_id ON public.favorites_70 USING btree (post_id); -- -- Name: index_favorites_70_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_70_on_user_id ON favorites_70 USING btree (user_id); +CREATE INDEX index_favorites_70_on_user_id ON public.favorites_70 USING btree (user_id); -- -- Name: index_favorites_71_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_71_on_post_id ON favorites_71 USING btree (post_id); +CREATE INDEX index_favorites_71_on_post_id ON public.favorites_71 USING btree (post_id); -- -- Name: index_favorites_71_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_71_on_user_id ON favorites_71 USING btree (user_id); +CREATE INDEX index_favorites_71_on_user_id ON public.favorites_71 USING btree (user_id); -- -- Name: index_favorites_72_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_72_on_post_id ON favorites_72 USING btree (post_id); +CREATE INDEX index_favorites_72_on_post_id ON public.favorites_72 USING btree (post_id); -- -- Name: index_favorites_72_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_72_on_user_id ON favorites_72 USING btree (user_id); +CREATE INDEX index_favorites_72_on_user_id ON public.favorites_72 USING btree (user_id); -- -- Name: index_favorites_73_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_73_on_post_id ON favorites_73 USING btree (post_id); +CREATE INDEX index_favorites_73_on_post_id ON public.favorites_73 USING btree (post_id); -- -- Name: index_favorites_73_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_73_on_user_id ON favorites_73 USING btree (user_id); +CREATE INDEX index_favorites_73_on_user_id ON public.favorites_73 USING btree (user_id); -- -- Name: index_favorites_74_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_74_on_post_id ON favorites_74 USING btree (post_id); +CREATE INDEX index_favorites_74_on_post_id ON public.favorites_74 USING btree (post_id); -- -- Name: index_favorites_74_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_74_on_user_id ON favorites_74 USING btree (user_id); +CREATE INDEX index_favorites_74_on_user_id ON public.favorites_74 USING btree (user_id); -- -- Name: index_favorites_75_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_75_on_post_id ON favorites_75 USING btree (post_id); +CREATE INDEX index_favorites_75_on_post_id ON public.favorites_75 USING btree (post_id); -- -- Name: index_favorites_75_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_75_on_user_id ON favorites_75 USING btree (user_id); +CREATE INDEX index_favorites_75_on_user_id ON public.favorites_75 USING btree (user_id); -- -- Name: index_favorites_76_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_76_on_post_id ON favorites_76 USING btree (post_id); +CREATE INDEX index_favorites_76_on_post_id ON public.favorites_76 USING btree (post_id); -- -- Name: index_favorites_76_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_76_on_user_id ON favorites_76 USING btree (user_id); +CREATE INDEX index_favorites_76_on_user_id ON public.favorites_76 USING btree (user_id); -- -- Name: index_favorites_77_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_77_on_post_id ON favorites_77 USING btree (post_id); +CREATE INDEX index_favorites_77_on_post_id ON public.favorites_77 USING btree (post_id); -- -- Name: index_favorites_77_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_77_on_user_id ON favorites_77 USING btree (user_id); +CREATE INDEX index_favorites_77_on_user_id ON public.favorites_77 USING btree (user_id); -- -- Name: index_favorites_78_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_78_on_post_id ON favorites_78 USING btree (post_id); +CREATE INDEX index_favorites_78_on_post_id ON public.favorites_78 USING btree (post_id); -- -- Name: index_favorites_78_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_78_on_user_id ON favorites_78 USING btree (user_id); +CREATE INDEX index_favorites_78_on_user_id ON public.favorites_78 USING btree (user_id); -- -- Name: index_favorites_79_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_79_on_post_id ON favorites_79 USING btree (post_id); +CREATE INDEX index_favorites_79_on_post_id ON public.favorites_79 USING btree (post_id); -- -- Name: index_favorites_79_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_79_on_user_id ON favorites_79 USING btree (user_id); +CREATE INDEX index_favorites_79_on_user_id ON public.favorites_79 USING btree (user_id); -- -- Name: index_favorites_7_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_7_on_post_id ON favorites_7 USING btree (post_id); +CREATE INDEX index_favorites_7_on_post_id ON public.favorites_7 USING btree (post_id); -- -- Name: index_favorites_7_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_7_on_user_id ON favorites_7 USING btree (user_id); +CREATE INDEX index_favorites_7_on_user_id ON public.favorites_7 USING btree (user_id); -- -- Name: index_favorites_80_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_80_on_post_id ON favorites_80 USING btree (post_id); +CREATE INDEX index_favorites_80_on_post_id ON public.favorites_80 USING btree (post_id); -- -- Name: index_favorites_80_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_80_on_user_id ON favorites_80 USING btree (user_id); +CREATE INDEX index_favorites_80_on_user_id ON public.favorites_80 USING btree (user_id); -- -- Name: index_favorites_81_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_81_on_post_id ON favorites_81 USING btree (post_id); +CREATE INDEX index_favorites_81_on_post_id ON public.favorites_81 USING btree (post_id); -- -- Name: index_favorites_81_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_81_on_user_id ON favorites_81 USING btree (user_id); +CREATE INDEX index_favorites_81_on_user_id ON public.favorites_81 USING btree (user_id); -- -- Name: index_favorites_82_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_82_on_post_id ON favorites_82 USING btree (post_id); +CREATE INDEX index_favorites_82_on_post_id ON public.favorites_82 USING btree (post_id); -- -- Name: index_favorites_82_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_82_on_user_id ON favorites_82 USING btree (user_id); +CREATE INDEX index_favorites_82_on_user_id ON public.favorites_82 USING btree (user_id); -- -- Name: index_favorites_83_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_83_on_post_id ON favorites_83 USING btree (post_id); +CREATE INDEX index_favorites_83_on_post_id ON public.favorites_83 USING btree (post_id); -- -- Name: index_favorites_83_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_83_on_user_id ON favorites_83 USING btree (user_id); +CREATE INDEX index_favorites_83_on_user_id ON public.favorites_83 USING btree (user_id); -- -- Name: index_favorites_84_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_84_on_post_id ON favorites_84 USING btree (post_id); +CREATE INDEX index_favorites_84_on_post_id ON public.favorites_84 USING btree (post_id); -- -- Name: index_favorites_84_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_84_on_user_id ON favorites_84 USING btree (user_id); +CREATE INDEX index_favorites_84_on_user_id ON public.favorites_84 USING btree (user_id); -- -- Name: index_favorites_85_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_85_on_post_id ON favorites_85 USING btree (post_id); +CREATE INDEX index_favorites_85_on_post_id ON public.favorites_85 USING btree (post_id); -- -- Name: index_favorites_85_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_85_on_user_id ON favorites_85 USING btree (user_id); +CREATE INDEX index_favorites_85_on_user_id ON public.favorites_85 USING btree (user_id); -- -- Name: index_favorites_86_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_86_on_post_id ON favorites_86 USING btree (post_id); +CREATE INDEX index_favorites_86_on_post_id ON public.favorites_86 USING btree (post_id); -- -- Name: index_favorites_86_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_86_on_user_id ON favorites_86 USING btree (user_id); +CREATE INDEX index_favorites_86_on_user_id ON public.favorites_86 USING btree (user_id); -- -- Name: index_favorites_87_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_87_on_post_id ON favorites_87 USING btree (post_id); +CREATE INDEX index_favorites_87_on_post_id ON public.favorites_87 USING btree (post_id); -- -- Name: index_favorites_87_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_87_on_user_id ON favorites_87 USING btree (user_id); +CREATE INDEX index_favorites_87_on_user_id ON public.favorites_87 USING btree (user_id); -- -- Name: index_favorites_88_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_88_on_post_id ON favorites_88 USING btree (post_id); +CREATE INDEX index_favorites_88_on_post_id ON public.favorites_88 USING btree (post_id); -- -- Name: index_favorites_88_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_88_on_user_id ON favorites_88 USING btree (user_id); +CREATE INDEX index_favorites_88_on_user_id ON public.favorites_88 USING btree (user_id); -- -- Name: index_favorites_89_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_89_on_post_id ON favorites_89 USING btree (post_id); +CREATE INDEX index_favorites_89_on_post_id ON public.favorites_89 USING btree (post_id); -- -- Name: index_favorites_89_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_89_on_user_id ON favorites_89 USING btree (user_id); +CREATE INDEX index_favorites_89_on_user_id ON public.favorites_89 USING btree (user_id); -- -- Name: index_favorites_8_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_8_on_post_id ON favorites_8 USING btree (post_id); +CREATE INDEX index_favorites_8_on_post_id ON public.favorites_8 USING btree (post_id); -- -- Name: index_favorites_8_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_8_on_user_id ON favorites_8 USING btree (user_id); +CREATE INDEX index_favorites_8_on_user_id ON public.favorites_8 USING btree (user_id); -- -- Name: index_favorites_90_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_90_on_post_id ON favorites_90 USING btree (post_id); +CREATE INDEX index_favorites_90_on_post_id ON public.favorites_90 USING btree (post_id); -- -- Name: index_favorites_90_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_90_on_user_id ON favorites_90 USING btree (user_id); +CREATE INDEX index_favorites_90_on_user_id ON public.favorites_90 USING btree (user_id); -- -- Name: index_favorites_91_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_91_on_post_id ON favorites_91 USING btree (post_id); +CREATE INDEX index_favorites_91_on_post_id ON public.favorites_91 USING btree (post_id); -- -- Name: index_favorites_91_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_91_on_user_id ON favorites_91 USING btree (user_id); +CREATE INDEX index_favorites_91_on_user_id ON public.favorites_91 USING btree (user_id); -- -- Name: index_favorites_92_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_92_on_post_id ON favorites_92 USING btree (post_id); +CREATE INDEX index_favorites_92_on_post_id ON public.favorites_92 USING btree (post_id); -- -- Name: index_favorites_92_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_92_on_user_id ON favorites_92 USING btree (user_id); +CREATE INDEX index_favorites_92_on_user_id ON public.favorites_92 USING btree (user_id); -- -- Name: index_favorites_93_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_93_on_post_id ON favorites_93 USING btree (post_id); +CREATE INDEX index_favorites_93_on_post_id ON public.favorites_93 USING btree (post_id); -- -- Name: index_favorites_93_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_93_on_user_id ON favorites_93 USING btree (user_id); +CREATE INDEX index_favorites_93_on_user_id ON public.favorites_93 USING btree (user_id); -- -- Name: index_favorites_94_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_94_on_post_id ON favorites_94 USING btree (post_id); +CREATE INDEX index_favorites_94_on_post_id ON public.favorites_94 USING btree (post_id); -- -- Name: index_favorites_94_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_94_on_user_id ON favorites_94 USING btree (user_id); +CREATE INDEX index_favorites_94_on_user_id ON public.favorites_94 USING btree (user_id); -- -- Name: index_favorites_95_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_95_on_post_id ON favorites_95 USING btree (post_id); +CREATE INDEX index_favorites_95_on_post_id ON public.favorites_95 USING btree (post_id); -- -- Name: index_favorites_95_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_95_on_user_id ON favorites_95 USING btree (user_id); +CREATE INDEX index_favorites_95_on_user_id ON public.favorites_95 USING btree (user_id); -- -- Name: index_favorites_96_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_96_on_post_id ON favorites_96 USING btree (post_id); +CREATE INDEX index_favorites_96_on_post_id ON public.favorites_96 USING btree (post_id); -- -- Name: index_favorites_96_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_96_on_user_id ON favorites_96 USING btree (user_id); +CREATE INDEX index_favorites_96_on_user_id ON public.favorites_96 USING btree (user_id); -- -- Name: index_favorites_97_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_97_on_post_id ON favorites_97 USING btree (post_id); +CREATE INDEX index_favorites_97_on_post_id ON public.favorites_97 USING btree (post_id); -- -- Name: index_favorites_97_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_97_on_user_id ON favorites_97 USING btree (user_id); +CREATE INDEX index_favorites_97_on_user_id ON public.favorites_97 USING btree (user_id); -- -- Name: index_favorites_98_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_98_on_post_id ON favorites_98 USING btree (post_id); +CREATE INDEX index_favorites_98_on_post_id ON public.favorites_98 USING btree (post_id); -- -- Name: index_favorites_98_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_98_on_user_id ON favorites_98 USING btree (user_id); +CREATE INDEX index_favorites_98_on_user_id ON public.favorites_98 USING btree (user_id); -- -- Name: index_favorites_99_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_99_on_post_id ON favorites_99 USING btree (post_id); +CREATE INDEX index_favorites_99_on_post_id ON public.favorites_99 USING btree (post_id); -- -- Name: index_favorites_99_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_99_on_user_id ON favorites_99 USING btree (user_id); +CREATE INDEX index_favorites_99_on_user_id ON public.favorites_99 USING btree (user_id); -- -- Name: index_favorites_9_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_9_on_post_id ON favorites_9 USING btree (post_id); +CREATE INDEX index_favorites_9_on_post_id ON public.favorites_9 USING btree (post_id); -- -- Name: index_favorites_9_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_favorites_9_on_user_id ON favorites_9 USING btree (user_id); +CREATE INDEX index_favorites_9_on_user_id ON public.favorites_9 USING btree (user_id); -- -- Name: index_forum_posts_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_posts_on_creator_id ON forum_posts USING btree (creator_id); +CREATE INDEX index_forum_posts_on_creator_id ON public.forum_posts USING btree (creator_id); -- -- Name: index_forum_posts_on_text_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_posts_on_text_index ON forum_posts USING gin (text_index); +CREATE INDEX index_forum_posts_on_text_index ON public.forum_posts USING gin (text_index); -- -- Name: index_forum_posts_on_topic_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_posts_on_topic_id ON forum_posts USING btree (topic_id); +CREATE INDEX index_forum_posts_on_topic_id ON public.forum_posts USING btree (topic_id); -- -- Name: index_forum_subscriptions_on_forum_topic_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_subscriptions_on_forum_topic_id ON forum_subscriptions USING btree (forum_topic_id); +CREATE INDEX index_forum_subscriptions_on_forum_topic_id ON public.forum_subscriptions USING btree (forum_topic_id); -- -- Name: index_forum_subscriptions_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_subscriptions_on_user_id ON forum_subscriptions USING btree (user_id); +CREATE INDEX index_forum_subscriptions_on_user_id ON public.forum_subscriptions USING btree (user_id); -- -- Name: index_forum_topic_visits_on_forum_topic_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topic_visits_on_forum_topic_id ON forum_topic_visits USING btree (forum_topic_id); +CREATE INDEX index_forum_topic_visits_on_forum_topic_id ON public.forum_topic_visits USING btree (forum_topic_id); -- -- Name: index_forum_topic_visits_on_last_read_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topic_visits_on_last_read_at ON forum_topic_visits USING btree (last_read_at); +CREATE INDEX index_forum_topic_visits_on_last_read_at ON public.forum_topic_visits USING btree (last_read_at); -- -- Name: index_forum_topic_visits_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topic_visits_on_user_id ON forum_topic_visits USING btree (user_id); +CREATE INDEX index_forum_topic_visits_on_user_id ON public.forum_topic_visits USING btree (user_id); -- -- Name: index_forum_topics_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topics_on_creator_id ON forum_topics USING btree (creator_id); +CREATE INDEX index_forum_topics_on_creator_id ON public.forum_topics USING btree (creator_id); -- -- Name: index_forum_topics_on_is_sticky_and_updated_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topics_on_is_sticky_and_updated_at ON forum_topics USING btree (is_sticky, updated_at); +CREATE INDEX index_forum_topics_on_is_sticky_and_updated_at ON public.forum_topics USING btree (is_sticky, updated_at); -- -- Name: index_forum_topics_on_text_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topics_on_text_index ON forum_topics USING gin (text_index); +CREATE INDEX index_forum_topics_on_text_index ON public.forum_topics USING gin (text_index); -- -- Name: index_forum_topics_on_updated_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_forum_topics_on_updated_at ON forum_topics USING btree (updated_at); +CREATE INDEX index_forum_topics_on_updated_at ON public.forum_topics USING btree (updated_at); -- -- Name: index_ip_bans_on_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_ip_bans_on_ip_addr ON ip_bans USING btree (ip_addr); +CREATE UNIQUE INDEX index_ip_bans_on_ip_addr ON public.ip_bans USING btree (ip_addr); -- -- Name: index_janitor_trials_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_janitor_trials_on_user_id ON janitor_trials USING btree (user_id); +CREATE INDEX index_janitor_trials_on_user_id ON public.janitor_trials USING btree (user_id); -- -- Name: index_news_updates_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_news_updates_on_created_at ON news_updates USING btree (created_at); +CREATE INDEX index_news_updates_on_created_at ON public.news_updates USING btree (created_at); -- -- Name: index_note_versions_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_note_versions_on_created_at ON note_versions USING btree (created_at); +CREATE INDEX index_note_versions_on_created_at ON public.note_versions USING btree (created_at); -- -- Name: index_note_versions_on_note_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_note_versions_on_note_id ON note_versions USING btree (note_id); +CREATE INDEX index_note_versions_on_note_id ON public.note_versions USING btree (note_id); -- -- Name: index_note_versions_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_note_versions_on_post_id ON note_versions USING btree (post_id); +CREATE INDEX index_note_versions_on_post_id ON public.note_versions USING btree (post_id); -- -- Name: index_note_versions_on_updater_id_and_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_note_versions_on_updater_id_and_post_id ON note_versions USING btree (updater_id, post_id); +CREATE INDEX index_note_versions_on_updater_id_and_post_id ON public.note_versions USING btree (updater_id, post_id); -- -- Name: index_note_versions_on_updater_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_note_versions_on_updater_ip_addr ON note_versions USING btree (updater_ip_addr); +CREATE INDEX index_note_versions_on_updater_ip_addr ON public.note_versions USING btree (updater_ip_addr); -- -- Name: index_notes_on_body_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_notes_on_body_index ON notes USING gin (body_index); +CREATE INDEX index_notes_on_body_index ON public.notes USING gin (body_index); -- -- Name: index_notes_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_notes_on_creator_id_and_post_id ON notes USING btree (creator_id, post_id); +CREATE INDEX index_notes_on_creator_id_and_post_id ON public.notes USING btree (creator_id, post_id); -- -- Name: index_notes_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_notes_on_post_id ON notes USING btree (post_id); +CREATE INDEX index_notes_on_post_id ON public.notes USING btree (post_id); -- -- Name: index_pixiv_ugoira_frame_data_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_pixiv_ugoira_frame_data_on_post_id ON pixiv_ugoira_frame_data USING btree (post_id); +CREATE UNIQUE INDEX index_pixiv_ugoira_frame_data_on_post_id ON public.pixiv_ugoira_frame_data USING btree (post_id); -- -- Name: index_pools_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pools_on_creator_id ON pools USING btree (creator_id); +CREATE INDEX index_pools_on_creator_id ON public.pools USING btree (creator_id); -- -- Name: index_pools_on_lower_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pools_on_lower_name ON pools USING btree (lower((name)::text)); +CREATE INDEX index_pools_on_lower_name ON public.pools USING btree (lower((name)::text)); -- -- Name: index_pools_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pools_on_name ON pools USING btree (name); +CREATE INDEX index_pools_on_name ON public.pools USING btree (name); -- -- Name: index_pools_on_name_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pools_on_name_trgm ON pools USING gin (lower((name)::text) gin_trgm_ops); +CREATE INDEX index_pools_on_name_trgm ON public.pools USING gin (lower((name)::text) public.gin_trgm_ops); -- -- Name: index_pools_on_updated_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_pools_on_updated_at ON pools USING btree (updated_at); +CREATE INDEX index_pools_on_updated_at ON public.pools USING btree (updated_at); -- -- Name: index_post_appeals_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_appeals_on_created_at ON post_appeals USING btree (created_at); +CREATE INDEX index_post_appeals_on_created_at ON public.post_appeals USING btree (created_at); -- -- Name: index_post_appeals_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_appeals_on_creator_id ON post_appeals USING btree (creator_id); +CREATE INDEX index_post_appeals_on_creator_id ON public.post_appeals USING btree (creator_id); -- -- Name: index_post_appeals_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_appeals_on_creator_ip_addr ON post_appeals USING btree (creator_ip_addr); +CREATE INDEX index_post_appeals_on_creator_ip_addr ON public.post_appeals USING btree (creator_ip_addr); -- -- Name: index_post_appeals_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_appeals_on_post_id ON post_appeals USING btree (post_id); +CREATE INDEX index_post_appeals_on_post_id ON public.post_appeals USING btree (post_id); -- -- Name: index_post_appeals_on_reason_tsvector; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_appeals_on_reason_tsvector ON post_appeals USING gin (to_tsvector('english'::regconfig, reason)); +CREATE INDEX index_post_appeals_on_reason_tsvector ON public.post_appeals USING gin (to_tsvector('english'::regconfig, reason)); -- -- Name: index_post_approvals_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_approvals_on_post_id ON post_approvals USING btree (post_id); +CREATE INDEX index_post_approvals_on_post_id ON public.post_approvals USING btree (post_id); -- -- Name: index_post_approvals_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_approvals_on_user_id ON post_approvals USING btree (user_id); +CREATE INDEX index_post_approvals_on_user_id ON public.post_approvals USING btree (user_id); -- -- Name: index_post_disapprovals_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_disapprovals_on_post_id ON post_disapprovals USING btree (post_id); +CREATE INDEX index_post_disapprovals_on_post_id ON public.post_disapprovals USING btree (post_id); -- -- Name: index_post_disapprovals_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_disapprovals_on_user_id ON post_disapprovals USING btree (user_id); +CREATE INDEX index_post_disapprovals_on_user_id ON public.post_disapprovals USING btree (user_id); -- -- Name: index_post_flags_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_flags_on_creator_id ON post_flags USING btree (creator_id); +CREATE INDEX index_post_flags_on_creator_id ON public.post_flags USING btree (creator_id); -- -- Name: index_post_flags_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_flags_on_creator_ip_addr ON post_flags USING btree (creator_ip_addr); +CREATE INDEX index_post_flags_on_creator_ip_addr ON public.post_flags USING btree (creator_ip_addr); -- -- Name: index_post_flags_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_flags_on_post_id ON post_flags USING btree (post_id); +CREATE INDEX index_post_flags_on_post_id ON public.post_flags USING btree (post_id); -- -- Name: index_post_flags_on_reason_tsvector; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_flags_on_reason_tsvector ON post_flags USING gin (to_tsvector('english'::regconfig, reason)); +CREATE INDEX index_post_flags_on_reason_tsvector ON public.post_flags USING gin (to_tsvector('english'::regconfig, reason)); -- -- Name: index_post_replacements_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_replacements_on_creator_id ON post_replacements USING btree (creator_id); +CREATE INDEX index_post_replacements_on_creator_id ON public.post_replacements USING btree (creator_id); -- -- Name: index_post_replacements_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_replacements_on_post_id ON post_replacements USING btree (post_id); +CREATE INDEX index_post_replacements_on_post_id ON public.post_replacements USING btree (post_id); -- -- Name: index_post_votes_on_post_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_votes_on_post_id ON post_votes USING btree (post_id); +CREATE INDEX index_post_votes_on_post_id ON public.post_votes USING btree (post_id); -- -- Name: index_post_votes_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_post_votes_on_user_id ON post_votes USING btree (user_id); +CREATE INDEX index_post_votes_on_user_id ON public.post_votes USING btree (user_id); -- -- Name: index_posts_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_created_at ON posts USING btree (created_at); +CREATE INDEX index_posts_on_created_at ON public.posts USING btree (created_at); -- -- Name: index_posts_on_file_size; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_file_size ON posts USING btree (file_size); +CREATE INDEX index_posts_on_file_size ON public.posts USING btree (file_size); -- -- Name: index_posts_on_image_height; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_image_height ON posts USING btree (image_height); +CREATE INDEX index_posts_on_image_height ON public.posts USING btree (image_height); -- -- Name: index_posts_on_image_width; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_image_width ON posts USING btree (image_width); +CREATE INDEX index_posts_on_image_width ON public.posts USING btree (image_width); -- -- Name: index_posts_on_is_flagged; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_is_flagged ON posts USING btree (is_flagged) WHERE (is_flagged = true); +CREATE INDEX index_posts_on_is_flagged ON public.posts USING btree (is_flagged) WHERE (is_flagged = true); -- -- Name: index_posts_on_is_pending; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_is_pending ON posts USING btree (is_pending) WHERE (is_pending = true); +CREATE INDEX index_posts_on_is_pending ON public.posts USING btree (is_pending) WHERE (is_pending = true); -- -- Name: index_posts_on_last_comment_bumped_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_last_comment_bumped_at ON posts USING btree (last_comment_bumped_at DESC NULLS LAST); +CREATE INDEX index_posts_on_last_comment_bumped_at ON public.posts USING btree (last_comment_bumped_at DESC NULLS LAST); -- -- Name: index_posts_on_last_noted_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_last_noted_at ON posts USING btree (last_noted_at DESC NULLS LAST); +CREATE INDEX index_posts_on_last_noted_at ON public.posts USING btree (last_noted_at DESC NULLS LAST); -- -- Name: index_posts_on_md5; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_posts_on_md5 ON posts USING btree (md5); +CREATE UNIQUE INDEX index_posts_on_md5 ON public.posts USING btree (md5); -- -- Name: index_posts_on_mpixels; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_mpixels ON posts USING btree (((((image_width * image_height))::numeric / 1000000.0))); +CREATE INDEX index_posts_on_mpixels ON public.posts USING btree (((((image_width * image_height))::numeric / 1000000.0))); -- -- Name: index_posts_on_parent_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_parent_id ON posts USING btree (parent_id); +CREATE INDEX index_posts_on_parent_id ON public.posts USING btree (parent_id); -- -- Name: index_posts_on_pixiv_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_pixiv_id ON posts USING btree (pixiv_id) WHERE (pixiv_id IS NOT NULL); +CREATE INDEX index_posts_on_pixiv_id ON public.posts USING btree (pixiv_id) WHERE (pixiv_id IS NOT NULL); -- -- Name: index_posts_on_source_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_source_pattern ON posts USING btree (sourcepattern(lower((source)::text)) text_pattern_ops); +CREATE INDEX index_posts_on_source_pattern ON public.posts USING btree (public.sourcepattern(lower((source)::text)) text_pattern_ops); -- -- Name: index_posts_on_tags_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_tags_index ON posts USING gin (tag_index); +CREATE INDEX index_posts_on_tags_index ON public.posts USING gin (tag_index); -- -- Name: index_posts_on_uploader_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_posts_on_uploader_id ON posts USING btree (uploader_id); +CREATE INDEX index_posts_on_uploader_id ON public.posts USING btree (uploader_id); -- -- Name: index_saved_searches_on_labels; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_saved_searches_on_labels ON saved_searches USING gin (labels); +CREATE INDEX index_saved_searches_on_labels ON public.saved_searches USING gin (labels); -- -- Name: index_saved_searches_on_query; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_saved_searches_on_query ON saved_searches USING btree (query); +CREATE INDEX index_saved_searches_on_query ON public.saved_searches USING btree (query); -- -- Name: index_saved_searches_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_saved_searches_on_user_id ON saved_searches USING btree (user_id); +CREATE INDEX index_saved_searches_on_user_id ON public.saved_searches USING btree (user_id); -- -- Name: index_tag_aliases_on_antecedent_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_aliases_on_antecedent_name ON tag_aliases USING btree (antecedent_name); +CREATE INDEX index_tag_aliases_on_antecedent_name ON public.tag_aliases USING btree (antecedent_name); -- -- Name: index_tag_aliases_on_antecedent_name_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_aliases_on_antecedent_name_pattern ON tag_aliases USING btree (antecedent_name text_pattern_ops); +CREATE INDEX index_tag_aliases_on_antecedent_name_pattern ON public.tag_aliases USING btree (antecedent_name text_pattern_ops); -- -- Name: index_tag_aliases_on_consequent_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_aliases_on_consequent_name ON tag_aliases USING btree (consequent_name); +CREATE INDEX index_tag_aliases_on_consequent_name ON public.tag_aliases USING btree (consequent_name); -- -- Name: index_tag_aliases_on_post_count; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_aliases_on_post_count ON tag_aliases USING btree (post_count); +CREATE INDEX index_tag_aliases_on_post_count ON public.tag_aliases USING btree (post_count); -- -- Name: index_tag_implications_on_antecedent_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_implications_on_antecedent_name ON tag_implications USING btree (antecedent_name); +CREATE INDEX index_tag_implications_on_antecedent_name ON public.tag_implications USING btree (antecedent_name); -- -- Name: index_tag_implications_on_consequent_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_implications_on_consequent_name ON tag_implications USING btree (consequent_name); +CREATE INDEX index_tag_implications_on_consequent_name ON public.tag_implications USING btree (consequent_name); -- -- Name: index_tag_subscriptions_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_subscriptions_on_creator_id ON tag_subscriptions USING btree (creator_id); +CREATE INDEX index_tag_subscriptions_on_creator_id ON public.tag_subscriptions USING btree (creator_id); -- -- Name: index_tag_subscriptions_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tag_subscriptions_on_name ON tag_subscriptions USING btree (name); +CREATE INDEX index_tag_subscriptions_on_name ON public.tag_subscriptions USING btree (name); -- -- Name: index_tags_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_tags_on_name ON tags USING btree (name); +CREATE UNIQUE INDEX index_tags_on_name ON public.tags USING btree (name); -- -- Name: index_tags_on_name_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tags_on_name_pattern ON tags USING btree (name text_pattern_ops); +CREATE INDEX index_tags_on_name_pattern ON public.tags USING btree (name text_pattern_ops); -- -- Name: index_tags_on_name_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_tags_on_name_trgm ON tags USING gin (name gin_trgm_ops); +CREATE INDEX index_tags_on_name_trgm ON public.tags USING gin (name public.gin_trgm_ops); -- -- Name: index_token_buckets_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_token_buckets_on_user_id ON token_buckets USING btree (user_id); +CREATE UNIQUE INDEX index_token_buckets_on_user_id ON public.token_buckets USING btree (user_id); -- -- Name: index_uploads_on_uploader_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_uploads_on_uploader_id ON uploads USING btree (uploader_id); +CREATE INDEX index_uploads_on_uploader_id ON public.uploads USING btree (uploader_id); -- -- Name: index_uploads_on_uploader_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_uploads_on_uploader_ip_addr ON uploads USING btree (uploader_ip_addr); +CREATE INDEX index_uploads_on_uploader_ip_addr ON public.uploads USING btree (uploader_ip_addr); -- -- Name: index_user_feedback_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_user_feedback_on_created_at ON user_feedback USING btree (created_at); +CREATE INDEX index_user_feedback_on_created_at ON public.user_feedback USING btree (created_at); -- -- Name: index_user_feedback_on_creator_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_user_feedback_on_creator_id ON user_feedback USING btree (creator_id); +CREATE INDEX index_user_feedback_on_creator_id ON public.user_feedback USING btree (creator_id); -- -- Name: index_user_feedback_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_user_feedback_on_user_id ON user_feedback USING btree (user_id); +CREATE INDEX index_user_feedback_on_user_id ON public.user_feedback USING btree (user_id); -- -- Name: index_user_name_change_requests_on_original_name; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_user_name_change_requests_on_original_name ON user_name_change_requests USING btree (original_name); +CREATE INDEX index_user_name_change_requests_on_original_name ON public.user_name_change_requests USING btree (original_name); -- -- Name: index_user_name_change_requests_on_user_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_user_name_change_requests_on_user_id ON user_name_change_requests USING btree (user_id); +CREATE INDEX index_user_name_change_requests_on_user_id ON public.user_name_change_requests USING btree (user_id); -- -- Name: index_users_on_email; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_users_on_email ON users USING btree (email); +CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email); -- -- Name: index_users_on_last_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_users_on_last_ip_addr ON users USING btree (last_ip_addr) WHERE (last_ip_addr IS NOT NULL); +CREATE INDEX index_users_on_last_ip_addr ON public.users USING btree (last_ip_addr) WHERE (last_ip_addr IS NOT NULL); -- -- Name: index_users_on_name; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_users_on_name ON users USING btree (lower((name)::text)); +CREATE UNIQUE INDEX index_users_on_name ON public.users USING btree (lower((name)::text)); -- -- Name: index_users_on_name_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_users_on_name_trgm ON users USING gin (lower((name)::text) gin_trgm_ops); +CREATE INDEX index_users_on_name_trgm ON public.users USING gin (lower((name)::text) public.gin_trgm_ops); -- -- Name: index_wiki_page_versions_on_created_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_page_versions_on_created_at ON wiki_page_versions USING btree (created_at); +CREATE INDEX index_wiki_page_versions_on_created_at ON public.wiki_page_versions USING btree (created_at); -- -- Name: index_wiki_page_versions_on_updater_ip_addr; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_page_versions_on_updater_ip_addr ON wiki_page_versions USING btree (updater_ip_addr); +CREATE INDEX index_wiki_page_versions_on_updater_ip_addr ON public.wiki_page_versions USING btree (updater_ip_addr); -- -- Name: index_wiki_page_versions_on_wiki_page_id; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_page_versions_on_wiki_page_id ON wiki_page_versions USING btree (wiki_page_id); +CREATE INDEX index_wiki_page_versions_on_wiki_page_id ON public.wiki_page_versions USING btree (wiki_page_id); -- -- Name: index_wiki_pages_on_body_index_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_pages_on_body_index_index ON wiki_pages USING gin (body_index); +CREATE INDEX index_wiki_pages_on_body_index_index ON public.wiki_pages USING gin (body_index); -- -- Name: index_wiki_pages_on_other_names_index; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_pages_on_other_names_index ON wiki_pages USING gin (other_names_index); +CREATE INDEX index_wiki_pages_on_other_names_index ON public.wiki_pages USING gin (other_names_index); -- -- Name: index_wiki_pages_on_title; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX index_wiki_pages_on_title ON wiki_pages USING btree (title); +CREATE UNIQUE INDEX index_wiki_pages_on_title ON public.wiki_pages USING btree (title); -- -- Name: index_wiki_pages_on_title_pattern; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_pages_on_title_pattern ON wiki_pages USING btree (title text_pattern_ops); +CREATE INDEX index_wiki_pages_on_title_pattern ON public.wiki_pages USING btree (title text_pattern_ops); -- -- Name: index_wiki_pages_on_updated_at; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_wiki_pages_on_updated_at ON wiki_pages USING btree (updated_at); +CREATE INDEX index_wiki_pages_on_updated_at ON public.wiki_pages USING btree (updated_at); -- -- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: - -- -CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); +CREATE UNIQUE INDEX unique_schema_migrations ON public.schema_migrations USING btree (version); -- -- Name: favorites insert_favorites_trigger; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER insert_favorites_trigger BEFORE INSERT ON favorites FOR EACH ROW EXECUTE PROCEDURE favorites_insert_trigger(); +CREATE TRIGGER insert_favorites_trigger BEFORE INSERT ON public.favorites FOR EACH ROW EXECUTE PROCEDURE public.favorites_insert_trigger(); -- -- Name: artists trigger_artists_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names'); +CREATE TRIGGER trigger_artists_on_update BEFORE INSERT OR UPDATE ON public.artists FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names'); -- -- Name: comments trigger_comments_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_comments_on_update BEFORE INSERT OR UPDATE ON comments FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); +CREATE TRIGGER trigger_comments_on_update BEFORE INSERT OR UPDATE ON public.comments FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); -- -- Name: dmails trigger_dmails_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_dmails_on_update BEFORE INSERT OR UPDATE ON dmails FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('message_index', 'pg_catalog.english', 'title', 'body'); +CREATE TRIGGER trigger_dmails_on_update BEFORE INSERT OR UPDATE ON public.dmails FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('message_index', 'pg_catalog.english', 'title', 'body'); -- -- Name: forum_posts trigger_forum_posts_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_forum_posts_on_update BEFORE INSERT OR UPDATE ON forum_posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'body'); +CREATE TRIGGER trigger_forum_posts_on_update BEFORE INSERT OR UPDATE ON public.forum_posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'body'); -- -- Name: forum_topics trigger_forum_topics_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_forum_topics_on_update BEFORE INSERT OR UPDATE ON forum_topics FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'title'); +CREATE TRIGGER trigger_forum_topics_on_update BEFORE INSERT OR UPDATE ON public.forum_topics FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('text_index', 'pg_catalog.english', 'title'); -- -- Name: notes trigger_notes_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON notes FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); +CREATE TRIGGER trigger_notes_on_update BEFORE INSERT OR UPDATE ON public.notes FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'pg_catalog.english', 'body'); -- -- Name: posts trigger_posts_on_tag_index_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string'); +CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON public.posts FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('tag_index', 'public.danbooru', 'tag_string', 'fav_string', 'pool_string'); -- -- Name: wiki_pages trigger_wiki_pages_on_update; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title'); +CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title'); -- -- Name: wiki_pages trigger_wiki_pages_on_update_for_other_names; Type: TRIGGER; Schema: public; Owner: - -- -CREATE TRIGGER trigger_wiki_pages_on_update_for_other_names BEFORE INSERT OR UPDATE ON wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names'); +CREATE TRIGGER trigger_wiki_pages_on_update_for_other_names BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('other_names_index', 'public.danbooru', 'other_names'); -- @@ -7264,305 +7276,158 @@ CREATE TRIGGER trigger_wiki_pages_on_update_for_other_names BEFORE INSERT OR UPD SET search_path TO "$user", public; -INSERT INTO schema_migrations (version) VALUES ('20100204211522'); +INSERT INTO "schema_migrations" (version) VALUES +('20100204211522'), +('20100204214746'), +('20100205162521'), +('20100205163027'), +('20100205224030'), +('20100211025616'), +('20100211181944'), +('20100211191709'), +('20100211191716'), +('20100213181847'), +('20100213183712'), +('20100214080549'), +('20100214080557'), +('20100214080605'), +('20100215182234'), +('20100215213756'), +('20100215223541'), +('20100215224629'), +('20100215224635'), +('20100215225710'), +('20100215230642'), +('20100219230537'), +('20100221003655'), +('20100221005812'), +('20100223001012'), +('20100224171915'), +('20100224172146'), +('20100307073438'), +('20100309211553'), +('20100318213503'), +('20100826232512'), +('20110328215652'), +('20110328215701'), +('20110607194023'), +('20110717010705'), +('20110722211855'), +('20110815233456'), +('20111101212358'), +('20130106210658'), +('20130114154400'), +('20130219171111'), +('20130219184743'), +('20130221032344'), +('20130221035518'), +('20130221214811'), +('20130302214500'), +('20130305005138'), +('20130307225324'), +('20130308204213'), +('20130318002652'), +('20130318012517'), +('20130318030619'), +('20130318231740'), +('20130320070700'), +('20130322162059'), +('20130322173202'), +('20130322173859'), +('20130323160259'), +('20130326035904'), +('20130328092739'), +('20130331180246'), +('20130331182719'), +('20130401013601'), +('20130409191950'), +('20130417221643'), +('20130424121410'), +('20130506154136'), +('20130606224559'), +('20130618230158'), +('20130620215658'), +('20130712162600'), +('20130914175431'), +('20131006193238'), +('20131117150705'), +('20131118153503'), +('20131130190411'), +('20131209181023'), +('20131217025233'), +('20131225002748'), +('20140111191413'), +('20140204233337'), +('20140221213349'), +('20140428015134'), +('20140505000956'), +('20140603225334'), +('20140604002414'), +('20140613004559'), +('20140701224800'), +('20140722225753'), +('20140725003232'), +('20141009231234'), +('20141017231608'), +('20141120045943'), +('20150119191042'), +('20150120005624'), +('20150128005954'), +('20150403224949'), +('20150613010904'), +('20150623191904'), +('20150629235905'), +('20150705014135'), +('20150721214646'), +('20150728170433'), +('20150805010245'), +('20151217213321'), +('20160219004022'), +('20160219010854'), +('20160219172840'), +('20160222211328'), +('20160526174848'), +('20160820003534'), +('20160822230752'), +('20160919234407'), +('20161018221128'), +('20161024220345'), +('20161101003139'), +('20161221225849'), +('20161227003428'), +('20161229001201'), +('20170106012138'), +('20170112021922'), +('20170112060921'), +('20170117233040'), +('20170218104710'), +('20170302014435'), +('20170314235626'), +('20170316224630'), +('20170319000519'), +('20170329185605'), +('20170330230231'), +('20170413000209'), +('20170414005856'), +('20170414233426'), +('20170414233617'), +('20170416224142'), +('20170428220448'), +('20170512221200'), +('20170515235205'), +('20170519204506'), +('20170526183928'), +('20170608043651'), +('20170613200356'), +('20170709190409'), +('20170914200122'), +('20171106075030'), +('20171127195124'), +('20171218213037'), +('20171219001521'), +('20171230220225'), +('20180113211343'), +('20180116001101'), +('20180403231351'); -INSERT INTO schema_migrations (version) VALUES ('20100204214746'); - -INSERT INTO schema_migrations (version) VALUES ('20100205162521'); - -INSERT INTO schema_migrations (version) VALUES ('20100205163027'); - -INSERT INTO schema_migrations (version) VALUES ('20100205224030'); - -INSERT INTO schema_migrations (version) VALUES ('20100211025616'); - -INSERT INTO schema_migrations (version) VALUES ('20100211181944'); - -INSERT INTO schema_migrations (version) VALUES ('20100211191709'); - -INSERT INTO schema_migrations (version) VALUES ('20100211191716'); - -INSERT INTO schema_migrations (version) VALUES ('20100213181847'); - -INSERT INTO schema_migrations (version) VALUES ('20100213183712'); - -INSERT INTO schema_migrations (version) VALUES ('20100214080549'); - -INSERT INTO schema_migrations (version) VALUES ('20100214080557'); - -INSERT INTO schema_migrations (version) VALUES ('20100214080605'); - -INSERT INTO schema_migrations (version) VALUES ('20100215182234'); - -INSERT INTO schema_migrations (version) VALUES ('20100215213756'); - -INSERT INTO schema_migrations (version) VALUES ('20100215223541'); - -INSERT INTO schema_migrations (version) VALUES ('20100215224629'); - -INSERT INTO schema_migrations (version) VALUES ('20100215224635'); - -INSERT INTO schema_migrations (version) VALUES ('20100215225710'); - -INSERT INTO schema_migrations (version) VALUES ('20100215230642'); - -INSERT INTO schema_migrations (version) VALUES ('20100219230537'); - -INSERT INTO schema_migrations (version) VALUES ('20100221003655'); - -INSERT INTO schema_migrations (version) VALUES ('20100221005812'); - -INSERT INTO schema_migrations (version) VALUES ('20100223001012'); - -INSERT INTO schema_migrations (version) VALUES ('20100224171915'); - -INSERT INTO schema_migrations (version) VALUES ('20100224172146'); - -INSERT INTO schema_migrations (version) VALUES ('20100307073438'); - -INSERT INTO schema_migrations (version) VALUES ('20100309211553'); - -INSERT INTO schema_migrations (version) VALUES ('20100318213503'); - -INSERT INTO schema_migrations (version) VALUES ('20100826232512'); - -INSERT INTO schema_migrations (version) VALUES ('20110328215652'); - -INSERT INTO schema_migrations (version) VALUES ('20110328215701'); - -INSERT INTO schema_migrations (version) VALUES ('20110607194023'); - -INSERT INTO schema_migrations (version) VALUES ('20110717010705'); - -INSERT INTO schema_migrations (version) VALUES ('20110722211855'); - -INSERT INTO schema_migrations (version) VALUES ('20110815233456'); - -INSERT INTO schema_migrations (version) VALUES ('20111101212358'); - -INSERT INTO schema_migrations (version) VALUES ('20130106210658'); - -INSERT INTO schema_migrations (version) VALUES ('20130114154400'); - -INSERT INTO schema_migrations (version) VALUES ('20130219171111'); - -INSERT INTO schema_migrations (version) VALUES ('20130219184743'); - -INSERT INTO schema_migrations (version) VALUES ('20130221032344'); - -INSERT INTO schema_migrations (version) VALUES ('20130221035518'); - -INSERT INTO schema_migrations (version) VALUES ('20130221214811'); - -INSERT INTO schema_migrations (version) VALUES ('20130302214500'); - -INSERT INTO schema_migrations (version) VALUES ('20130305005138'); - -INSERT INTO schema_migrations (version) VALUES ('20130307225324'); - -INSERT INTO schema_migrations (version) VALUES ('20130308204213'); - -INSERT INTO schema_migrations (version) VALUES ('20130318002652'); - -INSERT INTO schema_migrations (version) VALUES ('20130318012517'); - -INSERT INTO schema_migrations (version) VALUES ('20130318030619'); - -INSERT INTO schema_migrations (version) VALUES ('20130318231740'); - -INSERT INTO schema_migrations (version) VALUES ('20130320070700'); - -INSERT INTO schema_migrations (version) VALUES ('20130322162059'); - -INSERT INTO schema_migrations (version) VALUES ('20130322173202'); - -INSERT INTO schema_migrations (version) VALUES ('20130322173859'); - -INSERT INTO schema_migrations (version) VALUES ('20130323160259'); - -INSERT INTO schema_migrations (version) VALUES ('20130326035904'); - -INSERT INTO schema_migrations (version) VALUES ('20130328092739'); - -INSERT INTO schema_migrations (version) VALUES ('20130331180246'); - -INSERT INTO schema_migrations (version) VALUES ('20130331182719'); - -INSERT INTO schema_migrations (version) VALUES ('20130401013601'); - -INSERT INTO schema_migrations (version) VALUES ('20130409191950'); - -INSERT INTO schema_migrations (version) VALUES ('20130417221643'); - -INSERT INTO schema_migrations (version) VALUES ('20130424121410'); - -INSERT INTO schema_migrations (version) VALUES ('20130506154136'); - -INSERT INTO schema_migrations (version) VALUES ('20130606224559'); - -INSERT INTO schema_migrations (version) VALUES ('20130618230158'); - -INSERT INTO schema_migrations (version) VALUES ('20130620215658'); - -INSERT INTO schema_migrations (version) VALUES ('20130712162600'); - -INSERT INTO schema_migrations (version) VALUES ('20130914175431'); - -INSERT INTO schema_migrations (version) VALUES ('20131006193238'); - -INSERT INTO schema_migrations (version) VALUES ('20131117150705'); - -INSERT INTO schema_migrations (version) VALUES ('20131118153503'); - -INSERT INTO schema_migrations (version) VALUES ('20131130190411'); - -INSERT INTO schema_migrations (version) VALUES ('20131209181023'); - -INSERT INTO schema_migrations (version) VALUES ('20131217025233'); - -INSERT INTO schema_migrations (version) VALUES ('20131225002748'); - -INSERT INTO schema_migrations (version) VALUES ('20140111191413'); - -INSERT INTO schema_migrations (version) VALUES ('20140204233337'); - -INSERT INTO schema_migrations (version) VALUES ('20140221213349'); - -INSERT INTO schema_migrations (version) VALUES ('20140428015134'); - -INSERT INTO schema_migrations (version) VALUES ('20140505000956'); - -INSERT INTO schema_migrations (version) VALUES ('20140603225334'); - -INSERT INTO schema_migrations (version) VALUES ('20140604002414'); - -INSERT INTO schema_migrations (version) VALUES ('20140613004559'); - -INSERT INTO schema_migrations (version) VALUES ('20140701224800'); - -INSERT INTO schema_migrations (version) VALUES ('20140722225753'); - -INSERT INTO schema_migrations (version) VALUES ('20140725003232'); - -INSERT INTO schema_migrations (version) VALUES ('20141009231234'); - -INSERT INTO schema_migrations (version) VALUES ('20141017231608'); - -INSERT INTO schema_migrations (version) VALUES ('20141120045943'); - -INSERT INTO schema_migrations (version) VALUES ('20150119191042'); - -INSERT INTO schema_migrations (version) VALUES ('20150120005624'); - -INSERT INTO schema_migrations (version) VALUES ('20150128005954'); - -INSERT INTO schema_migrations (version) VALUES ('20150403224949'); - -INSERT INTO schema_migrations (version) VALUES ('20150613010904'); - -INSERT INTO schema_migrations (version) VALUES ('20150623191904'); - -INSERT INTO schema_migrations (version) VALUES ('20150629235905'); - -INSERT INTO schema_migrations (version) VALUES ('20150705014135'); - -INSERT INTO schema_migrations (version) VALUES ('20150721214646'); - -INSERT INTO schema_migrations (version) VALUES ('20150728170433'); - -INSERT INTO schema_migrations (version) VALUES ('20150805010245'); - -INSERT INTO schema_migrations (version) VALUES ('20151217213321'); - -INSERT INTO schema_migrations (version) VALUES ('20160219004022'); - -INSERT INTO schema_migrations (version) VALUES ('20160219010854'); - -INSERT INTO schema_migrations (version) VALUES ('20160219172840'); - -INSERT INTO schema_migrations (version) VALUES ('20160222211328'); - -INSERT INTO schema_migrations (version) VALUES ('20160526174848'); - -INSERT INTO schema_migrations (version) VALUES ('20160820003534'); - -INSERT INTO schema_migrations (version) VALUES ('20160822230752'); - -INSERT INTO schema_migrations (version) VALUES ('20160919234407'); - -INSERT INTO schema_migrations (version) VALUES ('20161018221128'); - -INSERT INTO schema_migrations (version) VALUES ('20161024220345'); - -INSERT INTO schema_migrations (version) VALUES ('20161101003139'); - -INSERT INTO schema_migrations (version) VALUES ('20161221225849'); - -INSERT INTO schema_migrations (version) VALUES ('20161227003428'); - -INSERT INTO schema_migrations (version) VALUES ('20161229001201'); - -INSERT INTO schema_migrations (version) VALUES ('20170106012138'); - -INSERT INTO schema_migrations (version) VALUES ('20170112021922'); - -INSERT INTO schema_migrations (version) VALUES ('20170112060921'); - -INSERT INTO schema_migrations (version) VALUES ('20170117233040'); - -INSERT INTO schema_migrations (version) VALUES ('20170218104710'); - -INSERT INTO schema_migrations (version) VALUES ('20170302014435'); - -INSERT INTO schema_migrations (version) VALUES ('20170314235626'); - -INSERT INTO schema_migrations (version) VALUES ('20170316224630'); - -INSERT INTO schema_migrations (version) VALUES ('20170319000519'); - -INSERT INTO schema_migrations (version) VALUES ('20170329185605'); - -INSERT INTO schema_migrations (version) VALUES ('20170330230231'); - -INSERT INTO schema_migrations (version) VALUES ('20170413000209'); - -INSERT INTO schema_migrations (version) VALUES ('20170414005856'); - -INSERT INTO schema_migrations (version) VALUES ('20170414233426'); - -INSERT INTO schema_migrations (version) VALUES ('20170414233617'); - -INSERT INTO schema_migrations (version) VALUES ('20170416224142'); - -INSERT INTO schema_migrations (version) VALUES ('20170428220448'); - -INSERT INTO schema_migrations (version) VALUES ('20170512221200'); - -INSERT INTO schema_migrations (version) VALUES ('20170515235205'); - -INSERT INTO schema_migrations (version) VALUES ('20170519204506'); - -INSERT INTO schema_migrations (version) VALUES ('20170526183928'); - -INSERT INTO schema_migrations (version) VALUES ('20170608043651'); - -INSERT INTO schema_migrations (version) VALUES ('20170613200356'); - -INSERT INTO schema_migrations (version) VALUES ('20170709190409'); - -INSERT INTO schema_migrations (version) VALUES ('20170914200122'); - -INSERT INTO schema_migrations (version) VALUES ('20171106075030'); - -INSERT INTO schema_migrations (version) VALUES ('20171127195124'); - -INSERT INTO schema_migrations (version) VALUES ('20171218213037'); - -INSERT INTO schema_migrations (version) VALUES ('20171219001521'); - -INSERT INTO schema_migrations (version) VALUES ('20171230220225'); - -INSERT INTO schema_migrations (version) VALUES ('20180113211343'); - -INSERT INTO schema_migrations (version) VALUES ('20180116001101'); diff --git a/script/fixes/047_trim_artcomm_whitespace.rb b/script/fixes/047_trim_artcomm_whitespace.rb index d3815ad39..d406a4c27 100755 --- a/script/fixes/047_trim_artcomm_whitespace.rb +++ b/script/fixes/047_trim_artcomm_whitespace.rb @@ -7,8 +7,6 @@ CurrentUser.ip_addr = "127.0.0.1" ArtistCommentary.without_timeout do ArtistCommentary.transaction do - # binding.pry - artcomms = ArtistCommentary.where(%( original_title ~ '^[[:space:]]|[[:space:]]$' OR translated_title ~ '^[[:space:]]|[[:space:]]$' diff --git a/test/factories/artist.rb b/test/factories/artist.rb index 100c70cfe..a147aa233 100644 --- a/test/factories/artist.rb +++ b/test/factories/artist.rb @@ -1,7 +1,8 @@ -FactoryGirl.define do +FactoryBot.define do factory(:artist) do name {rand(1_000_000).to_s} is_active true + association :creator, factory: :user end end diff --git a/test/factories/artist_commentary.rb b/test/factories/artist_commentary.rb index af4b30126..2a10e962e 100644 --- a/test/factories/artist_commentary.rb +++ b/test/factories/artist_commentary.rb @@ -1,6 +1,6 @@ -FactoryGirl.define do +FactoryBot.define do factory(:artist_commentary) do - post :factory => :post + post factory: :post original_title { FFaker::Lorem.sentences.join(" ") } original_description { FFaker::Lorem.sentences.join(" ") } translated_title { FFaker::Lorem.sentences.join(" ") } diff --git a/test/factories/artist_url.rb b/test/factories/artist_url.rb index 7891cc4ad..d11690ef1 100644 --- a/test/factories/artist_url.rb +++ b/test/factories/artist_url.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:artist_url) do artist url {FFaker::Internet.domain_name} diff --git a/test/factories/ban.rb b/test/factories/ban.rb index b1f464353..58c195d09 100644 --- a/test/factories/ban.rb +++ b/test/factories/ban.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:ban) do |f| banner :factory => :admin_user reason {FFaker::Lorem.words.join(" ")} diff --git a/test/factories/bulk_update_request.rb b/test/factories/bulk_update_request.rb index 82ae1c230..dcfda5961 100644 --- a/test/factories/bulk_update_request.rb +++ b/test/factories/bulk_update_request.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:bulk_update_request) do |f| title "xxx" script "create alias aaa -> bbb" diff --git a/test/factories/comment.rb b/test/factories/comment.rb index ec448a31d..184191c4e 100644 --- a/test/factories/comment.rb +++ b/test/factories/comment.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:comment) do |f| post body {FFaker::Lorem.sentences.join(" ")} diff --git a/test/factories/comment_vote.rb b/test/factories/comment_vote.rb index a7bc3e0df..25e451b47 100644 --- a/test/factories/comment_vote.rb +++ b/test/factories/comment_vote.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:comment_vote) do score 1 end diff --git a/test/factories/dmail.rb b/test/factories/dmail.rb index 5330b5a72..4b815519d 100644 --- a/test/factories/dmail.rb +++ b/test/factories/dmail.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:dmail) do to :factory => :user title {FFaker::Lorem.words.join(" ")} diff --git a/test/factories/favorite.rb b/test/factories/favorite.rb index 32e1960f1..192e8f8ff 100644 --- a/test/factories/favorite.rb +++ b/test/factories/favorite.rb @@ -1,3 +1,3 @@ -FactoryGirl.define do +FactoryBot.define do factory(:favorite) end diff --git a/test/factories/favorite_group.rb b/test/factories/favorite_group.rb index b789bc2a6..060d83af8 100644 --- a/test/factories/favorite_group.rb +++ b/test/factories/favorite_group.rb @@ -1,6 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :favorite_group do name { FFaker::Lorem.word } - creator end end diff --git a/test/factories/forum_post.rb b/test/factories/forum_post.rb index 6689311df..a1af4ae70 100644 --- a/test/factories/forum_post.rb +++ b/test/factories/forum_post.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:forum_post) do body {FFaker::Lorem.sentences.join(" ")} end diff --git a/test/factories/forum_subscription.rb b/test/factories/forum_subscription.rb index fedb14c94..cb6713b0b 100644 --- a/test/factories/forum_subscription.rb +++ b/test/factories/forum_subscription.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:forum_subscription) do end end diff --git a/test/factories/forum_topic.rb b/test/factories/forum_topic.rb index 689679509..a355795b8 100644 --- a/test/factories/forum_topic.rb +++ b/test/factories/forum_topic.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:forum_topic) do title {FFaker::Lorem.words.join(" ")} is_sticky false diff --git a/test/factories/forum_topic_visit.rb b/test/factories/forum_topic_visit.rb index 8195bab48..ed07fda71 100644 --- a/test/factories/forum_topic_visit.rb +++ b/test/factories/forum_topic_visit.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:forum_topic_visit) do end end diff --git a/test/factories/ip_ban.rb b/test/factories/ip_ban.rb index ad1caea7c..4d61a1186 100644 --- a/test/factories/ip_ban.rb +++ b/test/factories/ip_ban.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory(:ip_ban) do creator :factory => :user reason {FFaker::Lorem.words.join(" ")} - ip_addr "127.0.0.1" + ip_addr "127.0.0.2" end end diff --git a/test/factories/janitor_trial.rb b/test/factories/janitor_trial.rb index 1e86fb487..7864e4887 100644 --- a/test/factories/janitor_trial.rb +++ b/test/factories/janitor_trial.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:janitor_trial) do user end diff --git a/test/factories/mod_action.rb b/test/factories/mod_action.rb index 0b5e1d95b..329748d0e 100644 --- a/test/factories/mod_action.rb +++ b/test/factories/mod_action.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:mod_action) do creator :factory => :user description "1234" diff --git a/test/factories/news_update.rb b/test/factories/news_update.rb index d2e046d12..98d42ef94 100644 --- a/test/factories/news_update.rb +++ b/test/factories/news_update.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:news_update) do message "xxx" end diff --git a/test/factories/note.rb b/test/factories/note.rb index eb9597de4..f5c450df0 100644 --- a/test/factories/note.rb +++ b/test/factories/note.rb @@ -1,6 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory(:note) do - creator post x 1 y 1 diff --git a/test/factories/pool.rb b/test/factories/pool.rb index ea468bdf6..e2c68bf03 100644 --- a/test/factories/pool.rb +++ b/test/factories/pool.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:pool) do name {"pool_" + (rand(1_000_000) + 100).to_s} association :creator, :factory => :user diff --git a/test/factories/post.rb b/test/factories/post.rb index 2e13bb190..253a3eafb 100644 --- a/test/factories/post.rb +++ b/test/factories/post.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:post) do sequence :md5 do |n| n.to_s diff --git a/test/factories/post_appeal.rb b/test/factories/post_appeal.rb index e7e3263d5..0a8ca243e 100644 --- a/test/factories/post_appeal.rb +++ b/test/factories/post_appeal.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:post_appeal) do reason "xxx" end diff --git a/test/factories/post_disapproval.rb b/test/factories/post_disapproval.rb index 2f81d8783..156ac1edb 100644 --- a/test/factories/post_disapproval.rb +++ b/test/factories/post_disapproval.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:post_disapproval) do reason { %w(breaks_rules poor_quality disinterest).sample } message { FFaker::Lorem.sentence } diff --git a/test/factories/post_flag.rb b/test/factories/post_flag.rb index 6e382e9af..0e883c21f 100644 --- a/test/factories/post_flag.rb +++ b/test/factories/post_flag.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:post_flag) do reason "xxx" is_resolved false diff --git a/test/factories/post_replacement.rb b/test/factories/post_replacement.rb index 201e09e97..119242c0a 100644 --- a/test/factories/post_replacement.rb +++ b/test/factories/post_replacement.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:post_replacement) do original_url { FFaker::Internet.http_url } replacement_url { FFaker::Internet.http_url } diff --git a/test/factories/saved_search.rb b/test/factories/saved_search.rb index ce4921c4d..0b8269095 100644 --- a/test/factories/saved_search.rb +++ b/test/factories/saved_search.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:saved_search) do query { FFaker::Lorem.words } labels { [FFaker::Lorem.word] } diff --git a/test/factories/super_voter.rb b/test/factories/super_voter.rb index d9267450b..e30fa5ae0 100644 --- a/test/factories/super_voter.rb +++ b/test/factories/super_voter.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:super_voter) do end -end \ No newline at end of file +end diff --git a/test/factories/tag.rb b/test/factories/tag.rb index c83e0dd15..621fc2e13 100644 --- a/test/factories/tag.rb +++ b/test/factories/tag.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:tag) do name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"} post_count 0 diff --git a/test/factories/tag_alias.rb b/test/factories/tag_alias.rb index 4033c01dd..33900ba2b 100644 --- a/test/factories/tag_alias.rb +++ b/test/factories/tag_alias.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :tag_alias do antecedent_name "aaa" consequent_name "bbb" @@ -8,7 +8,7 @@ FactoryGirl.define do after(:create) do |tag_alias| unless tag_alias.status == "pending" - approver = FactoryGirl.create(:admin_user) unless approver.present? + approver = FactoryBot.create(:admin_user) unless approver.present? tag_alias.approve!(approver: approver) end end diff --git a/test/factories/tag_implication.rb b/test/factories/tag_implication.rb index 9a4ef48a0..1bd591830 100644 --- a/test/factories/tag_implication.rb +++ b/test/factories/tag_implication.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :tag_implication do antecedent_name "aaa" consequent_name "bbb" @@ -7,7 +7,7 @@ FactoryGirl.define do after(:create) do |tag_implication| unless tag_implication.status == "pending" - approver = FactoryGirl.create(:admin_user) unless approver.present? + approver = FactoryBot.create(:admin_user) unless approver.present? tag_implication.approve!(approver: approver) end end diff --git a/test/factories/upload.rb b/test/factories/upload.rb index cd6a89d0d..7b886da5f 100644 --- a/test/factories/upload.rb +++ b/test/factories/upload.rb @@ -1,4 +1,6 @@ -FactoryGirl.define do +require 'fileutils' + +FactoryBot.define do factory(:upload) do rating "s" uploader :factory => :user, :level => 20 @@ -19,6 +21,14 @@ FactoryGirl.define do ActionDispatch::Http::UploadedFile.new(tempfile: f, filename: "test.jpg") end end + + factory(:large_jpg_upload) do + file do + f = Tempfile.new + IO.copy_stream("#{Rails.root}/test/files/test-large.jpg", f.path) + ActionDispatch::Http::UploadedFile.new(tempfile: f, filename: "test.jpg") + end + end end end diff --git a/test/factories/user.rb b/test/factories/user.rb index 3d3d5eb5d..e4511807d 100644 --- a/test/factories/user.rb +++ b/test/factories/user.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:user, aliases: [:creator, :updater]) do name {(rand(1_000_000) + 10).to_s} password "password" @@ -15,7 +15,6 @@ FactoryGirl.define do factory(:banned_user) do transient { ban_duration 3 } is_banned true - after(:create) { |user, ctx| create(:ban, user: user, duration: ctx.ban_duration) } end factory(:member_user) do diff --git a/test/factories/user_feedback.rb b/test/factories/user_feedback.rb index a7e1dd140..97651690f 100644 --- a/test/factories/user_feedback.rb +++ b/test/factories/user_feedback.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:user_feedback) do user category "positive" diff --git a/test/factories/user_name_change_request.rb b/test/factories/user_name_change_request.rb index af0f42124..6ca0b5d32 100644 --- a/test/factories/user_name_change_request.rb +++ b/test/factories/user_name_change_request.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:user_name_change_request) do desired_name {FFaker::Internet.user_name} change_reason {FFaker::Lorem.sentence} diff --git a/test/factories/user_password_reset_nonce.rb b/test/factories/user_password_reset_nonce.rb index e5918bf30..03d1edc6a 100644 --- a/test/factories/user_password_reset_nonce.rb +++ b/test/factories/user_password_reset_nonce.rb @@ -1,3 +1,3 @@ -FactoryGirl.define do +FactoryBot.define do factory(:user_password_reset_nonce) end diff --git a/test/factories/wiki_page.rb b/test/factories/wiki_page.rb index 983ea3b43..1fd138b87 100644 --- a/test/factories/wiki_page.rb +++ b/test/factories/wiki_page.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory(:wiki_page) do creator :factory => :user title {FFaker::Lorem.words.join(" ")} diff --git a/test/functional/admin/dashboards_controller_test.rb b/test/functional/admin/dashboards_controller_test.rb index d33a30036..dae369dff 100644 --- a/test/functional/admin/dashboards_controller_test.rb +++ b/test/functional/admin/dashboards_controller_test.rb @@ -1,10 +1,14 @@ require 'test_helper' -class Admin::DashboardsControllerTest < ActionController::TestCase +class Admin::DashboardsControllerTest < ActionDispatch::IntegrationTest context "The admin dashboard controller" do + setup do + @admin = create(:admin_user) + end + context "show action" do should "render" do - get :show + get_auth admin_dashboard_path, @admin assert_response :success end end diff --git a/test/functional/admin/users_controller_test.rb b/test/functional/admin/users_controller_test.rb index 3435503b6..55e707ed7 100644 --- a/test/functional/admin/users_controller_test.rb +++ b/test/functional/admin/users_controller_test.rb @@ -1,18 +1,16 @@ require 'test_helper' -class Admin::UsersControllerTest < ActionController::TestCase +class Admin::UsersControllerTest < ActionDispatch::IntegrationTest context "Admin::UsersController" do setup do - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @mod - CurrentUser.ip_addr = "127.0.0.1" - @user = FactoryGirl.create(:user) - @admin = FactoryGirl.create(:admin_user) + @mod = create(:moderator_user) + @user = create(:user) + @admin = create(:admin_user) end context "#edit" do should "render" do - get :edit, {:id => @user.id}, {:user_id => @mod.id} + get_auth edit_admin_user_path(@user), @mod assert_response :success end end @@ -20,7 +18,7 @@ class Admin::UsersControllerTest < ActionController::TestCase context "#update" do context "on a basic user" do should "succeed" do - put :update, {:id => @user.id, :user => {:level => "30"}}, {:user_id => @mod.id} + put_auth admin_user_path(@user), @mod, params: {:user => {:level => "30"}} assert_redirected_to(edit_admin_user_path(@user)) @user.reload assert_equal(30, @user.level) @@ -29,7 +27,7 @@ class Admin::UsersControllerTest < ActionController::TestCase context "promoted to an admin" do should "fail" do - put :update, {:id => @user.id, :user => {:level => "50"}}, {:user_id => @mod.id} + put_auth admin_user_path(@user), @mod, params: {:user => {:level => "50"}} assert_response(403) @user.reload assert_equal(20, @user.level) @@ -39,7 +37,7 @@ class Admin::UsersControllerTest < ActionController::TestCase context "on an admin user" do should "fail" do - put :update, {:id => @admin.id, :user => {:level => "30"}}, {:user_id => @mod.id} + put_auth admin_user_path(@admin), @mod, params: {:user => {:level => "30"}} assert_response(403) @admin.reload assert_equal(50, @admin.level) diff --git a/test/functional/artist_commentaries_controller_test.rb b/test/functional/artist_commentaries_controller_test.rb index ae76150bc..1e2f50713 100644 --- a/test/functional/artist_commentaries_controller_test.rb +++ b/test/functional/artist_commentaries_controller_test.rb @@ -1,23 +1,19 @@ require 'test_helper' -class ArtistCommentariesControllerTest < ActionController::TestCase +class ArtistCommentariesControllerTest < ActionDispatch::IntegrationTest context "The artist commentaries controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) - @commentary1 = FactoryGirl.create(:artist_commentary) - @commentary2 = FactoryGirl.create(:artist_commentary) - end - - teardown do - CurrentUser.user = nil + as_user do + @commentary1 = create(:artist_commentary) + @commentary2 = create(:artist_commentary) + end end context "index action" do should "render" do - get :index + get artist_commentaries_path assert_response :success end @@ -32,17 +28,17 @@ class ArtistCommentariesControllerTest < ActionController::TestCase } } - get :index, params + get artist_commentaries_path(params) assert_response :success end end context "show action" do should "render" do - get :show, { id: @commentary1.id } + get artist_commentary_path(@commentary1.id) assert_redirected_to(@commentary1.post) - get :show, { post_id: @commentary1.post_id } + get artist_commentary_path(post_id: @commentary1.post_id) assert_redirected_to(@commentary1.post) end end @@ -52,12 +48,15 @@ class ArtistCommentariesControllerTest < ActionController::TestCase params = { artist_commentary: { original_title: "foo", - post_id: FactoryGirl.create(:post).id, - } + post_id: FactoryBot.create(:post).id, + }, + format: "js" } - post :create_or_update, params, { user_id: @user.id } - assert_redirected_to(ArtistCommentary.find_by_post_id(params[:artist_commentary][:post_id])) + assert_difference("ArtistCommentary.count", 1) do + put_auth create_or_update_artist_commentaries_path(params), @user, as: :js + end + assert_response :success end should "render for update" do @@ -65,11 +64,13 @@ class ArtistCommentariesControllerTest < ActionController::TestCase artist_commentary: { post_id: @commentary1.post_id, original_title: "foo", - } + }, + format: "js" } - post :create_or_update, params, { user_id: @user.id } - assert_redirected_to(@commentary1) + put_auth create_or_update_artist_commentaries_path(params), @user + @commentary1.reload + assert_response :success assert_equal("foo", @commentary1.reload.original_title) end end @@ -78,22 +79,20 @@ class ArtistCommentariesControllerTest < ActionController::TestCase should "work" do original_title = @commentary1.original_title @commentary1.update(original_title: "foo") - - post :revert, { :id => @commentary1.post_id, :version_id => @commentary1.versions(true).first.id }, {:user_id => @user.id} - assert_redirected_to(@commentary1) + @commentary1.reload + put_auth revert_artist_commentary_path(@commentary1.post_id, version_id: @commentary1.versions.first.id, format: "js"), @user + assert_response :success assert_equal(original_title, @commentary1.reload.original_title) end should "return 404 when trying to revert a nonexistent commentary" do - post :revert, { :id => -1, :version_id => -1 }, {:user_id => @user.id} - + put_auth revert_artist_commentary_path(-1, version_id: -1, format: "js"), @user assert_response 404 end should "not allow reverting to a previous version of another artist commentary" do - post :revert, { :id => @commentary1.post_id, :version_id => @commentary2.versions(true).first.id }, {:user_id => @user.id} + put_auth revert_artist_commentary_path(@commentary1.post_id, version_id: @commentary2.versions.first.id, format: "js"), @user @commentary1.reload - assert_not_equal(@commentary1.original_title, @commentary2.original_title) assert_response :missing end diff --git a/test/functional/artist_commentary_versions_controller_test.rb b/test/functional/artist_commentary_versions_controller_test.rb index 323677a5e..9fe51a13d 100644 --- a/test/functional/artist_commentary_versions_controller_test.rb +++ b/test/functional/artist_commentary_versions_controller_test.rb @@ -1,10 +1,19 @@ require 'test_helper' -class ArtistCommentaryVersionsControllerTest < ActionController::TestCase +class ArtistCommentaryVersionsControllerTest < ActionDispatch::IntegrationTest context "The artist commentary versions controller" do + setup do + @user = FactoryBot.create(:user) + + as_user do + @commentary1 = FactoryBot.create(:artist_commentary) + @commentary2 = FactoryBot.create(:artist_commentary) + end + end + context "index action" do should "render" do - get :index + get artist_commentary_versions_path assert_response :success end end diff --git a/test/functional/artist_versions_controller_test.rb b/test/functional/artist_versions_controller_test.rb index 4ab33e4af..17332aa68 100644 --- a/test/functional/artist_versions_controller_test.rb +++ b/test/functional/artist_versions_controller_test.rb @@ -1,25 +1,21 @@ require 'test_helper' -class ArtistVersionsControllerTest < ActionController::TestCase +class ArtistVersionsControllerTest < ActionDispatch::IntegrationTest context "An artist versions controller" do setup do - CurrentUser.user = FactoryGirl.create(:gold_user) - CurrentUser.ip_addr = "127.0.0.1" - @artist = FactoryGirl.create(:artist) - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = FactoryBot.create(:gold_user) + as_user do + @artist = create(:artist) + end end should "get the index page" do - get :index, {}, {:user_id => CurrentUser.id} + get_auth artist_versions_path, @user assert_response :success end should "get the index page when searching for something" do - get :index, {:search => {:name => @artist.name}}, {:user_id => CurrentUser.id} + get_auth artist_versions_path(search: {name: @artist.name}), @user assert_response :success end end diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index 17e4b8db6..b49794fe2 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -1,164 +1,157 @@ require 'test_helper' -class ArtistsControllerTest < ActionController::TestCase - def assert_artist_found(expected_artist, source_url) - get :finder, { :format => :json, :url => source_url }, { :user_id => @user.id } - +class ArtistsControllerTest < ActionDispatch::IntegrationTest + def assert_artist_found(expected_artist, source_url = nil) + if source_url + get_auth finder_artists_path(format: "json", url: source_url), @user + end assert_response :success - assert_equal(1, assigns(:artists).size, "Testing URL: #{source_url}") - assert_equal(expected_artist, assigns(:artists).first.name) + json = JSON.parse(response.body) + assert_equal(1, json.size, "Testing URL: #{source_url}") + assert_equal(expected_artist, json[0]["name"]) end def assert_artist_not_found(source_url) - get :finder, { :format => :json, :url => source_url }, { :user_id => @user.id } - + get_auth finder_artists_path(format: "json", url: source_url), @user assert_response :success - assert_equal(0, assigns(:artists).size, "Testing URL: #{source_url}") + json = JSON.parse(response.body) + assert_equal(0, json.size, "Testing URL: #{source_url}") end context "An artists controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @artist = FactoryGirl.create(:artist, :notes => "message") - - @masao = FactoryGirl.create(:artist, :name => "masao", :url_string => "http://www.pixiv.net/member.php?id=32777") - @artgerm = FactoryGirl.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @admin = create(:admin_user) + @user = create(:user) + as_user do + @artist = create(:artist, notes: "message") + @masao = create(:artist, name: "masao", url_string: "http://www.pixiv.net/member.php?id=32777") + @artgerm = create(:artist, name: "artgerm", url_string: "http://artgerm.deviantart.com/") + end end should "get the new page" do - get :new, {}, {:user_id => @user.id} + get_auth new_artist_path, @user assert_response :success end - should "get the show_or_new page" do - get :show_or_new, { name: "masao" }, { user_id: @user.id } + should "get the show_or_new page for an existing artist" do + get_auth show_or_new_artists_path(name: "masao"), @user assert_redirected_to(@masao) + end - get :show_or_new, { name: "nobody" }, { user_id: @user.id } + should "get the show_or_new page for a nonexisting artist" do + get_auth show_or_new_artists_path(name: "nobody"), @user assert_response :success end should "get the edit page" do - get :edit, {:id => @artist.id}, {:user_id => @user.id} + get_auth edit_artist_path(@artist.id), @user assert_response :success end should "get the show page" do - get :show, {:id => @artist.id} + get artist_path(@artist.id) assert_response :success end should "get the show page for a negated tag" do - @artist.update_attribute(:name, "-aaa") - get :show, {:id => @artist.id} + @artist.update(name: "-aaa") + get artist_path(@artist.id) assert_response :success end should "get the banned page" do - get :banned + get banned_artists_path assert_response :success end should "ban an artist" do - CurrentUser.scoped(FactoryGirl.create(:admin_user)) do - put :ban, { id: @artist.id }, { user_id: CurrentUser.id } - end - + put_auth ban_artist_path(@artist.id), @admin assert_redirected_to(@artist) - assert_equal(true, @artist.reload.is_banned) + @artist.reload + assert_equal(true, @artist.is_banned?) assert_equal(true, TagImplication.exists?(antecedent_name: @artist.name, consequent_name: "banned_artist")) end should "unban an artist" do - CurrentUser.scoped(FactoryGirl.create(:admin_user)) do + as_admin do @artist.ban! - put :unban, { id: @artist.id }, { user_id: CurrentUser.id } end + put_auth unban_artist_path(@artist.id), @admin assert_redirected_to(@artist) - assert_equal(false, @artist.reload.is_banned) + @artist.reload + assert_equal(false, @artist.is_banned?) assert_equal(false, TagImplication.exists?(antecedent_name: @artist.name, consequent_name: "banned_artist")) end should "get the index page" do - get :index + get artists_path assert_response :success end context "when searching the index page" do should "find artists by name" do - get :index, { :name => "masao" } - - assert_response :success - assert_equal(1, assigns(:artists).size) - assert_equal("masao", assigns(:artists).first.name) + get artists_path(name: "masao", format: "json") + assert_artist_found("masao") end should "find artists by image URL" do - get :index, { :name => "http://i2.pixiv.net/img04/img/syounen_no_uta/46170939_m.jpg" } - - assert_response :success - assert_equal(1, assigns(:artists).size) - assert_equal("masao", assigns(:artists).first.name) + get artists_path(name: "http://i2.pixiv.net/img04/img/syounen_no_uta/46170939_m.jpg", format: "json") + assert_artist_found("masao") end should "find artists by page URL" do url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46170939" - get :index, { :name => url } - - assert_response :success - assert_equal(1, assigns(:artists).size) - assert_equal("masao", assigns(:artists).first.name) + get artists_path(name: url, format: "json") + assert_artist_found("masao") end end should "create an artist" do + attributes = FactoryBot.attributes_for(:artist) assert_difference("Artist.count", 1) do - attributes = FactoryGirl.attributes_for(:artist) attributes.delete(:is_active) - post :create, {:artist => attributes}, {:user_id => @user.id} + post_auth artists_path, @user, params: {artist: attributes} end - artist = Artist.last - assert_redirected_to(artist_path(artist)) + artist = Artist.find_by_name(attributes[:name]) + assert_not_nil(artist) + assert_redirected_to(artist_path(artist.id)) end context "with an artist that has notes" do setup do - @artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") + as(@admin) do + @artist = create(:artist, name: "aaa", notes: "testing") + end @wiki_page = @artist.wiki_page - @another_user = FactoryGirl.create(:user) + @another_user = create(:user) end should "update an artist" do old_timestamp = @wiki_page.updated_at - Timecop.travel(1.minute.from_now) do - post :update, {:id => @artist.id, :artist => {:notes => "rex"}}, {:user_id => @user.id} + travel_to(1.minute.from_now) do + put_auth artist_path(@artist.id), @user, params: {artist: {notes: "rex"}} end @artist.reload - @wiki_page.reload + @wiki_page = @artist.wiki_page assert_equal("rex", @artist.notes) assert_not_equal(old_timestamp, @wiki_page.updated_at) - assert_redirected_to(artist_path(@artist)) + assert_redirected_to(artist_path(@artist.id)) end should "not touch the updater_id and updated_at fields when nothing is changed" do old_timestamp = @wiki_page.updated_at old_updater_id = @wiki_page.updater_id - Timecop.travel(1.minutes.from_now) do - CurrentUser.scoped(@another_user) do - @artist.update_attributes(notes: "testing") + travel_to(1.minutes.from_now) do + as(@another_user) do + @artist.update(notes: "testing") end end - @wiki_page.reload + @artist.reload + @wiki_page = @artist.wiki_page assert_equal(old_timestamp.to_i, @wiki_page.updated_at.to_i) assert_equal(old_updater_id, @wiki_page.updater_id) end @@ -166,7 +159,7 @@ class ArtistsControllerTest < ActionController::TestCase context "when renaming an artist" do should "automatically rename the artist's wiki page" do assert_difference("WikiPage.count", 0) do - post :update, {:id => @artist.id, :artist => {:name => "bbb", :notes => "more testing"}}, {:user_id => @user.id} + put_auth artist_path(@artist.id), @user, params: {artist: {name: "bbb", notes: "more testing"}} end @wiki_page.reload assert_equal("bbb", @wiki_page.title) @@ -174,49 +167,50 @@ class ArtistsControllerTest < ActionController::TestCase end should "merge the new notes with the existing wiki page's contents if a wiki page for the new name already exists" do - existing_wiki_page = FactoryGirl.create(:wiki_page, :title => "bbb", :body => "xxx") - post :update, {:id => @artist.id, :artist => {:name => "bbb", :notes => "yyy"}}, {:user_id => @user.id} - existing_wiki_page.reload - assert_equal("bbb", existing_wiki_page.title) - assert_equal("xxx\n\nyyy", existing_wiki_page.body) + as_user do + @existing_wiki_page = create(:wiki_page, title: "bbb", body: "xxx") + end + put_auth artist_path(@artist.id), @user, params: {artist: {name: "bbb", notes: "yyy"}} + @existing_wiki_page.reload + assert_equal("bbb", @existing_wiki_page.title) + assert_equal("xxx\n\nyyy", @existing_wiki_page.body) end end end should "delete an artist" do - CurrentUser.scoped(FactoryGirl.create(:builder_user)) do - delete :destroy, { id: @artist.id }, { user_id: CurrentUser.id } - end - - assert_redirected_to(artist_path(@artist)) - assert_equal(false, @artist.reload.is_active) + @builder = create(:builder_user) + delete_auth artist_path(@artist.id), @builder + assert_redirected_to(artist_path(@artist.id)) + @artist.reload + assert_equal(false, @artist.is_active) end should "undelete an artist" do - CurrentUser.scoped(FactoryGirl.create(:builder_user)) do - put :undelete, { id: @artist.id }, { user_id: CurrentUser.id } - end - - assert_redirected_to(artist_path(@artist)) + @builder = create(:builder_user) + post_auth undelete_artist_path(@artist.id), @builder + assert_redirected_to(artist_path(@artist.id)) assert_equal(true, @artist.reload.is_active) end context "reverting an artist" do should "work" do - @artist.update_attributes(:name => "xyz") - @artist.update_attributes(:name => "abc") + as_user do + @artist.update(name: "xyz") + @artist.update(name: "abc") + end version = @artist.versions.first - post :revert, {:id => @artist.id, :version_id => version.id} + put_auth revert_artist_path(@artist.id), @user, params: {version_id: version.id} end should "not allow reverting to a previous version of another artist" do - @artist2 = FactoryGirl.create(:artist) - - post :revert, { :id => @artist.id, :version_id => @artist2.versions(true).first.id }, {:user_id => @user.id} + as_user do + @artist2 = create(:artist) + end + put_auth artist_path(@artist.id), @user, params: {version_id: @artist2.versions.first.id} @artist.reload - assert_not_equal(@artist.name, @artist2.name) - assert_response :missing + assert_redirected_to(artist_path(@artist.id)) end end @@ -233,14 +227,23 @@ class ArtistsControllerTest < ActionController::TestCase assert_artist_found("artgerm", "http://fc06.deviantart.net/fs71/f/2014/150/d/c/peachy_princess_by_artgerm-d7k7tmu.jpg") end - should "find pixiv artists" do + should "find pixiv artists for img##" do assert_artist_found("masao", "http://i2.pixiv.net/img04/img/syounen_no_uta/46170939.jpg") + end + + should "find pixiv artists for img-original" do assert_artist_found("masao", "http://i2.pixiv.net/img-original/img/2014/09/25/00/57/24/46170939_p0.jpg") + end + + should "find pixiv artists for member_illust.php" do assert_artist_found("masao", "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46170939") end - should "not fail for malformed Pixiv URLs" do + should "fail for nonexisting illust ids" do assert_artist_not_found("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=herpderp") + end + + should "fail for malformed urls" do assert_artist_not_found("http://www.pixiv.net/wharrgarbl") end diff --git a/test/functional/bans_controller_test.rb b/test/functional/bans_controller_test.rb index bd6e320d9..0cae61dbe 100644 --- a/test/functional/bans_controller_test.rb +++ b/test/functional/bans_controller_test.rb @@ -1,50 +1,50 @@ require 'test_helper' -class BansControllerTest < ActionController::TestCase +class BansControllerTest < ActionDispatch::IntegrationTest context "A bans controller" do setup do - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @mod - CurrentUser.ip_addr = "127.0.0.1" - @user = FactoryGirl.create(:user) - @ban = FactoryGirl.create(:ban, :user_id => @user.id) - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @mod = create(:moderator_user) + @user = create(:user) + as(@mod) do + @ban = create(:ban, user: @user) + end end should "get the new page" do - get :new, {}, {:user_id => @mod.id} + get_auth new_ban_path, @mod assert_response :success end should "get the edit page" do - get :edit, {:id => @ban.id}, {:user_id => @mod.id} + get_auth edit_ban_path(@ban.id), @mod assert_response :success end should "get the show page" do - get :show, {:id => @ban.id} + get_auth ban_path(@ban.id), @mod assert_response :success end should "get the index page" do - get :index + get_auth bans_path, @mod + assert_response :success + end + + should "search" do + get_auth bans_path(search: {user_name: @user.name}), @mod assert_response :success end should "create a ban" do assert_difference("Ban.count", 1) do - post :create, {:ban => {:duration => 60, :reason => "xxx", :user_id => @user.id}}, {:user_id => @mod.id} + post_auth bans_path, @mod, params: {ban: {duration: 60, reason: "xxx", user_id: @user.id}} end ban = Ban.last assert_redirected_to(ban_path(ban)) end should "update a ban" do - post :update, {:id => @ban.id, :ban => {:reason => "xxx", :duration => 60}}, {:user_id => @mod.id} + put_auth ban_path(@ban.id), @mod, params: {ban: {reason: "xxx", duration: 60}} @ban.reload assert_equal("xxx", @ban.reason) assert_redirected_to(ban_path(@ban)) @@ -52,7 +52,7 @@ class BansControllerTest < ActionController::TestCase should "destroy a ban" do assert_difference("Ban.count", -1) do - post :destroy, {:id => @ban.id}, {:user_id => @mod.id} + delete_auth ban_path(@ban.id), @mod end assert_redirected_to(bans_path) end diff --git a/test/functional/bulk_update_requests_controller_test.rb b/test/functional/bulk_update_requests_controller_test.rb index ab8d211f0..6f540f8ea 100644 --- a/test/functional/bulk_update_requests_controller_test.rb +++ b/test/functional/bulk_update_requests_controller_test.rb @@ -1,15 +1,15 @@ require 'test_helper' -class BulkUpdateRequestsControllerTest < ActionController::TestCase +class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest context "BulkUpdateRequestsController" do setup do - @user = FactoryGirl.create(:user) - @admin = FactoryGirl.create(:admin_user) + @user = create(:user) + @admin = create(:admin_user) end context "#new" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth bulk_update_requests_path, @user assert_response :success end end @@ -17,26 +17,26 @@ class BulkUpdateRequestsControllerTest < ActionController::TestCase context "#create" do should "succeed" do assert_difference("BulkUpdateRequest.count", 1) do - post :create, {:bulk_update_request => {:skip_secondary_validations => "1", :script => "create alias aaa -> bbb", :title => "xxx"}}, {:user_id => @user.id} + post_auth bulk_update_requests_path, @user, params: {bulk_update_request: {skip_secondary_validations: "1", script: "create alias aaa -> bbb", title: "xxx"}} end end end context "#update" do setup do - CurrentUser.scoped(@user) do - @bulk_update_request = FactoryGirl.create(:bulk_update_request) + as_user do + @bulk_update_request = create(:bulk_update_request) end end should "still handle enabled secondary validations correctly" do - post :update, {:id => @bulk_update_request.id, :bulk_update_request => {:script => "create alias zzz -> 222", :skip_secondary_validations => "0"}}, {:user_id => @user.id} + put_auth bulk_update_request_path(@bulk_update_request.id), @user, params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "0"}} @bulk_update_request.reload assert_equal("create alias zzz -> 222", @bulk_update_request.script) end should "still handle disabled secondary validations correctly" do - post :update, {:id => @bulk_update_request.id, :bulk_update_request => {:script => "create alias zzz -> 222", :skip_secondary_validations => "1"}}, {:user_id => @user.id} + put_auth bulk_update_request_path(@bulk_update_request.id), @user, params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "1"}} @bulk_update_request.reload assert_equal("create alias zzz -> 222", @bulk_update_request.script) end @@ -44,27 +44,27 @@ class BulkUpdateRequestsControllerTest < ActionController::TestCase context "#index" do setup do - CurrentUser.scoped(@user) do - @bulk_update_request = FactoryGirl.create(:bulk_update_request) + as_user do + @bulk_update_request = create(:bulk_update_request) end end should "render" do - get :index, {}, {:user_id => @user.id} + get bulk_update_requests_path assert_response :success end end context "#destroy" do setup do - CurrentUser.scoped(@user) do - @bulk_update_request = FactoryGirl.create(:bulk_update_request) + as_user do + @bulk_update_request = create(:bulk_update_request) end end context "for the creator" do should "succeed" do - delete :destroy, {:id => @bulk_update_request.id}, {:user_id => @user.id} + delete_auth bulk_update_request_path(@bulk_update_request), @user @bulk_update_request.reload assert_equal("rejected", @bulk_update_request.status) end @@ -72,19 +72,19 @@ class BulkUpdateRequestsControllerTest < ActionController::TestCase context "for another member" do setup do - @another_user = FactoryGirl.create(:user) + @another_user = create(:user) end should "fail" do assert_difference("BulkUpdateRequest.count", 0) do - delete :destroy, {:id => @bulk_update_request.id}, {:user_id => @another_user.id} + delete_auth bulk_update_request_path(@bulk_update_request), @another_user end end end context "for an admin" do should "succeed" do - delete :destroy, {:id => @bulk_update_request.id}, {:user_id => @admin.id} + delete_auth bulk_update_request_path(@bulk_update_request), @admin @bulk_update_request.reload assert_equal("rejected", @bulk_update_request.status) end @@ -93,14 +93,14 @@ class BulkUpdateRequestsControllerTest < ActionController::TestCase context "#approve" do setup do - CurrentUser.scoped(@user) do - @bulk_update_request = FactoryGirl.create(:bulk_update_request) + as_user do + @bulk_update_request = create(:bulk_update_request) end end context "for a member" do should "fail" do - post :approve, {:id => @bulk_update_request.id}, {:user_id => @user.id} + post_auth approve_bulk_update_request_path(@bulk_update_request), @user @bulk_update_request.reload assert_equal("pending", @bulk_update_request.status) end @@ -108,7 +108,7 @@ class BulkUpdateRequestsControllerTest < ActionController::TestCase context "for an admin" do should "succeed" do - post :approve, {:id => @bulk_update_request.id}, {:user_id => @admin.id} + post_auth approve_bulk_update_request_path(@bulk_update_request), @admin @bulk_update_request.reload assert_equal("approved", @bulk_update_request.status) end diff --git a/test/functional/comment_votes_controller_test.rb b/test/functional/comment_votes_controller_test.rb index 740037b0a..b62bcd063 100644 --- a/test/functional/comment_votes_controller_test.rb +++ b/test/functional/comment_votes_controller_test.rb @@ -1,12 +1,12 @@ require 'test_helper' -class CommentVotesControllerTest < ActionController::TestCase +class CommentVotesControllerTest < ActionDispatch::IntegrationTest context "A comment votes controller" do setup do - CurrentUser.user = @user = FactoryGirl.create(:user) + CurrentUser.user = @user = create(:user) CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - @comment = FactoryGirl.create(:comment) + @comment = create(:comment) end teardown do @@ -17,16 +17,16 @@ class CommentVotesControllerTest < ActionController::TestCase context "#create.json" do should "create a vote" do assert_difference("CommentVote.count", 1) do - post :create, {:format => "json", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id} + post_auth comment_votes_path(comment_id: @comment.id, format: "json"), @user assert_response :success assert_equal("{\"success\": true}", @response.body.strip) end end should "fail silently on errors" do - FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1) + create(:comment_vote, comment: @comment, score: -1) assert_difference("CommentVote.count", 0) do - post :create, {:format => "json", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id} + post_auth comment_votes_path(comment_id: @comment.id, score: "-1", format: "json"), @user assert_response 422 assert_equal("{\"success\": false, \"errors\": \"Validation failed: You have already voted for this comment\"}", @response.body.strip) end @@ -36,15 +36,15 @@ class CommentVotesControllerTest < ActionController::TestCase context "#create.js" do should "create a vote" do assert_difference("CommentVote.count", 1) do - post :create, {:format => "js", :comment_id => @comment.id, :score => 1}, {:user_id => @user.id} + post_auth comment_votes_path(comment_id: @comment.id, format: "json", score: 1), @user assert_response :success end end should "fail on errors" do - FactoryGirl.create(:comment_vote, :comment => @comment, :score => -1) + create(:comment_vote, :comment => @comment, :score => -1) assert_difference("CommentVote.count", 0) do - post :create, {:format => "js", :comment_id => @comment.id, :score => -1}, {:user_id => @user.id} + post_auth comment_votes_path(comment_id: @comment.id, :score => -1, format: "js"), @user assert_response 422 end end diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 69b7dcb3e..df258fb7a 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -1,18 +1,18 @@ require 'test_helper' -class CommentsControllerTest < ActionController::TestCase +class CommentsControllerTest < ActionDispatch::IntegrationTest context "A comments controller" do setup do - @mod = FactoryGirl.create(:moderator_user) - @user = FactoryGirl.create(:member_user) + @mod = FactoryBot.create(:moderator_user) + @user = FactoryBot.create(:member_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - @post = FactoryGirl.create(:post) - @comment = FactoryGirl.create(:comment, :post => @post) + @post = FactoryBot.create(:post) + @comment = FactoryBot.create(:comment, :post => @post) CurrentUser.scoped(@mod) do - @mod_comment = FactoryGirl.create(:comment, :post => @post) + @mod_comment = FactoryBot.create(:comment, :post => @post) end end @@ -23,43 +23,43 @@ class CommentsControllerTest < ActionController::TestCase context "index action" do should "render for post" do - xhr :get, :index, { post_id: @post.id, group_by: "post", format: "js" } + get comments_path(post_id: @post.id, group_by: "post", format: "js") assert_response :success end should "render by post" do - get :index, {:group_by => "post"} + get comments_path(group_by: "post") assert_response :success end should "render by comment" do - get :index, {:group_by => "comment"} + get comments_path(group_by: "comment") assert_response :success end should "render for atom feeds" do - get :index, {:format => "atom"} + get comments_path(format: "atom") assert_response :success end end context "search action" do should "render" do - get :search + get search_comments_path assert_response :success end end context "show action" do should "render" do - get :show, {:id => @comment.id} + get comment_path(@comment.id) assert_response :success end end context "edit action" do should "render" do - get :edit, {:id => @comment.id}, {:user_id => @user.id} + get_auth edit_comment_path(@comment.id), @user assert_response :success end end @@ -67,13 +67,13 @@ class CommentsControllerTest < ActionController::TestCase context "update action" do context "when updating another user's comment" do should "succeed if updater is a moderator" do - post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @mod.id} + put_auth comment_path(@comment.id), @user, params: {comment: {body: "abc"}} assert_equal("abc", @comment.reload.body) assert_redirected_to post_path(@comment.post) end should "fail if updater is not a moderator" do - post :update, {:id => @mod_comment.id, :comment => {:body => "abc"}}, {:user_id => @user.id} + put_auth comment_path(@mod_comment.id), @user, params: {comment: {body: "abc"}} assert_not_equal("abc", @mod_comment.reload.body) assert_response 403 end @@ -81,51 +81,43 @@ class CommentsControllerTest < ActionController::TestCase context "when stickying a comment" do should "succeed if updater is a moderator" do - CurrentUser.user = @mod - post :update, {:id => @comment.id, :comment => {:is_sticky => true}}, {:user_id => @mod.id} + put_auth comment_path(@comment.id), @mod, params: {comment: {is_sticky: true}} assert_equal(true, @comment.reload.is_sticky) assert_redirected_to @comment.post end should "fail if updater is not a moderator" do - post :update, {:id => @comment.id, :comment => {:is_sticky => true}}, {:user_id => @user.id} + put_auth comment_path(@comment.id), @user, params: {comment: {is_sticky: true}} assert_equal(false, @comment.reload.is_sticky) - assert_redirected_to @comment.post end end should "update the body" do - post :update, {:id => @comment.id, :comment => {:body => "abc"}}, {:user_id => @comment.creator_id} + put_auth comment_path(@comment.id), @comment.creator, params: {comment: {body: "abc"}} assert_equal("abc", @comment.reload.body) assert_redirected_to post_path(@comment.post) end should "allow changing the body and is_deleted" do - params = { - id: @comment.id, - comment: { - body: "herp derp", - do_not_bump_post: true, - is_deleted: true, - post_id: FactoryGirl.create(:post).id, - } - } - - post :update, params, { :user_id => @comment.creator_id } - @comment.reload - - assert_equal("herp derp", @comment.body) - assert_equal(false, @comment.do_not_bump_post) + put_auth comment_path(@comment.id), @comment.creator, params: {comment: {body: "herp derp", is_deleted: true}} + assert_equal("herp derp", @comment.reload.body) assert_equal(true, @comment.is_deleted) - assert_equal(@post.id, @comment.post_id) - assert_redirected_to post_path(@post) end + + should "not allow changing do_not_bump_post or post_id" do + as_user do + @another_post = create(:post) + end + put_auth comment_path(@comment.id), @comment.creator, params: {do_not_bump_post: true, post_id: @another_post.id} + assert_equal(false, @comment.reload.do_not_bump_post) + assert_equal(@post.id, @comment.post_id) + end end context "new action" do should "redirect" do - get :new, {}, {:user_id => @user.id} + get_auth new_comment_path, @user assert_redirected_to comments_path end end @@ -133,31 +125,35 @@ class CommentsControllerTest < ActionController::TestCase context "create action"do should "create a comment" do assert_difference("Comment.count", 1) do - post :create, {:comment => FactoryGirl.attributes_for(:comment, :post_id => @post.id)}, {:user_id => @user.id} + post_auth comments_path, @user, params: {comment: FactoryBot.attributes_for(:comment, post_id: @post.id)} end comment = Comment.last assert_redirected_to post_path(comment.post) end should "not allow commenting on nonexistent posts" do - post :create, {:comment => FactoryGirl.attributes_for(:comment, :post_id => -1)}, {:user_id => @user.id} - assert_response :error + assert_difference("Comment.count", 0) do + post_auth comments_path, @user, params: {comment: FactoryBot.attributes_for(:comment, post_id: -1)} + end + assert_redirected_to comments_path end end context "destroy action" do should "mark comment as deleted" do - delete :destroy, {:id => @comment.id}, {:user_id => @user.id} + delete_auth comment_path(@comment.id), @user assert_equal(true, @comment.reload.is_deleted) assert_redirected_to @comment end end context "undelete action" do + setup do + @comment.delete! + end + should "mark comment as undeleted" do - @comment.delete! - put :undelete, { id: @comment.id }, { user_id: @user.id } - + post_auth undelete_comment_path(@comment.id), @user assert_equal(false, @comment.reload.is_deleted) assert_redirected_to(@comment) end diff --git a/test/functional/counts_controller_test.rb b/test/functional/counts_controller_test.rb index 52fe13113..24c6dad03 100644 --- a/test/functional/counts_controller_test.rb +++ b/test/functional/counts_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class CountsControllerTest < ActionController::TestCase +class CountsControllerTest < ActionDispatch::IntegrationTest context "The counts commentary controller" do context "posts action" do should "render" do - get :posts + get posts_counts_path assert_response :success end end diff --git a/test/functional/delayed_jobs_controller_test.rb b/test/functional/delayed_jobs_controller_test.rb index e3231f4cd..dc320b425 100644 --- a/test/functional/delayed_jobs_controller_test.rb +++ b/test/functional/delayed_jobs_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class DelayedJobsControllerTest < ActionController::TestCase +class DelayedJobsControllerTest < ActionDispatch::IntegrationTest context "The delayed jobs controller" do context "index action" do should "render" do - get :index + get delayed_jobs_path assert_response :success end end diff --git a/test/functional/dmails_controller_test.rb b/test/functional/dmails_controller_test.rb index 1c9c74f0e..8ce02c3b0 100644 --- a/test/functional/dmails_controller_test.rb +++ b/test/functional/dmails_controller_test.rb @@ -1,13 +1,13 @@ require 'test_helper' -class DmailsControllerTest < ActionController::TestCase +class DmailsControllerTest < ActionDispatch::IntegrationTest context "The dmails controller" do setup do - @user = FactoryGirl.create(:user) - @unrelated_user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @dmail = FactoryGirl.create(:dmail, :owner => @user) + @user = create(:user) + @unrelated_user = create(:user) + as_user do + @dmail = create(:dmail, :owner => @user) + end end teardown do @@ -17,55 +17,52 @@ class DmailsControllerTest < ActionController::TestCase context "new action" do should "get the page" do - get :new, {}, {:user_id => @user.id} + get_auth new_dmail_path, @user assert_response :success end context "with a respond_to_id" do should "check privileges" do - @user2 = FactoryGirl.create(:user) - get :new, {:respond_to_id => @dmail}, {:user_id => @user2.id} + @user2 = create(:user) + get_auth new_dmail_path, @user2, params: {:respond_to_id => @dmail.id} assert_response 403 end should "prefill the fields" do - get :new, {:respond_to_id => @dmail}, {:user_id => @user.id} + get_auth new_dmail_path, @user, params: {:respond_to_id => @dmail.id} assert_response :success - assert_not_nil assigns(:dmail) - assert_equal(@dmail.from_id, assigns(:dmail).to_id) end context "and a forward flag" do should "not populate the to field" do - get :new, {:respond_to_id => @dmail, :forward => true}, {:user_id => @user.id} + get_auth new_dmail_path, @user, params: {:respond_to_id => @dmail.id, :forward => true} assert_response :success - assert_not_nil assigns(:dmail) - assert_nil(assigns(:dmail).to_id) end end end end context "index action" do - should "show dmails owned by the current user" do - get :index, {:search => {:owner_id => @dmail.owner_id, :folder => "sent"}}, {:user_id => @dmail.owner_id} + should "show dmails owned by the current user by sent" do + get_auth dmails_path, @user, params: {:search => {:owner_id => @dmail.owner_id, :folder => "sent"}} assert_response :success - assert_equal(1, assigns[:dmails].size) + end - get :index, {:search => {:owner_id => @dmail.owner_id, :folder => "received"}}, {:user_id => @dmail.owner_id} + should "show dmails owned by the current user by received" do + get_auth dmails_path, @user, params: {:search => {:owner_id => @dmail.owner_id, :folder => "received"}} assert_response :success - assert_equal(1, assigns[:dmails].size) end should "not show dmails not owned by the current user" do - get :index, {:search => {:owner_id => @dmail.owner_id}}, {:user_id => @unrelated_user.id} + get_auth dmails_path, @user, params: {:search => {:owner_id => @dmail.owner_id}} assert_response :success - assert_equal(0, assigns[:dmails].size) end should "work for banned users" do - ban = FactoryGirl.create(:ban, :user => @user, :banner => FactoryGirl.create(:admin_user)) - get :index, {:search => {:owner_id => @dmail.owner_id, :folder => "sent"}}, {:user_id => @dmail.owner_id} + as(create(:admin_user)) do + create(:ban, :user => @user) + end + get_auth dmails_path, @dmail.owner, params: {:search => {:owner_id => @dmail.owner_id, :folder => "sent"}} assert_response :success end @@ -73,25 +70,25 @@ class DmailsControllerTest < ActionController::TestCase context "show action" do should "show dmails owned by the current user" do - get :show, {:id => @dmail.id}, {:user_id => @dmail.owner_id} + get_auth dmail_path(@dmail), @dmail.owner assert_response :success end should "not show dmails not owned by the current user" do - get :show, {:id => @dmail.id}, {:user_id => @unrelated_user.id} + get_auth dmail_path(@dmail), @unrelated_user assert_response(403) end end context "create action" do setup do - @user_2 = FactoryGirl.create(:user) + @user_2 = 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 = {:to_id => @user_2.id, :title => "abc", :body => "abc"} - post :create, {:dmail => dmail_attribs}, {:user_id => @user.id} + post_auth dmails_path, @user, params: {:dmail => dmail_attribs} assert_redirected_to dmail_path(Dmail.last) end end @@ -100,14 +97,14 @@ class DmailsControllerTest < ActionController::TestCase context "destroy action" do should "allow deletion if the dmail is owned by the current user" do assert_difference("Dmail.count", -1) do - post :destroy, {:id => @dmail.id}, {:user_id => @dmail.owner_id} + delete_auth dmail_path(@dmail), @user assert_redirected_to dmails_path end end should "not allow deletion if the dmail is not owned by the current user" do assert_difference("Dmail.count", 0) do - post :destroy, {:id => @dmail.id}, {:user_id => @unrelated_user.id} + delete_auth dmail_path(@dmail), @unrelated_user end end end diff --git a/test/functional/dtext_previews_controller_test.rb b/test/functional/dtext_previews_controller_test.rb index 6c4ced596..2d0e8726d 100644 --- a/test/functional/dtext_previews_controller_test.rb +++ b/test/functional/dtext_previews_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class DtextPreviewsControllerTest < ActionController::TestCase +class DtextPreviewsControllerTest < ActionDispatch::IntegrationTest context "The dtext previews controller" do context "create action" do should "render" do - post :create, { body: "h1. Touhou\n\n* [[touhou]]" } + post dtext_preview_path, params: { body: "h1. Touhou\n\n* [[touhou]]" } assert_response :success end end diff --git a/test/functional/explore/posts_controller_test.rb b/test/functional/explore/posts_controller_test.rb index 7d7b6fb1b..2f8a9a861 100644 --- a/test/functional/explore/posts_controller_test.rb +++ b/test/functional/explore/posts_controller_test.rb @@ -1,38 +1,39 @@ require "test_helper" module Explore - class PostsControllerTest < ActionController::TestCase + class PostsControllerTest < ActionDispatch::IntegrationTest context "in all cases" do setup do - CurrentUser.user = FactoryGirl.create(:user) - CurrentUser.ip_addr = "127.0.0.1" - FactoryGirl.create(:post) + @user = create(:user) + as_user do + create(:post) + end end context "#popular" do should "render" do - get :popular + get popular_explore_posts_path assert_response :success end end context "#searches" do should "render" do - get :searches + get searches_explore_posts_path assert_response :success end end context "#missed_searches" do should "render" do - get :missed_searches + get missed_searches_explore_posts_path assert_response :success end end context "#intro" do should "render" do - get :intro + get intro_explore_posts_path assert_response :success end end diff --git a/test/functional/favorite_groups_controller_test.rb b/test/functional/favorite_groups_controller_test.rb index 780ca09ea..36a185d57 100644 --- a/test/functional/favorite_groups_controller_test.rb +++ b/test/functional/favorite_groups_controller_test.rb @@ -1,80 +1,75 @@ require 'test_helper' -class FavoriteGroupsControllerTest < ActionController::TestCase +class FavoriteGroupsControllerTest < ActionDispatch::IntegrationTest context "The favorite groups controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) + as_user do + @favgroup = create(:favorite_group) + end end context "index action" do should "render" do - get :index + get favorite_groups_path assert_response :success end end context "show action" do should "render" do - favgroup = FactoryGirl.create(:favorite_group) - - get :show, { id: favgroup.id } + get favorite_group_path(@favgroup) assert_response :success end end context "new action" do should "render" do - get :new, {}, { user_id: @user.id } + get_auth new_favorite_group_path, @user assert_response :success end end context "create action" do should "render" do - post :create, { favorite_group: FactoryGirl.attributes_for(:favorite_group) }, { user_id: @user.id } + post_auth favorite_groups_path, @user, params: { favorite_group: FactoryBot.attributes_for(:favorite_group) } assert_redirected_to favorite_groups_path end end context "edit action" do should "render" do - favgroup = FactoryGirl.create(:favorite_group, creator: @user) - - get :edit, { id: favgroup.id }, { user_id: @user.id } + get_auth edit_favorite_group_path(@favgroup), @user assert_response :success end end context "update action" do should "render" do - favgroup = FactoryGirl.create(:favorite_group, creator: @user) - params = { id: favgroup.id, favorite_group: { name: "foo" } } - - put :update, params, { user_id: @user.id } - assert_redirected_to favgroup - assert_equal("foo", favgroup.reload.name) + params = { favorite_group: { name: "foo" } } + put_auth favorite_group_path(@favgroup), @user, params: params + assert_redirected_to @favgroup + assert_equal("foo", @favgroup.reload.name) end end context "destroy action" do should "render" do - favgroup = FactoryGirl.create(:favorite_group, creator: @user) - - delete :destroy, { id: favgroup.id }, { user_id: @user.id } + delete_auth favorite_group_path(@favgroup), @user assert_redirected_to favorite_groups_path end end context "add_post action" do should "render" do - favgroup = FactoryGirl.create(:favorite_group, creator: @user) - post = FactoryGirl.create(:post) + as_user do + @post = FactoryBot.create(:post) + end - put :add_post, { id: favgroup.id, post_id: post.id, format: "js" }, { user_id: @user.id } + put_auth add_post_favorite_group_path(@favgroup), @user, params: {post_id: @post.id, format: "js"} assert_response :success - assert_equal([post.id], favgroup.reload.post_id_array) + @favgroup.reload + assert_equal([@post.id], @favgroup.post_id_array) end end end diff --git a/test/functional/favorites_controller_test.rb b/test/functional/favorites_controller_test.rb index c25c73507..cfcfb7f79 100644 --- a/test/functional/favorites_controller_test.rb +++ b/test/functional/favorites_controller_test.rb @@ -1,59 +1,51 @@ require 'test_helper' -class FavoritesControllerTest < ActionController::TestCase +class FavoritesControllerTest < ActionDispatch::IntegrationTest context "The favorites controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) end context "index action" do setup do - @post = FactoryGirl.create(:post) + @post = create(:post) @post.add_favorite!(@user) end context "with a specified tags parameter" do should "redirect to the posts controller" do - get :index, {:tags => "fav:#{@user.name} abc"}, {:user_id => @user} + get_auth favorites_path, @user, params: {:tags => "fav:#{@user.name} abc"} assert_redirected_to(posts_path(:tags => "fav:#{@user.name} abc")) end end should "display the current user's favorites" do - get :index, {}, {:user_id => @user.id} + get_auth favorites_path, @user assert_response :success - assert_not_nil(assigns(:favorite_set)) end end context "create action" do setup do - @post = FactoryGirl.create(:post) + @post = create(:post) end should "create a favorite for the current user" do assert_difference("Favorite.count", 1) do - post :create, {:format => "js", :post_id => @post.id}, {:user_id => @user.id} + post_auth favorites_path, @user, params: {:format => "js", :post_id => @post.id} end end end context "destroy action" do setup do - @post = FactoryGirl.create(:post) + @post = create(:post) @post.add_favorite!(@user) end should "remove the favorite from the current user" do assert_difference("Favorite.count", -1) do - post :destroy, {:format => "js", :id => @post.id}, {:user_id => @user.id} + delete_auth favorite_path(@post.id), @user, params: {:format => "js"} end end end diff --git a/test/functional/forum_posts_controller_test.rb b/test/functional/forum_posts_controller_test.rb index 1a73b2684..5989c84d4 100644 --- a/test/functional/forum_posts_controller_test.rb +++ b/test/functional/forum_posts_controller_test.rb @@ -1,96 +1,91 @@ require 'test_helper' -class ForumPostsControllerTest < ActionController::TestCase +class ForumPostsControllerTest < ActionDispatch::IntegrationTest context "The forum posts controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @other_user = FactoryGirl.create(:user) - @mod = FactoryGirl.create(:moderator_user) - @forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user) - @forum_post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) + @other_user = create(:user) + @mod = create(:moderator_user) + as_user do + @forum_topic = create(:forum_topic, :title => "my forum topic") + @forum_post = create(:forum_post, :topic_id => @forum_topic.id, :body => "xxx") + end end context "index action" do should "list all forum posts" do - get :index + get forum_posts_path assert_response :success end context "with search conditions" do should "list all matching forum posts" do - get :index, {:search => {:body_matches => "xxx"}} + get forum_posts_path, params: {:search => {:body_matches => "xxx"}} assert_response :success - assert_equal(1, assigns(:forum_posts).size) + assert_select "#forum-post-#{@forum_post.id}" end should "list nothing for when the search matches nothing" do - get :index, {:search => {:body_matches => "bababa"}} + get forum_posts_path, params: {:search => {:body_matches => "bababa"}} assert_response :success - assert_equal(0, assigns(:forum_posts).size) + assert_select "#forum-post-#{@forum_post.id}", false end should "list by creator id" do - get :index, {:search => {:creator_id => @user.id}} + get forum_posts_path, params: {:search => {:creator_id => @user.id}} assert_response :success - assert_equal(1, assigns(:forum_posts).size) + assert_select "#forum-post-#{@forum_post.id}" end end context "with private topics" do setup do - CurrentUser.user = @mod - @mod_topic = FactoryGirl.create(:mod_up_forum_topic) - @mod_posts = 2.times.map do - FactoryGirl.create(:forum_post, :topic_id => @mod_topic.id) + as(@mod) do + @mod_topic = create(:mod_up_forum_topic) + @mod_posts = 2.times.map do + create(:forum_post, :topic_id => @mod_topic.id) + end end @mod_post_ids = ([@forum_post] + @mod_posts).map(&:id).reverse end should "list only permitted posts for members" do - CurrentUser.user = @user - get :index, {}, { :user_id => @user.id } + get forum_posts_path assert_response :success - assert_equal([@forum_post.id], assigns(:forum_posts).map(&:id)) + assert_select "#forum-post-#{@forum_post.id}" + assert_select "#forum-post-#{@mod_posts[0].id}", false end should "list only permitted posts for mods" do - CurrentUser.user = @mod - get :index, {}, { :user_id => @mod.id } + get_auth forum_posts_path, @mod assert_response :success - assert_equal(@mod_post_ids, assigns(:forum_posts).map(&:id)) + assert_select "#forum-post-#{@mod_posts[0].id}" end end end context "edit action" do should "render if the editor is the creator of the topic" do - get :edit, {:id => @forum_post.id}, {:user_id => @user.id} + get_auth edit_forum_post_path(@forum_post), @user assert_response :success end should "render if the editor is a moderator" do - get :edit, {:id => @forum_post.id}, {:user_id => @mod.id} + get_auth edit_forum_post_path(@forum_post), @mod assert_response :success end should "fail if the editor is not the creator of the topic and is not a moderator" do - get :edit, {:id => @forum_post.id}, {:user_id => @other_user.id} + get_auth edit_forum_post_path(@forum_post), @other_user assert_response(403) end end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id, :topic_id => @forum_topic.id}, {:user_id => @user.id} + get_auth new_forum_post_path, @user, params: {:topic_id => @forum_topic.id} assert_response :success end end @@ -98,7 +93,7 @@ class ForumPostsControllerTest < ActionController::TestCase context "create action" do should "create a new forum post" do assert_difference("ForumPost.count", 1) do - post :create, {:forum_post => {:body => "xaxaxa", :topic_id => @forum_topic.id}}, {:user_id => @user.id} + post_auth forum_posts_path, @user, params: {:forum_post => {:body => "xaxaxa", :topic_id => @forum_topic.id}} end forum_post = ForumPost.last @@ -108,8 +103,7 @@ class ForumPostsControllerTest < ActionController::TestCase context "destroy action" do should "destroy the posts" do - CurrentUser.user = @mod - post :destroy, {:id => @forum_post.id}, {:user_id => @mod.id} + delete_auth forum_post_path(@forum_post), @mod assert_redirected_to(forum_post_path(@forum_post)) @forum_post.reload assert_equal(true, @forum_post.is_deleted?) @@ -118,12 +112,13 @@ class ForumPostsControllerTest < ActionController::TestCase context "undelete action" do setup do - @forum_post.update_attribute(:is_deleted, true) + as(@mod) do + @forum_post.update(is_deleted: true) + end end should "restore the post" do - CurrentUser.user = @mod - post :undelete, {:id => @forum_post.id}, {:user_id => @mod.id} + post_auth undelete_forum_post_path(@forum_post), @mod assert_redirected_to(forum_post_path(@forum_post)) @forum_post.reload assert_equal(false, @forum_post.is_deleted?) diff --git a/test/functional/forum_topics_controller_test.rb b/test/functional/forum_topics_controller_test.rb index 61d4b6fde..36c33ec75 100644 --- a/test/functional/forum_topics_controller_test.rb +++ b/test/functional/forum_topics_controller_test.rb @@ -1,136 +1,149 @@ require 'test_helper' -class ForumTopicsControllerTest < ActionController::TestCase +class ForumTopicsControllerTest < ActionDispatch::IntegrationTest context "The forum topics controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @other_user = FactoryGirl.create(:user) - @mod = FactoryGirl.create(:moderator_user) - @forum_topic = FactoryGirl.create(:forum_topic, :title => "my forum topic", :creator => @user, :original_post_attributes => {:body => "xxx"}) - end + @user = create(:user) + @other_user = create(:user) + @mod = create(:moderator_user) - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + as_user do + @forum_topic = create(:forum_topic, :title => "my forum topic", :original_post_attributes => {:body => "xxx"}) + end end context "for a level restricted topic" do setup do - CurrentUser.user = @mod - @forum_topic.update_attribute(:min_level, User::Levels::MODERATOR) - CurrentUser.user = @user + as(@mod) do + @forum_topic.update(min_level: User::Levels::MODERATOR) + end end should "not allow users to see the topic" do - get :show, {:id => @forum_topic.id} + get_auth forum_topic_path(@forum_topic), @user assert_redirected_to forum_topics_path end should "not bump the forum for users without access" do - @gold_user = FactoryGirl.create(:gold_user) - CurrentUser.user = @gold_user + @gold_user = create(:gold_user) # An open topic should bump... - @open_topic = FactoryGirl.create(:forum_topic) - assert_equal(true, @gold_user.has_forum_been_updated?) + as(@gold_user) do + @open_topic = create(:forum_topic) + end + @gold_user.reload + as(@gold_user) do + assert(@gold_user.has_forum_been_updated?) + end # Marking it as read should clear it... - CurrentUser.scoped(@gold_user) do - post :mark_all_as_read, {}, {:user_id => @gold_user.id} + as(@gold_user) do + post_auth mark_all_as_read_forum_topics_path, @gold_user end + @gold_user.reload assert_redirected_to(forum_topics_path) - assert_equal(false, @gold_user.reload.has_forum_been_updated?) + as(@gold_user) do + assert(!@gold_user.has_forum_been_updated?) + end # Then adding an unread private topic should not bump. - CurrentUser.scoped(@mod) do - FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id) + as(@mod) do + create(:forum_post, :topic_id => @forum_topic.id) + end + @gold_user.reload + as(@gold_user) do + assert_equal(false, @gold_user.has_forum_been_updated?) end - assert_equal(false, @gold_user.reload.has_forum_been_updated?) end end context "show action" do should "render" do - get :show, {:id => @forum_topic.id} + get forum_topic_path(@forum_topic) assert_response :success end should "record a topic visit for html requests" do - get :show, {id: @forum_topic.id}, {user_id: @user.id} - assert_not_nil(@user.reload.last_forum_read_at) + get_auth forum_topic_path(@forum_topic), @user + @user.reload + assert_not_nil(@user.last_forum_read_at) end should "not record a topic visit for non-html requests" do - get :show, {id: @forum_topic.id, format: :json}, {user_id: @user.id} - assert_nil(@user.reload.last_forum_read_at) + get_auth forum_topic_path(@forum_topic), @user, params: {format: :json} + @user.reload + assert_nil(@user.last_forum_read_at) end should "render for atom feed" do - get :show, {:id => @forum_topic.id, :format => :atom} + get forum_topic_path(@forum_topic), params: {:format => :atom} assert_response :success end end context "index action" do setup do - @topic1 = FactoryGirl.create(:forum_topic, :is_sticky => true, :creator => @user, :original_post_attributes => {:body => "xxx"}) - @topic2 = FactoryGirl.create(:forum_topic, :creator => @user, :original_post_attributes => {:body => "xxx"}) + as_user do + @topic1 = create(:forum_topic, :is_sticky => true, :original_post_attributes => {:body => "xxx"}) + @topic2 = create(:forum_topic, :original_post_attributes => {:body => "xxx"}) + end end should "list all forum topics" do - get :index + get forum_topics_path assert_response :success end should "not list stickied topics first for JSON responses" do - get :index, {format: :json} + get forum_topics_path, params: {format: :json} forum_topics = JSON.parse(response.body) - assert_equal([@topic2.id, @topic1.id, @forum_topic.id], forum_topics.map {|t| t["id"]}) end should "render for atom feed" do - get :index, {:format => :atom} + get forum_topics_path, params: {:format => :atom} assert_response :success end context "with search conditions" do should "list all matching forum topics" do - get :index, {:search => {:title_matches => "forum"}} + get forum_topics_path, params: {:search => {:title_matches => "forum"}} assert_response :success - assert_equal(1, assigns(:forum_topics).size) + assert_select "a.forum-post-link", @forum_topic.title + assert_select "a.forum-post-link", {count: 0, text: @topic1.title} + assert_select "a.forum-post-link", {count: 0, text: @topic2.title} end should "list nothing for when the search matches nothing" do - get :index, {:search => {:title_matches => "bababa"}} + get forum_topics_path, params: {:search => {:title_matches => "bababa"}} assert_response :success - assert_equal(0, assigns(:forum_topics).size) + assert_select "a.forum-post-link", {count: 0, text: @forum_topic.title} + assert_select "a.forum-post-link", {count: 0, text: @topic1.title} + assert_select "a.forum-post-link", {count: 0, text: @topic2.title} end end end context "edit action" do should "render if the editor is the creator of the topic" do - get :edit, {:id => @forum_topic.id}, {:user_id => @user.id} + get_auth edit_forum_topic_path(@forum_topic), @user assert_response :success end should "render if the editor is a moderator" do - get :edit, {:id => @forum_topic.id}, {:user_id => @mod.id} + get_auth edit_forum_topic_path(@forum_topic), @mod assert_response :success end should "fail if the editor is not the creator of the topic and is not a moderator" do - get :edit, {:id => @forum_topic.id}, {:user_id => @other_user.id} + get_auth edit_forum_topic_path(@forum_topic), @other_user assert_response(403) end end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_forum_topic_path, @user assert_response :success end end @@ -138,7 +151,7 @@ class ForumTopicsControllerTest < ActionController::TestCase context "create action" do should "create a new forum topic and post" do assert_difference(["ForumPost.count", "ForumTopic.count"], 1) do - post :create, {:forum_topic => {:title => "bababa", :original_post_attributes => {:body => "xaxaxa"}}}, {:user_id => @user.id} + post_auth forum_topics_path, @user, params: {:forum_topic => {:title => "bababa", :original_post_attributes => {:body => "xaxaxa"}}} end forum_topic = ForumTopic.last @@ -148,29 +161,31 @@ class ForumTopicsControllerTest < ActionController::TestCase context "destroy action" do setup do - @post = FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id) + as_user do + @post = create(:forum_post, :topic_id => @forum_topic.id) + end end should "destroy the topic and any associated posts" do - CurrentUser.user = @mod - post :destroy, {:id => @forum_topic.id}, {:user_id => @mod.id} + delete_auth forum_topic_path(@forum_topic), @mod assert_redirected_to(forum_topic_path(@forum_topic)) @forum_topic.reload - assert_equal(true, @forum_topic.is_deleted?) + assert(@forum_topic.is_deleted?) end end context "undelete action" do setup do - @forum_topic.update_attribute(:is_deleted, true) + as(@mod) do + @forum_topic.update(is_deleted: true) + end end should "restore the topic" do - CurrentUser.user = @mod - post :undelete, {:id => @forum_topic.id}, {:user_id => @mod.id} + post_auth undelete_forum_topic_path(@forum_topic), @mod assert_redirected_to(forum_topic_path(@forum_topic)) @forum_topic.reload - assert_equal(false, @forum_topic.is_deleted?) + assert(!@forum_topic.is_deleted?) end end end diff --git a/test/functional/ip_bans_controller_test.rb b/test/functional/ip_bans_controller_test.rb index f6a30d952..ae35133ed 100644 --- a/test/functional/ip_bans_controller_test.rb +++ b/test/functional/ip_bans_controller_test.rb @@ -1,16 +1,14 @@ require 'test_helper' -class IpBansControllerTest < ActionController::TestCase +class IpBansControllerTest < ActionDispatch::IntegrationTest context "The ip bans controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" + @admin = create(:admin_user) end context "new action" do should "render" do - get :new, {}, {:user_id => @admin.id} + get_auth new_ip_ban_path, @admin assert_response :success end end @@ -18,24 +16,26 @@ class IpBansControllerTest < ActionController::TestCase context "create action" do should "create a new ip ban" do assert_difference("IpBan.count", 1) do - post :create, {:ip_ban => {:ip_addr => "1.2.3.4", :reason => "xyz"}}, {:user_id => @admin.id} + post_auth ip_bans_path, @admin, params: {:ip_ban => {:ip_addr => "1.2.3.4", :reason => "xyz"}} end end end context "index action" do setup do - FactoryGirl.create(:ip_ban) + as(@admin) do + create(:ip_ban) + end end should "render" do - get :index, {}, {:user_id => @admin.id} + get_auth ip_bans_path, @admin assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:ip_addr => "1.2.3.4"}}, {:user_id => @admin.id} + get_auth ip_bans_path, @admin, params: {:search => {:ip_addr => "1.2.3.4"}} assert_response :success end end @@ -43,12 +43,14 @@ class IpBansControllerTest < ActionController::TestCase context "destroy action" do setup do - @ip_ban = FactoryGirl.create(:ip_ban) + as(@admin) do + @ip_ban = create(:ip_ban) + end end should "destroy an ip ban" do assert_difference("IpBan.count", -1) do - post :destroy, {:id => @ip_ban.id, :format => "js"}, {:user_id => @admin.id} + delete_auth ip_ban_path(@ip_ban), @admin, params: {:format => "js"} end end end diff --git a/test/functional/iqdb_queries_controller_test.rb b/test/functional/iqdb_queries_controller_test.rb index c996e8d42..4c488742f 100644 --- a/test/functional/iqdb_queries_controller_test.rb +++ b/test/functional/iqdb_queries_controller_test.rb @@ -1,34 +1,33 @@ require 'test_helper' -class IqdbQueriesControllerTest < ActionController::TestCase +class IqdbQueriesControllerTest < ActionDispatch::IntegrationTest context "The iqdb controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - - @posts = FactoryGirl.create_list(:post, 2) + @user = create(:user) + as_user do + @posts = FactoryBot.create_list(:post, 2) + end mock_iqdb_service! end context "create action" do should "render with a post_id" do mock_iqdb_matches!(@posts[0], @posts) - post :create, { post_id: @posts[0].id, format: "js" }, { user_id: @user.id } - + post_auth iqdb_queries_path, @user, params: { post_id: @posts[0].id, format: "js" } + assert_response :success end should "render with an url" do mock_iqdb_matches!(@posts[0].source, @posts) - post :create, { url: @posts[0].source }, { user_id: @user.id } + post_auth iqdb_queries_path, @user, params: { url: @posts[0].source } assert_response :success end should "render for a json response" do mock_iqdb_matches!(@posts[0].source, @posts) - get :show, { url: @posts[0].source, format: "json" }, { user_id: @user.id } + get_auth iqdb_queries_path, @user, params: { url: @posts[0].source, format: "json" } assert_response :success end diff --git a/test/functional/janitor_trials_controller_test.rb b/test/functional/janitor_trials_controller_test.rb index 25e274d46..49777c2b1 100644 --- a/test/functional/janitor_trials_controller_test.rb +++ b/test/functional/janitor_trials_controller_test.rb @@ -1,21 +1,15 @@ require 'test_helper' -class JanitorTrialsControllerTest < ActionController::TestCase +class JanitorTrialsControllerTest < ActionDispatch::IntegrationTest context "The janitor trials controller" do setup do - @admin = FactoryGirl.create(:admin_user) - @user = FactoryGirl.create(:user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil + @admin = create(:admin_user) + @user = create(:user) end context "new action" do should "render" do - get :new, {}, {:user_id => @admin.id} + get_auth new_janitor_trial_path, @admin assert_response :success end end @@ -23,18 +17,20 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "create action" do should "create a new janitor trial" do assert_difference("JanitorTrial.count", 1) do - post :create, {:janitor_trial => {:user_id => @user.id}}, {:user_id => @admin.id} + post_auth janitor_trials_path, @admin, params: {:janitor_trial => {:user_id => @user.id}} end end end context "promote action" do setup do - @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) + as(@admin) do + @janitor_trial = create(:janitor_trial, :user_id => @user.id) + end end should "promote the janitor trial" do - post :promote, {:id => @janitor_trial.id}, {:user_id => @admin.id} + put_auth promote_janitor_trial_path(@janitor_trial), @admin @user.reload assert(@user.can_approve_posts?) @janitor_trial.reload @@ -44,11 +40,13 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "demote action" do setup do - @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) + as(@admin) do + @janitor_trial = create(:janitor_trial, :user_id => @user.id) + end end should "demote the janitor trial" do - post :demote, {:id => @janitor_trial.id}, {:user_id => @admin.id} + put_auth demote_janitor_trial_path(@janitor_trial), @admin @user.reload assert(!@user.can_approve_posts?) @janitor_trial.reload @@ -58,17 +56,19 @@ class JanitorTrialsControllerTest < ActionController::TestCase context "index action" do setup do - FactoryGirl.create(:janitor_trial) + as(@admin) do + create(:janitor_trial) + end end should "render" do - get :index, {}, {:user_id => @admin.id} + get_auth janitor_trials_path, @admin assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:user_name => @user.name}}, {:user_id => @admin.id} + get_auth janitor_trials_path, @admin, params: {:search => {:user_name => @user.name}} assert_response :success end end diff --git a/test/functional/maintenance/user/api_keys_controller_test.rb b/test/functional/maintenance/user/api_keys_controller_test.rb index ae0a619c0..22c037e70 100644 --- a/test/functional/maintenance/user/api_keys_controller_test.rb +++ b/test/functional/maintenance/user/api_keys_controller_test.rb @@ -2,57 +2,49 @@ require 'test_helper' module Maintenance module User - class ApiKeysControllerTest < ActionController::TestCase - def params(password = "password") - { :user_id => @user.id, :user => { :password => password } } - end - + class ApiKeysControllerTest < ActionDispatch::IntegrationTest context "An api keys controller" do setup do - @user = FactoryGirl.create(:gold_user, :password => "password") - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:gold_user, :password => "password") ApiKey.generate!(@user) end - teardown do - @user.api_key.destroy if @user.api_key - end - context "#show" do should "render" do - get :show, {:user_id => @user.id}, {:user_id => @user.id} + get_auth maintenance_user_api_key_path, @user, params: {user_id: @user.id} assert_response :success end end context "#view" do - context "with an incorrect password" do - should "redirect" do - post :view, params("hunter2"), { :user_id => @user.id } - assert_redirected_to(user_api_key_path(@user)) - end - end - context "with a correct password" do should "succeed" do - post :view, params, { :user_id => @user.id } + post_auth view_maintenance_user_api_key_path(user_id: @user.id), @user, params: {user: {password: "password"}} assert_response :success end - should "generate an API key if the user didn't already have one" do - @user.api_key.destroy + # hard to test this in integrationtest + # context "if the user doesn't already have an api key" do + # setup do + # ::User.any_instance.stubs(:api_key).returns(nil) + # cookies[:user_name] = @user.name + # cookies[:password_hash] = @user.bcrypt_cookie_password_hash + # end - assert_difference("ApiKey.count", 1) do - post :view, params, { :user_id => @user.id } - end + # should "generate one" do + # ApiKey.expects(:generate!) - assert_not_nil(@user.reload.api_key) - end + # assert_difference("ApiKey.count", 1) do + # post view_maintenance_user_api_key_path(user_id: @user.id), params: {user: {password: "password"}} + # end + + # assert_not_nil(@user.reload.api_key) + # end + # end should "not generate another API key if the user already has one" do assert_difference("ApiKey.count", 0) do - post :view, params, { :user_id => @user.id } + post_auth view_maintenance_user_api_key_path(user_id: @user.id), @user, params: {user: {password: "password"}} end end end @@ -61,14 +53,14 @@ module Maintenance context "#update" do should "regenerate the API key" do old_key = @user.api_key - post :update, params, { :user_id => @user.id } + put_auth maintenance_user_api_key_path, @user, params: {user_id: @user.id, user: {password: "password"}} assert_not_equal(old_key.key, @user.reload.api_key.key) end end context "#destroy" do should "delete the API key" do - post :destroy, params, { :user_id => @user.id } + delete_auth maintenance_user_api_key_path, @user, params: {user_id: @user.id, user: {password: "password"}} assert_nil(@user.reload.api_key) end end diff --git a/test/functional/maintenance/user/deletions_controller_test.rb b/test/functional/maintenance/user/deletions_controller_test.rb index e092a268b..a303343e9 100644 --- a/test/functional/maintenance/user/deletions_controller_test.rb +++ b/test/functional/maintenance/user/deletions_controller_test.rb @@ -2,24 +2,22 @@ require "test_helper" module Maintenance module User - class DeletionsControllerTest < ActionController::TestCase + class DeletionsControllerTest < ActionDispatch::IntegrationTest context "in all cases" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) end context "#show" do should "render" do - get :show, {}, {:user_id => @user.id} + get_auth maintenance_user_deletion_path, @user assert_response :success end end context "#destroy" do should "render" do - post :destroy, {:password => "password"}, {:user_id => @user.id} + delete_auth maintenance_user_deletion_path, @user, params: {:password => "password"} assert_redirected_to(posts_path) end end diff --git a/test/functional/maintenance/user/dmail_filters_controller_test.rb b/test/functional/maintenance/user/dmail_filters_controller_test.rb index 43b057d66..2ca6c8b56 100644 --- a/test/functional/maintenance/user/dmail_filters_controller_test.rb +++ b/test/functional/maintenance/user/dmail_filters_controller_test.rb @@ -2,24 +2,21 @@ require "test_helper" module Maintenance module User - class DmailFiltersControllerTest < ActionController::TestCase + class DmailFiltersControllerTest < ActionDispatch::IntegrationTest context "The dmail filters controller" do setup do - @user1 = FactoryGirl.create(:user) - @user2 = FactoryGirl.create(:user) - CurrentUser.user = @user1 - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user1 = create(:user) + @user2 = create(:user) end context "update action" do - should "not allow a user to create a filter belonging to another user" do - @dmail = FactoryGirl.create(:dmail, :owner => @user1) + setup do + as(@user1) do + @dmail = create(:dmail, owner: @user1) + end + end + should "not allow a user to create a filter belonging to another user" do params = { :dmail_id => @dmail.id, :dmail_filter => { @@ -28,10 +25,8 @@ module Maintenance } } - post :update, params, { :user_id => @user1.id } - + put_auth maintenance_user_dmail_filter_path, @user1, params: params assert_not_equal("owned", @user2.reload.dmail_filter.try(&:words)) - assert_redirected_to(@dmail) end end end diff --git a/test/functional/maintenance/user/email_changes_controller_test.rb b/test/functional/maintenance/user/email_changes_controller_test.rb index 647c21c63..0b4c51b3b 100644 --- a/test/functional/maintenance/user/email_changes_controller_test.rb +++ b/test/functional/maintenance/user/email_changes_controller_test.rb @@ -2,17 +2,15 @@ require "test_helper" module Maintenance module User - class EmailChangesControllerTest < ActionController::TestCase + class EmailChangesControllerTest < ActionDispatch::IntegrationTest context "in all cases" do setup do - @user = FactoryGirl.create(:user, :email => "bob@ogres.net") - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user, :email => "bob@ogres.net") end context "#new" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_maintenance_user_email_change_path, @user assert_response :success end end @@ -20,7 +18,7 @@ module Maintenance context "#create" do context "with the correct password" do should "work" do - post :create, {:email_change => {:password => "password", :email => "abc@ogres.net"}}, {:user_id => @user.id} + post_auth maintenance_user_email_change_path, @user, params: {:email_change => {:password => "password", :email => "abc@ogres.net"}} assert_redirected_to(edit_user_path(@user)) @user.reload assert_equal("abc@ogres.net", @user.email) @@ -29,7 +27,7 @@ module Maintenance context "with the incorrect password" do should "not work" do - post :create, {:email_change => {:password => "passwordx", :email => "abc@ogres.net"}}, {:user_id => @user.id} + post_auth maintenance_user_email_change_path, @user, params: {:email_change => {:password => "passwordx", :email => "abc@ogres.net"}} @user.reload assert_equal("bob@ogres.net", @user.email) end diff --git a/test/functional/maintenance/user/login_reminders_controller_test.rb b/test/functional/maintenance/user/login_reminders_controller_test.rb index de0c35356..c7cd8e28c 100644 --- a/test/functional/maintenance/user/login_reminders_controller_test.rb +++ b/test/functional/maintenance/user/login_reminders_controller_test.rb @@ -2,37 +2,28 @@ require "test_helper" module Maintenance module User - class LoginRemindersControllerTest < ActionController::TestCase + class LoginRemindersControllerTest < ActionDispatch::IntegrationTest context "A login reminder controller" do setup do - @user = FactoryGirl.create(:user) - @blank_email_user = FactoryGirl.create(:user, :email => "") - CurrentUser.user = nil - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) + @blank_email_user = create(:user, :email => "") ActionMailer::Base.delivery_method = :test ActionMailer::Base.deliveries.clear end - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end - should "render the new page" do - get :new + get new_maintenance_user_login_reminder_path assert_response :success end should "deliver an email with the login to the user" do - post :create, {:user => {:email => @user.email}} - assert_equal(flash[:notice], "Email sent") + post maintenance_user_login_reminder_path, params: {:user => {:email => @user.email}} assert_equal(1, ActionMailer::Base.deliveries.size) end context "for a user with a blank email" do should "fail" do - post :create, {:user => {:email => ""}} - assert_equal("Email address not found", flash[:notice]) + post maintenance_user_login_reminder_path, params: {:user => {:email => ""}} @blank_email_user.reload assert_equal(@blank_email_user.created_at.to_i, @blank_email_user.updated_at.to_i) assert_equal(0, ActionMailer::Base.deliveries.size) diff --git a/test/functional/maintenance/user/password_resets_controller_test.rb b/test/functional/maintenance/user/password_resets_controller_test.rb index b6be2d84f..e74442935 100644 --- a/test/functional/maintenance/user/password_resets_controller_test.rb +++ b/test/functional/maintenance/user/password_resets_controller_test.rb @@ -2,30 +2,23 @@ require "test_helper" module Maintenance module User - class PasswordResetsControllerTest < ActionController::TestCase + class PasswordResetsControllerTest < ActionDispatch::IntegrationTest context "A password resets controller" do setup do - @user = FactoryGirl.create(:user, :email => "abc@com.net") - CurrentUser.user = nil - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user, :email => "abc@com.net") ActionMailer::Base.delivery_method = :test ActionMailer::Base.deliveries.clear end - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end - should "render the new page" do - get :new + get new_maintenance_user_password_reset_path assert_response :success end context "create action" do context "given invalid parameters" do setup do - post :create, {:nonce => {:email => ""}} + post maintenance_user_password_reset_path, params: {:nonce => {:email => ""}} end should "not create a new nonce" do @@ -43,7 +36,7 @@ module Maintenance context "given valid parameters" do setup do - post :create, {:nonce => {:email => @user.email}} + post maintenance_user_password_reset_path, params: {:nonce => {:email => @user.email}} end should "create a new nonce" do @@ -63,7 +56,7 @@ module Maintenance context "edit action" do context "with invalid parameters" do setup do - get :edit, :email => "a@b.c" + get edit_maintenance_user_password_reset_path, params: {:email => "a@b.c"} end should "succeed silently" do @@ -73,10 +66,10 @@ module Maintenance context "with valid parameters" do setup do - @user = FactoryGirl.create(:user) - @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) + @user = create(:user) + @nonce = create(:user_password_reset_nonce, :email => @user.email) ActionMailer::Base.deliveries.clear - get :edit, :email => @nonce.email, :key => @nonce.key + get edit_maintenance_user_password_reset_path, params: {:email => @nonce.email, :key => @nonce.key} end should "succeed" do @@ -86,23 +79,13 @@ module Maintenance end context "update action" do - context "with invalid parameters" do - setup do - get :update - end - - should "fail" do - assert_redirected_to new_maintenance_user_password_reset_path - end - end - context "with valid parameters" do setup do - @user = FactoryGirl.create(:user) - @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) + @user = create(:user) + @nonce = create(:user_password_reset_nonce, :email => @user.email) ActionMailer::Base.deliveries.clear @old_password = @user.bcrypt_password_hash - post :update, :email => @nonce.email, :key => @nonce.key + put maintenance_user_password_reset_path, params: {:email => @nonce.email, :key => @nonce.key} end should "succeed" do diff --git a/test/functional/meta_searches_controller_test.rb b/test/functional/meta_searches_controller_test.rb index 630cb0607..b776778e4 100644 --- a/test/functional/meta_searches_controller_test.rb +++ b/test/functional/meta_searches_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class MetaSearchesControllerTest < ActionController::TestCase +class MetaSearchesControllerTest < ActionDispatch::IntegrationTest context "The meta searches controller" do context "tags action" do should "work" do - get :tags, { name: "long_hair" } + get meta_searches_tags_path, params: {name: "long_hair"} assert_response :success end end diff --git a/test/functional/mod_actions_controller_test.rb b/test/functional/mod_actions_controller_test.rb index b4b8fcecc..28b156656 100644 --- a/test/functional/mod_actions_controller_test.rb +++ b/test/functional/mod_actions_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class ModActionsControllerTest < ActionController::TestCase +class ModActionsControllerTest < ActionDispatch::IntegrationTest context "The mod actions controller" do context "index action" do should "work" do - get :index + get mod_actions_path assert_response :success end end diff --git a/test/functional/moderator/dashboards_controller_test.rb b/test/functional/moderator/dashboards_controller_test.rb index 6259601e9..c6a62da10 100644 --- a/test/functional/moderator/dashboards_controller_test.rb +++ b/test/functional/moderator/dashboards_controller_test.rb @@ -1,130 +1,141 @@ require 'test_helper' module Moderator - class DashboardsControllerTest < ActionController::TestCase + class DashboardsControllerTest < ActionDispatch::IntegrationTest context "The moderator dashboards controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" + travel_to(1.month.ago) do + @user = create(:gold_user) + end + @admin = create(:admin_user) Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) end context "show action" do context "for mod actions" do setup do - @mod_action = FactoryGirl.create(:mod_action) + as(@admin) do + @mod_action = create(:mod_action) + end end should "render" do - assert_equal(1, ModAction.count) - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for user feedbacks" do setup do - @feedback = FactoryGirl.create(:user_feedback) + as(@user) do + @feedback = create(:user_feedback) + end end should "render" do - assert_equal(1, UserFeedback.count) - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for wiki pages" do setup do - @wiki_page = FactoryGirl.create(:wiki_page) + as(@user) do + @wiki_page = create(:wiki_page) + end end should "render" do - assert_equal(1, WikiPageVersion.count) - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for tags and uploads" do setup do - @post = FactoryGirl.create(:post) + as(@user) do + @post = create(:post) + end end should "render" do - assert_equal(1, PostArchive.count) - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for notes"do setup do - @post = FactoryGirl.create(:post) - @note = FactoryGirl.create(:note, :post_id => @post.id) + as(@user) do + @post = create(:post) + @note = create(:note, :post_id => @post.id) + end end should "render" do - assert_equal(1, NoteVersion.count) - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for comments" do setup do - @users = (0..5).map {FactoryGirl.create(:user)} + @users = (0..5).map {create(:user)} - CurrentUser.scoped(@users[0], "1.2.3.4") do - @comment = FactoryGirl.create(:comment) + CurrentUser.as(@users[0]) do + @comment = create(:comment) end @users.each do |user| - CurrentUser.scoped(user, "1.2.3.4") do + CurrentUser.as(user) do @comment.vote!(-1) end end end should "render" do - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for artists" do setup do - @artist = FactoryGirl.create(:artist) + as(@user) do + @artist = create(:artist) + end end should "render" do - get :show, {}, {:user_id => @admin.id} - assert_equal(1, ArtistVersion.count) + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for flags" do setup do - @post = FactoryGirl.create(:post) - @post.flag!("blah") + as(@user) do + @post = create(:post) + @post.flag!("blah") + end end should "render" do - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end context "for appeals" do setup do - @post = FactoryGirl.create(:post, :is_deleted => true) - @post.appeal!("blah") + as(@user) do + @post = create(:post, :is_deleted => true) + @post.appeal!("blah") + end end should "render" do - get :show, {}, {:user_id => @admin.id} + get_auth moderator_dashboard_path, @admin assert_response :success end end diff --git a/test/functional/moderator/invitations_controller_test.rb b/test/functional/moderator/invitations_controller_test.rb deleted file mode 100644 index 994e83190..000000000 --- a/test/functional/moderator/invitations_controller_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'test_helper' - -module Moderator - class InvitationsControllerTest < ActionController::TestCase - context "The invitations controller" do - setup do - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @mod - CurrentUser.ip_addr = "127.0.0.1" - - @user_1 = FactoryGirl.create(:user) - @user_2 = FactoryGirl.create(:user, :inviter_id => @mod.id) - end - - should "render the new page" do - get :new, {:invitation => {:name => @user_1.name}}, {:user_id => @mod.id} - assert_response :success - end - - should "create a new invite" do - post :create, {:invitation => {:user_id => @user_1.id, :level => User::Levels::BUILDER, :can_upload_free => "1"}}, {:user_id => @mod.id} - assert_redirected_to(moderator_invitations_path) - @user_1.reload - assert_equal(User::Levels::BUILDER, @user_1.level) - assert_equal(true, @user_1.can_upload_free?) - end - - should "list invites" do - get :index, {}, {:user_id => @mod.id} - assert_response :success - end - end - end -end diff --git a/test/functional/moderator/ip_addrs_controller_test.rb b/test/functional/moderator/ip_addrs_controller_test.rb index 70e7ef6b8..2a36592e7 100644 --- a/test/functional/moderator/ip_addrs_controller_test.rb +++ b/test/functional/moderator/ip_addrs_controller_test.rb @@ -1,40 +1,38 @@ require 'test_helper' module Moderator - class IpAddrsControllerTest < ActionController::TestCase + class IpAddrsControllerTest < ActionDispatch::IntegrationTest context "The ip addrs controller" do setup do PoolArchive.delete_all PostArchive.delete_all - @user = FactoryGirl.create(:moderator_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - FactoryGirl.create(:comment) - end + travel_to(1.month.ago) do + @user = create(:moderator_user) + end - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + as_user do + create(:comment) + end end should "find by ip addr" do - get :index, {:search => {:ip_addr => "127.0.0.1"}}, {:user_id => @user.id} + get_auth moderator_ip_addrs_path, @user, params: {:search => {:ip_addr => "127.0.0.1"}} assert_response :success end should "find by user id" do - get :index, {:search => {:user_id => @user.id.to_s}}, {:user_id => @user.id} + get_auth moderator_ip_addrs_path, @user, params: {:search => {:user_id => @user.id.to_s}} assert_response :success end should "find by user name" do - get :index, {:search => {:user_name => @user.name}}, {:user_id => @user.id} + get_auth moderator_ip_addrs_path, @user, params: {:search => {:user_name => @user.name}} assert_response :success end should "render the search page" do - get :search, {}, {:user_id => @user.id} + get_auth search_moderator_ip_addrs_path, @user assert_response :success end end diff --git a/test/functional/moderator/post/approvals_controller_test.rb b/test/functional/moderator/post/approvals_controller_test.rb index a9df343a0..b6aab9fc2 100644 --- a/test/functional/moderator/post/approvals_controller_test.rb +++ b/test/functional/moderator/post/approvals_controller_test.rb @@ -2,19 +2,18 @@ require 'test_helper' module Moderator module Post - class ApprovalsControllerTest < ActionController::TestCase + class ApprovalsControllerTest < ActionDispatch::IntegrationTest context "The moderator post approvals controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - - @post = FactoryGirl.create(:post, :is_pending => true) + @admin = create(:admin_user) + as_admin do + @post = create(:post, :is_pending => true) + end end context "create action" do should "render" do - post :create, {:post_id => @post.id, :format => "js"}, {:user_id => @admin.id} + post_auth moderator_post_approval_path, @admin, params: {:post_id => @post.id, :format => "js"} assert_response :success @post.reload assert(!@post.is_pending?) diff --git a/test/functional/moderator/post/disapprovals_controller_test.rb b/test/functional/moderator/post/disapprovals_controller_test.rb index 5d62a2629..bd7af7f09 100644 --- a/test/functional/moderator/post/disapprovals_controller_test.rb +++ b/test/functional/moderator/post/disapprovals_controller_test.rb @@ -2,20 +2,19 @@ require 'test_helper' module Moderator module Post - class DisapprovalsControllerTest < ActionController::TestCase + class DisapprovalsControllerTest < ActionDispatch::IntegrationTest context "The moderator post disapprovals controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - - @post = FactoryGirl.create(:post, :is_pending => true) + @admin = create(:admin_user) + as_user do + @post = create(:post, :is_pending => true) + end end context "create action" do should "render" do assert_difference("PostDisapproval.count", 1) do - post :create, {:post_id => @post.id, :format => "js"}, {:user_id => @admin.id} + post_auth moderator_post_disapproval_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "js" } end assert_response :success end diff --git a/test/functional/moderator/post/posts_controller_test.rb b/test/functional/moderator/post/posts_controller_test.rb index b7ffd55f6..dc26643ae 100644 --- a/test/functional/moderator/post/posts_controller_test.rb +++ b/test/functional/moderator/post/posts_controller_test.rb @@ -2,44 +2,47 @@ require 'test_helper' module Moderator module Post - class PostsControllerTest < ActionController::TestCase + class PostsControllerTest < ActionDispatch::IntegrationTest context "The moderator posts controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @admin = create(:admin_user) + travel_to(1.month.ago) do + @user = create(:gold_user) + end + + as_user do + @post = create(:post) + end end context "confirm_delete action" do should "render" do - get :confirm_delete, { id: @post.id }, { user_id: @admin.id } + get_auth confirm_delete_moderator_post_post_path(@post), @admin assert_response :success end end context "delete action" do should "render" do - post :delete, {:id => @post.id, :reason => "xxx", :format => "js", :commit => "Delete"}, {:user_id => @admin.id} + post_auth delete_moderator_post_post_path(@post), @admin, params: {:reason => "xxx", :format => "js", :commit => "Delete"} assert(@post.reload.is_deleted?) end should "work even if the deleter has flagged the post previously" do - PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) - post :delete, {:id => @post.id, :reason => "xxx", :format => "js", :commit => "Delete"}, {:user_id => @admin.id} + as_user do + PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) + end + post_auth delete_moderator_post_post_path(@post), @admin, params: {:reason => "xxx", :format => "js", :commit => "Delete"} assert(@post.reload.is_deleted?) end end context "undelete action" do should "render" do - @post.update(is_deleted: true) - post :undelete, {:id => @post.id, :format => "js"}, {:user_id => @admin.id} + as_user do + @post.update(is_deleted: true) + end + post_auth undelete_moderator_post_post_path(@post), @admin, params: {:format => "js"} assert_response :success assert(!@post.reload.is_deleted?) @@ -48,41 +51,38 @@ module Moderator context "confirm_move_favorites action" do should "render" do - get :confirm_move_favorites, { id: @post.id }, { user_id: @admin.id } + get_auth confirm_ban_moderator_post_post_path(@post), @admin assert_response :success end end context "move_favorites action" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" + @admin = create(:admin_user) end - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end + should "render" do + as_user do + @parent = create(:post) + @child = create(:post, parent: @parent) + end + users = FactoryBot.create_list(:user, 2) + users.each do |u| + @child.add_favorite!(u) + end - should "1234 render" do - parent = FactoryGirl.create(:post) - child = FactoryGirl.create(:post, parent: parent) - users = FactoryGirl.create_list(:user, 2) - users.each { |u| child.add_favorite!(u) } - - put :move_favorites, { id: child.id, commit: "Submit" }, { user_id: @admin.id } - - CurrentUser.user = @admin - assert_redirected_to(child) - assert_equal(users, parent.reload.favorited_users) - assert_equal([], child.reload.favorited_users) + post_auth move_favorites_moderator_post_post_path(@child.id), @admin, params: { commit: "Submit" } + assert_redirected_to(@child) + as(@admin) do + assert_equal(users, @parent.reload.favorited_users) + assert_equal([], @child.reload.favorited_users) + end end end context "expunge action" do should "render" do - put :expunge, { id: @post.id, format: "js" }, { user_id: @admin.id } + post_auth expunge_moderator_post_post_path(@post), @admin, params: { format: "js" } assert_response :success assert_equal(false, ::Post.exists?(@post.id)) @@ -91,14 +91,14 @@ module Moderator context "confirm_ban action" do should "render" do - get :confirm_ban, { id: @post.id }, { user_id: @admin.id } + get_auth confirm_ban_moderator_post_post_path(@post), @admin assert_response :success end end context "ban action" do should "render" do - put :ban, { id: @post.id, commit: "Ban", format: "js" }, { user_id: @admin.id } + post_auth ban_moderator_post_post_path(@post), @admin, params: { commit: "Ban", format: "js" } assert_response :success assert_equal(true, @post.reload.is_banned?) @@ -108,7 +108,7 @@ module Moderator context "unban action" do should "render" do @post.ban! - put :unban, { id: @post.id, format: "js" }, { user_id: @admin.id } + post_auth unban_moderator_post_post_path(@post), @admin, params: { format: "js" } assert_redirected_to(@post) assert_equal(false, @post.reload.is_banned?) diff --git a/test/functional/moderator/post/queues_controller_test.rb b/test/functional/moderator/post/queues_controller_test.rb index f7dde5edf..52b194bf5 100644 --- a/test/functional/moderator/post/queues_controller_test.rb +++ b/test/functional/moderator/post/queues_controller_test.rb @@ -2,26 +2,26 @@ require 'test_helper' module Moderator module Post - class QueuesControllerTest < ActionController::TestCase + class QueuesControllerTest < ActionDispatch::IntegrationTest context "The moderator post queues controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - - @post = FactoryGirl.create(:post, :is_pending => true) + @admin = create(:admin_user) + @user = create(:user) + as_user do + @post = create(:post, :is_pending => true) + end end context "show action" do should "render" do - get :show, {}, {:user_id => @admin.id} + get_auth moderator_post_queue_path, @admin assert_response :success end end context "random action" do should "render" do - get :random, {}, {:user_id => @admin.id} + get_auth moderator_post_queue_path, @admin assert_response :success end end diff --git a/test/functional/moderator/tags_controller_test.rb b/test/functional/moderator/tags_controller_test.rb index 41e4484f6..925439601 100644 --- a/test/functional/moderator/tags_controller_test.rb +++ b/test/functional/moderator/tags_controller_test.rb @@ -1,27 +1,27 @@ require 'test_helper' module Moderator - class TagsControllerTest < ActionController::TestCase + class TagsControllerTest < ActionDispatch::IntegrationTest context "The tags controller" do setup do - @user = FactoryGirl.create(:moderator_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) + @user = create(:moderator_user) + as_user do + @post = create(:post) + end end should "render the edit action" do - get :edit, {}, {:user_id => @user.id} + get_auth edit_moderator_tag_path, @user assert_response :success end should "execute the update action" do - post :update, {:tag => {:predicate => "aaa", :consequent => "bbb"}}, {:user_id => @user.id} + put_auth moderator_tag_path, @user, params: {:tag => {:predicate => "aaa", :consequent => "bbb"}} assert_redirected_to edit_moderator_tag_path end should "fail gracefully if the update action fails" do - post :update, {:tag => {:predicate => "", :consequent => "bbb"}}, {:user_id => @user.id} + put_auth moderator_tag_path, @user, params: {:tag => {:predicate => "", :consequent => "bbb"}} assert_redirected_to edit_moderator_tag_path end end diff --git a/test/functional/news_updates_controller_test.rb b/test/functional/news_updates_controller_test.rb index d6ca95299..4c26d109d 100644 --- a/test/functional/news_updates_controller_test.rb +++ b/test/functional/news_updates_controller_test.rb @@ -1,58 +1,57 @@ require 'test_helper' -class NewsUpdatesControllerTest < ActionController::TestCase +class NewsUpdatesControllerTest < ActionDispatch::IntegrationTest context "the news updates controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - @news_update = FactoryGirl.create(:news_update) - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @admin = create(:admin_user) + as(@admin) do + @news_update = create(:news_update) + end end context "index action" do should "render" do - get :index, {}, :user_id => @admin.id + get_auth news_updates_path, @admin assert_response :success end end context "new action" do should "render" do - get :new, {}, :user_id => @admin.id + get_auth new_news_update_path, @admin assert_response :success end end context "edit action" do should "render" do - get :edit, {:id => @news_update.id}, {:user_id => @admin.id} + get_auth edit_news_update_path(@news_update), @admin assert_response :success end end context "update action" do should "work" do - post :update, {:id => @news_update.id, :news_update => {:message => "zzz"}}, {:user_id => @admin.id} + put_auth news_update_path(@news_update), @admin, params: {:news_update => {:message => "zzz"}} assert_redirected_to(news_updates_path) end end context "create action" do should "work" do - post :create, {:news_update => {:message => "zzz"}}, {:user_id => @admin.id} + assert_difference("NewsUpdate.count") do + post_auth news_updates_path, @admin, params: {:news_update => {:message => "zzz"}} + end assert_redirected_to(news_updates_path) end end context "destroy action" do should "work" do - post :destroy, {:id => @news_update.id, :format => "js"}, {:user_id => @admin.id} - assert_response :success + assert_difference("NewsUpdate.count", -1) do + delete_auth news_update_path(@news_update), @admin + end + assert_redirected_to(news_updates_path) end end end diff --git a/test/functional/note_previews_controller_test.rb b/test/functional/note_previews_controller_test.rb index 1a8016945..5558f334d 100644 --- a/test/functional/note_previews_controller_test.rb +++ b/test/functional/note_previews_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class NotePreviewsControllerTest < ActionController::TestCase +class NotePreviewsControllerTest < ActionDispatch::IntegrationTest context "The note previews controller" do context "show action" do should "work" do - get :show, { body: "test", format: "json" } + get note_previews_path, params: { body: "test", format: "json" } assert_response :success end end diff --git a/test/functional/note_versions_controller_test.rb b/test/functional/note_versions_controller_test.rb index 89dd9d12c..96b883c03 100644 --- a/test/functional/note_versions_controller_test.rb +++ b/test/functional/note_versions_controller_test.rb @@ -1,22 +1,17 @@ require 'test_helper' -class NoteVersionsControllerTest < ActionController::TestCase +class NoteVersionsControllerTest < ActionDispatch::IntegrationTest context "The note versions controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) end context "index action" do setup do - @note = FactoryGirl.create(:note) - @user_2 = FactoryGirl.create(:user) + as_user do + @note = create(:note) + end + @user_2 = create(:user) CurrentUser.scoped(@user_2, "1.2.3.4") do @note.update_attributes(:body => "1 2") @@ -28,17 +23,13 @@ class NoteVersionsControllerTest < ActionController::TestCase end should "list all versions" do - get :index + get note_versions_path assert_response :success - assert_not_nil(assigns(:note_versions)) - assert_equal(3, assigns(:note_versions).size) end should "list all versions that match the search criteria" do - get :index, {:search => {:updater_id => @user_2.id}} + get note_versions_path, params: {:search => {:updater_id => @user_2.id}} assert_response :success - assert_not_nil(assigns(:note_versions)) - assert_equal(1, assigns(:note_versions).size) end end end diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index a0e46ac88..95bf7c487 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -1,21 +1,17 @@ require 'test_helper' -class NotesControllerTest < ActionController::TestCase +class NotesControllerTest < ActionDispatch::IntegrationTest context "The notes controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @note = FactoryGirl.create(:note, body: "000") - end - - teardown do - CurrentUser.user = nil + @user = create(:user) + as_user do + @note = create(:note, body: "000") + end end context "index action" do should "list all notes" do - get :index + get notes_path assert_response :success end @@ -32,14 +28,14 @@ class NotesControllerTest < ActionController::TestCase } } - get :index, params + get notes_path, params: params assert_response :success end end context "show action" do should "render" do - get :show, { id: @note.id, format: "json" } + get note_path(@note), params: { format: "json" } assert_response :success end end @@ -47,53 +43,58 @@ class NotesControllerTest < ActionController::TestCase context "create action" do should "create a note" do assert_difference("Note.count", 1) do - @post = FactoryGirl.create(:post) - post :create, {:note => {:x => 0, :y => 0, :width => 10, :height => 10, :body => "abc", :post_id => @post.id}, :format => :json}, {:user_id => @user.id} + as_user do + @post = create(:post) + end + post_auth notes_path, @user, params: {:note => {:x => 0, :y => 0, :width => 10, :height => 10, :body => "abc", :post_id => @post.id}, :format => :json} end end end context "update action" do should "update a note" do - post :update, {:id => @note.id, :note => {:body => "xyz"}}, {:user_id => @user.id} + put_auth note_path(@note), @user, params: {:note => {:body => "xyz"}} assert_equal("xyz", @note.reload.body) end should "not allow changing the post id to another post" do - @other = FactoryGirl.create(:post) - post :update, {:format => "json", :id => @note.id, :note => {:post_id => @other.id}}, {:user_id => @user.id} - + as(@admin) do + @other = create(:post) + end + put_auth note_path(@note), @user, params: {:format => "json", :id => @note.id, :note => {:post_id => @other.id}} assert_not_equal(@other.id, @note.reload.post_id) end end context "destroy action" do should "destroy a note" do - post :destroy, {:id => @note.id}, {:user_id => @user.id} + delete_auth note_path(@note), @user assert_equal(false, @note.reload.is_active?) end end context "revert action" do setup do - Timecop.travel(1.day.from_now) do - @note.update_attributes(:body => "111") - end - Timecop.travel(2.days.from_now) do - @note.update_attributes(:body => "222") + as_user do + travel_to(1.day.from_now) do + @note.update(:body => "111") + end + travel_to(2.days.from_now) do + @note.update(:body => "222") + end end end should "revert to a previous version" do - post :revert, {:id => @note.id, :version_id => @note.versions(true).first.id}, {:user_id => @user.id} + put_auth revert_note_path(@note), @user, params: {:version_id => @note.versions.first.id} assert_equal("000", @note.reload.body) end should "not allow reverting to a previous version of another note" do - @note2 = FactoryGirl.create(:note, :body => "note 2") - - post :revert, { :id => @note.id, :version_id => @note2.versions(true).first.id }, {:user_id => @user.id} - + as_user do + @note2 = create(:note, :body => "note 2") + end + put_auth revert_note_path(@note), @user, params: { :version_id => @note2.versions.first.id } assert_not_equal(@note.reload.body, @note2.body) assert_response :missing end diff --git a/test/functional/pool_elements_controller_test.rb b/test/functional/pool_elements_controller_test.rb index d9e05ce8d..e9d2d2462 100644 --- a/test/functional/pool_elements_controller_test.rb +++ b/test/functional/pool_elements_controller_test.rb @@ -1,33 +1,32 @@ require 'test_helper' -class PoolElementsControllerTest < ActionController::TestCase +class PoolElementsControllerTest < ActionDispatch::IntegrationTest context "The pools posts controller" do setup do mock_pool_archive_service! start_pool_archive_transaction - @user = Timecop.travel(1.month.ago) {FactoryGirl.create(:user)} - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) - @pool = FactoryGirl.create(:pool, :name => "abc") + @user = travel_to(1.month.ago) {create(:user)} + @mod = create(:moderator_user) + as_user do + @post = create(:post) + @pool = create(:pool, :name => "abc") + end end teardown do rollback_pool_archive_transaction - CurrentUser.user = nil end context "create action" do should "add a post to a pool" do - post :create, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id} + post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"} @pool.reload assert_equal([@post.id], @pool.post_id_array) end should "add a post to a pool once and only once" do @pool.add!(@post) - post :create, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id} + post_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"} @pool.reload assert_equal([@post.id], @pool.post_id_array) end @@ -39,14 +38,16 @@ class PoolElementsControllerTest < ActionController::TestCase end should "remove a post from a pool" do - post :destroy, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id} + delete_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"} @pool.reload assert_equal([], @pool.post_id_array) end should "do nothing if the post is not a member of the pool" do - @pool.remove!(@post) - post :destroy, {:pool_id => @pool.id, :post_id => @post.id, :format => "json"}, {:user_id => @user.id} + as_user do + @pool.remove!(@post) + end + delete_auth pool_element_path, @user, params: {:pool_id => @pool.id, :post_id => @post.id, :format => "json"} @pool.reload assert_equal([], @pool.post_id_array) end diff --git a/test/functional/pool_versions_controller_test.rb b/test/functional/pool_versions_controller_test.rb index 049c1d43e..3925efdba 100644 --- a/test/functional/pool_versions_controller_test.rb +++ b/test/functional/pool_versions_controller_test.rb @@ -1,48 +1,50 @@ require 'test_helper' -class PoolVersionsControllerTest < ActionController::TestCase +class PoolVersionsControllerTest < ActionDispatch::IntegrationTest context "The pool versions controller" do setup do mock_pool_archive_service! start_pool_archive_transaction - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) end teardown do rollback_pool_archive_transaction - CurrentUser.user = nil - CurrentUser.ip_addr = nil end context "index action" do setup do - @pool = FactoryGirl.create(:pool) - @user_2 = FactoryGirl.create(:user) - @user_3 = FactoryGirl.create(:user) + as_user do + @pool = create(:pool) + end + @user_2 = create(:user) + @user_3 = create(:user) CurrentUser.scoped(@user_2, "1.2.3.4") do - @pool.update_attributes(:post_ids => "1 2") + @pool.update(:post_ids => "1 2") end CurrentUser.scoped(@user_3, "5.6.7.8") do - @pool.update_attributes(:post_ids => "1 2 3 4") + @pool.update(:post_ids => "1 2 3 4") end + + @versions = @pool.versions end should "list all versions" do - get :index + get pool_versions_path assert_response :success - assert_not_nil(assigns(:pool_versions)) - assert_equal(3, assigns(:pool_versions).size) + assert_select "#pool-version-#{@versions[0].id}" + assert_select "#pool-version-#{@versions[1].id}" + assert_select "#pool-version-#{@versions[2].id}" end should "list all versions that match the search criteria" do - get :index, {:search => {:updater_id => @user_2.id}} + get pool_versions_path, params: {:search => {:updater_id => @user_2.id}} assert_response :success - assert_not_nil(assigns(:pool_versions)) - assert_equal(1, assigns(:pool_versions).size) + assert_select "#pool-version-#{@versions[0].id}", false + assert_select "#pool-version-#{@versions[1].id}" + assert_select "#pool-version-#{@versions[2].id}", false end end end diff --git a/test/functional/pools_controller_test.rb b/test/functional/pools_controller_test.rb index 93d11fe9c..8dd42b181 100644 --- a/test/functional/pools_controller_test.rb +++ b/test/functional/pools_controller_test.rb @@ -1,63 +1,55 @@ require 'test_helper' -class PoolsControllerTest < ActionController::TestCase +class PoolsControllerTest < ActionDispatch::IntegrationTest context "The pools controller" do setup do - Timecop.travel(1.month.ago) do - @user = FactoryGirl.create(:user) - @mod = FactoryGirl.create(:moderator_user) - end - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) mock_pool_archive_service! PoolArchive.sqs_service.stubs(:merge?).returns(false) start_pool_archive_transaction + + travel_to(1.month.ago) do + @user = create(:user) + @mod = create(:moderator_user) + end + as_user do + @post = create(:post) + @pool = create(:pool) + end end teardown do rollback_pool_archive_transaction - CurrentUser.user = nil end context "index action" do - setup do - FactoryGirl.create(:pool, :name => "abc") - end - should "list all pools" do - get :index + get pools_path assert_response :success end should "list all pools (with search)" do - get :index, {:search => {:name_matches => "abc"}} + get pools_path, params: {:search => {:name_matches => @pool.name}} assert_response :success end end context "show action" do - setup do - @pool = FactoryGirl.create(:pool) - end - should "render" do - get :show, {:id => @pool.id} + get pool_path(@pool) assert_response :success end end context "gallery action" do should "render" do - pool = FactoryGirl.create(:pool) - get :gallery, {:id => pool.id} + get gallery_pools_path assert_response :success end end context "new action" do should "render" do - get :new, {}, { user_id: @user.id } + get_auth new_pool_path, @user assert_response :success end end @@ -65,39 +57,35 @@ class PoolsControllerTest < ActionController::TestCase context "create action" do should "create a pool" do assert_difference("Pool.count", 1) do - post :create, {:pool => {:name => "xxx", :description => "abc"}}, {:user_id => @user.id} + post_auth pools_path, @user, params: {:pool => {:name => "xxx", :description => "abc"}} end end end context "edit action" do should "render" do - pool = FactoryGirl.create(:pool) - - get :edit, { id: pool.id }, { user_id: @user.id } + get_auth edit_pool_path(@pool), @user assert_response :success end end context "update action" do - setup do - @pool = FactoryGirl.create(:pool) + should "update a pool" do + put_auth pool_path(@pool), @user, params: { pool: { name: "xyz", post_ids: @post.id.to_s }} + assert_equal("xyz", @pool.reload.name) + assert_equal(@post.id.to_s, @pool.post_ids) end - should "update a pool" do - post :update, {:id => @pool.id, :pool => {:name => "xyz"}}, {:user_id => @user.id} - @pool.reload - assert_equal("xyz", @pool.name) + should "not allow updating unpermitted attributes" do + put_auth pool_path(@pool), @user, params: { pool: { is_deleted: true, post_count: -42 }} + assert_equal(false, @pool.reload.is_deleted?) + assert_equal(0, @pool.post_count) end end context "destroy action" do - setup do - @pool = FactoryGirl.create(:pool) - end - should "destroy a pool" do - post :destroy, {:id => @pool.id}, {:user_id => @mod.id} + delete_auth pool_path(@pool), @mod @pool.reload assert_equal(true, @pool.is_deleted?) end @@ -105,13 +93,14 @@ class PoolsControllerTest < ActionController::TestCase context "undelete action" do setup do - @pool = FactoryGirl.create(:pool) - @pool.is_deleted = true - @pool.save + as(@mod) do + @pool.is_deleted = true + @pool.save + end end should "restore a pool" do - post :undelete, {:id => @pool.id}, {:user_id => @mod.id} + post_auth undelete_pool_path(@pool), @mod @pool.reload assert_equal(false, @pool.is_deleted?) end @@ -119,28 +108,30 @@ class PoolsControllerTest < ActionController::TestCase context "revert action" do setup do - @post_2 = FactoryGirl.create(:post) - @pool = FactoryGirl.create(:pool, :post_ids => "#{@post.id}") - 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}") - CurrentUser.ip_addr = "127.0.0.1" + as_user do + @post_2 = create(:post) + @pool = create(:pool, :post_ids => "#{@post.id}") + end + CurrentUser.scoped(@user, "1.2.3.4") do + @pool.update(:post_ids => "#{@post.id} #{@post_2.id}") + end end should "revert to a previous version" do @pool.reload version = @pool.versions.first assert_equal([@post.id], version.post_ids) - post :revert, {:id => @pool.id, :version_id => version.id}, {:user_id => @mod.id} + put_auth revert_pool_path(@pool), @mod, params: {:version_id => version.id} @pool.reload assert_equal([@post.id], @pool.post_id_array) end should "not allow reverting to a previous version of another pool" do - @pool2 = FactoryGirl.create(:pool) - - post :revert, { :id => @pool.id, :version_id => @pool2.versions.first.id }, {:user_id => @user.id} + as_user do + @pool2 = create(:pool) + end + put_auth revert_pool_path(@pool), @user, params: {:version_id => @pool2.versions.first.id } @pool.reload - assert_not_equal(@pool.name, @pool2.name) assert_response :missing end diff --git a/test/functional/post_appeals_controller_test.rb b/test/functional/post_appeals_controller_test.rb index 66b685d35..2bf362a07 100644 --- a/test/functional/post_appeals_controller_test.rb +++ b/test/functional/post_appeals_controller_test.rb @@ -1,39 +1,34 @@ require 'test_helper' -class PostAppealsControllerTest < ActionController::TestCase +class PostAppealsControllerTest < ActionDispatch::IntegrationTest context "The post appeals controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_post_appeal_path, @user assert_response :success end end context "index action" do setup do - @post = FactoryGirl.create(:post, :is_deleted => true) - @post_appeal = FactoryGirl.create(:post_appeal, :post => @post) + as_user do + @post = create(:post, :is_deleted => true) + @post_appeal = create(:post_appeal, :post => @post) + end end should "render" do - get :index, {}, {:user_id => @user.id} + get_auth post_appeals_path, @user assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:post_id => @post_appeal.post_id}}, {:user_id => @user.id} + get_auth post_appeals_path, @user, params: {:search => {:post_id => @post_appeal.post_id}} assert_response :success end end @@ -41,14 +36,15 @@ class PostAppealsControllerTest < ActionController::TestCase context "create action" do setup do - @post = FactoryGirl.create(:post, :is_deleted => true) + as_user do + @post = create(:post, :is_deleted => true) + end end should "create a new appeal" do assert_difference("PostAppeal.count", 1) do - post :create, {:format => "js", :post_appeal => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id} - assert_not_nil(assigns(:post_appeal)) - assert_equal([], assigns(:post_appeal).errors.full_messages) + post_auth post_appeals_path, @user, params: {:format => "js", :post_appeal => {:post_id => @post.id, :reason => "xxx"}} + assert_response :success end end end diff --git a/test/functional/post_events_controller_test.rb b/test/functional/post_events_controller_test.rb index 0129198b2..d8805fbff 100644 --- a/test/functional/post_events_controller_test.rb +++ b/test/functional/post_events_controller_test.rb @@ -1,41 +1,34 @@ require 'test_helper' -class PostEventsControllerTest < ActionController::TestCase - def setup - super - - Timecop.travel(2.weeks.ago) do - CurrentUser.user = FactoryGirl.create(:user) - CurrentUser.ip_addr = "127.0.0.1" +class PostEventsControllerTest < ActionDispatch::IntegrationTest + setup do + travel_to(2.weeks.ago) do + @user = create(:user) + @mod = create(:mod_user) end - @post = FactoryGirl.create(:post) - @post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) - @post_appeal = PostAppeal.create(:post => @post, :reason => "aaa") + as_user do + @post = create(:post) + @post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) + @post_appeal = PostAppeal.create(:post => @post, :reason => "aaa") + end end - def teardown - super - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end - - context "GET /posts/:post_id/events" do + context "get /posts/:post_id/events" do should "render" do - get :index, {:post_id => @post.id}, {:user_id => CurrentUser.user.id} + get_auth post_events_path(post_id: @post.id), @user assert_response :ok end should "render for mods" do - get :index, {:post_id => @post.id}, {:user_id => FactoryGirl.create(:moderator_user).id } + get_auth post_events_path(post_id: @post.id), @mod assert_response :success end end - context "GET /posts/:post_id/events.xml" do + context "get /posts/:post_id/events.xml" do setup do - get :index, {:post_id => @post.id, :format => :xml}, {:user_id => CurrentUser.user.id} - + get_auth post_events_path(post_id: @post.id), @user, params: {:format => "xml"} @xml = Hash.from_xml(response.body) @appeal = @xml["post_events"].find { |e| e["type"] == "a" } end diff --git a/test/functional/post_flags_controller_test.rb b/test/functional/post_flags_controller_test.rb index d8e48588a..2125180ec 100644 --- a/test/functional/post_flags_controller_test.rb +++ b/test/functional/post_flags_controller_test.rb @@ -1,41 +1,36 @@ require 'test_helper' -class PostFlagsControllerTest < ActionController::TestCase +class PostFlagsControllerTest < ActionDispatch::IntegrationTest context "The post flags controller" do setup do - Timecop.travel(2.weeks.ago) do - @user = FactoryGirl.create(:user) + travel_to(2.weeks.ago) do + @user = create(:user) end - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_post_flag_path, @user assert_response :success end end context "index action" do setup do - @post = FactoryGirl.create(:post) - @post_flag = FactoryGirl.create(:post_flag, :post => @post) + @user.as_current do + @post = create(:post) + @post_flag = create(:post_flag, :post => @post) + end end should "render" do - get :index, {}, {:user_id => @user.id} + get_auth post_flags_path, @user assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:post_id => @post_flag.post_id}}, {:user_id => @user.id} + get_auth post_flags_path, @user, params: {:search => {:post_id => @post_flag.post_id}} assert_response :success end end @@ -43,14 +38,16 @@ class PostFlagsControllerTest < ActionController::TestCase context "create action" do setup do - @post = FactoryGirl.create(:post) + @user.as_current do + @post = create(:post) + end end should "create a new flag" do assert_difference("PostFlag.count", 1) do - post :create, {:format => "js", :post_flag => {:post_id => @post.id, :reason => "xxx"}}, {:user_id => @user.id} - assert_not_nil(assigns(:post_flag)) - assert_equal([], assigns(:post_flag).errors.full_messages) + assert_difference("PostFlag.count") do + post_auth post_flags_path, @user, params: {:format => "js", :post_flag => {:post_id => @post.id, :reason => "xxx"}} + end end end end diff --git a/test/functional/post_replacements_controller_test.rb b/test/functional/post_replacements_controller_test.rb index 5944215de..1ef51801f 100644 --- a/test/functional/post_replacements_controller_test.rb +++ b/test/functional/post_replacements_controller_test.rb @@ -1,16 +1,15 @@ require 'test_helper' -class PostReplacementsControllerTest < ActionController::TestCase +class PostReplacementsControllerTest < ActionDispatch::IntegrationTest context "The post replacements controller" do setup do Delayed::Worker.delay_jobs = true # don't delete the old images right away - @user = FactoryGirl.create(:moderator_user, can_approve_posts: true, created_at: 1.month.ago) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - - @post = FactoryGirl.create(:post) - @post_replacement = FactoryGirl.create(:post_replacement, post_id: @post.id) + @user = create(:moderator_user, can_approve_posts: true, created_at: 1.month.ago) + @user.as_current do + @post = create(:post) + @post_replacement = create(:post_replacement, post: @post) + end end teardown do @@ -27,12 +26,12 @@ class PostReplacementsControllerTest < ActionController::TestCase } } - assert_difference("@post.replacements.size") do - post :create, params, { user_id: @user.id } + assert_difference(lambda { @post.replacements.size }) do + post_auth post_replacements_path, @user, params: params @post.reload end - Timecop.travel(Time.now + PostReplacement::DELETION_GRACE_PERIOD + 1.day) do + travel_to(Time.now + PostReplacement::DELETION_GRACE_PERIOD + 1.day) do Delayed::Worker.new.work_off end @@ -54,9 +53,8 @@ class PostReplacementsControllerTest < ActionController::TestCase } } - put :update, params, { user_id: @user.id } + put_auth post_replacement_path(@post_replacement), @user, params: params @post_replacement.reload - assert_equal(23, @post_replacement.file_size_was) assert_equal(42, @post_replacement.file_size) end @@ -64,7 +62,7 @@ class PostReplacementsControllerTest < ActionController::TestCase context "index action" do should "render" do - get :index, {format: :json} + get post_replacements_path, params: {format: "json"} assert_response :success end end diff --git a/test/functional/post_versions_controller_test.rb b/test/functional/post_versions_controller_test.rb index 005e0a038..824f185aa 100644 --- a/test/functional/post_versions_controller_test.rb +++ b/test/functional/post_versions_controller_test.rb @@ -1,39 +1,38 @@ require 'test_helper' -class PostVersionsControllerTest < ActionController::TestCase - def setup - super - - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - def teardown - super - - CurrentUser.user = nil - CurrentUser.ip_addr = nil +class PostVersionsControllerTest < ActionDispatch::IntegrationTest + setup do + @user = create(:user) end context "The post versions controller" do context "index action" do - setup do - @post = FactoryGirl.create(:post) - @post.update_attributes(:tag_string => "1 2", :source => "xxx") - @post.update_attributes(:tag_string => "2 3", :rating => "e") + setup do + @user.as_current do + @post = create(:post) + travel_to(2.hours.from_now) do + @post.update(:tag_string => "1 2", :source => "xxx") + end + travel_to(4.hours.from_now) do + @post.update(:tag_string => "2 3", :rating => "e") + end + @versions = @post.versions + @post2 = create(:post) + end end should "list all versions" do - get :index, {}, {:user_id => @user.id} + get_auth post_versions_path, @user assert_response :success - assert_not_nil(assigns(:post_versions)) + assert_select "#post-version-#{@versions[0].id}" + assert_select "#post-version-#{@versions[1].id}" + assert_select "#post-version-#{@versions[2].id}" end should "list all versions that match the search criteria" do - get :index, {:search => {:post_id => @post.id}}, {:user_id => @user.id} + get_auth post_versions_path, @user, params: {:search => {:post_id => @post.id}} assert_response :success - assert_not_nil(assigns(:post_versions)) + assert_select "#post-version-#{@post2.versions[0].id}", false end end end diff --git a/test/functional/post_votes_controller_test.rb b/test/functional/post_votes_controller_test.rb index 020ea8496..d0930a489 100644 --- a/test/functional/post_votes_controller_test.rb +++ b/test/functional/post_votes_controller_test.rb @@ -1,71 +1,52 @@ require 'test_helper' -class PostVotesControllerTest < ActionController::TestCase +class PostVotesControllerTest < ActionDispatch::IntegrationTest context "The post vote controller" do setup do - @user = FactoryGirl.create(:gold_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:gold_user) + @user.as_current do + @post = create(:post) + end end context "create action" do should "not allow anonymous users to vote" do - p1 = FactoryGirl.create(:post) - post :create, {:post_id => p1.id, :score => "up", :format => "js"} - + post post_votes_path(post_id: @post.id), params: {:score => "up", :format => "js"} assert_response 403 - assert_equal(0, p1.reload.score) + assert_equal(0, @post.reload.score) end should "not allow banned users to vote" do - CurrentUser.scoped(FactoryGirl.create(:banned_user)) do - p1 = FactoryGirl.create(:post) - post :create, {:post_id => p1.id, :score => "up", :format => "js"}, {:user_id => CurrentUser.id} - - assert_response 403 - assert_equal(0, p1.reload.score) - end + @banned = create(:banned_user) + post_auth post_votes_path(post_id: @post.id), @banned, params: {:score => "up", :format => "js"} + assert_response 403 + assert_equal(0, @post.reload.score) end should "not allow members to vote" do - CurrentUser.scoped(FactoryGirl.create(:member_user)) do - p1 = FactoryGirl.create(:post) - post :create, {:post_id => p1.id, :score => "up", :format => "js"}, {:user_id => CurrentUser.id} - - assert_response 403 - assert_equal(0, p1.reload.score) - end + @member = create(:member_user) + post_auth post_votes_path(post_id: @post.id), @member, params: {:score => "up", :format => "js"} + assert_response 403 + assert_equal(0, @post.reload.score) end should "increment a post's score if the score is positive" do - post :create, {:post_id => @post.id, :score => "up", :format => "js"}, {:user_id => @user.id} + post_auth post_votes_path(post_id: @post.id), @user, params: {:score => "up", :format => "js"} assert_response :success @post.reload assert_equal(1, @post.score) end - context "that fails" do - should "return a 500" do - post :create, {:post_id => @post.id, :score => "up", :format => "json"}, {:user_id => @user.id} - post :create, {:post_id => @post.id, :score => "up", :format => "json"}, {:user_id => @user.id} - assert_equal("{\"success\": false, \"reason\": \"You have already voted for this post\"}", response.body.strip) - end - end - context "for a post that has already been voted on" do setup do - @post.vote!("up") + @user.as_current do + @post.vote!("up") + end end should "fail silently on an error" do assert_nothing_raised do - post :create, {:post_id => @post.id, :score => "up", :format => "js"}, {:user_id => @user.id} + post_auth post_votes_path(post_id: @post.id), @user, params: {:score => "up", :format => "js"} end end end diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 749c88367..15ea331a8 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -1,36 +1,30 @@ require "test_helper" -class PostsControllerTest < ActionController::TestCase +class PostsControllerTest < ActionDispatch::IntegrationTest context "The posts controller" do setup do - @user = Timecop.travel(1.month.ago) {FactoryGirl.create(:user)} - @api_key = ApiKey.generate!(@user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post, :uploader_id => @user.id, :tag_string => "aaaa") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = travel_to(1.month.ago) {create(:user)} + as_user do + @post = create(:post, :tag_string => "aaaa") + end end context "for api calls" do + setup do + @api_key = ApiKey.generate!(@user) + end + context "passing the api limit" do setup do - @post = FactoryGirl.create(:post) - @bucket = TokenBucket.create(user_id: @user.id, token_count: 5, last_touched_at: Time.now) - User.any_instance.stubs(:api_burst_limit).returns(5) - User.any_instance.stubs(:api_regen_multiplier).returns(0) + as_user do + @post = create(:post) + end + TokenBucket.any_instance.stubs(:throttled?).returns(true) + @bucket = TokenBucket.create(user_id: @user.id, token_count: 0, last_touched_at: Time.now) end should "work" do - @user.api_burst_limit.times do - post :update, {:format => "json", :id => @post.id, :post => {:rating => "q"}, :login => @user.name, :api_key => @user.api_key.key} - assert_response :success - end - - post :update, {:format => "json", :id => @post.id, :post => {:rating => "q"}, :login => @user.name, :api_key => @user.api_key.key} + put post_path(@post), params: {:format => "json", :post => {:rating => "q"}, :login => @user.name, :api_key => @user.api_key.key} assert_response 429 end end @@ -38,39 +32,37 @@ class PostsControllerTest < ActionController::TestCase context "using http basic auth" do should "succeed for password matches" do @basic_auth_string = "Basic #{::Base64.encode64("#{@user.name}:#{@api_key.key}")}" - @request.env['HTTP_AUTHORIZATION'] = @basic_auth_string - get :index, {:format => "json"} + get posts_path, params: {:format => "json"}, headers: {'HTTP_AUTHORIZATION' => @basic_auth_string} assert_response :success end should "fail for password mismatches" do @basic_auth_string = "Basic #{::Base64.encode64("#{@user.name}:badpassword")}" - @request.env['HTTP_AUTHORIZATION'] = @basic_auth_string - get :index, {:format => "json"} + get posts_path, params: {:format => "json"}, headers: {'HTTP_AUTHORIZATION' => @basic_auth_string} assert_response 401 end end context "using the api_key parameter" do should "succeed for password matches" do - get :index, {:format => "json", :login => @user.name, :api_key => @api_key.key} + get posts_path, params: {:format => "json", :login => @user.name, :api_key => @api_key.key} assert_response :success end should "fail for password mismatches" do - get :index, {:format => "json", :login => @user.name, :api_key => "bad"} + get posts_path, params: {:format => "json", :login => @user.name, :api_key => "bad"} assert_response 401 end end context "using the password_hash parameter" do should "succeed for password matches" do - get :index, {:format => "json", :login => @user.name, :password_hash => User.sha1("password")} + get posts_path, params: {:format => "json", :login => @user.name, :password_hash => User.sha1("password")} assert_response :success end # should "fail for password mismatches" do - # get :index, {:format => "json", :login => @user.name, :password_hash => "bad"} + # get posts_path, {:format => "json", :login => @user.name, :password_hash => "bad"} # assert_response 403 # end end @@ -78,20 +70,20 @@ class PostsControllerTest < ActionController::TestCase context "index action" do should "render" do - get :index + get posts_path assert_response :success end context "with a search" do should "render" do - get :index, {:tags => "aaaa"} + get posts_path, params: {:tags => "aaaa"} assert_response :success end end context "with an md5 param" do should "render" do - get :index, { md5: @post.md5 } + get posts_path, params: { md5: @post.md5 } assert_redirected_to(@post) end end @@ -99,33 +91,33 @@ class PostsControllerTest < ActionController::TestCase context "show_seq action" do should "render" do - posts = FactoryGirl.create_list(:post, 3) + posts = FactoryBot.create_list(:post, 3) - get :show_seq, { seq: "prev", id: posts[1].id } + get show_seq_post_path(posts[1].id), params: { seq: "prev" } assert_redirected_to(posts[2]) - get :show_seq, { seq: "next", id: posts[1].id } + get show_seq_post_path(posts[1].id), params: { seq: "next" } assert_redirected_to(posts[0]) end end context "random action" do should "render" do - get :random, { tags: "aaaa" } + get random_posts_path, params: { tags: "aaaa" } assert_redirected_to(post_path(@post, tags: "aaaa")) end end context "show action" do should "render" do - get :show, {:id => @post.id} + get post_path(@post), params: {:id => @post.id} assert_response :success end end context "update action" do should "work" do - post :update, {:id => @post.id, :post => {:tag_string => "bbb"}}, {:user_id => @user.id} + put_auth post_path(@post), @user, params: {:post => {:tag_string => "bbb"}} assert_redirected_to post_path(@post) @post.reload @@ -133,35 +125,35 @@ class PostsControllerTest < ActionController::TestCase end should "ignore restricted params" do - post :update, {:id => @post.id, :post => {:last_noted_at => 1.minute.ago}}, {:user_id => @user.id} - assert_redirected_to post_path(@post) - - @post.reload - assert_nil(@post.last_noted_at) + put_auth post_path(@post), @user, params: {:post => {:last_noted_at => 1.minute.ago}} + assert_nil(@post.reload.last_noted_at) end end context "revert action" do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post.update_attributes(:tag_string => "zzz") + as_user do + @post.update(tag_string: "zzz") + end end should "work" do @version = @post.versions.first assert_equal("aaaa", @version.tags) - post :revert, {:id => @post.id, :version_id => @version.id}, {:user_id => @user.id} + put_auth revert_post_path(@post), @user, params: {:version_id => @version.id} assert_redirected_to post_path(@post) @post.reload assert_equal("aaaa", @post.tag_string) end should "not allow reverting to a previous version of another post" do - @post2 = FactoryGirl.create(:post, :uploader_id => @user.id, :tag_string => "herp") + as_user do + @post2 = create(:post, :uploader_id => @user.id, :tag_string => "herp") + end - post :revert, { :id => @post.id, :version_id => @post2.versions.first.id }, {:user_id => @user.id} + put_auth revert_post_path(@post), @user, params: { :version_id => @post2.versions.first.id } @post.reload - assert_not_equal(@post.tag_string, @post2.tag_string) assert_response :missing end diff --git a/test/functional/related_tags_controller_test.rb b/test/functional/related_tags_controller_test.rb index ec9e241dc..b7fa741ac 100644 --- a/test/functional/related_tags_controller_test.rb +++ b/test/functional/related_tags_controller_test.rb @@ -1,10 +1,10 @@ require 'test_helper' -class RelatedTagsControllerTest < ActionController::TestCase +class RelatedTagsControllerTest < ActionDispatch::IntegrationTest context "The related tags controller" do context "show action" do should "work" do - get :show, { query: "touhou" } + get related_tag_path, params: { query: "touhou" } assert_response :success end end diff --git a/test/functional/reports_controller_test.rb b/test/functional/reports_controller_test.rb index d1fb32163..faf98b6ef 100644 --- a/test/functional/reports_controller_test.rb +++ b/test/functional/reports_controller_test.rb @@ -1,43 +1,27 @@ require 'test_helper' -class ReportsControllerTest < ActionController::TestCase - def setup - super - - CurrentUser.user = FactoryGirl.create(:mod_user) - CurrentUser.ip_addr = "127.0.0.1" - session[:user_id] = CurrentUser.user.id - - @users = FactoryGirl.create_list(:contributor_user, 2) - @posts = @users.map { |u| FactoryGirl.create(:post, uploader: u) } - end - - def teardown - super - - CurrentUser.user = nil - CurrentUser.ip_addr = nil - session[:user_id] = nil - end - +class ReportsControllerTest < ActionDispatch::IntegrationTest context "The reports controller" do - context "uploads action" do - should "render" do - get :uploads - assert_response :success + setup do + @mod = create(:mod_user) + @users = FactoryBot.create_list(:contributor_user, 2) + @posts = @users.map do |u| + as(u) do + create(:post) + end end end - context "similar_users action" do + context "uploads action" do should "render" do - #get :similar_users - #assert_response :success + get_auth reports_uploads_path, @mod + assert_response :success end end context "post_versions action" do should "render" do - get :post_versions + get_auth reports_post_versions_path, @mod assert_response :success end end diff --git a/test/functional/saved_searches_controller_test.rb b/test/functional/saved_searches_controller_test.rb index 8cee03c00..52c5fe30c 100644 --- a/test/functional/saved_searches_controller_test.rb +++ b/test/functional/saved_searches_controller_test.rb @@ -1,55 +1,65 @@ require 'test_helper' -class SavedSearchesControllerTest < ActionController::TestCase +class SavedSearchesControllerTest < ActionDispatch::IntegrationTest context "The saved searches controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:user) + as_user do + @saved_search = create(:saved_search, user: @user) + end mock_saved_search_service! end context "index action" do should "render" do - get :index, {}, { user_id: @user.id } + get_auth saved_searches_path, @user assert_response :success + assert_select "#saved-search-#{@saved_search.id}" end end context "create action" do should "render" do - params = { saved_search_tags: "bkub", saved_search_labels: "artist" } - - post :create, params, { user_id: @user.id } + post_auth saved_searches_path, @user, params: { saved_search: { query: "bkub", label_string: "artist" }} assert_response :redirect end + + should "disable labels when the disable_labels param is given" do + post_auth saved_searches_path, @user, params: { saved_search: { query: "bkub", disable_labels: "1" }} + assert_equal(true, @user.reload.disable_categorized_saved_searches) + end end context "edit action" do should "render" do - saved_search = FactoryGirl.create(:saved_search, user: @user) + as_user do + @saved_search = create(:saved_search, user: @user) + end - get :edit, { id: saved_search.id }, { user_id: @user.id } + get_auth edit_saved_search_path(@saved_search), @user, params: { id: @saved_search.id } assert_response :success end end context "update action" do should "render" do - saved_search = FactoryGirl.create(:saved_search, user: @user) - params = { id: saved_search.id, saved_search: { label_string: "foo" } } - - put :update, params, { user_id: @user.id } + as_user do + @saved_search = create(:saved_search, user: @user) + end + params = { id: @saved_search.id, saved_search: { label_string: "foo" } } + put_auth saved_search_path(@saved_search), @user, params: params assert_redirected_to saved_searches_path - assert_equal(["foo"], saved_search.reload.labels) + assert_equal(["foo"], @saved_search.reload.labels) end end context "destroy action" do should "render" do - saved_search = FactoryGirl.create(:saved_search, user: @user) + as_user do + @saved_search = create(:saved_search, user: @user) + end - delete :destroy, { id: saved_search.id }, { user_id: @user.id } + delete_auth saved_search_path(@saved_search), @user assert_redirected_to saved_searches_path end end diff --git a/test/functional/sessions_controller_test.rb b/test/functional/sessions_controller_test.rb index 7743ac6c2..0dd3bdbfc 100644 --- a/test/functional/sessions_controller_test.rb +++ b/test/functional/sessions_controller_test.rb @@ -1,56 +1,31 @@ require 'test_helper' -class SessionsControllerTest < ActionController::TestCase +class SessionsControllerTest < ActionDispatch::IntegrationTest context "the sessions controller" do setup do - @user = FactoryGirl.create(:user) + @user = create(:user) end context "new action" do should "render" do - get :new + get new_session_path assert_response :success end end context "create action" do should "create a new session" do - post :create, {:name => @user.name, :password => "password"} + post session_path, params: {:name => @user.name, :password => "password"} assert_redirected_to posts_path @user.reload assert_equal(@user.id, session[:user_id]) assert_not_nil(@user.last_ip_addr) end - - should "unban user if user has expired ban" do - CurrentUser.scoped(@user, "127.0.0.1") do - @banned = FactoryGirl.create(:banned_user, ban_duration: 3) - end - - travel_to(4.days.from_now) do - post :create, {name: @banned.name, password: "password"} - SessionLoader.new(session, {}, request, {}).load - - assert_equal(@banned.id, session[:user_id]) - assert_equal(true, @banned.ban_expired?) - assert_equal(false, @banned.reload.is_banned) - end - end end context "destroy action" do - setup do - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end - should "clear the session" do - post :destroy, {}, {:user_id => @user.id} + delete_auth session_path, @user assert_redirected_to posts_path assert_nil(session[:user_id]) end diff --git a/test/functional/sources_controller_test.rb b/test/functional/sources_controller_test.rb index 3012cad43..f58b87de4 100644 --- a/test/functional/sources_controller_test.rb +++ b/test/functional/sources_controller_test.rb @@ -1,15 +1,16 @@ require 'test_helper' -class SourcesControllerTest < ActionController::TestCase +class SourcesControllerTest < ActionDispatch::IntegrationTest context "The sources controller" do context "show action" do should "work for a pixiv URL" do - get :show, { url: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=14901720", format: "json" } + get source_path, params: { url: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=14901720", format: "json" } assert_response :success end should "work for a direct twitter URL with referer" do - get :show, { + skip "Twitter keys are not set" if !Danbooru.config.twitter_api_key + get source_path, params: { url: "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:large", ref: "https://twitter.com/nounproject/status/540944400767922176", format: "json" diff --git a/test/functional/tag_alias_corrections_controller_test.rb b/test/functional/tag_alias_corrections_controller_test.rb index ffd21bcdf..4fb0da21f 100644 --- a/test/functional/tag_alias_corrections_controller_test.rb +++ b/test/functional/tag_alias_corrections_controller_test.rb @@ -1,29 +1,24 @@ require 'test_helper' -class TagAliasCorrectionsControllerTest < ActionController::TestCase +class TagAliasCorrectionsControllerTest < ActionDispatch::IntegrationTest context "The tag alias correction controller" do setup do - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @admin - CurrentUser.ip_addr = "127.0.0.1" - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @admin = create(:admin_user) + as(@admin) do + @tag_alias = create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + end end context "show action" do should "render" do - get :show, {:tag_alias_id => @tag_alias.id}, {:user_id => @admin.id} + get_auth tag_alias_correction_path(tag_alias_id: @tag_alias.id), @admin assert_response :success end end context "create action" do should "render" do - post :create, {:tag_alias_id => @tag_alias.id, :commit => "Fix"}, {:user_id => @admin.id} + post_auth tag_alias_correction_path(tag_alias_id: @tag_alias.id), @admin, params: {:commit => "Fix"} assert_redirected_to(tag_alias_correction_path(:tag_alias_id => @tag_alias.id)) end end diff --git a/test/functional/tag_alias_requests_controller_test.rb b/test/functional/tag_alias_requests_controller_test.rb index c37f116dd..d67c6965e 100644 --- a/test/functional/tag_alias_requests_controller_test.rb +++ b/test/functional/tag_alias_requests_controller_test.rb @@ -1,21 +1,14 @@ require 'test_helper' -class TagAliasRequestsControllerTest < ActionController::TestCase +class TagAliasRequestsControllerTest < ActionDispatch::IntegrationTest context "The tag alias request controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_tag_alias_request_path, @user assert_response :success end end @@ -23,7 +16,7 @@ class TagAliasRequestsControllerTest < ActionController::TestCase context "create action" do should "render" do assert_difference("ForumTopic.count", 1) do - post :create, {:tag_alias_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}}, {:user_id => @user.id} + post_auth tag_alias_request_path, @user, params: {:tag_alias_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}} end assert_redirected_to(forum_topic_path(ForumTopic.last)) end diff --git a/test/functional/tag_aliases_controller_test.rb b/test/functional/tag_aliases_controller_test.rb index 331da445b..76360d09d 100644 --- a/test/functional/tag_aliases_controller_test.rb +++ b/test/functional/tag_aliases_controller_test.rb @@ -1,47 +1,46 @@ require 'test_helper' -class TagAliasesControllerTest < ActionController::TestCase +class TagAliasesControllerTest < ActionDispatch::IntegrationTest context "The tag aliases controller" do setup do - @user = FactoryGirl.create(:admin_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:admin_user) end context "edit action" do setup do - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + as_admin do + @tag_alias = create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + end end should "render" do - get :edit, {:id => @tag_alias.id} + get_auth edit_tag_alias_path(@tag_alias), @user assert_response :success end end context "update action" do setup do - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + as_admin do + @tag_alias = create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + end end context "for a pending alias" do setup do - @tag_alias.update_attribute(:status, "pending") + as_admin do + @tag_alias.update(status: "pending") + end end should "succeed" do - post :update, {:id => @tag_alias.id, :tag_alias => {:antecedent_name => "xxx"}}, {:user_id => @user.id} + put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:antecedent_name => "xxx"}} @tag_alias.reload assert_equal("xxx", @tag_alias.antecedent_name) end should "not allow changing the status" do - post :update, {:id => @tag_alias.id, :tag_alias => {:status => "active"}}, {:user_id => @user.id} + put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:status => "active"}} @tag_alias.reload assert_equal("pending", @tag_alias.status) end @@ -56,7 +55,7 @@ class TagAliasesControllerTest < ActionController::TestCase end should "fail" do - post :update, {:id => @tag_alias.id, :tag_alias => {:antecedent_name => "xxx"}}, {:user_id => @user.id} + put_auth tag_alias_path(@tag_alias), @user, params: {:tag_alias => {:antecedent_name => "xxx"}} @tag_alias.reload assert_equal("aaa", @tag_alias.antecedent_name) end @@ -65,28 +64,32 @@ class TagAliasesControllerTest < ActionController::TestCase context "index action" do setup do - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + as_admin do + @tag_alias = create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + end end should "list all tag alias" do - get :index, {}, {:user_id => @user.id} + get_auth tag_aliases_path, @user assert_response :success end should "list all tag_alias (with search)" do - get :index, {:search => {:antecedent_name => "aaa"}}, {:user_id => @user.id} + get_auth tag_aliases_path, @user, params: {:search => {:antecedent_name => "aaa"}} assert_response :success end end context "destroy action" do setup do - @tag_alias = FactoryGirl.create(:tag_alias) + as_admin do + @tag_alias = create(:tag_alias) + end end should "destroy a tag_alias" do assert_difference("TagAlias.count", -1) do - post :destroy, {:id => @tag_alias.id}, {:user_id => @user.id} + delete_auth tag_alias_path(@tag_alias), @user end end end diff --git a/test/functional/tag_implication_requests_controller_test.rb b/test/functional/tag_implication_requests_controller_test.rb index 4bc8613d6..a48b7a3bc 100644 --- a/test/functional/tag_implication_requests_controller_test.rb +++ b/test/functional/tag_implication_requests_controller_test.rb @@ -1,23 +1,16 @@ require 'test_helper' -class TagImplicationRequestsControllerTest < ActionController::TestCase +class TagImplicationRequestsControllerTest < ActionDispatch::IntegrationTest context "The tag implication request controller" do setup do - Timecop.travel(1.month.ago) do - @user = FactoryGirl.create(:user) + travel_to(1.month.ago) do + @user = create(:user) end - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_tag_implication_request_path, @user assert_response :success end end @@ -25,7 +18,7 @@ class TagImplicationRequestsControllerTest < ActionController::TestCase context "create action" do should "create forum post" do assert_difference("ForumTopic.count", 1) do - post :create, {:tag_implication_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}}, {:user_id => @user.id} + post_auth tag_implication_request_path, @user, params: {:tag_implication_request => {:antecedent_name => "aaa", :consequent_name => "bbb", :reason => "ccc", :skip_secondary_validations => true}} end assert_redirected_to(forum_topic_path(ForumTopic.last)) end @@ -40,14 +33,10 @@ class TagImplicationRequestsControllerTest < ActionController::TestCase } } - post :create, params, {:user_id => @user.id} - - tir = assigns(:tag_implication_request) - assert_redirected_to(forum_topic_path(tir.forum_topic)) - - assert("foo", tir.tag_implication.antecedent_name) - assert("bar", tir.tag_implication.consequent_name) - assert("pending", tir.tag_implication.status) + assert_difference("ForumTopic.count") do + post_auth tag_implication_request_path, @user, params: params + end + assert_redirected_to(forum_topic_path(ForumTopic.last)) end end end diff --git a/test/functional/tag_implications_controller_test.rb b/test/functional/tag_implications_controller_test.rb index 2d9377ae8..1d43a5b44 100644 --- a/test/functional/tag_implications_controller_test.rb +++ b/test/functional/tag_implications_controller_test.rb @@ -1,54 +1,49 @@ require 'test_helper' -class TagImplicationsControllerTest < ActionController::TestCase +class TagImplicationsControllerTest < ActionDispatch::IntegrationTest context "The tag implications controller" do setup do - @user = FactoryGirl.create(:admin_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @user = create(:admin_user) end - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil - end - - context "edit action" do setup do - @tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + as_admin do + @tag_implication = create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + end end should "render" do - get :edit, {:id => @tag_implication.id} + get_auth tag_implication_path(@tag_implication), @user assert_response :success end end context "update action" do setup do - @tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + as_admin do + @tag_implication = create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + end end context "for a pending implication" do setup do - @tag_implication.update_attribute(:status, "pending") + as_admin do + @tag_implication.update(status: "pending") + end end should "succeed" do - post :update, {:id => @tag_implication.id, :tag_implication => {:antecedent_name => "xxx"}}, {:user_id => @user.id} + put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:antecedent_name => "xxx"}} @tag_implication.reload assert_equal("xxx", @tag_implication.antecedent_name) end should "not allow changing the status" do - post :update, {:id => @tag_implication.id, :tag_implication => {:status => "active"}}, {:user_id => @user.id} + put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:status => "active"}} @tag_implication.reload assert_equal("pending", @tag_implication.status) end - - # TODO: Broken in shoulda-matchers 2.8.0. Need to upgrade to 3.1.1. - should_eventually permit(:antecedent_name, :consequent_name, :forum_topic_id).for(:update) end context "for an approved implication" do @@ -57,7 +52,7 @@ class TagImplicationsControllerTest < ActionController::TestCase end should "fail" do - post :update, {:id => @tag_implication.id, :tag_implication => {:antecedent_name => "xxx"}}, {:user_id => @user.id} + put_auth tag_implication_path(@tag_implication), @user, params: {:tag_implication => {:antecedent_name => "xxx"}} @tag_implication.reload assert_equal("aaa", @tag_implication.antecedent_name) end @@ -66,32 +61,32 @@ class TagImplicationsControllerTest < ActionController::TestCase context "index action" do setup do - CurrentUser.scoped(@user, "127.0.0.1") do - @tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + as_user do + @tag_implication = create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") end end should "list all tag implications" do - get :index + get tag_implications_path assert_response :success end should "list all tag_implications (with search)" do - get :index, {:search => {:antecedent_name => "aaa"}} + get tag_implications_path, params: {:search => {:antecedent_name => "aaa"}} assert_response :success end end context "destroy action" do setup do - CurrentUser.scoped(@user, "127.0.0.1") do - @tag_implication = FactoryGirl.create(:tag_implication) + as_user do + @tag_implication = create(:tag_implication) end end should "destroy a tag_implication" do assert_difference("TagImplication.count", -1) do - post :destroy, {:id => @tag_implication.id}, {:user_id => @user.id} + delete_auth tag_implication_path(@tag_implication), @user end end end diff --git a/test/functional/tags_controller_test.rb b/test/functional/tags_controller_test.rb index a57e36460..6936de81e 100644 --- a/test/functional/tags_controller_test.rb +++ b/test/functional/tags_controller_test.rb @@ -1,50 +1,37 @@ require 'test_helper' -class TagsControllerTest < ActionController::TestCase +class TagsControllerTest < ActionDispatch::IntegrationTest context "The tags controller" do setup do - @user = FactoryGirl.create(:builder_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:builder_user) + as_user do + @tag = create(:tag, name: "touhou", category: Tag.categories.copyright, post_count: 1) + end end context "edit action" do - setup do - @tag = FactoryGirl.create(:tag, :name => "aaa") - end - should "render" do - get :edit, {:id => @tag.id}, {:user_id => @user.id} + get_auth tag_path(@tag), @user, params: {:id => @tag.id} assert_response :success end end context "index action" do - setup do - @tag = FactoryGirl.create(:tag, name: "aaa", post_count: 1) - end - should "render" do - get :index + get tags_path assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:name_matches => "aaa"}} + get tags_path, params: {:search => {:name_matches => "touhou"}} assert_response :success end end context "with blank search parameters" do should "strip the blank parameters with a redirect" do - get :index, { search: { name: "touhou", category: "" } } - + get tags_path, params: { search: { name: "touhou", category: "" } } assert_redirected_to tags_path(search: { name: "touhou" }) end end @@ -52,42 +39,72 @@ class TagsControllerTest < ActionController::TestCase context "autocomplete action" do should "render" do - FactoryGirl.create(:tag, name: "touhou", post_count: 1) - - get :autocomplete, { search: { name_matches: "t" }, format: :json } + get autocomplete_tags_path, params: { search: { name_matches: "t" }, format: :json } assert_response :success end end context "show action" do - setup do - @tag = FactoryGirl.create(:tag) - end - should "render" do - get :show, {:id => @tag.id} + get tag_path(@tag) assert_response :success end end context "update action" do setup do - @tag = FactoryGirl.create(:tag) + @mod = create(:moderator_user) end should "update the tag" do - post :update, {:id => @tag.id, :tag => {:category => "1"}}, {:user_id => @user.id} + put_auth tag_path(@tag), @user, params: {:tag => {:category => Tag.categories.general}} assert_redirected_to tag_path(@tag) - @tag.reload - assert_equal(1, @tag.category) + assert_equal(Tag.categories.general, @tag.reload.category) + end + + should "lock the tag for a moderator" do + put_auth tag_path(@tag), @mod, params: { tag: { is_locked: true } } + + assert_redirected_to @tag + assert_equal(true, @tag.reload.is_locked) + end + + should "not lock the tag for a user" do + put_auth tag_path(@tag), @user, params: {tag: { is_locked: true }} + + assert_equal(false, @tag.reload.is_locked) + end + + context "for a tag with >50 posts" do + setup do + as_user do + @tag.update(post_count: 100) + end + end + + should "not update the category for a member" do + @member = create(:member_user) + put_auth tag_path(@tag), @member, params: {tag: { category: Tag.categories.general }} + + assert_not_equal(Tag.categories.general, @tag.reload.category) + end + + should "update the category for a builder" do + put_auth tag_path(@tag), @user, params: {tag: { category: Tag.categories.general }} + + assert_redirected_to @tag + assert_equal(Tag.categories.general, @tag.reload.category) + end end should "not change category when the tag is too large to be changed by a builder" do - @tag.update_columns(post_count: 1001) - post :update, {:id => @tag.id, :tag => {:category => "1"}}, {:user_id => @user.id} + as_user do + @tag.update(category: Tag.categories.general, post_count: 1001) + end + put_auth tag_path(@tag), @user, params: {:tag => {:category => Tag.categories.artist}} assert_response :forbidden - assert_equal(0, @tag.reload.category) + assert_equal(Tag.categories.general, @tag.reload.category) end end end diff --git a/test/functional/uploads_controller_test.rb b/test/functional/uploads_controller_test.rb index 74ecac5bd..56803c936 100644 --- a/test/functional/uploads_controller_test.rb +++ b/test/functional/uploads_controller_test.rb @@ -1,34 +1,24 @@ require 'test_helper' -class UploadsControllerTest < ActionController::TestCase - def setup - super - mock_iqdb_service! - end - +class UploadsControllerTest < ActionDispatch::IntegrationTest context "The uploads controller" do setup do - @user = FactoryGirl.create(:contributor_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:contributor_user) + mock_iqdb_service! end context "batch action" do context "for twitter galleries" do should "render" do - get :batch, {:url => "https://twitter.com/lvlln/status/567054278486151168"}, {:user_id => @user.id} + skip "Twitter keys are not set" unless Danbooru.config.twitter_api_key + get_auth batch_uploads_path, @user, params: {:url => "https://twitter.com/lvlln/status/567054278486151168"} assert_response :success end end context "for pixiv ugoira galleries" do should "render" do - get :batch, {:url => "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=59523577"}, {:user_id => @user.id} + get_auth batch_uploads_path, @user, params: {:url => "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=59523577"} assert_response :success assert_no_match(/59523577_ugoira0\.jpg/, response.body) end @@ -37,46 +27,47 @@ class UploadsControllerTest < ActionController::TestCase context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_upload_path, @user assert_response :success end context "for a twitter post" do - setup do - get :new, {:url => "https://twitter.com/frappuccino/status/566030116182949888"}, {:user_id => @user.id} - end - should "render" do + skip "Twitter keys are not set" unless Danbooru.config.twitter_api_key + get_auth new_upload_path, @user, params: {:url => "https://twitter.com/frappuccino/status/566030116182949888"} assert_response :success end end context "for a post that has already been uploaded" do setup do - @post = FactoryGirl.create(:post, :source => "aaa") + as_user do + @post = create(:post, :source => "aaa") + end end should "initialize the post" do - get :new, {:url => "aaa"}, {:user_id => @user.id} + get_auth new_upload_path, @user, params: {:url => "http://google.com/aaa"} assert_response :success - assert_not_nil(assigns(:post)) end end end context "index action" do setup do - @upload = FactoryGirl.create(:source_upload) + as_user do + @upload = create(:source_upload) + end end should "render" do - get :index, {}, {:user_id => @user.id} + get_auth uploads_path, @user assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:source => @upload.source}}, {:user_id => @user.id} + get_auth uploads_path, @user, params: {:search => {:source => @upload.source}} assert_response :success end end @@ -84,11 +75,13 @@ class UploadsControllerTest < ActionController::TestCase context "show action" do setup do - @upload = FactoryGirl.create(:jpg_upload) + as_user do + @upload = create(:jpg_upload) + end end should "render" do - get :show, {:id => @upload.id}, {:user_id => @user.id} + get_auth upload_path(@upload), @user assert_response :success end end @@ -97,19 +90,20 @@ class UploadsControllerTest < ActionController::TestCase should "create a new upload" do assert_difference("Upload.count", 1) do file = Rack::Test::UploadedFile.new("#{Rails.root}/test/files/test.jpg", "image/jpeg") - file.stubs(:tempfile).returns(file) - post :create, {:upload => {:file => file, :tag_string => "aaa", :rating => "q", :source => "aaa"}}, {:user_id => @user.id} + post_auth uploads_path, @user, params: {:upload => {:file => file, :tag_string => "aaa", :rating => "q", :source => "aaa"}} end end end context "update action" do setup do - @upload = FactoryGirl.create(:jpg_upload) + as_user do + @upload = create(:source_upload) + end end should "process an unapproval" do - post :update, {:id => @upload.id}, {:user_id => @user.id} + put_auth upload_path(@upload), @user @upload.reload assert_equal("completed", @upload.status) end diff --git a/test/functional/user_feedbacks_controller_test.rb b/test/functional/user_feedbacks_controller_test.rb index 688705d02..5b909b963 100644 --- a/test/functional/user_feedbacks_controller_test.rb +++ b/test/functional/user_feedbacks_controller_test.rb @@ -1,51 +1,48 @@ require 'test_helper' -class UserFeedbacksControllerTest < ActionController::TestCase +class UserFeedbacksControllerTest < ActionDispatch::IntegrationTest context "The user feedbacks controller" do setup do - @user = FactoryGirl.create(:user) - @critic = FactoryGirl.create(:gold_user) - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @critic - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) + @critic = create(:gold_user) + @mod = create(:moderator_user) end context "new action" do should "render" do - get :new, {}, {:user_id => @critic.id} + get_auth new_user_feedback_path, @critic, params: { user_feedback: { user_id: @user.id } } assert_response :success end end context "edit action" do setup do - @user_feedback = FactoryGirl.create(:user_feedback) + as(@critic) do + @user_feedback = create(:user_feedback, user: @user) + end end should "render" do - get :edit, {:id => @user_feedback.id}, {:user_id => @critic.id} + get_auth edit_user_feedback_path(@user_feedback), @critic assert_response :success end end context "index action" do setup do - @user_feedback = FactoryGirl.create(:user_feedback) + as(@critic) do + @user_feedback = create(:user_feedback, user: @user) + end end should "render" do - get :index, {}, {:user_id => @user.id} + get_auth user_feedbacks_path, @user assert_response :success end context "with search parameters" do should "render" do - get :index, {:search => {:user_id => @user.id}}, {:user_id => @critic.id} + get_auth user_feedbacks_path, @critic, params: {:search => {:user_id => @user.id}} assert_response :success end end @@ -54,35 +51,50 @@ class UserFeedbacksControllerTest < ActionController::TestCase context "create action" do should "create a new feedback" do assert_difference("UserFeedback.count", 1) do - post :create, {:user_feedback => {:category => "positive", :user_name => @user.name, :body => "xxx"}}, {:user_id => @critic.id} - assert_not_nil(assigns(:user_feedback)) - assert_equal([], assigns(:user_feedback).errors.full_messages) + post_auth user_feedbacks_path, @critic, params: {:user_feedback => {:category => "positive", :user_name => @user.name, :body => "xxx"}} end end end + context "update action" do + should "update the feedback" do + as(@critic) do + @feedback = create(:user_feedback, user: @user, category: "negative") + end + put_auth user_feedback_path(@feedback), @critic, params: { id: @feedback.id, user_feedback: { category: "positive" }} + + assert_redirected_to(@feedback) + assert("positive", @feedback.reload.category) + end + end + context "destroy action" do setup do - @user_feedback = FactoryGirl.create(:user_feedback, user: @user) + as(@critic) do + @user_feedback = create(:user_feedback, user: @user) + end end should "delete a feedback" do assert_difference "UserFeedback.count", -1 do - post :destroy, {:id => @user_feedback.id}, {:user_id => @critic.id} + delete_auth user_feedback_path(@user_feedback), @critic end end context "by a moderator" do should "allow deleting feedbacks given to other users" do assert_difference "UserFeedback.count", -1 do - post :destroy, {:id => @user_feedback.id}, {:user_id => @mod.id} + delete_auth user_feedback_path(@user_feedback), @mod end end should "not allow deleting feedbacks given to themselves" do - @user_feedback = FactoryGirl.create(:user_feedback, user: @mod) + as(@critic) do + @user_feedback = create(:user_feedback, user: @mod) + end + assert_difference "UserFeedback.count", 0 do - post :destroy, {:id => @user_feedback.id}, {:user_id => @mod.id} + delete_auth user_feedback_path(@user_feedback), @mod end end end diff --git a/test/functional/user_name_change_requests_controller_test.rb b/test/functional/user_name_change_requests_controller_test.rb index d9ae1fd41..b967d9469 100644 --- a/test/functional/user_name_change_requests_controller_test.rb +++ b/test/functional/user_name_change_requests_controller_test.rb @@ -1,41 +1,45 @@ require 'test_helper' -class UserNameChangeRequestsControllerTest < ActionController::TestCase +class UserNameChangeRequestsControllerTest < ActionDispatch::IntegrationTest context "The user name change requests controller" do setup do - @user = FactoryGirl.create(:gold_user) - @admin = FactoryGirl.create(:admin_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - @change_request = UserNameChangeRequest.create!( - :user_id => @user.id, - :original_name => @user.name, - :desired_name => "abc", - :change_reason => "hello" - ) + @user = create(:gold_user) + @admin = create(:admin_user) + as(@user) do + @change_request = UserNameChangeRequest.create!( + :user_id => @user.id, + :original_name => @user.name, + :desired_name => "abc", + :change_reason => "hello" + ) + end end context "new action" do should "render" do - get :new, {}, {:user_id => @user.id} + get_auth new_user_name_change_request_path, @user + assert_response :success + end + end + + context "create action" do + should "work" do + post_auth user_name_change_requests_path, @user, params: { user_name_change_request: { desired_name: "zun" }} assert_response :success end end context "show action" do should "render" do - get :show, {:id => @change_request.id}, {:user_id => @user.id} + get_auth user_name_change_request_path(@change_request), @user assert_response :success end context "when the current user is not an admin and does not own the request" do - setup do - CurrentUser.user = FactoryGirl.create(:user) - end - should "fail" do - get :show, {:id => @change_request.id} - assert_redirected_to(new_session_path(:url => user_name_change_request_path(@change_request))) + @another_user = create(:user) + get_auth user_name_change_request_path(@change_request), @another_user + assert_response :forbidden end end end @@ -43,21 +47,21 @@ class UserNameChangeRequestsControllerTest < ActionController::TestCase context "for actions restricted to admins" do context "index action" do should "render" do - get :index, {}, {:user_id => @admin.id} + get_auth user_name_change_requests_path, @admin assert_response :success end end context "approve action" do should "succeed" do - post :approve, {:id => @change_request.id}, {:user_id => @admin.id} + post_auth approve_user_name_change_request_path(@change_request), @admin assert_redirected_to(user_name_change_request_path(@change_request)) end end context "reject action" do should "succeed" do - post :reject, {:id => @change_request.id}, {:user_id => @admin.id} + post_auth reject_user_name_change_request_path(@change_request), @admin assert_redirected_to(user_name_change_request_path(@change_request)) end end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index f7aa9f292..7f3ccd426 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -1,35 +1,29 @@ require 'test_helper' -class UsersControllerTest < ActionController::TestCase +class UsersControllerTest < ActionDispatch::IntegrationTest context "The users controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil + @user = create(:user) end context "index action" do should "list all users" do - get :index + get users_path assert_response :success end should "list all users for /users?name=" do - get :index, { name: @user.name } + get users_path, params: { name: @user.name } assert_redirected_to(@user) end should "raise error for /users?name=" do - get :index, { name: "nobody" } + get users_path, params: { name: "nobody" } assert_response :error end should "list all users (with search)" do - get :index, {:search => {:name_matches => @user.name}} + get users_path, params: {:search => {:name_matches => @user.name}} assert_response :success end end @@ -37,18 +31,20 @@ class UsersControllerTest < ActionController::TestCase context "show action" do setup do # flesh out profile to get more test coverage of user presenter. - @user = FactoryGirl.create(:banned_user, can_approve_posts: true, is_super_voter: true) - FactoryGirl.create(:saved_search, user: @user) - FactoryGirl.create(:post, uploader: @user, tag_string: "fav:#{@user.name}") + @user = create(:banned_user, can_approve_posts: true, is_super_voter: true) + as_user do + create(:saved_search, user: @user) + create(:post, uploader: @user, tag_string: "fav:#{@user.name}") + end end should "render" do - get :show, {:id => @user.id} + get user_path(@user) assert_response :success end should "show hidden attributes to the owner" do - get :show, {id: @user.id, format: :json}, {user_id: @user.id} + get_auth user_path(@user), @user, params: {format: :json} json = JSON.parse(response.body) assert_response :success @@ -56,9 +52,9 @@ class UsersControllerTest < ActionController::TestCase end should "not show hidden attributes to others" do - another = FactoryGirl.create(:user) + @another = create(:user) - get :show, {id: another.id, format: :json}, {user_id: @user.id} + get_auth user_path(@another), @user, params: {format: :json} json = JSON.parse(response.body) assert_response :success @@ -66,7 +62,7 @@ class UsersControllerTest < ActionController::TestCase end should "strip '?' from attributes" do - get :show, {id: @user.id, format: :xml}, {user_id: @user.id} + get_auth user_path(@user), @user, params: {format: :xml} xml = Hash.from_xml(response.body) assert_response :success @@ -80,7 +76,7 @@ class UsersControllerTest < ActionController::TestCase end should "render" do - get :new + get new_user_path assert_response :success end end @@ -88,58 +84,53 @@ class UsersControllerTest < ActionController::TestCase context "create action" do should "create a user" do assert_difference("User.count", 1) do - post :create, {:user => {:name => "xxx", :password => "xxxxx1", :password_confirmation => "xxxxx1"}}, {:user_id => @user.id} - assert_not_nil(assigns(:user)) - assert_equal([], assigns(:user).errors.full_messages) + post users_path, params: {:user => {:name => "xxx", :password => "xxxxx1", :password_confirmation => "xxxxx1"}} end end - should "not allow registering multiple accounts with the same IP" do - Danbooru.config.unstub(:enable_sock_puppet_validation?) - request.env["REMOTE_ADDR"] = "1.2.3.4" - CurrentUser.user = nil + context "with sockpuppet validation enabled" do + setup do + Danbooru.config.unstub(:enable_sock_puppet_validation?) + @user.update(last_ip_addr: "127.0.0.1") + end - post :create, {:user => {:name => "user", :password => "xxxxx1", :password_confirmation => "xxxxx1"}}, {} - session.clear - post :create, {:user => {:name => "dupe", :password => "xxxxx1", :password_confirmation => "xxxxx1"}}, {} - - assert_equal(true, User.where(name: "user").exists?) - assert_equal(false, User.where(name: "dupe").exists?) - - assert_equal(IPAddr.new("1.2.3.4"), User.find_by_name("user").last_ip_addr) - assert_match(/Sign up failed: Last ip addr was used recently/, flash[:notice]) + should "not allow registering multiple accounts with the same IP" do + assert_difference("User.count", 0) do + post users_path, params: {:user => {:name => "dupe", :password => "xxxxx1", :password_confirmation => "xxxxx1"}} + end + end end end context "edit action" do setup do - @user = FactoryGirl.create(:user) + @user = create(:user) end should "render" do - get :edit, {:id => @user.id}, {:user_id => @user.id} + get_auth edit_user_path(@user), @user assert_response :success end end context "update action" do setup do - @user = FactoryGirl.create(:user) + @user = create(:user) end should "update a user" do - post :update, {:id => @user.id, :user => {:favorite_tags => "xyz"}}, {:user_id => @user.id} + put_auth user_path(@user), @user, params: {:user => {:favorite_tags => "xyz"}} @user.reload assert_equal("xyz", @user.favorite_tags) end context "changing the level" do setup do - @cuser = FactoryGirl.create(:user) + @cuser = create(:user) end should "not work" do - post :update, {:id => @user.id, :user => {:level => 40}}, {:user_id => @cuser.id} + put_auth user_path(@user), @cuser, params: {:user => {:level => 40}} @user.reload assert_equal(20, @user.level) end @@ -147,8 +138,8 @@ class UsersControllerTest < ActionController::TestCase context "for a banned user" do should "allow the user to edit their settings" do - @user = FactoryGirl.create(:banned_user) - post :update, {:id => @user.id, :user => {:favorite_tags => "xyz"}}, {:user_id => @user.id} + @user = create(:banned_user) + put_auth user_path(@user), @user, params: {:user => {:favorite_tags => "xyz"}} assert_equal("xyz", @user.reload.favorite_tags) end diff --git a/test/functional/wiki_page_versions_controller_test.rb b/test/functional/wiki_page_versions_controller_test.rb index 0a7dac6ac..73410f259 100644 --- a/test/functional/wiki_page_versions_controller_test.rb +++ b/test/functional/wiki_page_versions_controller_test.rb @@ -1,46 +1,38 @@ require 'test_helper' -class WikiPageVersionsControllerTest < ActionController::TestCase +class WikiPageVersionsControllerTest < ActionDispatch::IntegrationTest context "The wiki page versions controller" do setup do - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - - @wiki_page = FactoryGirl.create(:wiki_page) - @wiki_page.update_attributes(:body => "1 2") - @wiki_page.update_attributes(:body => "2 3") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + @user = create(:user) + as_user do + @wiki_page = create(:wiki_page) + @wiki_page.update(:body => "1 2") + @wiki_page.update(:body => "2 3") + end end context "index action" do should "list all versions" do - get :index + get wiki_page_versions_path assert_response :success - assert_not_nil(assigns(:wiki_page_versions)) end should "list all versions that match the search criteria" do - get :index, {:search => {:wiki_page_id => @wiki_page.id}} + get wiki_page_versions_path, params: {:search => {:wiki_page_id => @wiki_page.id}} assert_response :success - assert_not_nil(assigns(:wiki_page_versions)) end end context "show action" do should "render" do - get :show, { id: @wiki_page.versions.first.id } + get wiki_page_version_path(@wiki_page.versions.first) assert_response :success end end context "diff action" do should "render" do - get :diff, { thispage: @wiki_page.versions.first.id, otherpage: @wiki_page.versions.last.id } + get diff_wiki_page_versions_path, params: { thispage: @wiki_page.versions.first.id, otherpage: @wiki_page.versions.last.id } assert_response :success end end diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb index 45b9b55b5..d5f046d9e 100644 --- a/test/functional/wiki_pages_controller_test.rb +++ b/test/functional/wiki_pages_controller_test.rb @@ -1,95 +1,99 @@ require 'test_helper' -class WikiPagesControllerTest < ActionController::TestCase +class WikiPagesControllerTest < ActionDispatch::IntegrationTest context "The wiki pages controller" do setup do - @user = FactoryGirl.create(:user) - @mod = FactoryGirl.create(:moderator_user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" - end - - teardown do - CurrentUser.user = nil + @user = create(:user) + @mod = create(:moderator_user) end context "index action" do setup do - @wiki_page_abc = FactoryGirl.create(:wiki_page, :title => "abc") - @wiki_page_def = FactoryGirl.create(:wiki_page, :title => "def") + as_user do + @wiki_page_abc = create(:wiki_page, :title => "abc") + @wiki_page_def = create(:wiki_page, :title => "def") + end end should "list all wiki_pages" do - get :index + get wiki_pages_path assert_response :success end should "list all wiki_pages (with search)" do - get :index, {:search => {:title => "abc"}} + get wiki_pages_path, params: {:search => {:title => "abc"}} assert_redirected_to(wiki_page_path(@wiki_page_abc)) end should "list wiki_pages without tags with order=post_count" do - get :index, {:search => {:title => "abc", :order => "post_count"}} + get wiki_pages_path, params: {:search => {:title => "abc", :order => "post_count"}} assert_redirected_to(wiki_page_path(@wiki_page_abc)) end end context "show action" do setup do - @wiki_page = FactoryGirl.create(:wiki_page) + as_user do + @wiki_page = create(:wiki_page) + end end should "render" do - get :show, {:id => @wiki_page.id} + get wiki_page_path(@wiki_page) assert_response :success end should "render for a title" do - get :show, {:id => @wiki_page.title} + get wiki_page_path(:id => @wiki_page.title) assert_response :success end should "redirect for a nonexistent title" do - get :show, {:id => "what"} + get wiki_page_path(:id => "what") assert_redirected_to(show_or_new_wiki_pages_path(title: "what")) end should "render for a negated tag" do - @wiki_page.update_attribute(:title, "-aaa") - get :show, {:id => @wiki_page.id} + as_user do + @wiki_page.update(title: "-aaa") + end + get wiki_page_path(:id => @wiki_page.id) assert_response :success end end context "show_or_new action" do setup do - @wiki_page = FactoryGirl.create(:wiki_page) + as_user do + @wiki_page = create(:wiki_page) + end end should "redirect when given a title" do - get :show_or_new, { title: @wiki_page.title } + get show_or_new_wiki_pages_path, params: { title: @wiki_page.title } assert_redirected_to(@wiki_page) end should "render when given a nonexistent title" do - get :show_or_new, { title: "what" } + get show_or_new_wiki_pages_path, params: { title: "what" } assert_response :success end end context "new action" do should "render" do - get :new, {}, { user_id: @mod.id } + get_auth new_wiki_page_path, @mod, params: { wiki_page: { title: "test" }} assert_response :success end end context "edit action" do should "render" do - wiki_page = FactoryGirl.create(:wiki_page) + as_user do + @wiki_page = create(:wiki_page) + end - get :edit, { id: wiki_page.id }, { user_id: @mod.id } + get_auth wiki_page_path(@wiki_page), @mod assert_response :success end end @@ -97,54 +101,57 @@ class WikiPagesControllerTest < ActionController::TestCase context "create action" do should "create a wiki_page" do assert_difference("WikiPage.count", 1) do - post :create, {:wiki_page => {:title => "abc", :body => "abc"}}, {:user_id => @user.id} + post_auth wiki_pages_path, @user, params: {:wiki_page => {:title => "abc", :body => "abc"}} end end end context "update action" do setup do - @tag = FactoryGirl.create(:tag, name: "foo", post_count: 42) - @wiki_page = FactoryGirl.create(:wiki_page, title: "foo") + as_user do + @tag = create(:tag, name: "foo", post_count: 42) + @wiki_page = create(:wiki_page, title: "foo") + end end should "update a wiki_page" do - post :update, {:id => @wiki_page.id, :wiki_page => {:body => "xyz"}}, {:user_id => @user.id} + put_auth wiki_page_path(@wiki_page), @user, params: {:wiki_page => {:body => "xyz"}} @wiki_page.reload assert_equal("xyz", @wiki_page.body) end should "not rename a wiki page with a non-empty tag" do - post :update, {:id => @wiki_page.id, :wiki_page => {:title => "bar"}}, {:user_id => @user.id} - + put_auth wiki_page_path(@wiki_page), @user, params: {:wiki_page => {:title => "bar"}} assert_equal("foo", @wiki_page.reload.title) end should "rename a wiki page with a non-empty tag if secondary validations are skipped" do - post :update, {:id => @wiki_page.id, :wiki_page => {:title => "bar", :skip_secondary_validations => "1"}}, {:user_id => @user.id} - + put_auth wiki_page_path(@wiki_page), @user, params: {:wiki_page => {:title => "bar", :skip_secondary_validations => "1"}} assert_equal("bar", @wiki_page.reload.title) end + + should "not allow non-Builders to delete wiki pages" do + put_auth wiki_page_path(@wiki_page), @user, params: {wiki_page: { is_deleted: true }} + assert_equal(false, @wiki_page.reload.is_deleted?) + end end context "destroy action" do setup do - @wiki_page = FactoryGirl.create(:wiki_page) - @mod = FactoryGirl.create(:mod_user) + as_user do + @wiki_page = create(:wiki_page) + end + @mod = create(:mod_user) end should "destroy a wiki_page" do - CurrentUser.scoped(@mod) do - post :destroy, {:id => @wiki_page.id}, {:user_id => @mod.id} - end + delete_auth wiki_page_path(@wiki_page), @mod @wiki_page.reload assert_equal(true, @wiki_page.is_deleted?) end should "record the deleter" do - CurrentUser.scoped(@mod) do - post :destroy, {:id => @wiki_page.id}, {:user_id => @mod.id} - end + delete_auth wiki_page_path(@wiki_page), @mod @wiki_page.reload assert_equal(@mod.id, @wiki_page.updater_id) end @@ -152,27 +159,31 @@ class WikiPagesControllerTest < ActionController::TestCase context "revert action" do setup do - @wiki_page = FactoryGirl.create(:wiki_page, :body => "1") - Timecop.travel(1.day.from_now) do - @wiki_page.update_attributes(:body => "1 2") + as_user do + @wiki_page = create(:wiki_page, :body => "1") end - Timecop.travel(2.days.from_now) do - @wiki_page.update_attributes(:body => "1 2 3") + travel_to(1.day.from_now) do + @wiki_page.update(:body => "1 2") + end + travel_to(2.days.from_now) do + @wiki_page.update(:body => "1 2 3") end end should "revert to a previous version" do - version = @wiki_page.versions(true).first + version = @wiki_page.versions.first assert_equal("1", version.body) - post :revert, {:id => @wiki_page.id, :version_id => version.id}, {:user_id => @user.id} + put_auth revert_wiki_page_path(@wiki_page), @user, params: {:version_id => version.id} @wiki_page.reload assert_equal("1", @wiki_page.body) end should "not allow reverting to a previous version of another wiki page" do - @wiki_page_2 = FactoryGirl.create(:wiki_page) + as_user do + @wiki_page_2 = create(:wiki_page) + end - post :revert, { :id => @wiki_page.id, :version_id => @wiki_page_2.versions(true).first.id }, {:user_id => @user.id} + put_auth revert_wiki_page_path(@wiki_page), @user, params: { :version_id => @wiki_page_2.versions.first.id } @wiki_page.reload assert_not_equal(@wiki_page.body, @wiki_page_2.body) diff --git a/test/models/post_keeper_manager_test.rb b/test/models/post_keeper_manager_test.rb index ade48baf6..bfa1065e9 100644 --- a/test/models/post_keeper_manager_test.rb +++ b/test/models/post_keeper_manager_test.rb @@ -6,14 +6,14 @@ class PostKeeperManagerTest < ActiveSupport::TestCase context "#check_and_update" do setup do Timecop.travel(1.month.ago) do - @alice = FactoryGirl.create(:user) - @bob = FactoryGirl.create(:user) - @carol = FactoryGirl.create(:user) + @alice = FactoryBot.create(:user) + @bob = FactoryBot.create(:user) + @carol = FactoryBot.create(:user) end PostArchive.sqs_service.stubs(:merge?).returns(false) CurrentUser.scoped(@alice) do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) end CurrentUser.scoped(@bob) do Timecop.travel(2.hours.from_now) do @@ -37,13 +37,13 @@ class PostKeeperManagerTest < ActiveSupport::TestCase context "#check" do setup do Timecop.travel(1.month.ago) do - @alice = FactoryGirl.create(:user) - @bob = FactoryGirl.create(:user) - @carol = FactoryGirl.create(:user) + @alice = FactoryBot.create(:user) + @bob = FactoryBot.create(:user) + @carol = FactoryBot.create(:user) end CurrentUser.scoped(@alice) do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) end end diff --git a/test/models/super_voter_test.rb b/test/models/super_voter_test.rb index 44099ef04..e3d77f28c 100644 --- a/test/models/super_voter_test.rb +++ b/test/models/super_voter_test.rb @@ -3,12 +3,12 @@ require 'test_helper' class SuperVoterTest < ActiveSupport::TestCase def setup super - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end context "#init" do setup do - @admin = FactoryGirl.create(:admin_user) + @admin = FactoryBot.create(:admin_user) @user_mock = mock("user") @user_mock.expects(:user_id).twice.returns(@user.id) @admin_mock = mock("admin") @@ -25,7 +25,7 @@ class SuperVoterTest < ActiveSupport::TestCase context "creation" do should "update the is_super_voter field on the user object" do - FactoryGirl.create(:super_voter, user: @user) + FactoryBot.create(:super_voter, user: @user) @user.reload assert_equal(true, @user.is_super_voter?) end @@ -33,7 +33,7 @@ class SuperVoterTest < ActiveSupport::TestCase context "destruction" do should "update the is_super_voter field on the user object" do - voter = FactoryGirl.create(:super_voter, user: @user) + voter = FactoryBot.create(:super_voter, user: @user) voter.destroy @user.reload assert_equal(false, @user.is_super_voter?) diff --git a/test/test_helper.rb b/test/test_helper.rb index 9a7dd29da..93532d75f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -20,10 +20,33 @@ Dotenv.load(Rails.root + ".env.local") Shoulda::Matchers.configure do |config| config.integrate do |with| + with.test_framework :minitest with.library :rails end end +module TestHelpers + def create(factory_bot_model, params = {}) + record = FactoryBot.build(factory_bot_model, params) + record.save + raise ActiveRecord::RecordInvalid.new(record) if record.errors.any? + record + end + + def as(user, &block) + CurrentUser.as(user, &block) + end + + def as_user(&block) + CurrentUser.as(@user, &block) + end + + def as_admin(&block) + CurrentUser.as_admin(&block) + end +end + + class ActiveSupport::TestCase include PostArchiveTestHelper include PoolArchiveTestHelper @@ -32,6 +55,7 @@ class ActiveSupport::TestCase include IqdbTestHelper include SavedSearchTestHelper include UploadTestHelper + include TestHelpers setup do mock_popular_search_service! @@ -50,15 +74,32 @@ class ActiveSupport::TestCase end end -class ActionController::TestCase - def assert_authentication_passes(action, http_method, role, params, session) - __send__(http_method, action, params, session.merge(:user_id => @users[role].id)) - assert_response :success +class ActionDispatch::IntegrationTest + include PostArchiveTestHelper + include PoolArchiveTestHelper + include TestHelpers + + def method_authenticated(method_name, url, user, options) + Thread.current[:test_user_id] = user.id + self.send(method_name, url, options) + ensure + Thread.current[:test_user_id] = nil end - def assert_authentication_fails(action, http_method, role) - __send__(http_method, action, params, session.merge(:user_id => @users[role].id)) - assert_redirected_to(new_sessions_path) + def get_auth(url, user, options = {}) + method_authenticated(:get, url, user, options) + end + + def post_auth(url, user, options = {}) + method_authenticated(:post, url, user, options) + end + + def put_auth(url, user, options = {}) + method_authenticated(:put, url, user, options) + end + + def delete_auth(url, user, options = {}) + method_authenticated(:delete, url, user, options) end def setup @@ -73,6 +114,5 @@ class ActionController::TestCase end Delayed::Worker.delay_jobs = false -TestAfterCommit.enabled = false Rails.application.load_seed diff --git a/test/test_helpers/download_helper.rb b/test/test_helpers/download_test_helper.rb similarity index 62% rename from test/test_helpers/download_helper.rb rename to test/test_helpers/download_test_helper.rb index 8381f4629..dcdadc641 100644 --- a/test/test_helpers/download_helper.rb +++ b/test/test_helpers/download_test_helper.rb @@ -1,10 +1,10 @@ +require 'ptools' + module DownloadTestHelper def assert_downloaded(expected_filesize, source) - assert_nothing_raised(Downloads::File::Error) do - tempfile = Downloads::File.new(source).download! - assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}") - tempfile.close! - end + download = Downloads::File.new(source) + tempfile = download.download! + assert_equal(expected_filesize, tempfile.size, "Tested source URL: #{source}") end def assert_rewritten(expected_source, test_source) @@ -17,4 +17,8 @@ module DownloadTestHelper def assert_not_rewritten(source) assert_rewritten(source, source) end -end + + def check_ffmpeg + File.which("ffmpeg") && File.which("mkvmerge") + end +end \ No newline at end of file diff --git a/test/test_helpers/post_archive_test_helper.rb b/test/test_helpers/post_archive_test_helper.rb index 7380665d1..e4bf043a4 100644 --- a/test/test_helpers/post_archive_test_helper.rb +++ b/test/test_helpers/post_archive_test_helper.rb @@ -26,6 +26,9 @@ module PostArchiveTestHelper else json["added_tags"] = json["tags"].scan(/\S+/) end + json["parent_changed"] = (prev.nil? || json.key?("parent_id") && prev.parent_id != json["parent_id"]) + json["source_changed"] = (prev.nil? || json.key?("source") && prev.source != json["source"]) + json["rating_changed"] = (prev.nil? || json.key?("rating") && prev.rating != json["rating"]) if merge?(prev, json) prev.update_columns(json) else diff --git a/test/unit/alias_and_implication_importer_test.rb b/test/unit/alias_and_implication_importer_test.rb index d4f91f68f..1d0e07678 100644 --- a/test/unit/alias_and_implication_importer_test.rb +++ b/test/unit/alias_and_implication_importer_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class AliasAndImplicationImporterTest < ActiveSupport::TestCase context "The alias and implication importer" do setup do - CurrentUser.user = FactoryGirl.create(:admin_user) + CurrentUser.user = FactoryBot.create(:admin_user) CurrentUser.ip_addr = "127.0.0.1" end @@ -66,9 +66,9 @@ class AliasAndImplicationImporterTest < ActiveSupport::TestCase end should "rename an aliased tag's artist entry and wiki page" do - tag1 = FactoryGirl.create(:tag, :name => "aaa", :category => 1) - tag2 = FactoryGirl.create(:tag, :name => "bbb") - artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") + tag1 = FactoryBot.create(:tag, :name => "aaa", :category => 1) + tag2 = FactoryBot.create(:tag, :name => "bbb") + artist = FactoryBot.create(:artist, :name => "aaa", :notes => "testing") @importer = AliasAndImplicationImporter.new("create alias aaa -> bbb", "", "1") @importer.process! artist.reload diff --git a/test/unit/api_key_test.rb b/test/unit/api_key_test.rb index 412d9c243..51b6b5524 100644 --- a/test/unit/api_key_test.rb +++ b/test/unit/api_key_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ApiKeyTest < ActiveSupport::TestCase context "in all cases a user" do setup do - @user = FactoryGirl.create(:gold_user, :name => "abcdef") + @user = FactoryBot.create(:gold_user, :name => "abcdef") @api_key = ApiKey.generate!(@user) end diff --git a/test/unit/application_record.rb b/test/unit/application_record.rb index bbcb7dded..543e43f3e 100644 --- a/test/unit/application_record.rb +++ b/test/unit/application_record.rb @@ -2,7 +2,7 @@ require 'test_helper' class ApplicationRecordTest < ActiveSupport::TestCase setup do - @tags = FactoryGirl.create_list(:tag, 3, post_count: 1) + @tags = FactoryBot.create_list(:tag, 3, post_count: 1) end context "ApplicationRecord#search" do diff --git a/test/unit/artist_commentary_test.rb b/test/unit/artist_commentary_test.rb index 42c8b0ce5..09a7df47e 100644 --- a/test/unit/artist_commentary_test.rb +++ b/test/unit/artist_commentary_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class ArtistCommentaryTest < ActiveSupport::TestCase setup do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -13,21 +13,21 @@ class ArtistCommentaryTest < ActiveSupport::TestCase end should "A post should not have more than one commentary" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_raise(ActiveRecord::RecordInvalid) do - FactoryGirl.create(:artist_commentary, post_id: post.id) - FactoryGirl.create(:artist_commentary, post_id: post.id) + FactoryBot.create(:artist_commentary, post_id: post.id) + FactoryBot.create(:artist_commentary, post_id: post.id) end end context "An artist commentary" do context "when searched" do setup do - @post1 = FactoryGirl.create(:post, tag_string: "artcomm1") - @post2 = FactoryGirl.create(:post, tag_string: "artcomm2") - @artcomm1 = FactoryGirl.create(:artist_commentary, post_id: @post1.id, original_title: "foo", translated_title: "bar") - @artcomm2 = FactoryGirl.create(:artist_commentary, post_id: @post2.id, original_title: "", original_description: "", translated_title: "", translated_description: "") + @post1 = FactoryBot.create(:post, tag_string: "artcomm1") + @post2 = FactoryBot.create(:post, tag_string: "artcomm2") + @artcomm1 = FactoryBot.create(:artist_commentary, post_id: @post1.id, original_title: "foo", translated_title: "bar") + @artcomm2 = FactoryBot.create(:artist_commentary, post_id: @post2.id, original_title: "", original_description: "", translated_title: "", translated_description: "") end should "find the correct match" do @@ -46,7 +46,7 @@ class ArtistCommentaryTest < ActiveSupport::TestCase context "when created" do should "create a new version" do - @artcomm = FactoryGirl.create(:artist_commentary, original_title: "foo") + @artcomm = FactoryBot.create(:artist_commentary, original_title: "foo") assert_equal(1, @artcomm.versions.size) assert_equal("foo", @artcomm.versions.last.original_title) @@ -55,8 +55,8 @@ class ArtistCommentaryTest < ActiveSupport::TestCase context "when updated" do setup do - @post = FactoryGirl.create(:post) - @artcomm = FactoryGirl.create(:artist_commentary, post_id: @post.id) + @post = FactoryBot.create(:post) + @artcomm = FactoryBot.create(:artist_commentary, post_id: @post.id) @artcomm.reload end diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 7a096a47e..f7014255c 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -15,7 +15,7 @@ class ArtistTest < ActiveSupport::TestCase context "An artist" do setup do - user = Timecop.travel(1.month.ago) {FactoryGirl.create(:user)} + user = Timecop.travel(1.month.ago) {FactoryBot.create(:user)} CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -33,8 +33,8 @@ class ArtistTest < ActiveSupport::TestCase context "with a matching tag alias" do setup do - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - @artist = FactoryGirl.create(:artist, :name => "aaa") + @tag_alias = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + @artist = FactoryBot.create(:artist, :name => "aaa") end should "know it has an alias" do @@ -48,9 +48,9 @@ class ArtistTest < ActiveSupport::TestCase context "that has been banned" do setup do - @post = FactoryGirl.create(:post, :tag_string => "aaa") - @artist = FactoryGirl.create(:artist, :name => "aaa") - @admin = FactoryGirl.create(:admin_user) + @post = FactoryBot.create(:post, :tag_string => "aaa") + @artist = FactoryBot.create(:artist, :name => "aaa") + @admin = FactoryBot.create(:admin_user) CurrentUser.scoped(@admin) { @artist.ban! } @post.reload end @@ -88,7 +88,7 @@ class ArtistTest < ActiveSupport::TestCase should "create a new wiki page to store any note information" do artist = nil assert_difference("WikiPage.count") do - artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") + artist = FactoryBot.create(:artist, :name => "aaa", :notes => "testing") end assert_equal("testing", artist.notes) assert_equal("testing", artist.wiki_page.body) @@ -97,8 +97,8 @@ class ArtistTest < ActiveSupport::TestCase context "when a wiki page with the same name already exists" do setup do - @wiki_page = FactoryGirl.create(:wiki_page, :title => "aaa") - @artist = FactoryGirl.build(:artist, :name => "aaa") + @wiki_page = FactoryBot.create(:wiki_page, :title => "aaa") + @artist = FactoryBot.build(:artist, :name => "aaa") end should "not validate" do @@ -108,7 +108,7 @@ class ArtistTest < ActiveSupport::TestCase end should "update the wiki page when notes are assigned" do - artist = FactoryGirl.create(:artist, :name => "aaa", :notes => "testing") + artist = FactoryBot.create(:artist, :name => "aaa", :notes => "testing") artist.update_attribute(:notes, "kokoko") artist.reload assert_equal("kokoko", artist.notes) @@ -116,33 +116,32 @@ class ArtistTest < ActiveSupport::TestCase end should "normalize its name" do - artist = FactoryGirl.create(:artist, :name => " AAA BBB ") + artist = FactoryBot.create(:artist, :name => " AAA BBB ") assert_equal("aaa_bbb", artist.name) end should "resolve ambiguous urls" do - bobross = FactoryGirl.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg") - bob = FactoryGirl.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg") + bobross = FactoryBot.create(:artist, :name => "bob_ross", :url_string => "http://artists.com/bobross/image.jpg") + bob = FactoryBot.create(:artist, :name => "bob", :url_string => "http://artists.com/bob/image.jpg") matches = Artist.find_all_by_url("http://artists.com/bob/test.jpg") assert_equal(1, matches.size) assert_equal("bob", matches.first.name) end should "parse urls" do - artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com") + artist = FactoryBot.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg http://aaa.com") artist.reload assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort) end should "not allow invalid urls" do - artist = FactoryGirl.build(:artist, :url_string => "blah") - + artist = FactoryBot.create(:artist, :url_string => "blah") assert_equal(false, artist.valid?) - assert_equal(["'blah' must begin with http:// or https://"], artist.errors[:url]) + assert_equal(["Url must begin with http:// or https://"], artist.errors[:url]) end should "make sure old urls are deleted" do - artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") + artist = FactoryBot.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") artist.url_string = "http://not.rembrandt.com/test.jpg" artist.save artist.reload @@ -150,7 +149,7 @@ class ArtistTest < ActiveSupport::TestCase end should "not delete urls that have not changed" do - artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") + artist = FactoryBot.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg") old_url_ids = ArtistUrl.order("id").pluck(&:id) artist.url_string = "http://rembrandt.com/test.jpg" artist.save @@ -158,15 +157,15 @@ class ArtistTest < ActiveSupport::TestCase end should "ignore pixiv.net/ and pixiv.net/img/ url matches" do - a1 = FactoryGirl.create(:artist, :name => "yomosaka", :url_string => "http://i2.pixiv.net/img100/img/yomosaka/27618292.jpg") - a2 = FactoryGirl.create(:artist, :name => "niwatazumi_bf", :url_string => "http://i2.pixiv.net/img16/img/niwatazumi_bf/35488864_big_p6.jpg") + a1 = FactoryBot.create(:artist, :name => "yomosaka", :url_string => "http://i2.pixiv.net/img100/img/yomosaka/27618292.jpg") + a2 = FactoryBot.create(:artist, :name => "niwatazumi_bf", :url_string => "http://i2.pixiv.net/img16/img/niwatazumi_bf/35488864_big_p6.jpg") assert_equal([], Artist.find_all_by_url("http://i2.pixiv.net/img28/img/kyang692/35563903.jpg")) end should "find matches by url" do - a1 = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/x/test.jpg") - a2 = FactoryGirl.create(:artist, :name => "subway", :url_string => "http://subway.com/x/test.jpg") - a3 = FactoryGirl.create(:artist, :name => "minko", :url_string => "https://minko.com/x/test.jpg") + a1 = FactoryBot.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/x/test.jpg") + a2 = FactoryBot.create(:artist, :name => "subway", :url_string => "http://subway.com/x/test.jpg") + a3 = FactoryBot.create(:artist, :name => "minko", :url_string => "https://minko.com/x/test.jpg") assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/x/test.jpg").map(&:name)) assert_equal(["rembrandt"], Artist.find_all_by_url("http://rembrandt.com/x/another.jpg").map(&:name)) @@ -176,24 +175,24 @@ class ArtistTest < ActiveSupport::TestCase end should "not find duplicates" do - FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/x/a/image.jpg\nhttp://warhol.com/x/b/image.jpg") + FactoryBot.create(:artist, :name => "warhol", :url_string => "http://warhol.com/x/a/image.jpg\nhttp://warhol.com/x/b/image.jpg") assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/x/test.jpg").map(&:name)) end should "not include duplicate urls" do - artist = FactoryGirl.create(:artist, :url_string => "http://foo.com http://foo.com") + artist = FactoryBot.create(:artist, :url_string => "http://foo.com http://foo.com") assert_equal(["http://foo.com"], artist.url_array) end should "hide deleted artists" do - FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false) + FactoryBot.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)) end context "when finding deviantart artists" do setup do - FactoryGirl.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/") - FactoryGirl.create(:artist, :name => "trixia", :url_string => "http://trixdraws.deviantart.com/") + FactoryBot.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/") + FactoryBot.create(:artist, :name => "trixia", :url_string => "http://trixdraws.deviantart.com/") end should "find the correct artist for page URLs" do @@ -221,9 +220,9 @@ class ArtistTest < ActiveSupport::TestCase context "when finding pixiv artists" do setup do - FactoryGirl.create(:artist, :name => "masao",:url_string => "http://www.pixiv.net/member.php?id=32777") - FactoryGirl.create(:artist, :name => "bkub", :url_string => "http://www.pixiv.net/member.php?id=9948") - FactoryGirl.create(:artist, :name => "ryuura", :url_string => "http://www.pixiv.net/member.php?id=8678371") + FactoryBot.create(:artist, :name => "masao",:url_string => "http://www.pixiv.net/member.php?id=32777") + FactoryBot.create(:artist, :name => "bkub", :url_string => "http://www.pixiv.net/member.php?id=9948") + FactoryBot.create(:artist, :name => "ryuura", :url_string => "http://www.pixiv.net/member.php?id=8678371") end should "find the correct artist by looking up the profile url" do @@ -267,8 +266,8 @@ class ArtistTest < ActiveSupport::TestCase context "when finding nico seiga artists" do setup do - FactoryGirl.create(:artist, :name => "osamari", :url_string => "http://seiga.nicovideo.jp/user/illust/7017777") - FactoryGirl.create(:artist, :name => "hakuro109", :url_string => "http://seiga.nicovideo.jp/user/illust/16265470") + FactoryBot.create(:artist, :name => "osamari", :url_string => "http://seiga.nicovideo.jp/user/illust/7017777") + FactoryBot.create(:artist, :name => "hakuro109", :url_string => "http://seiga.nicovideo.jp/user/illust/16265470") end should "find the artist by the profile" do @@ -284,8 +283,9 @@ class ArtistTest < ActiveSupport::TestCase context "when finding twitter artists" do setup do - FactoryGirl.create(:artist, :name => "hammer_(sunset_beach)", :url_string => "http://twitter.com/hamaororon") - FactoryGirl.create(:artist, :name => "haruyama_kazunori", :url_string => "https://twitter.com/kazuharoom") + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key + FactoryBot.create(:artist, :name => "hammer_(sunset_beach)", :url_string => "http://twitter.com/hamaororon") + FactoryBot.create(:artist, :name => "haruyama_kazunori", :url_string => "https://twitter.com/kazuharoom") end should "find the correct artist for twitter.com sources" do @@ -317,8 +317,9 @@ class ArtistTest < ActiveSupport::TestCase context "when finding pawoo artists" do setup do - FactoryGirl.create(:artist, :name => "evazion", :url_string => "https://pawoo.net/@evazion") - FactoryGirl.create(:artist, :name => "yasumo01", :url_string => "https://pawoo.net/web/accounts/28816") + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id + FactoryBot.create(:artist, :name => "evazion", :url_string => "https://pawoo.net/@evazion") + FactoryBot.create(:artist, :name => "yasumo01", :url_string => "https://pawoo.net/web/accounts/28816") end should "find the artist" do @@ -336,8 +337,8 @@ class ArtistTest < ActiveSupport::TestCase context "when finding nijie artists" do setup do - FactoryGirl.create(:artist, :name => "evazion", :url_string => "http://nijie.info/members.php?id=236014") - FactoryGirl.create(:artist, :name => "728995", :url_string => "http://nijie.info/members.php?id=728995") + FactoryBot.create(:artist, :name => "evazion", :url_string => "http://nijie.info/members.php?id=236014") + FactoryBot.create(:artist, :name => "728995", :url_string => "http://nijie.info/members.php?id=728995") end should "find the artist" do @@ -352,8 +353,8 @@ class ArtistTest < ActiveSupport::TestCase context "when finding tumblr artists" do setup do - FactoryGirl.create(:artist, :name => "ilya_kuvshinov", :url_string => "http://kuvshinov-ilya.tumblr.com") - FactoryGirl.create(:artist, :name => "j.k.", :url_string => "https://jdotkdot5.tumblr.com") + FactoryBot.create(:artist, :name => "ilya_kuvshinov", :url_string => "http://kuvshinov-ilya.tumblr.com") + FactoryBot.create(:artist, :name => "j.k.", :url_string => "https://jdotkdot5.tumblr.com") end should "find the artist" do @@ -367,19 +368,19 @@ class ArtistTest < ActiveSupport::TestCase end should "normalize its other names" do - artist = FactoryGirl.create(:artist, :name => "a1", :other_names_comma => "aaa, bbb, ccc ddd") + artist = FactoryBot.create(:artist, :name => "a1", :other_names_comma => "aaa, bbb, ccc ddd") assert_equal("aaa, bbb, ccc_ddd", artist.other_names_comma) end should "search on its name should return results" do - artist = FactoryGirl.create(:artist, :name => "artist") + artist = FactoryBot.create(:artist, :name => "artist") assert_not_nil(Artist.search(:name => "artist").first) assert_not_nil(Artist.search(:name_matches => "artist").first) assert_not_nil(Artist.search(:any_name_matches => "artist").first) end should "search on other names should return matches" do - artist = FactoryGirl.create(:artist, :name => "artist", :other_names_comma => "aaa, ccc ddd") + artist = FactoryBot.create(:artist, :name => "artist", :other_names_comma => "aaa, ccc ddd") assert_nil(Artist.other_names_match("artist").first) assert_not_nil(Artist.other_names_match("aaa").first) assert_not_nil(Artist.other_names_match("ccc_ddd").first) @@ -391,8 +392,8 @@ class ArtistTest < ActiveSupport::TestCase end should "search on group name and return matches" do - cat_or_fish = FactoryGirl.create(:artist, :name => "cat_or_fish") - yuu = FactoryGirl.create(:artist, :name => "yuu", :group_name => "cat_or_fish") + cat_or_fish = FactoryBot.create(:artist, :name => "cat_or_fish") + yuu = FactoryBot.create(:artist, :name => "yuu", :group_name => "cat_or_fish") cat_or_fish.reload assert_equal("yuu", cat_or_fish.member_names) assert_not_nil(Artist.search(:name => "group:cat_or_fish").first) @@ -402,20 +403,20 @@ class ArtistTest < ActiveSupport::TestCase end should "search on has_tag and return matches" do - post = FactoryGirl.create(:post, tag_string: "bkub") - bkub = FactoryGirl.create(:artist, name: "bkub") - none = FactoryGirl.create(:artist, name: "none") + post = FactoryBot.create(:post, tag_string: "bkub") + bkub = FactoryBot.create(:artist, name: "bkub") + none = FactoryBot.create(:artist, name: "none") assert_equal(bkub.id, Artist.search(has_tag: "true").first.id) assert_equal(none.id, Artist.search(has_tag: "false").first.id) end should "revert to prior versions" do - user = FactoryGirl.create(:user) - reverter = FactoryGirl.create(:user) + user = FactoryBot.create(:user) + reverter = FactoryBot.create(:user) artist = nil assert_difference("ArtistVersion.count") do - artist = FactoryGirl.create(:artist, :other_names => "yyy") + artist = FactoryBot.create(:artist, :other_names => "yyy") end assert_difference("ArtistVersion.count") do @@ -433,15 +434,15 @@ class ArtistTest < ActiveSupport::TestCase end should "update the category of the tag when created" do - tag = FactoryGirl.create(:tag, :name => "abc") - artist = FactoryGirl.create(:artist, :name => "abc") + tag = FactoryBot.create(:tag, :name => "abc") + artist = FactoryBot.create(:artist, :name => "abc") tag.reload assert_equal(Tag.categories.artist, tag.category) end should "update the category of the tag when renamed" do - tag = FactoryGirl.create(:tag, :name => "def") - artist = FactoryGirl.create(:artist, :name => "abc") + tag = FactoryBot.create(:tag, :name => "def") + artist = FactoryBot.create(:artist, :name => "abc") artist.name = "def" artist.save tag.reload @@ -450,12 +451,12 @@ class ArtistTest < ActiveSupport::TestCase context "when updated" do setup do - @artist = FactoryGirl.create(:artist) + @artist = FactoryBot.create(:artist) @artist.stubs(:merge_version?).returns(false) end should "create a new version" do - assert_difference("@artist.versions.count") do + assert_difference("ArtistVersion.count") do @artist.update(:url_string => "http://foo.com") end end diff --git a/test/unit/artist_url_test.rb b/test/unit/artist_url_test.rb index fd7306f84..37fa84bca 100644 --- a/test/unit/artist_url_test.rb +++ b/test/unit/artist_url_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class ArtistUrlTest < ActiveSupport::TestCase context "An artist url" do setup do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" end @@ -13,24 +13,24 @@ class ArtistUrlTest < ActiveSupport::TestCase end should "always add a trailing slash when normalized" do - url = FactoryGirl.create(:artist_url, :url => "http://monet.com") + url = FactoryBot.create(:artist_url, :url => "http://monet.com") assert_equal("http://monet.com", url.url) assert_equal("http://monet.com/", url.normalized_url) - url = FactoryGirl.create(:artist_url, :url => "http://monet.com/") + url = FactoryBot.create(:artist_url, :url => "http://monet.com/") assert_equal("http://monet.com/", url.url) assert_equal("http://monet.com/", url.normalized_url) end should "normalise https" do - url = FactoryGirl.create(:artist_url, :url => "https://google.com") + url = FactoryBot.create(:artist_url, :url => "https://google.com") assert_equal("https://google.com", url.url) assert_equal("http://google.com/", url.normalized_url) end context "normalize twitter profile urls" do setup do - @url = FactoryGirl.create(:artist_url, :url => "https://twitter.com/BLAH") + @url = FactoryBot.create(:artist_url, :url => "https://twitter.com/BLAH") end should "downcase the url" do @@ -39,36 +39,36 @@ class ArtistUrlTest < ActiveSupport::TestCase end should "normalize fc2 urls" do - url = FactoryGirl.create(:artist_url, :url => "http://blog55.fc2.com/monet") + url = FactoryBot.create(:artist_url, :url => "http://blog55.fc2.com/monet") assert_equal("http://blog55.fc2.com/monet", url.url) assert_equal("http://blog.fc2.com/monet/", url.normalized_url) - url = FactoryGirl.create(:artist_url, :url => "http://blog-imgs-55.fc2.com/monet") + url = FactoryBot.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.fc2.com/monet/", url.normalized_url) end should "normalize nico seiga artist urls" do - url = FactoryGirl.create(:artist_url, :url => "http://seiga.nicovideo.jp/user/illust/1826959") + url = FactoryBot.create(:artist_url, :url => "http://seiga.nicovideo.jp/user/illust/1826959") assert_equal("http://seiga.nicovideo.jp/user/illust/1826959/", url.normalized_url) - url = FactoryGirl.create(:artist_url, :url => "http://seiga.nicovideo.jp/seiga/im4937663") + url = FactoryBot.create(:artist_url, :url => "http://seiga.nicovideo.jp/seiga/im4937663") assert_equal("http://seiga.nicovideo.jp/user/illust/7017777/", url.normalized_url) end should "normalize hentai foundry artist urls" do - url = FactoryGirl.create(:artist_url, :url => "http://pictures.hentai-foundry.com//a/AnimeFlux/219123.jpg") + url = FactoryBot.create(:artist_url, :url => "http://pictures.hentai-foundry.com//a/AnimeFlux/219123.jpg") assert_equal("http://pictures.hentai-foundry.com/a/AnimeFlux/219123.jpg/", url.normalized_url) end should "normalize pixiv urls" do - url = FactoryGirl.create(:artist_url, :url => "https://i.pximg.net/img-original/img/2010/11/30/08/39/58/14901720_p0.png") + url = FactoryBot.create(:artist_url, :url => "https://i.pximg.net/img-original/img/2010/11/30/08/39/58/14901720_p0.png") assert_equal("https://i.pximg.net/img-original/img/2010/11/30/08/39/58/14901720_p0.png", url.url) assert_equal("http://www.pixiv.net/member.php?id=339253/", url.normalized_url) end should "normalize twitter urls" do - url = FactoryGirl.create(:artist_url, :url => "https://twitter.com/MONET/status/12345") + url = FactoryBot.create(:artist_url, :url => "https://twitter.com/MONET/status/12345") assert_equal("https://twitter.com/MONET/status/12345", url.url) assert_equal("http://twitter.com/monet/status/12345/", url.normalized_url) end diff --git a/test/unit/ban_test.rb b/test/unit/ban_test.rb index 4eba9b429..52ce0f659 100644 --- a/test/unit/ban_test.rb +++ b/test/unit/ban_test.rb @@ -4,7 +4,7 @@ class BanTest < ActiveSupport::TestCase context "A ban" do context "created by an admin" do setup do - @banner = FactoryGirl.create(:admin_user) + @banner = FactoryBot.create(:admin_user) CurrentUser.user = @banner CurrentUser.ip_addr = "127.0.0.1" end @@ -16,42 +16,42 @@ class BanTest < ActiveSupport::TestCase end should "set the is_banned flag on the user" do - user = FactoryGirl.create(:user) - ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:user) + ban = FactoryBot.build(:ban, :user => user, :banner => @banner) ban.save user.reload assert(user.is_banned?) end should "not be valid against another admin" do - user = FactoryGirl.create(:admin_user) - ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:admin_user) + ban = FactoryBot.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) end should "be valid against anyone who is not an admin" do - user = FactoryGirl.create(:moderator_user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:moderator_user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = FactoryGirl.create(:contributor_user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:contributor_user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = FactoryGirl.create(:gold_user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:gold_user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = FactoryGirl.create(:user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) end end context "created by a moderator" do setup do - @banner = FactoryGirl.create(:moderator_user) + @banner = FactoryBot.create(:moderator_user) CurrentUser.user = @banner CurrentUser.ip_addr = "127.0.0.1" end @@ -63,47 +63,47 @@ class BanTest < ActiveSupport::TestCase end should "not be valid against an admin or moderator" do - user = FactoryGirl.create(:admin_user) - ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:admin_user) + ban = FactoryBot.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) - user = FactoryGirl.create(:moderator_user) - ban = FactoryGirl.build(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:moderator_user) + ban = FactoryBot.build(:ban, :user => user, :banner => @banner) ban.save assert(ban.errors.any?) end should "be valid against anyone who is not an admin or a moderator" do - user = FactoryGirl.create(:contributor_user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:contributor_user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = FactoryGirl.create(:gold_user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:gold_user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) - user = FactoryGirl.create(:user) - ban = FactoryGirl.create(:ban, :user => user, :banner => @banner) + user = FactoryBot.create(:user) + ban = FactoryBot.create(:ban, :user => user, :banner => @banner) assert(ban.errors.empty?) end end should "initialize the expiration date" do - user = FactoryGirl.create(:user) - admin = FactoryGirl.create(:admin_user) + user = FactoryBot.create(:user) + admin = FactoryBot.create(:admin_user) CurrentUser.scoped(admin) do - ban = FactoryGirl.create(:ban, :user => user, :banner => admin) + ban = FactoryBot.create(:ban, :user => user, :banner => admin) assert_not_nil(ban.expires_at) end end should "update the user's feedback" do - user = FactoryGirl.create(:user) - admin = FactoryGirl.create(:admin_user) + user = FactoryBot.create(:user) + admin = FactoryBot.create(:admin_user) assert(user.feedback.empty?) CurrentUser.scoped(admin) do - FactoryGirl.create(:ban, :user => user, :banner => admin) + FactoryBot.create(:ban, :user => user, :banner => admin) end assert(!user.feedback.empty?) assert_equal("negative", user.feedback.last.category) @@ -112,11 +112,11 @@ class BanTest < ActiveSupport::TestCase context "Searching for a ban" do should "find a given ban" do - CurrentUser.user = FactoryGirl.create(:admin_user) + CurrentUser.user = FactoryBot.create(:admin_user) CurrentUser.ip_addr = "127.0.0.1" - user = FactoryGirl.create(:user) - ban = FactoryGirl.create(:ban, user: user) + user = FactoryBot.create(:user) + ban = FactoryBot.create(:ban, user: user) params = { user_name: user.name, banner_name: ban.banner.name, @@ -133,10 +133,10 @@ class BanTest < ActiveSupport::TestCase context "by user id" do setup do - @admin = FactoryGirl.create(:admin_user) + @admin = FactoryBot.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end teardown do @@ -146,7 +146,7 @@ class BanTest < ActiveSupport::TestCase context "when only expired bans exist" do setup do - @ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => -1) + @ban = FactoryBot.create(:ban, :user => @user, :banner => @admin, :duration => -1) end should "not return expired bans" do @@ -156,7 +156,7 @@ class BanTest < ActiveSupport::TestCase context "when active bans still exist" do setup do - @ban = FactoryGirl.create(:ban, :user => @user, :banner => @admin, :duration => 1) + @ban = FactoryBot.create(:ban, :user => @user, :banner => @admin, :duration => 1) end should "return active bans" do diff --git a/test/unit/bulk_revert_test.rb b/test/unit/bulk_revert_test.rb index 21bc1d36b..a001bce36 100644 --- a/test/unit/bulk_revert_test.rb +++ b/test/unit/bulk_revert_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class BulkRevertTest < ActiveSupport::TestCase context "#find_post_versions" do subject do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) BulkRevert.new end diff --git a/test/unit/bulk_update_request_test.rb b/test/unit/bulk_update_request_test.rb index 3d507dbb1..4f6226fe7 100644 --- a/test/unit/bulk_update_request_test.rb +++ b/test/unit/bulk_update_request_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class BulkUpdateRequestTest < ActiveSupport::TestCase context "a bulk update request" do setup do - @admin = FactoryGirl.create(:admin_user) + @admin = FactoryBot.create(:admin_user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" end @@ -20,7 +20,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase create implication bar -> baz ) - @bur = FactoryGirl.create(:bulk_update_request, :script => @script) + @bur = FactoryBot.create(:bulk_update_request, :script => @script) @bur.approve!(@admin) @ta = TagAlias.where(:antecedent_name => "foo", :consequent_name => "bar").first @@ -54,8 +54,8 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "that has an invalid alias" do setup do - @alias1 = FactoryGirl.create(:tag_alias) - @req = FactoryGirl.build(:bulk_update_request, :script => "create alias bbb -> aaa") + @alias1 = FactoryBot.create(:tag_alias) + @req = FactoryBot.build(:bulk_update_request, :script => "create alias bbb -> aaa") end should "not validate" do @@ -68,9 +68,9 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "for an implication that is redundant with an existing implication" do should "not validate" do - FactoryGirl.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") - FactoryGirl.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") - bur = FactoryGirl.build(:bulk_update_request, :script => "imply a -> c") + FactoryBot.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") + FactoryBot.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") + bur = FactoryBot.build(:bulk_update_request, :script => "imply a -> c") bur.save assert_equal(["Error: a already implies c through another implication (create implication a -> c)"], bur.errors.full_messages) @@ -79,8 +79,8 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "for an implication that is redundant with another implication in the same BUR" do setup do - FactoryGirl.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") - @bur = FactoryGirl.build(:bulk_update_request, :script => "imply a -> b\nimply a -> c") + FactoryBot.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") + @bur = FactoryBot.build(:bulk_update_request, :script => "imply a -> b\nimply a -> c") @bur.save end @@ -98,7 +98,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "for a `category -> type` change" do should "work" do tag = Tag.find_or_create_by_name("tagme") - bur = FactoryGirl.create(:bulk_update_request, :script => "category tagme -> meta") + bur = FactoryBot.create(:bulk_update_request, :script => "category tagme -> meta") bur.approve!(@admin) assert_equal(Tag.categories.meta, tag.reload.category) @@ -107,9 +107,9 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "with an associated forum topic" do setup do - @topic = FactoryGirl.create(:forum_topic, :title => "[bulk] hoge") - @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) - @req = FactoryGirl.create(:bulk_update_request, :script => "create alias AAA -> BBB", :forum_topic_id => @topic.id, :forum_post_id => @post.id, :title => "[bulk] hoge") + @topic = FactoryBot.create(:forum_topic, :title => "[bulk] hoge") + @post = FactoryBot.create(:forum_post, :topic_id => @topic.id) + @req = FactoryBot.create(:bulk_update_request, :script => "create alias AAA -> BBB", :forum_topic_id => @topic.id, :forum_post_id => @post.id, :title => "[bulk] hoge") end should "gracefully handle validation errors during approval" do @@ -169,8 +169,8 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase context "when searching" do setup do - @bur1 = FactoryGirl.create(:bulk_update_request, title: "foo", script: "create alias aaa -> bbb", user_id: @admin.id) - @bur2 = FactoryGirl.create(:bulk_update_request, title: "bar", script: "create implication bbb -> ccc", user_id: @admin.id) + @bur1 = FactoryBot.create(:bulk_update_request, title: "foo", script: "create alias aaa -> bbb", user_id: @admin.id) + @bur2 = FactoryBot.create(:bulk_update_request, title: "bar", script: "create implication bbb -> ccc", user_id: @admin.id) @bur1.approve!(@admin) end diff --git a/test/unit/comment_test.rb b/test/unit/comment_test.rb index e14da6afc..f95e69879 100644 --- a/test/unit/comment_test.rb +++ b/test/unit/comment_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class CommentTest < ActiveSupport::TestCase context "A comment" do setup do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,16 +15,16 @@ class CommentTest < ActiveSupport::TestCase context "that mentions a user" do setup do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) Danbooru.config.stubs(:member_comment_limit).returns(100) Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) end context "added in an edit" do should "dmail the added user" do - @user1 = FactoryGirl.create(:user) - @user2 = FactoryGirl.create(:user) - @comment = FactoryGirl.create(:comment, :post_id => @post.id, :body => "@#{@user1.name}") + @user1 = FactoryBot.create(:user) + @user2 = FactoryBot.create(:user) + @comment = FactoryBot.create(:comment, :post_id => @post.id, :body => "@#{@user1.name}") assert_no_difference("@user1.dmails.count") do assert_difference("@user2.dmails.count") do @@ -37,32 +37,32 @@ class CommentTest < ActiveSupport::TestCase context "in a quote block" do setup do - @user2 = FactoryGirl.create(:user, :created_at => 2.weeks.ago) + @user2 = FactoryBot.create(:user, :created_at => 2.weeks.ago) end should "not create a dmail" do assert_difference("Dmail.count", 0) do - FactoryGirl.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote]") + FactoryBot.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote]") end assert_difference("Dmail.count", 0) do - FactoryGirl.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote] blah [quote]@#{@user2.name}[/quote]") + FactoryBot.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote] blah [quote]@#{@user2.name}[/quote]") end assert_difference("Dmail.count", 0) do - FactoryGirl.create(:comment, :post_id => @post.id, :body => "[quote][quote]@#{@user2.name}[/quote][/quote]") + FactoryBot.create(:comment, :post_id => @post.id, :body => "[quote][quote]@#{@user2.name}[/quote][/quote]") end assert_difference("Dmail.count", 1) do - FactoryGirl.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote] @#{@user2.name}") + FactoryBot.create(:comment, :post_id => @post.id, :body => "[quote]@#{@user2.name}[/quote] @#{@user2.name}") end end end context "outside a quote block" do setup do - @user2 = FactoryGirl.create(:user) - @comment = FactoryGirl.build(:comment, :post_id => @post.id, :body => "Hey @#{@user2.name} check this out!") + @user2 = FactoryBot.create(:user) + @comment = FactoryBot.build(:comment, :post_id => @post.id, :body => "Hey @#{@user2.name} check this out!") end should "create a dmail" do @@ -89,7 +89,7 @@ class CommentTest < ActiveSupport::TestCase end should "fail creation" do - comment = FactoryGirl.build(:comment) + comment = FactoryBot.build(:comment) comment.save assert_equal(["You can not post comments within 1 week of sign up"], comment.errors.full_messages) end @@ -103,9 +103,9 @@ class CommentTest < ActiveSupport::TestCase context "that is then deleted" do setup do - @post = FactoryGirl.create(:post) - @comment = FactoryGirl.create(:comment, :post_id => @post.id) - @comment.update({is_deleted: true}, as: :member) + @post = FactoryBot.create(:post) + @comment = FactoryBot.create(:comment, :post_id => @post.id) + @comment.update(is_deleted: true) @post.reload end @@ -115,59 +115,59 @@ class CommentTest < ActiveSupport::TestCase end should "be created" do - comment = FactoryGirl.build(:comment) + comment = FactoryBot.build(:comment) comment.save assert(comment.errors.empty?, comment.errors.full_messages.join(", ")) end should "not validate if the post does not exist" do - comment = FactoryGirl.build(:comment, :post_id => -1) + comment = FactoryBot.build(:comment, :post_id => -1) assert_not(comment.valid?) assert_equal(["must exist"], comment.errors[:post]) end should "not bump the parent post" do - post = FactoryGirl.create(:post) - comment = FactoryGirl.create(:comment, :do_not_bump_post => true, :post => post) + post = FactoryBot.create(:post) + comment = FactoryBot.create(:comment, :do_not_bump_post => true, :post => post) post.reload assert_nil(post.last_comment_bumped_at) - comment = FactoryGirl.create(:comment, :post => post) + comment = FactoryBot.create(:comment, :post => post) post.reload assert_not_nil(post.last_comment_bumped_at) end should "not bump the post after exceeding the threshold" do Danbooru.config.stubs(:comment_threshold).returns(1) - p = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:comment, :post => p) + p = FactoryBot.create(:post) + c1 = FactoryBot.create(:comment, :post => p) Timecop.travel(2.seconds.from_now) do - c2 = FactoryGirl.create(:comment, :post => p) + c2 = FactoryBot.create(:comment, :post => p) end p.reload assert_equal(c1.created_at.to_s, p.last_comment_bumped_at.to_s) end should "always record the last_commented_at properly" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) Danbooru.config.stubs(:comment_threshold).returns(1) - c1 = FactoryGirl.create(:comment, :do_not_bump_post => true, :post => post) + c1 = FactoryBot.create(:comment, :do_not_bump_post => true, :post => post) post.reload assert_equal(c1.created_at.to_s, post.last_commented_at.to_s) Timecop.travel(2.seconds.from_now) do - c2 = FactoryGirl.create(:comment, :post => post) + c2 = FactoryBot.create(:comment, :post => post) post.reload assert_equal(c2.created_at.to_s, post.last_commented_at.to_s) end end should "not record the user id of the voter" do - user = FactoryGirl.create(:user) - post = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:comment, :post => post) + user = FactoryBot.create(:user) + post = FactoryBot.create(:post) + c1 = FactoryBot.create(:comment, :post => post) CurrentUser.scoped(user, "127.0.0.1") do c1.vote!("up") c1.reload @@ -176,9 +176,9 @@ class CommentTest < ActiveSupport::TestCase end should "not allow duplicate votes" do - user = FactoryGirl.create(:user) - post = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:comment, :post => post) + user = FactoryBot.create(:user) + post = FactoryBot.create(:post) + c1 = FactoryBot.create(:comment, :post => post) assert_nothing_raised { c1.vote!("down") } exception = assert_raises(ActiveRecord::RecordInvalid) { c1.vote!("down") } @@ -186,24 +186,24 @@ class CommentTest < ActiveSupport::TestCase assert_equal(1, CommentVote.count) assert_equal(-1, CommentVote.last.score) - c2 = FactoryGirl.create(:comment, :post => post) + c2 = FactoryBot.create(:comment, :post => post) assert_nothing_raised { c2.vote!("down") } assert_equal(2, CommentVote.count) end should "not allow upvotes by the creator" do - user = FactoryGirl.create(:user) - post = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:comment, :post => post) + user = FactoryBot.create(:user) + post = FactoryBot.create(:post) + c1 = FactoryBot.create(:comment, :post => post) exception = assert_raises(ActiveRecord::RecordInvalid) { c1.vote!("up") } assert_equal("Validation failed: You cannot upvote your own comments", exception.message) end should "allow undoing of votes" do - user = FactoryGirl.create(:user) - post = FactoryGirl.create(:post) - comment = FactoryGirl.create(:comment, :post => post) + user = FactoryBot.create(:user) + post = FactoryBot.create(:post) + comment = FactoryBot.create(:comment, :post => post) CurrentUser.scoped(user, "127.0.0.1") do comment.vote!("up") comment.unvote! @@ -214,9 +214,9 @@ class CommentTest < ActiveSupport::TestCase end should "be searchable" do - c1 = FactoryGirl.create(:comment, :body => "aaa bbb ccc") - c2 = FactoryGirl.create(:comment, :body => "aaa ddd") - c3 = FactoryGirl.create(:comment, :body => "eee") + c1 = FactoryBot.create(:comment, :body => "aaa bbb ccc") + c2 = FactoryBot.create(:comment, :body => "aaa ddd") + c3 = FactoryBot.create(:comment, :body => "eee") matches = Comment.body_matches("aaa") assert_equal(2, matches.count) @@ -225,7 +225,7 @@ class CommentTest < ActiveSupport::TestCase end should "default to id_desc order when searched with no options specified" do - comms = FactoryGirl.create_list(:comment, 3) + comms = FactoryBot.create_list(:comment, 3) matches = Comment.search({}) assert_equal([comms[2].id, comms[1].id, comms[0].id], matches.map(&:id)) @@ -233,38 +233,38 @@ class CommentTest < ActiveSupport::TestCase context "that is edited by a moderator" do setup do - @post = FactoryGirl.create(:post) - @comment = FactoryGirl.create(:comment, :post_id => @post.id) - @mod = FactoryGirl.create(:moderator_user) + @post = FactoryBot.create(:post) + @comment = FactoryBot.create(:comment, :post_id => @post.id) + @mod = FactoryBot.create(:moderator_user) CurrentUser.user = @mod end should "create a mod action" do assert_difference("ModAction.count") do - @comment.update_attributes({:body => "nope"}, :as => :moderator) + @comment.update_attributes(:body => "nope") end end should "credit the moderator as the updater" do - @comment.update({ body: "test" }, as: :moderator) + @comment.update(body: "test") assert_equal(@mod.id, @comment.updater_id) end end context "that is below the score threshold" do should "be hidden if not stickied" do - user = FactoryGirl.create(:user, :comment_threshold => 0) - post = FactoryGirl.create(:post) - comment = FactoryGirl.create(:comment, :post => post, :score => -5) + user = FactoryBot.create(:user, :comment_threshold => 0) + post = FactoryBot.create(:post) + comment = FactoryBot.create(:comment, :post => post, :score => -5) assert_equal([comment], post.comments.hidden(user)) assert_equal([], post.comments.visible(user)) end should "be visible if stickied" do - user = FactoryGirl.create(:user, :comment_threshold => 0) - post = FactoryGirl.create(:post) - comment = FactoryGirl.create(:comment, :post => post, :score => -5, :is_sticky => true) + user = FactoryBot.create(:user, :comment_threshold => 0) + post = FactoryBot.create(:post) + comment = FactoryBot.create(:comment, :post => post, :score => -5, :is_sticky => true) assert_equal([], post.comments.hidden(user)) assert_equal([comment], post.comments.visible(user)) @@ -273,7 +273,7 @@ class CommentTest < ActiveSupport::TestCase context "that is quoted" do should "strip [quote] tags correctly" do - comment = FactoryGirl.create(:comment, body: <<-EOS.strip_heredoc) + comment = FactoryBot.create(:comment, body: <<-EOS.strip_heredoc) paragraph one [quote] diff --git a/test/unit/current_user_test.rb b/test/unit/current_user_test.rb index fdd16c616..2ef0d1d8a 100644 --- a/test/unit/current_user_test.rb +++ b/test/unit/current_user_test.rb @@ -23,7 +23,7 @@ class CurrentUserTest < ActiveSupport::TestCase req = mock() req.stubs(:host).returns("danbooru") req.stubs(:params).returns({}) - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.set_safe_mode(req) assert_equal(false, CurrentUser.safe_mode?) end @@ -33,7 +33,7 @@ class CurrentUserTest < ActiveSupport::TestCase req.stubs(:host).returns("danbooru") req.stubs(:params).returns({}) - CurrentUser.user = FactoryGirl.create(:user, enable_safe_mode: true) + CurrentUser.user = FactoryBot.create(:user, enable_safe_mode: true) CurrentUser.set_safe_mode(req) assert_equal(true, CurrentUser.safe_mode?) @@ -42,7 +42,7 @@ class CurrentUserTest < ActiveSupport::TestCase context "The current user" do should "be set only within the scope of the block" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) assert_nil(CurrentUser.user) assert_nil(CurrentUser.ip_addr) @@ -58,8 +58,8 @@ class CurrentUserTest < ActiveSupport::TestCase context "A scoped current user" do should "reset the current user after the block has exited" do - user1 = FactoryGirl.create(:user) - user2 = FactoryGirl.create(:user) + user1 = FactoryBot.create(:user) + user2 = FactoryBot.create(:user) CurrentUser.user = user1 CurrentUser.scoped(user2, nil) do assert_equal(user2.id, CurrentUser.user.id) @@ -68,8 +68,8 @@ class CurrentUserTest < ActiveSupport::TestCase end should "reset the current user even if an exception is thrown" do - user1 = FactoryGirl.create(:user) - user2 = FactoryGirl.create(:user) + user1 = FactoryBot.create(:user) + user2 = FactoryBot.create(:user) CurrentUser.user = user1 assert_raises(RuntimeError) do CurrentUser.scoped(user2, nil) do diff --git a/test/models/dmail_filter_test.rb b/test/unit/dmail_filter_test.rb similarity index 92% rename from test/models/dmail_filter_test.rb rename to test/unit/dmail_filter_test.rb index b2c17bb03..2c62ae506 100644 --- a/test/models/dmail_filter_test.rb +++ b/test/unit/dmail_filter_test.rb @@ -4,8 +4,8 @@ class DmailFilterTest < ActiveSupport::TestCase def setup super - @receiver = FactoryGirl.create(:user) - @sender = FactoryGirl.create(:user) + @receiver = FactoryBot.create(:user) + @sender = FactoryBot.create(:user) end def create_dmail(body, title) diff --git a/test/unit/dmail_test.rb b/test/unit/dmail_test.rb index 25f91cb43..45594f52a 100644 --- a/test/unit/dmail_test.rb +++ b/test/unit/dmail_test.rb @@ -3,24 +3,22 @@ require 'test_helper' class DmailTest < ActiveSupport::TestCase context "A dmail" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "1.2.3.4" ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true ActionMailer::Base.deliveries = [] - TestAfterCommit.enabled = true end teardown do CurrentUser.user = nil - TestAfterCommit.enabled = false end context "spam" do setup do Dmail.any_instance.stubs(:spam?).returns(true) - @recipient = FactoryGirl.create(:user) + @recipient = FactoryBot.create(:user) end should "not validate" do @@ -33,7 +31,7 @@ class DmailTest < ActiveSupport::TestCase should "autoban spammers after sending spam to N distinct users" do Dmail.any_instance.expects(:spam?).returns(true) - users = FactoryGirl.create_list(:user, Dmail::AUTOBAN_THRESHOLD) + users = FactoryBot.create_list(:user, Dmail::AUTOBAN_THRESHOLD) users.each do |user| Dmail.create_split(from: @user, to: user, title: "spam", body: "wonderful spam") end @@ -47,9 +45,9 @@ class DmailTest < ActiveSupport::TestCase context "filter" do setup do - @recipient = FactoryGirl.create(:user) + @recipient = FactoryBot.create(:user) @recipient.create_dmail_filter(:words => "banned") - @dmail = FactoryGirl.build(:dmail, :title => "xxx", :owner => @recipient, :body => "banned word here", :to => @recipient, :from => @user) + @dmail = FactoryBot.build(:dmail, :title => "xxx", :owner => @recipient, :body => "banned word here", :to => @recipient, :from => @user) end should "detect banned words" do @@ -68,8 +66,8 @@ class DmailTest < ActiveSupport::TestCase end should "be ignored when sender is a moderator" do - CurrentUser.scoped(FactoryGirl.create(:moderator_user), "127.0.0.1") do - @dmail = FactoryGirl.create(:dmail, :owner => @recipient, :body => "banned word here", :to => @recipient) + CurrentUser.scoped(FactoryBot.create(:moderator_user), "127.0.0.1") do + @dmail = FactoryBot.create(:dmail, :owner => @recipient, :body => "banned word here", :to => @recipient) end assert_equal(false, !!@recipient.dmail_filter.filtered?(@dmail)) @@ -94,7 +92,7 @@ class DmailTest < ActiveSupport::TestCase end should "not validate" do - dmail = FactoryGirl.build(:dmail, :title => "xxx", :owner => @user) + dmail = FactoryBot.build(:dmail, :title => "xxx", :owner => @user) dmail.save assert_equal(1, dmail.errors.size) assert_equal(["Sender is banned and cannot send messages"], dmail.errors.full_messages) @@ -103,7 +101,7 @@ class DmailTest < ActiveSupport::TestCase context "search" do should "return results based on title contents" do - dmail = FactoryGirl.create(:dmail, :title => "xxx", :owner => @user) + dmail = FactoryBot.create(:dmail, :title => "xxx", :owner => @user) matches = Dmail.search(title_matches: "x") assert_equal([dmail.id], matches.map(&:id)) @@ -119,7 +117,7 @@ class DmailTest < ActiveSupport::TestCase end should "return results based on body contents" do - dmail = FactoryGirl.create(:dmail, :body => "xxx", :owner => @user) + dmail = FactoryBot.create(:dmail, :body => "xxx", :owner => @user) matches = Dmail.search_message("xxx") assert(matches.any?) matches = Dmail.search_message("aaa") @@ -128,14 +126,14 @@ class DmailTest < ActiveSupport::TestCase end should "should parse user names" do - dmail = FactoryGirl.build(:dmail, :owner => @user) + dmail = FactoryBot.build(:dmail, :owner => @user) dmail.to_id = nil dmail.to_name = @user.name assert(dmail.to_id == @user.id) end should "construct a response" do - dmail = FactoryGirl.create(:dmail, :owner => @user) + dmail = FactoryBot.create(:dmail, :owner => @user) response = dmail.build_response assert_equal("Re: #{dmail.title}", response.title) assert_equal(dmail.from_id, response.to_id) @@ -143,41 +141,41 @@ class DmailTest < ActiveSupport::TestCase end should "create a copy for each user" do - @new_user = FactoryGirl.create(:user) + @new_user = FactoryBot.create(:user) assert_difference("Dmail.count", 2) do Dmail.create_split(:to_id => @new_user.id, :title => "foo", :body => "foo") end end should "record the creator's ip addr" do - dmail = FactoryGirl.create(:dmail, owner: @user) + dmail = FactoryBot.create(:dmail, owner: @user) assert_equal(CurrentUser.ip_addr, dmail.creator_ip_addr.to_s) end should "send an email if the user wants it" do - user = FactoryGirl.create(:user, :receive_email_notifications => true) + user = FactoryBot.create(:user, :receive_email_notifications => true) assert_difference("ActionMailer::Base.deliveries.size", 1) do - FactoryGirl.create(:dmail, :to => user, :owner => user) + FactoryBot.create(:dmail, :to => user, :owner => user) end end should "create only one message for a split response" do - user = FactoryGirl.create(:user, :receive_email_notifications => true) + user = FactoryBot.create(:user, :receive_email_notifications => true) assert_difference("ActionMailer::Base.deliveries.size", 1) do Dmail.create_split(:to_id => user.id, :title => "foo", :body => "foo") end end should "be marked as read after the user reads it" do - dmail = FactoryGirl.create(:dmail, :owner => @user) + dmail = FactoryBot.create(:dmail, :owner => @user) assert(!dmail.is_read?) dmail.mark_as_read! assert(dmail.is_read?) end should "notify the recipient he has mail" do - @recipient = FactoryGirl.create(:user) - dmail = FactoryGirl.create(:dmail, :owner => @recipient) + @recipient = FactoryBot.create(:user) + dmail = FactoryBot.create(:dmail, :owner => @recipient) recipient = dmail.to recipient.reload assert(recipient.has_mail?) @@ -192,7 +190,7 @@ class DmailTest < ActiveSupport::TestCase context "that is automated" do setup do - @bot = FactoryGirl.create(:user) + @bot = FactoryBot.create(:user) User.stubs(:system).returns(@bot) end diff --git a/test/unit/downloads/file_test.rb b/test/unit/downloads/file_test.rb index 7698941d8..8d53a6552 100644 --- a/test/unit/downloads/file_test.rb +++ b/test/unit/downloads/file_test.rb @@ -4,6 +4,7 @@ module Downloads class FileTest < ActiveSupport::TestCase context "A twitter video download" do setup do + skip "Twitter is not configured" unless Danbooru.config.twitter_api_key @source = "https://twitter.com/CincinnatiZoo/status/859073537713328129" @download = Downloads::File.new(@source) end diff --git a/test/unit/downloads/pawoo_test.rb b/test/unit/downloads/pawoo_test.rb index 4340e2e04..f3bb34371 100644 --- a/test/unit/downloads/pawoo_test.rb +++ b/test/unit/downloads/pawoo_test.rb @@ -4,6 +4,7 @@ module Downloads class PawooTest < ActiveSupport::TestCase context "downloading a 'https://pawoo.net/web/statuses/:id' url" do should "download the original file" do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @source = "https://pawoo.net/web/statuses/1202176" @rewrite = "https://img.pawoo.net/media_attachments/files/000/128/953/original/4c0a06087b03343f.png" assert_rewritten(@rewrite, @source) @@ -13,6 +14,7 @@ module Downloads context "downloading a 'https://pawoo.net/:user/:id' url" do should "download the original file" do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @source = "https://pawoo.net/@9ed00e924818/1202176" @rewrite = "https://img.pawoo.net/media_attachments/files/000/128/953/original/4c0a06087b03343f.png" assert_rewritten(@rewrite, @source) @@ -22,6 +24,7 @@ module Downloads context "downloading a 'https://img.pawoo.net/media_attachments/:id/small/:file' url" do should "download the original file" do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @source = "https://img.pawoo.net/media_attachments/files/000/128/953/small/4c0a06087b03343f.png" @rewrite = "https://img.pawoo.net/media_attachments/files/000/128/953/original/4c0a06087b03343f.png" assert_rewritten(@rewrite, @source) diff --git a/test/unit/downloads/tumblr_test.rb b/test/unit/downloads/tumblr_test.rb index 0a20cdc0c..adfbe7881 100644 --- a/test/unit/downloads/tumblr_test.rb +++ b/test/unit/downloads/tumblr_test.rb @@ -4,6 +4,7 @@ module Downloads class TumblrTest < ActiveSupport::TestCase context "a download for a tumblr 500 sample" do should "instead download the raw version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://24.media.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_500.jpg" @rewrite = "http://data.tumblr.com/fc328250915434e66e8e6a92773f79d0/tumblr_mf4nshfibc1s0oswoo1_raw.jpg" assert_rewritten(@rewrite, @source) @@ -13,6 +14,7 @@ module Downloads context "a download for a *.media.tumblr.com/tumblr_$id_$size image without a larger size" do should "download the same version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://25.media.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg" @rewrite = "http://data.tumblr.com/tumblr_lxbzel2H5y1r9yjhso1_500.jpg" assert_rewritten(@rewrite, @source) @@ -22,6 +24,7 @@ module Downloads context "a download for a *.media.tumblr.com/tumblr_$id_$size image with a larger size" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://25.media.tumblr.com/tumblr_m2dxb8aOJi1rop2v0o1_500.png" @rewrite = "http://data.tumblr.com/tumblr_m2dxb8aOJi1rop2v0o1_1280.png" assert_rewritten(@rewrite, @source) @@ -31,6 +34,7 @@ module Downloads context "a download for a *.media.tumblr.com/$hash/tumblr_$id_rN_$size image" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://33.media.tumblr.com/4b7fecf9a5a8284fbaefb051a2369b55/tumblr_npozqfwc9h1rt6u7do1_r1_500.gif" @rewrite = "http://data.tumblr.com/4b7fecf9a5a8284fbaefb051a2369b55/tumblr_npozqfwc9h1rt6u7do1_r1_raw.gif" assert_rewritten(@rewrite, @source) @@ -40,6 +44,7 @@ module Downloads context "a download for a *.media.tumblr.com/$hash/tumblr_inline_$id_$size image" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://68.media.tumblr.com/ee02048f5578595badc95905e17154b4/tumblr_inline_ofbr4452601sk4jd9_250.gif" @rewrite = "http://data.tumblr.com/ee02048f5578595badc95905e17154b4/tumblr_inline_ofbr4452601sk4jd9_500.gif" assert_rewritten(@rewrite, @source) @@ -49,6 +54,7 @@ module Downloads context "a download for a data.tumblr.com/$id_$size image with a larger size" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "http://data.tumblr.com/0DNBGJovY5j3smfeQs8nB53z_400.jpg" @rewrite = "http://data.tumblr.com/0DNBGJovY5j3smfeQs8nB53z_500.jpg" assert_rewritten(@rewrite, @source) @@ -58,6 +64,7 @@ module Downloads context "a download for a data.tumblr.com/tumblr_$id_$size.jpg image" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "http://data.tumblr.com/tumblr_m24kbxqKAX1rszquso1_250.jpg" @rewrite = "http://data.tumblr.com/tumblr_m24kbxqKAX1rszquso1_1280.jpg" assert_rewritten(@rewrite, @source) @@ -67,6 +74,7 @@ module Downloads context "a download for a gs1.wac.edgecastcdn.net image" do should "rewrite to the full tumblr version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://gs1.wac.edgecastcdn.net/8019B6/data.tumblr.com/tumblr_m2dxb8aOJi1rop2v0o1_500.png" @rewrite = "http://data.tumblr.com/tumblr_m2dxb8aOJi1rop2v0o1_1280.png" @@ -77,6 +85,7 @@ module Downloads context "a download for a *.tumblr.com/post/* html page" do should "download the best available version" do + skip "Tumblr keys are not set" unless Danbooru.config.tumblr_consumer_key @source = "https://noizave.tumblr.com/post/162206271767" @rewrite = "http://data.tumblr.com/3bbfcbf075ddf969c996641b264086fd/tumblr_os2buiIOt51wsfqepo1_raw.png" diff --git a/test/unit/downloads/twitter_test.rb b/test/unit/downloads/twitter_test.rb index a7f1e7bf7..0aee27c30 100644 --- a/test/unit/downloads/twitter_test.rb +++ b/test/unit/downloads/twitter_test.rb @@ -4,6 +4,7 @@ module Downloads class TwitterTest < ActiveSupport::TestCase context "downloading a 'https://twitter.com/:user/status/:id' url containing a video" do should "download the largest video" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @source = "https://twitter.com/CincinnatiZoo/status/859073537713328129" @rewrite = "https://video.twimg.com/ext_tw_video/859073467769126913/pu/vid/1280x720/cPGgVROXHy3yrK6u.mp4" assert_rewritten(@rewrite, @source) @@ -13,6 +14,7 @@ module Downloads context "downloading a 'https://twitter.com/:user/status/:id/photo/:n' card url" do should "download the orig file" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @source = "https://twitter.com/masayasuf/status/870734961778630656/photo/1" @rewrite = "https://pbs.twimg.com/media/DBV40M2UIAAHYlt.jpg:orig" assert_rewritten(@rewrite, @source) @@ -22,6 +24,7 @@ module Downloads context "downloading a 'https://mobile.twitter.com/:user/status/:id/photo/:n' mobile url" do should "download the orig file" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @source = "https://mobile.twitter.com/Strangestone/status/556440271961858051" @rewrite = "https://pbs.twimg.com/media/B7jfc1JCcAEyeJh.png:orig" assert_rewritten(@rewrite, @source) @@ -31,6 +34,7 @@ module Downloads context "downloading a 'https://pbs.twimg.com/media/*:large' url" do should "download the orig file" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @source = "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:large" @rewrite = "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:orig" assert_rewritten(@rewrite, @source) diff --git a/test/unit/favorite_group_test.rb b/test/unit/favorite_group_test.rb index 2a50bb867..dae620b37 100644 --- a/test/unit/favorite_group_test.rb +++ b/test/unit/favorite_group_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class FavoriteTest < ActiveSupport::TestCase def setup super - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @fav_group = FactoryGirl.create(:favorite_group, creator: @user, name: "blah") + @fav_group = FactoryBot.create(:favorite_group, creator: @user, name: "blah") end def teardown @@ -63,7 +63,7 @@ class FavoriteTest < ActiveSupport::TestCase context "expunging a post" do setup do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) @fav_group.add!(@post) end diff --git a/test/unit/favorite_test.rb b/test/unit/favorite_test.rb index 58900305e..0d52f0db4 100644 --- a/test/unit/favorite_test.rb +++ b/test/unit/favorite_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class FavoriteTest < ActiveSupport::TestCase setup do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" Favorite # need to force loading the favorite model @@ -15,21 +15,21 @@ class FavoriteTest < ActiveSupport::TestCase context "A favorite" do should "delete from all tables" do - user1 = FactoryGirl.create(:user) - p1 = FactoryGirl.create(:post) + user1 = FactoryBot.create(:user) + p1 = FactoryBot.create(:post) user1.add_favorite!(p1) assert_equal(1, Favorite.count) - Favorite.destroy_all(:user_id => user1.id, :post_id => p1.id) + Favorite.where(:user_id => user1.id, :post_id => p1.id).delete_all assert_equal(0, Favorite.count) end should "know which table it belongs to" do - user1 = FactoryGirl.create(:user) - user2 = FactoryGirl.create(:user) - p1 = FactoryGirl.create(:post) - p2 = FactoryGirl.create(:post) + user1 = FactoryBot.create(:user) + user2 = FactoryBot.create(:user) + p1 = FactoryBot.create(:post) + p2 = FactoryBot.create(:post) user1.add_favorite!(p1) user1.add_favorite!(p2) @@ -46,9 +46,9 @@ class FavoriteTest < ActiveSupport::TestCase end should "not allow duplicates" do - user1 = FactoryGirl.create(:user) - p1 = FactoryGirl.create(:post) - p2 = FactoryGirl.create(:post) + user1 = FactoryBot.create(:user) + p1 = FactoryBot.create(:post) + p2 = FactoryBot.create(:post) user1.add_favorite!(p1) user1.add_favorite!(p1) diff --git a/test/unit/forum_post_test.rb b/test/unit/forum_post_test.rb index 2b60d66d5..b565c30c8 100644 --- a/test/unit/forum_post_test.rb +++ b/test/unit/forum_post_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class ForumPostTest < ActiveSupport::TestCase context "A forum post" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @topic = FactoryGirl.create(:forum_topic) + @topic = FactoryBot.create(:forum_topic) end teardown do @@ -17,32 +17,32 @@ class ForumPostTest < ActiveSupport::TestCase context "that mentions a user" do context "in a quote block" do setup do - @user2 = FactoryGirl.create(:user) + @user2 = FactoryBot.create(:user) end should "not create a dmail" do assert_difference("Dmail.count", 0) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote]") + FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote]") end assert_difference("Dmail.count", 0) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote] blah [quote]@#{@user2.name}[/quote]") + FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote] blah [quote]@#{@user2.name}[/quote]") end assert_difference("Dmail.count", 0) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "[quote][quote]@#{@user2.name}[/quote][/quote]") + FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "[quote][quote]@#{@user2.name}[/quote][/quote]") end assert_difference("Dmail.count", 1) do - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote] @#{@user2.name}") + FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "[quote]@#{@user2.name}[/quote] @#{@user2.name}") end end end context "outside a quote block" do setup do - @user2 = FactoryGirl.create(:user) - @post = FactoryGirl.build(:forum_post, :topic_id => @topic.id, :body => "Hey @#{@user2.name} check this out!") + @user2 = FactoryBot.create(:user) + @post = FactoryBot.build(:forum_post, :topic_id => @topic.id, :body => "Hey @#{@user2.name} check this out!") end should "create a dmail" do @@ -67,16 +67,16 @@ class ForumPostTest < ActiveSupport::TestCase Danbooru.config.stubs(:posts_per_page).returns(3) @posts = [] 9.times do - @posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) + @posts << FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) end Timecop.travel(2.seconds.from_now) do - @posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) + @posts << FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) end end context "that is deleted" do setup do - CurrentUser.user = FactoryGirl.create(:moderator_user) + CurrentUser.user = FactoryBot.create(:moderator_user) end should "update the topic's updated_at timestamp" do @@ -104,7 +104,7 @@ class ForumPostTest < ActiveSupport::TestCase context "belonging to a locked topic" do setup do - @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "zzz") + @post = FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "zzz") @topic.update_attribute(:is_locked, true) @post.reload end @@ -116,15 +116,16 @@ class ForumPostTest < ActiveSupport::TestCase end should "not be deletable" do - @post.destroy - assert_equal(1, ForumPost.count) + assert_difference("ForumPost.count", 0) do + @post.destroy + end end end should "update the topic when created" do @original_topic_updated_at = @topic.updated_at Timecop.travel(1.second.from_now) do - post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) + post = FactoryBot.create(:forum_post, :topic_id => @topic.id) end @topic.reload assert_not_equal(@original_topic_updated_at.to_s, @topic.updated_at.to_s) @@ -133,7 +134,7 @@ class ForumPostTest < ActiveSupport::TestCase should "update the topic when updated only for the original post" do posts = [] 3.times do - posts << FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) + posts << FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => rand(100_000)) end # updating the original post @@ -151,20 +152,20 @@ class ForumPostTest < ActiveSupport::TestCase end should "be searchable by body content" do - post = FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "xxx") + post = FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "xxx") assert_equal(1, ForumPost.body_matches("xxx").count) assert_equal(0, ForumPost.body_matches("aaa").count) end should "initialize its creator" do - post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) + post = FactoryBot.create(:forum_post, :topic_id => @topic.id) assert_equal(@user.id, post.creator_id) end context "updated by a second user" do setup do - @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id) - @second_user = FactoryGirl.create(:user) + @post = FactoryBot.create(:forum_post, :topic_id => @topic.id) + @second_user = FactoryBot.create(:user) CurrentUser.user = @second_user end diff --git a/test/unit/forum_topic_test.rb b/test/unit/forum_topic_test.rb index d81f39b2c..04b96f48c 100644 --- a/test/unit/forum_topic_test.rb +++ b/test/unit/forum_topic_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class ForumTopicTest < ActiveSupport::TestCase context "A forum topic" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @topic = FactoryGirl.create(:forum_topic, :title => "xxx") + @topic = FactoryBot.create(:forum_topic, :title => "xxx") end teardown do @@ -37,7 +37,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "that predates the topic" do setup do - FactoryGirl.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 16.hours.from_now) + FactoryBot.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 16.hours.from_now) end should "return false" do @@ -47,7 +47,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "that postdates the topic" do setup do - FactoryGirl.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 2.days.from_now) + FactoryBot.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 2.days.from_now) end should "return true" do @@ -67,7 +67,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "and a visit" do context "that predates the topic" do setup do - FactoryGirl.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.day.ago) + FactoryBot.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.day.ago) end should "return false" do @@ -77,7 +77,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "that postdates the topic" do setup do - FactoryGirl.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.days.from_now) + FactoryBot.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.days.from_now) end should "return true" do @@ -99,7 +99,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "with a previous visit" do setup do - FactoryGirl.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.day.ago) + FactoryBot.create(:forum_topic_visit, user: @user, forum_topic: @topic, last_read_at: 1.day.ago) end should "update the visit" do @@ -112,9 +112,9 @@ class ForumTopicTest < ActiveSupport::TestCase context "#merge" do setup do - @topic2 = FactoryGirl.create(:forum_topic, :title => "yyy") - FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => "xxx") - FactoryGirl.create(:forum_post, :topic_id => @topic2.id, :body => "xxx") + @topic2 = FactoryBot.create(:forum_topic, :title => "yyy") + FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => "xxx") + FactoryBot.create(:forum_post, :topic_id => @topic2.id, :body => "xxx") end should "merge all the posts in one topic into the other" do @@ -126,7 +126,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "constructed with nested attributes for its original post" do should "create a matching forum post" do assert_difference(["ForumTopic.count", "ForumPost.count"], 1) do - @topic = FactoryGirl.create(:forum_topic, :title => "abc", :original_post_attributes => {:body => "abc"}) + @topic = FactoryBot.create(:forum_topic, :title => "abc", :original_post_attributes => {:body => "abc"}) end end end @@ -147,7 +147,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "updated by a second user" do setup do - @second_user = FactoryGirl.create(:user) + @second_user = FactoryBot.create(:user) CurrentUser.user = @second_user end @@ -160,7 +160,7 @@ class ForumTopicTest < ActiveSupport::TestCase context "with multiple posts that has been deleted" do setup do 5.times do - FactoryGirl.create(:forum_post, :topic_id => @topic.id) + FactoryBot.create(:forum_post, :topic_id => @topic.id) end end diff --git a/test/unit/ip_ban_test.rb b/test/unit/ip_ban_test.rb index 1e8ebc4ed..57cf5315b 100644 --- a/test/unit/ip_ban_test.rb +++ b/test/unit/ip_ban_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class IpBanTest < ActiveSupport::TestCase setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) @@ -14,16 +14,16 @@ class IpBanTest < ActiveSupport::TestCase end should "be able to count the number of comments an IP address is associated with" do - comment = FactoryGirl.create(:comment) + comment = FactoryBot.create(:comment) 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 should "be able to count any updates from a user, groupiny by IP address" do CurrentUser.scoped(@user, "1.2.3.4") do - comment = FactoryGirl.create(:comment, :body => "aaa") + comment = FactoryBot.create(:comment, :body => "aaa") 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 end diff --git a/test/unit/janitor_trial_test.rb b/test/unit/janitor_trial_test.rb index e91ff867c..d4728514d 100644 --- a/test/unit/janitor_trial_test.rb +++ b/test/unit/janitor_trial_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class JanitorTrialTest < ActiveSupport::TestCase context "A janitor trial" do setup do - @admin = FactoryGirl.create(:admin_user) - @user = FactoryGirl.create(:user) + @admin = FactoryBot.create(:admin_user) + @user = FactoryBot.create(:user) CurrentUser.user = @admin CurrentUser.ip_addr = "127.0.0.1" end @@ -30,7 +30,7 @@ class JanitorTrialTest < ActiveSupport::TestCase context "upon demotion" do setup do - @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryBot.create(:janitor_trial, :user_id => @user.id) end should "create a negative feedback record" do @@ -48,7 +48,7 @@ class JanitorTrialTest < ActiveSupport::TestCase context "upon promotion" do setup do - @janitor_trial = FactoryGirl.create(:janitor_trial, :user_id => @user.id) + @janitor_trial = FactoryBot.create(:janitor_trial, :user_id => @user.id) end should "destroy the trial object" do diff --git a/test/unit/maintenance/user/login_reminder_mailer_test.rb b/test/unit/maintenance/user/login_reminder_mailer_test.rb index 7a938beb7..7d240bfdd 100644 --- a/test/unit/maintenance/user/login_reminder_mailer_test.rb +++ b/test/unit/maintenance/user/login_reminder_mailer_test.rb @@ -5,7 +5,7 @@ module Maintenance class LoginReminderMailerTest < ActionMailer::TestCase context "The login reminder mailer" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end should "send the notice" do diff --git a/test/unit/meta_searches/tag_test.rb b/test/unit/meta_searches/tag_test.rb index 8d81459a4..545ff8eb6 100644 --- a/test/unit/meta_searches/tag_test.rb +++ b/test/unit/meta_searches/tag_test.rb @@ -4,11 +4,11 @@ module MetaSearches class TagTest < ActionMailer::TestCase context "The tag metasearch" do setup do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" - FactoryGirl.create(:post, :tag_string => "xxx") - FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + FactoryBot.create(:post, :tag_string => "xxx") + FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") end should "find the tag" do diff --git a/test/unit/moderator/ip_addr_search_test.rb b/test/unit/moderator/ip_addr_search_test.rb index 6556627e7..28b3b3aaf 100644 --- a/test/unit/moderator/ip_addr_search_test.rb +++ b/test/unit/moderator/ip_addr_search_test.rb @@ -4,11 +4,11 @@ module Moderator class IpAddrSearchTest < ActiveSupport::TestCase context "an ip addr search" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:member_comment_time_threshold).returns(1.week.from_now) - @comment = FactoryGirl.create(:comment) + @comment = FactoryBot.create(:comment) PoolArchive.stubs(:enabled?).returns(false) PostArchive.stubs(:enabled?).returns(false) end @@ -20,7 +20,7 @@ module Moderator should "find by ip addr" do @search = IpAddrSearch.new(:ip_addr => "127.0.0.1") - assert_equal({@user => 1}, @search.execute) + assert_equal({@user => 1, @comment.post.uploader => 1}, @search.execute) end should "find by user id" do diff --git a/test/unit/moderator/tag_batch_change_test.rb b/test/unit/moderator/tag_batch_change_test.rb index dd5248273..35965f2ac 100644 --- a/test/unit/moderator/tag_batch_change_test.rb +++ b/test/unit/moderator/tag_batch_change_test.rb @@ -9,10 +9,10 @@ module Moderator context "a tag batch change" do setup do - @user = FactoryGirl.create(:moderator_user) + @user = FactoryBot.create(:moderator_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post, :tag_string => "aaa") + @post = FactoryBot.create(:post, :tag_string => "aaa") end teardown do @@ -28,7 +28,7 @@ module Moderator end should "move saved searches" do - ss = FactoryGirl.create(:saved_search, :user => @user, :query => "123 ... 456") + ss = FactoryBot.create(:saved_search, :user => @user, :query => "123 ... 456") tag_batch_change = TagBatchChange.new("...", "bbb", @user.id, "127.0.0.1") tag_batch_change.perform @@ -36,7 +36,7 @@ module Moderator end should "move only saved searches that match the mass update exactly" do - ss = FactoryGirl.create(:saved_search, :user => @user, :query => "123 ... 456") + ss = FactoryBot.create(:saved_search, :user => @user, :query => "123 ... 456") tag_batch_change = TagBatchChange.new("1", "bbb", @user.id, "127.0.0.1") tag_batch_change.perform diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index c750c4b89..d091d3362 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class NoteTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,8 +15,8 @@ class NoteTest < ActiveSupport::TestCase context "#merge_version" do setup do - @post = FactoryGirl.create(:post) - @note = FactoryGirl.create(:note, :post => @post) + @post = FactoryBot.create(:post) + @note = FactoryBot.create(:note, :post => @post) end should "not increment version" do @@ -28,8 +28,8 @@ class NoteTest < ActiveSupport::TestCase context "for a post that already has a note" do setup do - @post = FactoryGirl.create(:post) - @note = FactoryGirl.create(:note, :post => @post) + @post = FactoryBot.create(:post) + @note = FactoryBot.create(:note, :post => @post) end context "when the note is deleted the post" do @@ -46,29 +46,29 @@ class NoteTest < ActiveSupport::TestCase context "creating a note" do setup do - @post = FactoryGirl.create(:post, :image_width => 1000, :image_height => 1000) + @post = FactoryBot.create(:post, :image_width => 1000, :image_height => 1000) end should "not validate if the note is outside the image" do - @note = FactoryGirl.build(:note, :x => 1001, :y => 500, :post => @post) + @note = FactoryBot.build(:note, :x => 1001, :y => 500, :post => @post) @note.save assert_equal(["Note must be inside the image"], @note.errors.full_messages) end should "not validate if the note is larger than the image" do - @note = FactoryGirl.build(:note, :x => 500, :y => 500, :height => 501, :width => 500, :post => @post) + @note = FactoryBot.build(:note, :x => 500, :y => 500, :height => 501, :width => 500, :post => @post) @note.save assert_equal(["Note must be inside the image"], @note.errors.full_messages) end should "not validate if the post does not exist" do - @note = FactoryGirl.build(:note, :x => 500, :y => 500, :post_id => -1) + @note = FactoryBot.build(:note, :x => 500, :y => 500, :post_id => -1) @note.save assert_equal(["Post must exist"], @note.errors.full_messages) end should "not validate if the body is blank" do - @note = FactoryGirl.build(:note, body: " ") + @note = FactoryBot.build(:note, body: " ") assert_equal(false, @note.valid?) assert_equal(["Body can't be blank"], @note.errors.full_messages) @@ -77,7 +77,7 @@ class NoteTest < ActiveSupport::TestCase should "create a version" do assert_difference("NoteVersion.count", 1) do Timecop.travel(1.day.from_now) do - @note = FactoryGirl.create(:note, :post => @post) + @note = FactoryBot.create(:note, :post => @post) end end @@ -89,7 +89,7 @@ class NoteTest < ActiveSupport::TestCase should "update the post's last_noted_at field" do assert_nil(@post.last_noted_at) - @note = FactoryGirl.create(:note, :post => @post) + @note = FactoryBot.create(:note, :post => @post) @post.reload assert_not_nil(@post.last_noted_at) end @@ -101,7 +101,7 @@ class NoteTest < ActiveSupport::TestCase should "fail" do assert_difference("Note.count", 0) do - @note = FactoryGirl.build(:note, :post => @post) + @note = FactoryBot.build(:note, :post => @post) @note.save end assert_equal(["Post is note locked"], @note.errors.full_messages) @@ -111,8 +111,8 @@ class NoteTest < ActiveSupport::TestCase context "updating a note" do setup do - @post = FactoryGirl.create(:post, :image_width => 1000, :image_height => 1000) - @note = FactoryGirl.create(:note, :post => @post) + @post = FactoryBot.create(:post, :image_width => 1000, :image_height => 1000) + @note = FactoryBot.create(:note, :post => @post) @note.stubs(:merge_version?).returns(false) end @@ -165,8 +165,8 @@ class NoteTest < ActiveSupport::TestCase context "when notes have been vandalized by one user" do setup do - @vandal = FactoryGirl.create(:user) - @note = FactoryGirl.create(:note, :x => 5, :y => 5) + @vandal = FactoryBot.create(:user) + @note = FactoryBot.create(:note, :x => 5, :y => 5) CurrentUser.scoped(@vandal, "127.0.0.1") do @note.update_attributes(:x => 10, :y => 10) end @@ -191,7 +191,7 @@ class NoteTest < ActiveSupport::TestCase context "searching for a note" do setup do - @note = FactoryGirl.create(:note, :body => "aaa") + @note = FactoryBot.create(:note, :body => "aaa") end context "where the body contains the string 'aaa'" do diff --git a/test/unit/pixiv_ugoira_converter_test.rb b/test/unit/pixiv_ugoira_converter_test.rb index bba9e4c58..56ea3431e 100644 --- a/test/unit/pixiv_ugoira_converter_test.rb +++ b/test/unit/pixiv_ugoira_converter_test.rb @@ -14,6 +14,7 @@ class PixivUgoiraConverterTest < ActiveSupport::TestCase end should "output to webm" do + skip "ffmpeg is not installed" unless check_ffmpeg sample_file = PixivUgoiraConverter.generate_webm(@zipfile, @frame_data) preview_file = PixivUgoiraConverter.generate_preview(@zipfile) assert_operator(sample_file.size, :>, 1_000) diff --git a/test/unit/pool_test.rb b/test/unit/pool_test.rb index a7ceb927e..1b2b4e3ec 100644 --- a/test/unit/pool_test.rb +++ b/test/unit/pool_test.rb @@ -5,7 +5,7 @@ require 'test_helper' class PoolTest < ActiveSupport::TestCase setup do Timecop.travel(1.month.ago) do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user end @@ -24,7 +24,7 @@ class PoolTest < ActiveSupport::TestCase context "A name" do setup do - @pool = FactoryGirl.create(:pool, :name => "xxx") + @pool = FactoryBot.create(:pool, :name => "xxx") end should "be mapped to a pool id" do @@ -34,7 +34,7 @@ class PoolTest < ActiveSupport::TestCase context "A multibyte character name" do setup do - @mb_pool = FactoryGirl.create(:pool, :name => "àáâãäå") + @mb_pool = FactoryBot.create(:pool, :name => "àáâãäå") end should "be mapped to a pool id" do @@ -44,7 +44,7 @@ class PoolTest < ActiveSupport::TestCase context "An id number" do setup do - @pool = FactoryGirl.create(:pool) + @pool = FactoryBot.create(:pool) end should "be mapped to a pool id" do @@ -56,10 +56,10 @@ class PoolTest < ActiveSupport::TestCase setup do PoolArchive.stubs(:enabled?).returns(true) - @pool = FactoryGirl.create(:pool) - @p1 = FactoryGirl.create(:post) - @p2 = FactoryGirl.create(:post) - @p3 = FactoryGirl.create(:post) + @pool = FactoryBot.create(:pool) + @p1 = FactoryBot.create(:post) + @p2 = FactoryBot.create(:post) + @p3 = FactoryBot.create(:post) CurrentUser.scoped(@user, "1.2.3.4") do @pool.add!(@p1) end @@ -104,9 +104,9 @@ class PoolTest < ActiveSupport::TestCase context "Updating a pool" do setup do - @pool = FactoryGirl.create(:pool) - @p1 = FactoryGirl.create(:post) - @p2 = FactoryGirl.create(:post) + @pool = FactoryBot.create(:pool) + @p1 = FactoryBot.create(:post) + @p2 = FactoryBot.create(:post) end context "by adding a new post" do @@ -147,7 +147,7 @@ class PoolTest < ActiveSupport::TestCase context "to a deleted pool" do setup do # must be a builder to update deleted pools. - CurrentUser.user = FactoryGirl.create(:builder_user) + CurrentUser.user = FactoryBot.create(:builder_user) @pool.update_attribute(:is_deleted, true) @pool.post_ids = "#{@pool.post_ids} #{@p2.id}" @@ -215,7 +215,7 @@ class PoolTest < ActiveSupport::TestCase should "create new versions for each distinct user" do assert_equal(1, @pool.versions.size) - user2 = Timecop.travel(1.month.ago) {FactoryGirl.create(:user)} + user2 = Timecop.travel(1.month.ago) {FactoryBot.create(:user)} CurrentUser.scoped(user2, "127.0.0.2") do @pool.post_ids = "#{@p1.id}" @@ -262,24 +262,21 @@ class PoolTest < ActiveSupport::TestCase end context "when validating names" do - should_not allow_value("foo,bar").for(:name) - should_not allow_value("foo*bar").for(:name) - should_not allow_value("123").for(:name) - should_not allow_value("___").for(:name) - should_not allow_value(" ").for(:name) - - %w[any none series collection].each do |type| - should_not allow_value(type).for(:name) + should "not be valid for bad names" do + ["foo,bar", "foo*bar", "123", "___", " ", "any", "none", "series", "collection"].each do |bad_name| + pool = Pool.create(name: bad_name) + assert pool.invalid? + end end end end context "An existing pool" do setup do - @pool = FactoryGirl.create(:pool) - @p1 = FactoryGirl.create(:post) - @p2 = FactoryGirl.create(:post) - @p3 = FactoryGirl.create(:post) + @pool = FactoryBot.create(:pool) + @p1 = FactoryBot.create(:post) + @p2 = FactoryBot.create(:post) + @p3 = FactoryBot.create(:post) @pool.add!(@p1) @pool.add!(@p2) @pool.add!(@p3) diff --git a/test/unit/post_appeal_test.rb b/test/unit/post_appeal_test.rb index e2322d50e..71581973a 100644 --- a/test/unit/post_appeal_test.rb +++ b/test/unit/post_appeal_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostAppealTest < ActiveSupport::TestCase context "In all cases" do setup do - @alice = FactoryGirl.create(:user) + @alice = FactoryBot.create(:user) CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.1" Danbooru.config.stubs(:max_appeals_per_day).returns(5) @@ -16,7 +16,7 @@ class PostAppealTest < ActiveSupport::TestCase context "a user" do setup do - @post = FactoryGirl.create(:post, :tag_string => "aaa", :is_deleted => true) + @post = FactoryBot.create(:post, :tag_string => "aaa", :is_deleted => true) end should "not be able to appeal a post more than twice" do diff --git a/test/unit/post_approval_test.rb b/test/unit/post_approval_test.rb index dbb7343a9..f6a82ba8b 100644 --- a/test/unit/post_approval_test.rb +++ b/test/unit/post_approval_test.rb @@ -3,13 +3,13 @@ require 'test_helper' class PostApprovalTest < ActiveSupport::TestCase context "a pending post" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post, uploader_id: @user.id, is_pending: true) + @post = FactoryBot.create(:post, uploader_id: @user.id, is_pending: true) - @approver = FactoryGirl.create(:user) + @approver = FactoryBot.create(:user) @approver.can_approve_posts = true @approver.save CurrentUser.user = @approver @@ -35,9 +35,9 @@ class PostApprovalTest < ActiveSupport::TestCase context "that is then flagged" do setup do - @user2 = FactoryGirl.create(:user) - @user3 = FactoryGirl.create(:user) - @approver2 = FactoryGirl.create(:user) + @user2 = FactoryBot.create(:user) + @user3 = FactoryBot.create(:user) + @approver2 = FactoryBot.create(:user) @approver2.can_approve_posts = true @approver2.save end diff --git a/test/unit/post_archive_test.rb b/test/unit/post_archive_test.rb index 083b693bd..54c3fad38 100644 --- a/test/unit/post_archive_test.rb +++ b/test/unit/post_archive_test.rb @@ -6,7 +6,7 @@ class PostArchiveTest < ActiveSupport::TestCase context "A post" do setup do Timecop.travel(1.month.ago) do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @@ -20,7 +20,7 @@ class PostArchiveTest < ActiveSupport::TestCase context "#undo" do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post = FactoryGirl.create(:post, :tag_string => "1") + @post = FactoryBot.create(:post, :tag_string => "1") @post.update_attributes(:tag_string => "1 2") @post.update_attributes(:tag_string => "2 3") end @@ -37,7 +37,7 @@ class PostArchiveTest < ActiveSupport::TestCase context "that has multiple versions: " do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post = FactoryGirl.create(:post, :tag_string => "1") + @post = FactoryBot.create(:post, :tag_string => "1") @post.update_attributes(:tag_string => "1 2") @post.update_attributes(:tag_string => "2 3") end @@ -56,8 +56,8 @@ class PostArchiveTest < ActiveSupport::TestCase context "that has been created" do setup do - @parent = FactoryGirl.create(:post) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") + @parent = FactoryBot.create(:post) + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") end should "also create a version" do @@ -73,8 +73,8 @@ class PostArchiveTest < ActiveSupport::TestCase context "that is tagged with a pool: metatag" do setup do mock_pool_archive_service! - @pool = FactoryGirl.create(:pool) - @post = FactoryGirl.create(:post, tag_string: "tagme pool:#{@pool.id}") + @pool = FactoryBot.create(:pool) + @post = FactoryBot.create(:post, tag_string: "tagme pool:#{@pool.id}") end should "create a version" do @@ -88,8 +88,8 @@ class PostArchiveTest < ActiveSupport::TestCase context "that should be merged" do setup do - @parent = FactoryGirl.create(:post) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @parent = FactoryBot.create(:post) + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") end should "delete the previous version" do @@ -103,7 +103,7 @@ class PostArchiveTest < ActiveSupport::TestCase context "that has been updated" do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") @post.update_attributes(:tag_string => "bbb ccc xxx", :source => "") end @@ -140,7 +140,7 @@ class PostArchiveTest < ActiveSupport::TestCase should "should create a version if the parent changes" do assert_difference("@post.versions.size", 1) do - @parent = FactoryGirl.create(:post) + @parent = FactoryBot.create(:post) @post.update(parent_id: @parent.id) assert_equal(@parent.id, @post.versions.sort_by(&:id).last.parent_id) end diff --git a/test/unit/post_disapproval_test.rb b/test/unit/post_disapproval_test.rb index 6e23f1f6d..9bbec4f2a 100644 --- a/test/unit/post_disapproval_test.rb +++ b/test/unit/post_disapproval_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PostDisapprovalTest < ActiveSupport::TestCase context "In all cases" do setup do - @alice = FactoryGirl.create(:moderator_user) + @alice = FactoryBot.create(:moderator_user) CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.1" end @@ -15,8 +15,8 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "A post disapproval" do setup do - @post_1 = FactoryGirl.create(:post, :is_pending => true) - @post_2 = FactoryGirl.create(:post, :is_pending => true) + @post_1 = FactoryBot.create(:post, :is_pending => true) + @post_2 = FactoryBot.create(:post, :is_pending => true) end context "made by alice" do @@ -37,7 +37,7 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "when the current user is brittony" do setup do - @brittony = FactoryGirl.create(:moderator_user) + @brittony = FactoryBot.create(:moderator_user) CurrentUser.user = @brittony end @@ -50,8 +50,8 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "for a post that has been approved" do setup do - @post = FactoryGirl.create(:post) - @user = FactoryGirl.create(:user) + @post = FactoryBot.create(:post) + @user = FactoryBot.create(:user) Timecop.travel(2.months.ago) do @disapproval = PostDisapproval.create(:user => @user, :post => @post) end @@ -66,20 +66,20 @@ class PostDisapprovalTest < ActiveSupport::TestCase context "when sending dmails" do setup do - @uploaders = FactoryGirl.create_list(:user, 2) - @disapprovers = FactoryGirl.create_list(:mod_user, 2) + @uploaders = FactoryBot.create_list(:user, 2) + @disapprovers = FactoryBot.create_list(:mod_user, 2) # 2 uploaders, with 2 uploads each, and 2 disapprovals on each upload. @uploaders.each do |uploader| - FactoryGirl.create_list(:post, 2, uploader: uploader).each do |post| - FactoryGirl.create(:post_disapproval, post: post, user: @disapprovers[0]) - FactoryGirl.create(:post_disapproval, post: post, user: @disapprovers[1]) + FactoryBot.create_list(:post, 2, uploader: uploader).each do |post| + FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[0]) + FactoryBot.create(:post_disapproval, post: post, user: @disapprovers[1]) end end end should "dmail the uploaders" do - bot = FactoryGirl.create(:user) + bot = FactoryBot.create(:user) User.stubs(:system).returns(bot) assert_difference(["@uploaders[0].dmails.count", "@uploaders[1].dmails.count"], 1) do diff --git a/test/unit/post_event_test.rb b/test/unit/post_event_test.rb index f4066e339..2b709149d 100644 --- a/test/unit/post_event_test.rb +++ b/test/unit/post_event_test.rb @@ -5,11 +5,11 @@ class PostEventTest < ActiveSupport::TestCase super Timecop.travel(2.weeks.ago) do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" end - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) @post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false) @post_appeal = PostAppeal.create(:post => @post, :reason => "aaa") end diff --git a/test/unit/post_flag_test.rb b/test/unit/post_flag_test.rb index 1eb00dd41..a968d2639 100644 --- a/test/unit/post_flag_test.rb +++ b/test/unit/post_flag_test.rb @@ -4,11 +4,11 @@ class PostFlagTest < ActiveSupport::TestCase context "In all cases" do setup do Timecop.travel(2.weeks.ago) do - @alice = FactoryGirl.create(:gold_user) + @alice = FactoryBot.create(:gold_user) end CurrentUser.user = @alice CurrentUser.ip_addr = "127.0.0.2" - @post = FactoryGirl.create(:post, :tag_string => "aaa") + @post = FactoryBot.create(:post, :tag_string => "aaa") end teardown do @@ -19,7 +19,7 @@ class PostFlagTest < ActiveSupport::TestCase context "a basic user" do setup do Timecop.travel(2.weeks.ago) do - @bob = FactoryGirl.create(:user) + @bob = FactoryBot.create(:user) end CurrentUser.user = @bob end @@ -72,18 +72,18 @@ class PostFlagTest < ActiveSupport::TestCase end should "not be able to flag a post in the cooldown period" do - users = FactoryGirl.create_list(:user, 2, created_at: 2.weeks.ago) - flag1 = FactoryGirl.create(:post_flag, post: @post, creator: users.first) + users = FactoryBot.create_list(:user, 2, created_at: 2.weeks.ago) + flag1 = FactoryBot.create(:post_flag, post: @post, creator: users.first) @post.approve! travel_to(PostFlag::COOLDOWN_PERIOD.from_now - 1.minute) do - flag2 = FactoryGirl.build(:post_flag, post: @post, creator: users.second) + flag2 = FactoryBot.build(:post_flag, post: @post, creator: users.second) assert(flag2.invalid?) assert_match(/cannot be flagged more than once/, flag2.errors[:post].join) end travel_to(PostFlag::COOLDOWN_PERIOD.from_now + 1.minute) do - flag3 = FactoryGirl.build(:post_flag, post: @post, creator: users.second) + flag3 = FactoryBot.build(:post_flag, post: @post, creator: users.second) assert(flag3.valid?) end end @@ -98,13 +98,13 @@ class PostFlagTest < ActiveSupport::TestCase context "a moderator user" do setup do Timecop.travel(2.weeks.ago) do - @dave = FactoryGirl.create(:moderator_user) + @dave = FactoryBot.create(:moderator_user) end CurrentUser.user = @dave end should "not be able to view flags on their own uploads" do - @modpost = FactoryGirl.create(:post, :tag_string => "mmm",:uploader_id => @dave.id) + @modpost = FactoryBot.create(:post, :tag_string => "mmm",:uploader_id => @dave.id) CurrentUser.scoped(@alice) do @flag1 = PostFlag.create(:post => @modpost, :reason => "aaa", :is_resolved => false) end diff --git a/test/unit/post_pruner_test.rb b/test/unit/post_pruner_test.rb index 32076adc7..7941671bc 100644 --- a/test/unit/post_pruner_test.rb +++ b/test/unit/post_pruner_test.rb @@ -4,20 +4,20 @@ class PostPrunerTest < ActiveSupport::TestCase def setup super - @user = FactoryGirl.create(:admin_user) + @user = FactoryBot.create(:admin_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" Timecop.travel(2.weeks.ago) do - @flagger = FactoryGirl.create(:gold_user) + @flagger = FactoryBot.create(:gold_user) end - @old_post = FactoryGirl.create(:post, :created_at => 5.days.ago, :is_pending => true) - @unresolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true) - @resolved_flagged_post = FactoryGirl.create(:post, :is_flagged => true) + @old_post = FactoryBot.create(:post, :created_at => 5.days.ago, :is_pending => true) + @unresolved_flagged_post = FactoryBot.create(:post, :is_flagged => true) + @resolved_flagged_post = FactoryBot.create(:post, :is_flagged => true) CurrentUser.scoped(@flagger, "127.0.0.2") do - @unresolved_post_flag = FactoryGirl.create(:post_flag, :created_at => 5.days.ago, :is_resolved => false, :post_id => @unresolved_flagged_post.id) - @resolved_post_flag = FactoryGirl.create(:post_flag, :created_at => 5.days.ago, :is_resolved => true, :post_id => @resolved_flagged_post.id) + @unresolved_post_flag = FactoryBot.create(:post_flag, :created_at => 5.days.ago, :is_resolved => false, :post_id => @unresolved_flagged_post.id) + @resolved_post_flag = FactoryBot.create(:post_flag, :created_at => 5.days.ago, :is_resolved => true, :post_id => @resolved_flagged_post.id) end PostPruner.new.prune! diff --git a/test/unit/post_replacement_test.rb b/test/unit/post_replacement_test.rb index 8d8df7653..5daab0321 100644 --- a/test/unit/post_replacement_test.rb +++ b/test/unit/post_replacement_test.rb @@ -7,11 +7,11 @@ class PostReplacementTest < ActiveSupport::TestCase mock_iqdb_service! Delayed::Worker.delay_jobs = true # don't delete the old images right away - @system = FactoryGirl.create(:user, created_at: 2.weeks.ago) + @system = FactoryBot.create(:user, created_at: 2.weeks.ago) User.stubs(:system).returns(@system) - @uploader = FactoryGirl.create(:user, created_at: 2.weeks.ago, can_upload_free: true) - @replacer = FactoryGirl.create(:user, created_at: 2.weeks.ago, can_approve_posts: true) + @uploader = FactoryBot.create(:user, created_at: 2.weeks.ago, can_upload_free: true) + @replacer = FactoryBot.create(:user, created_at: 2.weeks.ago, can_approve_posts: true) CurrentUser.user = @replacer CurrentUser.ip_addr = "127.0.0.1" end @@ -27,7 +27,7 @@ class PostReplacementTest < ActiveSupport::TestCase context "Replacing" do setup do CurrentUser.scoped(@uploader, "127.0.0.2") do - upload = FactoryGirl.create(:jpg_upload, as_pending: "0", tag_string: "lowres tag1") + upload = FactoryBot.create(:jpg_upload, as_pending: "0", tag_string: "lowres tag1") upload.process! @post = upload.post end @@ -118,7 +118,7 @@ class PostReplacementTest < ActiveSupport::TestCase context "a post with notes" do setup do - @post.update({image_width: 160, image_height: 164}, without_protection: true) + @post.update(image_width: 160, image_height: 164) CurrentUser.scoped(@uploader, "127.0.0.1") do @note = @post.notes.create(x: 80, y: 82, width: 80, height: 82, body: "test") end @@ -169,6 +169,7 @@ class PostReplacementTest < ActiveSupport::TestCase context "a post that is replaced by a ugoira" do should "save the frame data" do + skip "ffmpeg not installed" unless check_ffmpeg @post.replace!(replacement_url: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364") @post.reload @@ -186,6 +187,8 @@ class PostReplacementTest < ActiveSupport::TestCase context "a post that is replaced to another file then replaced back to the original file" do should "not delete the original files" do + skip "ffmpeg is not installed" unless check_ffmpeg + @post.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247350") @post.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247364") @post.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247350") @@ -204,8 +207,10 @@ class PostReplacementTest < ActiveSupport::TestCase context "two posts that have had their files swapped" do should "not delete the still active files" do - @post1 = FactoryGirl.create(:post) - @post2 = FactoryGirl.create(:post) + skip "ffmpeg is not installed" unless check_ffmpeg + + @post1 = FactoryBot.create(:post) + @post2 = FactoryBot.create(:post) # swap the images between @post1 and @post2. @post1.replace!(replacement_url: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=62247350") @@ -245,6 +250,7 @@ class PostReplacementTest < ActiveSupport::TestCase context "a post when replaced with a HTML source" do should "record the image URL as the replacement URL, not the HTML source" do + skip "Twitter key not set" unless Danbooru.config.twitter_api_key replacement_url = "https://twitter.com/nounproject/status/540944400767922176" image_url = "https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:orig" @post.replace!(replacement_url: replacement_url) diff --git a/test/unit/post_sets/favorite_test.rb b/test/unit/post_sets/favorite_test.rb index ef06e39a4..f57bafe3f 100644 --- a/test/unit/post_sets/favorite_test.rb +++ b/test/unit/post_sets/favorite_test.rb @@ -4,13 +4,13 @@ module PostSets class FavoriteTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post_1 = FactoryGirl.create(:post) - @post_2 = FactoryGirl.create(:post) - @post_3 = FactoryGirl.create(:post) + @post_1 = FactoryBot.create(:post) + @post_2 = FactoryBot.create(:post) + @post_3 = FactoryBot.create(:post) @post_2.add_favorite!(@user) @post_1.add_favorite!(@user) @post_3.add_favorite!(@user) @@ -24,13 +24,11 @@ module PostSets context "a favorite set for before the most recent post" do setup do id = ::Favorite.where(:user_id => @user.id, :post_id => @post_3.id).first.id - ::Favorite.stubs(:records_per_page).returns(1) - @set = PostSets::Favorite.new(@user.id, "b#{id}") + @set = PostSets::Favorite.new(@user.id, "b#{id}", limit: 1) end context "a sequential paginator" do should "return the second most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_1.id, @set.posts.first.id) end @@ -50,7 +48,6 @@ module PostSets context "a sequential paginator" do should "return the second most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_1.id, @set.posts.first.id) end @@ -70,7 +67,6 @@ module PostSets context "a sequential paginator" do should "return the third most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_2.id, @set.posts.first.id) end @@ -90,7 +86,6 @@ module PostSets context "a sequential paginator" do should "return the most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_3.id, @set.posts.first.id) end @@ -109,7 +104,6 @@ module PostSets context "a numbered paginator" do should "return the second most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_1.id, @set.posts.first.id) end @@ -127,7 +121,6 @@ module PostSets end should "return the most recent element" do - assert_equal(1, @set.posts.size) assert_equal(@post_3.id, @set.posts.first.id) end diff --git a/test/unit/post_sets/intro_test.rb b/test/unit/post_sets/intro_test.rb index 00b3eb66e..6db4c8289 100644 --- a/test/unit/post_sets/intro_test.rb +++ b/test/unit/post_sets/intro_test.rb @@ -5,13 +5,13 @@ module PostSets class IntroTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post_1 = FactoryGirl.create(:post, :tag_string => "a") - @post_2 = FactoryGirl.create(:post, :tag_string => "b") - @post_3 = FactoryGirl.create(:post, :tag_string => "c") + @post_1 = FactoryBot.create(:post, :tag_string => "a") + @post_2 = FactoryBot.create(:post, :tag_string => "b") + @post_3 = FactoryBot.create(:post, :tag_string => "c") end teardown do @@ -21,8 +21,8 @@ module PostSets context "a set for the 'a' tag query" do setup do - @post_4 = FactoryGirl.create(:post, :tag_string => "a", :fav_count => 5) - @post_5 = FactoryGirl.create(:post, :tag_string => "a", :fav_count => 5) + @post_4 = FactoryBot.create(:post, :tag_string => "a", :fav_count => 5) + @post_5 = FactoryBot.create(:post, :tag_string => "a", :fav_count => 5) end context "with no page" do diff --git a/test/unit/post_sets/pool_test.rb b/test/unit/post_sets/pool_test.rb index c548cccd6..f49d37ad1 100644 --- a/test/unit/post_sets/pool_test.rb +++ b/test/unit/post_sets/pool_test.rb @@ -4,17 +4,17 @@ module PostSets class PoolTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" mock_pool_archive_service! start_pool_archive_transaction - @post_1 = FactoryGirl.create(:post) - @post_2 = FactoryGirl.create(:post) - @post_3 = FactoryGirl.create(:post) - @pool = FactoryGirl.create(:pool) + @post_1 = FactoryBot.create(:post) + @post_2 = FactoryBot.create(:post) + @post_3 = FactoryBot.create(:post) + @pool = FactoryBot.create(:pool) @pool.add!(@post_2) @pool.add!(@post_1) @pool.add!(@post_3) diff --git a/test/unit/post_sets/post_test.rb b/test/unit/post_sets/post_test.rb index d9bb9abf6..1ddf6a62f 100644 --- a/test/unit/post_sets/post_test.rb +++ b/test/unit/post_sets/post_test.rb @@ -5,13 +5,13 @@ module PostSets class PostTest < ActiveSupport::TestCase context "In all cases" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post_1 = FactoryGirl.create(:post, :tag_string => "a") - @post_2 = FactoryGirl.create(:post, :tag_string => "b") - @post_3 = FactoryGirl.create(:post, :tag_string => "c") + @post_1 = FactoryBot.create(:post, :tag_string => "a") + @post_2 = FactoryBot.create(:post, :tag_string => "b") + @post_3 = FactoryBot.create(:post, :tag_string => "c") end teardown do @@ -32,8 +32,8 @@ module PostSets context "a set for the 'a' tag query" do setup do - @post_4 = FactoryGirl.create(:post, :tag_string => "a") - @post_5 = FactoryGirl.create(:post, :tag_string => "a") + @post_4 = FactoryBot.create(:post, :tag_string => "a") + @post_5 = FactoryBot.create(:post, :tag_string => "a") end context "with no page" do @@ -107,7 +107,7 @@ module PostSets context "for a gold user" do setup do - CurrentUser.user = FactoryGirl.create(:gold_user) + CurrentUser.user = FactoryBot.create(:gold_user) end should "pass" do @@ -141,7 +141,7 @@ module PostSets context "that has a matching wiki page" do setup do - @wiki_page = FactoryGirl.create(:wiki_page, :title => "a") + @wiki_page = FactoryBot.create(:wiki_page, :title => "a") end should "find the wiki page" do @@ -152,7 +152,7 @@ module PostSets context "that has a matching artist" do setup do - @artist = FactoryGirl.create(:artist, :name => "a") + @artist = FactoryBot.create(:artist, :name => "a") end should "find the artist" do diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 6e1e06e3d..330ab99d9 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -9,7 +9,7 @@ class PostTest < ActiveSupport::TestCase super Timecop.travel(2.weeks.ago) do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @@ -28,7 +28,7 @@ class PostTest < ActiveSupport::TestCase context "Deletion:" do context "Expunging a post" do setup do - @upload = FactoryGirl.create(:jpg_upload) + @upload = FactoryBot.create(:jpg_upload) @upload.process! @post = @upload.post Favorite.add(post: @post, user: @user) @@ -38,18 +38,14 @@ class PostTest < ActiveSupport::TestCase assert_nothing_raised { @post.file(:preview) } assert_nothing_raised { @post.file(:original) } - TestAfterCommit.with_commits(true) do - @post.expunge! - end + @post.expunge! assert_raise(StandardError) { @post.file(:preview) } assert_raise(StandardError) { @post.file(:original) } end should "remove all favorites" do - TestAfterCommit.with_commits(true) do - @post.expunge! - end + @post.expunge! assert_equal(0, Favorite.for_user(@user.id).where("post_id = ?", @post.id).count) end @@ -61,7 +57,7 @@ class PostTest < ActiveSupport::TestCase end should "decrement the user's note update count" do - FactoryGirl.create(:note, post: @post) + FactoryBot.create(:note, post: @post) assert_difference(["@post.uploader.reload.note_update_count"], -1) do @post.expunge! end @@ -84,14 +80,12 @@ class PostTest < ActiveSupport::TestCase mock_iqdb_service! Post.iqdb_sqs_service.expects(:send_message).with("remove\n#{@post.id}") - TestAfterCommit.with_commits(true) do - @post.expunge! - end + @post.expunge! end context "that is status locked" do setup do - @post.update_attributes({:is_status_locked => true}, :as => :admin) + @post.update(is_status_locked: true) end should "not destroy the record" do @@ -103,13 +97,13 @@ class PostTest < ActiveSupport::TestCase context "that belongs to a pool" do setup do # must be a builder to update deleted pools. must be >1 week old to remove posts from pools. - CurrentUser.user = FactoryGirl.create(:builder_user, created_at: 1.month.ago) + CurrentUser.user = FactoryBot.create(:builder_user, created_at: 1.month.ago) SqsService.any_instance.stubs(:send_message) - @pool = FactoryGirl.create(:pool) + @pool = FactoryBot.create(:pool) @pool.add!(@post) - @deleted_pool = FactoryGirl.create(:pool) + @deleted_pool = FactoryBot.create(:pool) @deleted_pool.add!(@post) @deleted_pool.update_columns(is_deleted: true) @@ -140,8 +134,7 @@ class PostTest < ActiveSupport::TestCase context "that is status locked" do setup do - @post = FactoryGirl.create(:post) - @post.update_attributes({:is_status_locked => true}, :as => :admin) + @post = FactoryBot.create(:post, is_status_locked: true) end should "fail" do @@ -153,7 +146,7 @@ class PostTest < ActiveSupport::TestCase context "that is pending" do setup do - @post = FactoryGirl.create(:post, is_pending: true) + @post = FactoryBot.create(:post, is_pending: true) end should "succeed" do @@ -167,7 +160,7 @@ class PostTest < ActiveSupport::TestCase context "with the banned_artist tag" do should "also ban the post" do - post = FactoryGirl.create(:post, :tag_string => "banned_artist") + post = FactoryBot.create(:post, :tag_string => "banned_artist") post.delete!("test") post.reload assert(post.is_banned?) @@ -176,7 +169,7 @@ class PostTest < ActiveSupport::TestCase context "that is still in cooldown after being flagged" do should "succeed" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) post.flag!("test flag") post.delete!("test deletion") @@ -185,46 +178,29 @@ class PostTest < ActiveSupport::TestCase end end - should "update the fast count" do - Danbooru.config.stubs(:estimate_post_counts).returns(false) - post = FactoryGirl.create(:post, :tag_string => "aaa") - assert_equal(1, Post.fast_count) - assert_equal(1, Post.fast_count("aaa")) - post.delete!("test") - assert_equal(1, Post.fast_count) - assert_equal(1, Post.fast_count("aaa")) - end - should "toggle the is_deleted flag" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_equal(false, post.is_deleted?) post.delete!("test") assert_equal(true, post.is_deleted?) end - - should "not decrement the tag counts" do - post = FactoryGirl.create(:post, :tag_string => "aaa") - assert_equal(1, Tag.find_by_name("aaa").post_count) - post.delete!("test") - assert_equal(1, Tag.find_by_name("aaa").post_count) - end end end context "Parenting:" do context "Assigning a parent to a post" do should "update the has_children flag on the parent" do - p1 = FactoryGirl.create(:post) + p1 = FactoryBot.create(:post) assert(!p1.has_children?, "Parent should not have any children") - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + c1 = FactoryBot.create(:post, :parent_id => p1.id) p1.reload assert(p1.has_children?, "Parent not updated after child was added") end should "update the has_children flag on the old parent" do - p1 = FactoryGirl.create(:post) - p2 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + p2 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.parent_id = p2.id c1.save p1.reload @@ -237,17 +213,17 @@ class PostTest < ActiveSupport::TestCase context "Expunging a post with" do context "a parent" do should "reset the has_children flag of the parent" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.expunge! p1.reload assert_equal(false, p1.has_children?) end should "reassign favorites to the parent" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) - user = FactoryGirl.create(:user) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) + user = FactoryBot.create(:user) c1.add_favorite!(user) c1.expunge! p1.reload @@ -257,8 +233,8 @@ class PostTest < ActiveSupport::TestCase end should "update the parent's has_children flag" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.expunge! p1.reload assert(!p1.has_children?, "Parent should not have children") @@ -267,8 +243,8 @@ class PostTest < ActiveSupport::TestCase context "one child" do should "remove the parent of that child" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) p1.expunge! c1.reload assert_nil(c1.parent) @@ -279,10 +255,10 @@ class PostTest < ActiveSupport::TestCase setup do # ensure initial post versions won't be merged. travel_to(1.day.ago) do - @p1 = FactoryGirl.create(:post) - @c1 = FactoryGirl.create(:post, :parent_id => @p1.id) - @c2 = FactoryGirl.create(:post, :parent_id => @p1.id) - @c3 = FactoryGirl.create(:post, :parent_id => @p1.id) + @p1 = FactoryBot.create(:post) + @c1 = FactoryBot.create(:post, :parent_id => @p1.id) + @c2 = FactoryBot.create(:post, :parent_id => @p1.id) + @c3 = FactoryBot.create(:post, :parent_id => @p1.id) end end @@ -316,9 +292,9 @@ class PostTest < ActiveSupport::TestCase context "Deleting a post with" do context "a parent" do should "not reassign favorites to the parent by default" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) - user = FactoryGirl.create(:gold_user) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) + user = FactoryBot.create(:gold_user) c1.add_favorite!(user) c1.delete!("test") p1.reload @@ -327,9 +303,9 @@ class PostTest < ActiveSupport::TestCase end should "reassign favorites to the parent if specified" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) - user = FactoryGirl.create(:gold_user) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) + user = FactoryBot.create(:gold_user) c1.add_favorite!(user) c1.delete!("test", :move_favorites => true) p1.reload @@ -338,17 +314,17 @@ class PostTest < ActiveSupport::TestCase end should "not update the parent's has_children flag" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.delete!("test") p1.reload assert(p1.has_children?, "Parent should have children") end should "clear the has_active_children flag when the 'move favorites' option is set" do - user = FactoryGirl.create(:gold_user) - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + user = FactoryBot.create(:gold_user) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.add_favorite!(user) assert_equal(true, p1.reload.has_active_children?) @@ -359,16 +335,16 @@ class PostTest < ActiveSupport::TestCase context "one child" do should "not remove the has_children flag" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) p1.delete!("test") p1.reload assert_equal(true, p1.has_children?) end should "not remove the parent of that child" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) p1.delete!("test") c1.reload assert_not_nil(c1.parent) @@ -377,10 +353,10 @@ class PostTest < ActiveSupport::TestCase context "two or more children" do should "not reparent all children to the first child" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) - c2 = FactoryGirl.create(:post, :parent_id => p1.id) - c3 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) + c2 = FactoryBot.create(:post, :parent_id => p1.id) + c3 = FactoryBot.create(:post, :parent_id => p1.id) p1.delete!("test") c1.reload c2.reload @@ -394,9 +370,9 @@ class PostTest < ActiveSupport::TestCase context "Undeleting a post with a parent" do should "update with a new approver" do - new_user = FactoryGirl.create(:moderator_user) - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + new_user = FactoryBot.create(:moderator_user) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.delete!("test") CurrentUser.scoped(new_user, "127.0.0.1") do c1.undelete! @@ -406,8 +382,8 @@ class PostTest < ActiveSupport::TestCase end should "preserve the parent's has_children flag" do - p1 = FactoryGirl.create(:post) - c1 = FactoryGirl.create(:post, :parent_id => p1.id) + p1 = FactoryBot.create(:post) + c1 = FactoryBot.create(:post, :parent_id => p1.id) c1.delete!("test") c1.undelete! p1.reload @@ -420,12 +396,12 @@ class PostTest < ActiveSupport::TestCase context "Moderation:" do context "A deleted post" do setup do - @post = FactoryGirl.create(:post, :is_deleted => true) + @post = FactoryBot.create(:post, :is_deleted => true) end context "that is status locked" do setup do - @post.update_attributes({:is_status_locked => true}, :as => :admin) + @post.update(is_status_locked: true) end should "not allow undeletion" do @@ -437,7 +413,7 @@ class PostTest < ActiveSupport::TestCase context "that is undeleted" do setup do - @mod = FactoryGirl.create(:moderator_user) + @mod = FactoryBot.create(:moderator_user) CurrentUser.user = @mod end @@ -503,7 +479,7 @@ class PostTest < ActiveSupport::TestCase context "An approved post" do should "be flagged" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_difference("PostFlag.count", 1) do post.flag!("bad") end @@ -512,7 +488,7 @@ class PostTest < ActiveSupport::TestCase end should "not be flagged if no reason is given" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_difference("PostFlag.count", 0) do assert_raises(PostFlag::Error) do post.flag!("") @@ -523,14 +499,14 @@ class PostTest < ActiveSupport::TestCase context "An unapproved post" do should "preserve the approver's identity when approved" do - post = FactoryGirl.create(:post, :is_pending => true) + post = FactoryBot.create(:post, :is_pending => true) post.approve! assert_equal(post.approver_id, CurrentUser.id) end context "that was uploaded by person X" do setup do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) @post.flag!("reason") end @@ -544,9 +520,9 @@ class PostTest < ActiveSupport::TestCase context "that was previously approved by person X" do setup do - @user = FactoryGirl.create(:moderator_user, :name => "xxx") - @user2 = FactoryGirl.create(:moderator_user, :name => "yyy") - @post = FactoryGirl.create(:post, :approver_id => @user.id) + @user = FactoryBot.create(:moderator_user, :name => "xxx") + @user2 = FactoryBot.create(:moderator_user, :name => "yyy") + @post = FactoryBot.create(:post, :approver_id => @user.id) @post.flag!("bad") end @@ -563,7 +539,7 @@ class PostTest < ActiveSupport::TestCase context "that has been reapproved" do should "no longer be flagged or pending" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) post.flag!("bad") post.approve! assert(post.errors.empty?, post.errors.full_messages.join(", ")) @@ -576,8 +552,7 @@ class PostTest < ActiveSupport::TestCase context "A status locked post" do setup do - @post = FactoryGirl.create(:post) - @post.update_attributes({:is_status_locked => true}, :as => :admin) + @post = FactoryBot.create(:post, is_status_locked: true) end should "not allow new flags" do @@ -602,13 +577,13 @@ class PostTest < ActiveSupport::TestCase context "Tagging:" do context "A post" do setup do - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) end context "as a new user" do setup do @post.update(:tag_string => "aaa bbb ccc ddd tagme") - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) end should "not allow you to remove tags" do @@ -625,11 +600,11 @@ class PostTest < ActiveSupport::TestCase context "with a banned artist" do setup do - CurrentUser.scoped(FactoryGirl.create(:admin_user)) do - @artist = FactoryGirl.create(:artist) + CurrentUser.scoped(FactoryBot.create(:admin_user)) do + @artist = FactoryBot.create(:artist) @artist.ban! end - @post = FactoryGirl.create(:post, :tag_string => @artist.name) + @post = FactoryBot.create(:post, :tag_string => @artist.name) end should "ban the post" do @@ -639,7 +614,7 @@ class PostTest < ActiveSupport::TestCase context "with an artist tag that is then changed to copyright" do setup do - CurrentUser.user = FactoryGirl.create(:builder_user) + CurrentUser.user = FactoryBot.create(:builder_user) @post = Post.find(@post.id) @post.update(:tag_string => "art:abc") @post = Post.find(@post.id) @@ -664,7 +639,7 @@ class PostTest < ActiveSupport::TestCase context "using a tag prefix on an aliased tag" do setup do - FactoryGirl.create(:tag_alias, :antecedent_name => "abc", :consequent_name => "xyz") + FactoryBot.create(:tag_alias, :antecedent_name => "abc", :consequent_name => "xyz") @post = Post.find(@post.id) @post.update(:tag_string => "art:abc") @post.reload @@ -724,7 +699,7 @@ class PostTest < ActiveSupport::TestCase context "that already exists" do setup do %W(___ ~foo _foo foo_ foo__bar foo*bar foo,bar foo\abar café 東方).each do |tag| - FactoryGirl.build(:tag, name: tag).save(validate: false) + FactoryBot.build(:tag, name: tag).save(validate: false) end end @@ -745,7 +720,7 @@ class PostTest < ActiveSupport::TestCase context "for typing a tag" do setup do - @post = FactoryGirl.create(:post, tag_string: "char:hoge") + @post = FactoryBot.create(:post, tag_string: "char:hoge") @tags = @post.tag_array end @@ -756,8 +731,8 @@ class PostTest < ActiveSupport::TestCase context "for typing an aliased tag" do setup do - @alias = FactoryGirl.create(:tag_alias, antecedent_name: "hoge", consequent_name: "moge") - @post = FactoryGirl.create(:post, tag_string: "char:hoge") + @alias = FactoryBot.create(:tag_alias, antecedent_name: "hoge", consequent_name: "moge") + @post = FactoryBot.create(:post, tag_string: "char:hoge") @tags = @post.tag_array end @@ -770,7 +745,7 @@ class PostTest < ActiveSupport::TestCase context "for a cosplay tag" do setup do - @post = FactoryGirl.create(:post, tag_string: "char:someone_(cosplay)") + @post = FactoryBot.create(:post, tag_string: "char:someone_(cosplay)") @tags = @post.tag_array end @@ -785,9 +760,9 @@ class PostTest < ActiveSupport::TestCase end should "apply aliases when the character tag is added" do - FactoryGirl.create(:tag, name: "jim", category: Tag.categories.general) - FactoryGirl.create(:tag, name: "james", category: Tag.categories.character) - FactoryGirl.create(:tag_alias, antecedent_name: "jim", consequent_name: "james") + FactoryBot.create(:tag, name: "jim", category: Tag.categories.general) + FactoryBot.create(:tag, name: "james", category: Tag.categories.character) + FactoryBot.create(:tag_alias, antecedent_name: "jim", consequent_name: "james") @post.add_tag("jim_(cosplay)") @post.save @@ -796,7 +771,7 @@ class PostTest < ActiveSupport::TestCase end should "apply implications after the character tag is added" do - FactoryGirl.create(:tag_implication, antecedent_name: "jimmy", consequent_name: "jim") + FactoryBot.create(:tag_implication, antecedent_name: "jimmy", consequent_name: "jim") @post.add_tag("jimmy_(cosplay)") @post.save @@ -806,7 +781,7 @@ class PostTest < ActiveSupport::TestCase context "for a parent" do setup do - @parent = FactoryGirl.create(:post) + @parent = FactoryBot.create(:post) end should "update the parent relationships for both posts" do @@ -841,8 +816,8 @@ class PostTest < ActiveSupport::TestCase context "for a favgroup" do setup do - @favgroup = FactoryGirl.create(:favorite_group, creator: @user) - @post = FactoryGirl.create(:post, :tag_string => "aaa favgroup:#{@favgroup.id}") + @favgroup = FactoryBot.create(:favorite_group, creator: @user) + @post = FactoryBot.create(:post, :tag_string => "aaa favgroup:#{@favgroup.id}") end should "add the post to the favgroup" do @@ -870,8 +845,8 @@ class PostTest < ActiveSupport::TestCase context "on creation" do setup do - @pool = FactoryGirl.create(:pool) - @post = FactoryGirl.create(:post, :tag_string => "aaa pool:#{@pool.id}") + @pool = FactoryBot.create(:pool) + @post = FactoryBot.create(:post, :tag_string => "aaa pool:#{@pool.id}") end should "add the post to the pool" do @@ -884,8 +859,8 @@ class PostTest < ActiveSupport::TestCase context "negated" do setup do - @pool = FactoryGirl.create(:pool) - @post = FactoryGirl.create(:post, :tag_string => "aaa") + @pool = FactoryBot.create(:pool) + @post = FactoryBot.create(:post, :tag_string => "aaa") @post.add_pool!(@pool) @post.tag_string = "aaa -pool:#{@pool.id}" @post.save @@ -901,7 +876,7 @@ class PostTest < ActiveSupport::TestCase context "id" do setup do - @pool = FactoryGirl.create(:pool) + @pool = FactoryBot.create(:pool) @post.update_attributes(:tag_string => "aaa pool:#{@pool.id}") end @@ -916,7 +891,7 @@ class PostTest < ActiveSupport::TestCase context "name" do context "that exists" do setup do - @pool = FactoryGirl.create(:pool, :name => "abc") + @pool = FactoryBot.create(:pool, :name => "abc") @post.update_attributes(:tag_string => "aaa pool:abc") end @@ -967,7 +942,7 @@ class PostTest < ActiveSupport::TestCase context "that is locked" do should "change the rating if locked in the same update" do - @post.update({ :tag_string => "rating:e", :is_rating_locked => true }, :as => :builder) + @post.update(tag_string: "rating:e", is_rating_locked: true) assert(@post.valid?) assert_equal("e", @post.reload.rating) @@ -997,7 +972,7 @@ class PostTest < ActiveSupport::TestCase context "for a child" do setup do - @child = FactoryGirl.create(:post) + @child = FactoryBot.create(:post) end should "update the parent relationships for both posts" do @@ -1039,7 +1014,7 @@ class PostTest < ActiveSupport::TestCase context "of" do setup do - @builder = FactoryGirl.create(:builder_user) + @builder = FactoryBot.create(:builder_user) end context "locked:notes" do @@ -1094,7 +1069,7 @@ class PostTest < ActiveSupport::TestCase context "by an admin" do should "lock/unlock the status" do - CurrentUser.scoped(FactoryGirl.create(:admin_user)) do + CurrentUser.scoped(FactoryBot.create(:admin_user)) do @post.update(:tag_string => "locked:status") assert_equal(true, @post.is_status_locked) @@ -1108,7 +1083,7 @@ class PostTest < ActiveSupport::TestCase context "of" do setup do - @gold = FactoryGirl.create(:gold_user) + @gold = FactoryBot.create(:gold_user) end context "upvote:self or downvote:self" do @@ -1132,7 +1107,7 @@ class PostTest < ActiveSupport::TestCase context "by a gold user" do should "upvote the post" do - CurrentUser.scoped(FactoryGirl.create(:gold_user)) do + CurrentUser.scoped(FactoryBot.create(:gold_user)) do @post.update(:tag_string => "tag1 tag2 upvote:self") assert_equal(false, @post.errors.any?) assert_equal(1, @post.score) @@ -1140,7 +1115,7 @@ class PostTest < ActiveSupport::TestCase end should "downvote the post" do - CurrentUser.scoped(FactoryGirl.create(:gold_user)) do + CurrentUser.scoped(FactoryBot.create(:gold_user)) do @post.update(:tag_string => "tag1 tag2 downvote:self") assert_equal(false, @post.errors.any?) assert_equal(-1, @post.score) @@ -1160,7 +1135,7 @@ class PostTest < ActiveSupport::TestCase end should "resolve aliases" do - FactoryGirl.create(:tag_alias, :antecedent_name => "/tr", :consequent_name => "translation_request") + FactoryBot.create(:tag_alias, :antecedent_name => "/tr", :consequent_name => "translation_request") @post.update(:tag_string => "aaa translation_request -/tr") assert_equal("aaa", @post.tag_string) @@ -1168,7 +1143,8 @@ class PostTest < ActiveSupport::TestCase end should "have an array representation of its tags" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) + post.reload post.set_tag_string("aaa bbb") assert_equal(%w(aaa bbb), post.tag_array) assert_equal(%w(tag1 tag2), post.tag_array_was) @@ -1215,7 +1191,7 @@ class PostTest < ActiveSupport::TestCase context "with a .webm file extension" do setup do - FactoryGirl.create(:tag_implication, antecedent_name: "webm", consequent_name: "animated") + FactoryBot.create(:tag_implication, antecedent_name: "webm", consequent_name: "animated") @post.file_ext = "webm" @post.tag_string = "" @post.save @@ -1259,12 +1235,12 @@ class PostTest < ActiveSupport::TestCase context "that has been updated" do should "create a new version if it's the first version" do assert_difference("PostArchive.count", 1) do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) end end should "create a new version if it's been over an hour since the last update" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) Timecop.travel(6.hours.from_now) do assert_difference("PostArchive.count", 1) do post.update_attributes(:tag_string => "zzz") @@ -1273,7 +1249,7 @@ class PostTest < ActiveSupport::TestCase end should "merge with the previous version if the updater is the same user and it's been less than an hour" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_difference("PostArchive.count", 0) do post.update_attributes(:tag_string => "zzz") end @@ -1282,7 +1258,7 @@ class PostTest < ActiveSupport::TestCase should "increment the updater's post_update_count" do PostArchive.sqs_service.stubs(:merge?).returns(false) - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") # XXX in the test environment the update count gets bumped twice: and # once by Post#post_update_count, and once by the counter cache. in @@ -1294,8 +1270,8 @@ class PostTest < ActiveSupport::TestCase end should "reset its tag array cache" do - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - user = FactoryGirl.create(:user) + post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + user = FactoryBot.create(:user) assert_equal(%w(aaa bbb ccc), post.tag_array) post.tag_string = "ddd eee fff" post.tag_string = "ddd eee fff" @@ -1306,17 +1282,18 @@ class PostTest < ActiveSupport::TestCase should "create the actual tag records" do assert_difference("Tag.count", 3) do - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") end end should "update the post counts of relevant tag records" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - post2 = FactoryGirl.create(:post, :tag_string => "bbb ccc ddd") - post3 = FactoryGirl.create(:post, :tag_string => "ccc ddd eee") + post1 = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + post2 = FactoryBot.create(:post, :tag_string => "bbb ccc ddd") + post3 = FactoryBot.create(:post, :tag_string => "ccc ddd eee") assert_equal(1, Tag.find_by_name("aaa").post_count) assert_equal(2, Tag.find_by_name("bbb").post_count) assert_equal(3, Tag.find_by_name("ccc").post_count) + post3.reload post3.tag_string = "xxx" post3.save assert_equal(1, Tag.find_by_name("aaa").post_count) @@ -1328,10 +1305,10 @@ class PostTest < ActiveSupport::TestCase end should "update its tag counts" do - artist_tag = FactoryGirl.create(:artist_tag) - copyright_tag = FactoryGirl.create(:copyright_tag) - general_tag = FactoryGirl.create(:tag) - new_post = FactoryGirl.create(:post, :tag_string => "#{artist_tag.name} #{copyright_tag.name} #{general_tag.name}") + artist_tag = FactoryBot.create(:artist_tag) + copyright_tag = FactoryBot.create(:copyright_tag) + general_tag = FactoryBot.create(:tag) + new_post = FactoryBot.create(:post, :tag_string => "#{artist_tag.name} #{copyright_tag.name} #{general_tag.name}") assert_equal(1, new_post.tag_count_artist) assert_equal(1, new_post.tag_count_copyright) assert_equal(1, new_post.tag_count_general) @@ -1348,7 +1325,7 @@ class PostTest < ActiveSupport::TestCase end should "merge any tag changes that were made after loading the initial set of tags part 1" do - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") # user a adds post_edited_by_user_a = Post.find(post.id) @@ -1371,7 +1348,7 @@ class PostTest < ActiveSupport::TestCase # This is the same as part 1, only the order of operations is reversed. # The results should be the same. - post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") # user a removes adds post_edited_by_user_a = Post.find(post.id) @@ -1391,8 +1368,8 @@ class PostTest < ActiveSupport::TestCase end should "merge any parent, source, and rating changes that were made after loading the initial set" do - post = FactoryGirl.create(:post, :parent => nil, :source => "", :rating => "q") - parent_post = FactoryGirl.create(:post) + post = FactoryBot.create(:post, :parent => nil, :source => "", :rating => "q") + parent_post = FactoryBot.create(:post) # user a changes rating to safe, adds parent post_edited_by_user_a = Post.find(post.id) @@ -1424,7 +1401,7 @@ class PostTest < ActiveSupport::TestCase context "that has been tagged with a metatag" do should "not include the metatag in its tag string" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) post.tag_string = "aaa pool:1234 pool:test rating:s fav:bob" post.save assert_equal("aaa", post.tag_string) @@ -1613,7 +1590,7 @@ class PostTest < ActiveSupport::TestCase end should "warn when a tag removal failed due to implications or automatic tags" do - ti = FactoryGirl.create(:tag_implication, antecedent_name: "cat", consequent_name: "animal") + ti = FactoryBot.create(:tag_implication, antecedent_name: "cat", consequent_name: "animal") @post.reload @post.update(old_tag_string: @post.tag_string, tag_string: "chen_(cosplay) char:chen cosplay cat animal") @post.warnings.clear @@ -1624,7 +1601,7 @@ class PostTest < ActiveSupport::TestCase end should "warn when a post from a known source is missing an artist tag" do - post = FactoryGirl.build(:post, source: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65985331") + post = FactoryBot.build(:post, source: "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65985331") post.save assert_match(/Artist tag is required/, post.warnings.full_messages.join) end @@ -1634,7 +1611,7 @@ class PostTest < ActiveSupport::TestCase end should "warn when an upload doesn't have enough tags" do - post = FactoryGirl.create(:post, tag_string: "tagme") + post = FactoryBot.create(:post, tag_string: "tagme") assert_match(/Uploads must have at least \d+ general tags/, post.warnings.full_messages.join) end end @@ -1643,27 +1620,49 @@ class PostTest < ActiveSupport::TestCase context "Updating:" do context "A rating unlocked post" do - setup { @post = FactoryGirl.create(:post) } + setup { @post = FactoryBot.create(:post) } subject { @post } - should_not allow_value("S", "safe", "derp").for(:rating) - should allow_value("s", "q", "e").for(:rating) + should "not allow values S, safe, derp" do + ["S", "safe", "derp"].each do |rating| + subject.rating = rating + assert(!subject.valid?) + end + end + + should "allow values s, q, e" do + ["s", "q", "e"].each do |rating| + subject.rating = rating + assert(subject.valid?) + end + end end context "A rating locked post" do - setup { @post = FactoryGirl.create(:post, :is_rating_locked => true) } + setup { @post = FactoryBot.create(:post, :is_rating_locked => true) } subject { @post } - should_not allow_value("S", "safe", "derp").for(:rating) - should_not allow_value("s", "e").for(:rating) + should "not allow values S, safe, derp" do + ["S", "safe", "derp"].each do |rating| + subject.rating = rating + assert(!subject.valid?) + end + end + + should "not allow values s, e" do + ["s", "e"].each do |rating| + subject.rating = rating + assert(!subject.valid?) + end + end end end context "Favorites:" do context "Removing a post from a user's favorites" do setup do - @user = FactoryGirl.create(:contributor_user) - @post = FactoryGirl.create(:post) + @user = FactoryBot.create(:contributor_user) + @post = FactoryBot.create(:post) @post.add_favorite!(@user) @user.reload end @@ -1681,14 +1680,14 @@ class PostTest < ActiveSupport::TestCase end should "not decrement the post's score for basic users" do - @member = FactoryGirl.create(:user) + @member = FactoryBot.create(:user) assert_no_difference("@post.score") { @post.add_favorite!(@member) } assert_no_difference("@post.score") { @post.remove_favorite!(@member) } end should "not decrement the user's favorite_count if the user did not favorite the post" do - @post2 = FactoryGirl.create(:post) + @post2 = FactoryBot.create(:post) assert_no_difference("@user.favorite_count") do @post2.remove_favorite!(@user) end @@ -1697,8 +1696,8 @@ class PostTest < ActiveSupport::TestCase context "Adding a post to a user's favorites" do setup do - @user = FactoryGirl.create(:contributor_user) - @post = FactoryGirl.create(:post) + @user = FactoryBot.create(:contributor_user) + @post = FactoryBot.create(:post) end should "periodically clean the fav_string" do @@ -1722,7 +1721,7 @@ class PostTest < ActiveSupport::TestCase end should "not increment the post's score for basic users" do - @member = FactoryGirl.create(:user) + @member = FactoryBot.create(:user) @post.add_favorite!(@member) assert_equal(0, @post.score) end @@ -1752,12 +1751,12 @@ class PostTest < ActiveSupport::TestCase context "Moving favorites to a parent post" do setup do - @parent = FactoryGirl.create(:post) - @child = FactoryGirl.create(:post, parent: @parent) + @parent = FactoryBot.create(:post) + @child = FactoryBot.create(:post, parent: @parent) - @user1 = FactoryGirl.create(:user, enable_privacy_mode: true) - @gold1 = FactoryGirl.create(:gold_user) - @supervoter1 = FactoryGirl.create(:user, is_super_voter: true) + @user1 = FactoryBot.create(:user, enable_privacy_mode: true) + @gold1 = FactoryBot.create(:gold_user) + @supervoter1 = FactoryBot.create(:user, is_super_voter: true) @child.add_favorite!(@user1) @child.add_favorite!(@gold1) @@ -1794,8 +1793,8 @@ class PostTest < ActiveSupport::TestCase context "Removing a post from a pool" do should "update the post's pool string" do - post = FactoryGirl.create(:post) - pool = FactoryGirl.create(:pool) + post = FactoryBot.create(:post) + pool = FactoryBot.create(:pool) post.add_pool!(pool) post.remove_pool!(pool) post.reload @@ -1808,8 +1807,8 @@ class PostTest < ActiveSupport::TestCase context "Adding a post to a pool" do should "update the post's pool string" do - post = FactoryGirl.create(:post) - pool = FactoryGirl.create(:pool) + post = FactoryBot.create(:post) + pool = FactoryBot.create(:pool) post.add_pool!(pool) post.reload assert_equal("pool:#{pool.id} pool:series", post.pool_string) @@ -1826,10 +1825,10 @@ class PostTest < ActiveSupport::TestCase context "Uploading:" do context "Uploading a post" do should "capture who uploaded the post" do - post = FactoryGirl.create(:post) - user1 = FactoryGirl.create(:user) - user2 = FactoryGirl.create(:user) - user3 = FactoryGirl.create(:user) + post = FactoryBot.create(:post) + user1 = FactoryBot.create(:user) + user2 = FactoryBot.create(:user) + user3 = FactoryBot.create(:user) post.uploader = user1 assert_equal(user1.id, post.uploader_id) @@ -1848,102 +1847,102 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the age:<1minute tag" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_tag_match([post], "age:<1minute") end should "return posts for the age:<1minute tag when the user is in Pacific time zone" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) Time.zone = "Pacific Time (US & Canada)" assert_tag_match([post], "age:<1minute") Time.zone = "Eastern Time (US & Canada)" end should "return posts for the age:<1minute tag when the user is in Tokyo time zone" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) Time.zone = "Asia/Tokyo" assert_tag_match([post], "age:<1minute") Time.zone = "Eastern Time (US & Canada)" end should "return posts for the ' tag" do - post1 = FactoryGirl.create(:post, :tag_string => "'") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post1 = FactoryBot.create(:post, :tag_string => "'") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") assert_tag_match([post1], "'") end should "return posts for the \\ tag" do - post1 = FactoryGirl.create(:post, :tag_string => "\\") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post1 = FactoryBot.create(:post, :tag_string => "\\") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") assert_tag_match([post1], "\\") end should "return posts for the ( tag" do - post1 = FactoryGirl.create(:post, :tag_string => "(") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post1 = FactoryBot.create(:post, :tag_string => "(") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") assert_tag_match([post1], "(") end should "return posts for the ? tag" do - post1 = FactoryGirl.create(:post, :tag_string => "?") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") + post1 = FactoryBot.create(:post, :tag_string => "?") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") assert_tag_match([post1], "?") end should "return posts for 1 tag" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post2, post1], "aaa") end should "return posts for a 2 tag join" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post2], "aaa bbb") end should "return posts for a 2 tag union" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaab bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaab bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post3, post1], "~aaa ~ccc") end should "return posts for 1 tag with exclusion" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaa bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post1], "aaa -bbb") end should "return posts for 1 tag with a pattern" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaab bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaab bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post2, post1], "a*") end should "return posts for 2 tags, one with a pattern" do - post1 = FactoryGirl.create(:post, :tag_string => "aaa") - post2 = FactoryGirl.create(:post, :tag_string => "aaab bbb") - post3 = FactoryGirl.create(:post, :tag_string => "bbb ccc") + post1 = FactoryBot.create(:post, :tag_string => "aaa") + post2 = FactoryBot.create(:post, :tag_string => "aaab bbb") + post3 = FactoryBot.create(:post, :tag_string => "bbb ccc") assert_tag_match([post2], "a* bbb") end should "return posts for the id: metatag" do - posts = FactoryGirl.create_list(:post, 3) + posts = FactoryBot.create_list(:post, 3) assert_tag_match([posts[1]], "id:#{posts[1].id}") assert_tag_match([posts[2]], "id:>#{posts[1].id}") @@ -1957,9 +1956,9 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the fav: metatag" do - users = FactoryGirl.create_list(:user, 2) + users = FactoryBot.create_list(:user, 2) posts = users.map do |u| - CurrentUser.scoped(u) { FactoryGirl.create(:post, tag_string: "fav:#{u.name}") } + CurrentUser.scoped(u) { FactoryBot.create(:post, tag_string: "fav:#{u.name}") } end assert_tag_match([posts[0]], "fav:#{users[0].name}") @@ -1967,8 +1966,8 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the ordfav: metatag" do - post1 = FactoryGirl.create(:post, tag_string: "fav:#{CurrentUser.name}") - post2 = FactoryGirl.create(:post, tag_string: "fav:#{CurrentUser.name}") + post1 = FactoryBot.create(:post, tag_string: "fav:#{CurrentUser.name}") + post2 = FactoryBot.create(:post, tag_string: "fav:#{CurrentUser.name}") assert_tag_match([post2, post1], "ordfav:#{CurrentUser.name}") end @@ -1976,10 +1975,10 @@ class PostTest < ActiveSupport::TestCase should "return posts for the pool: metatag" do SqsService.any_instance.stubs(:send_message) - FactoryGirl.create(:pool, name: "test_a", category: "series") - FactoryGirl.create(:pool, name: "test_b", category: "collection") - post1 = FactoryGirl.create(:post, tag_string: "pool:test_a") - post2 = FactoryGirl.create(:post, tag_string: "pool:test_b") + FactoryBot.create(:pool, name: "test_a", category: "series") + FactoryBot.create(:pool, name: "test_b", category: "collection") + post1 = FactoryBot.create(:post, tag_string: "pool:test_a") + post2 = FactoryBot.create(:post, tag_string: "pool:test_b") assert_tag_match([post1], "pool:test_a") assert_tag_match([post2], "-pool:test_a") @@ -1996,14 +1995,14 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the ordpool: metatag" do - posts = FactoryGirl.create_list(:post, 2, tag_string: "newpool:test") + posts = FactoryBot.create_list(:post, 2, tag_string: "newpool:test") assert_tag_match(posts, "ordpool:test") end should "return posts for the parent: metatag" do - parent = FactoryGirl.create(:post) - child = FactoryGirl.create(:post, tag_string: "parent:#{parent.id}") + parent = FactoryBot.create(:post) + child = FactoryBot.create(:post, tag_string: "parent:#{parent.id}") assert_tag_match([parent], "parent:none") assert_tag_match([child], "-parent:none") @@ -2015,8 +2014,8 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the favgroup: metatag" do - favgroups = FactoryGirl.create_list(:favorite_group, 2, creator: CurrentUser.user) - posts = favgroups.map { |g| FactoryGirl.create(:post, tag_string: "favgroup:#{g.name}") } + favgroups = FactoryBot.create_list(:favorite_group, 2, creator: CurrentUser.user) + posts = favgroups.map { |g| FactoryBot.create(:post, tag_string: "favgroup:#{g.name}") } assert_tag_match([posts[0]], "favgroup:#{favgroups[0].name}") assert_tag_match([posts[1]], "-favgroup:#{favgroups[0].name}") @@ -2024,17 +2023,17 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the user: metatag" do - users = FactoryGirl.create_list(:user, 2) - posts = users.map { |u| FactoryGirl.create(:post, uploader: u) } + users = FactoryBot.create_list(:user, 2) + posts = users.map { |u| FactoryBot.create(:post, uploader: u) } assert_tag_match([posts[0]], "user:#{users[0].name}") assert_tag_match([posts[1]], "-user:#{users[0].name}") end should "return posts for the approver: metatag" do - users = FactoryGirl.create_list(:user, 2) - posts = users.map { |u| FactoryGirl.create(:post, approver: u) } - posts << FactoryGirl.create(:post, approver: nil) + users = FactoryBot.create_list(:user, 2) + posts = users.map { |u| FactoryBot.create(:post, approver: u) } + posts << FactoryBot.create(:post, approver: nil) assert_tag_match([posts[0]], "approver:#{users[0].name}") assert_tag_match([posts[1]], "-approver:#{users[0].name}") @@ -2043,46 +2042,46 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the commenter: metatag" do - users = FactoryGirl.create_list(:user, 2, created_at: 2.weeks.ago) - posts = FactoryGirl.create_list(:post, 2) - comms = users.zip(posts).map { |u, p| FactoryGirl.create(:comment, creator: u, post: p) } + users = FactoryBot.create_list(:user, 2, created_at: 2.weeks.ago) + posts = FactoryBot.create_list(:post, 2) + comms = users.zip(posts).map { |u, p| as(u) { FactoryBot.create(:comment, post: p) } } assert_tag_match([posts[0]], "commenter:#{users[0].name}") assert_tag_match([posts[1]], "commenter:#{users[1].name}") end should "return posts for the commenter: metatag" do - posts = FactoryGirl.create_list(:post, 2) - FactoryGirl.create(:comment, post: posts[0], is_deleted: false) - FactoryGirl.create(:comment, post: posts[1], is_deleted: true) + posts = FactoryBot.create_list(:post, 2) + FactoryBot.create(:comment, post: posts[0], is_deleted: false) + FactoryBot.create(:comment, post: posts[1], is_deleted: true) assert_tag_match([posts[0]], "commenter:any") assert_tag_match([posts[1]], "commenter:none") end should "return posts for the noter: metatag" do - users = FactoryGirl.create_list(:user, 2) - posts = FactoryGirl.create_list(:post, 2) - notes = users.zip(posts).map { |u, p| FactoryGirl.create(:note, creator: u, post: p) } + users = FactoryBot.create_list(:user, 2) + posts = FactoryBot.create_list(:post, 2) + notes = users.zip(posts).map { |u, p| FactoryBot.create(:note, creator: u, post: p) } assert_tag_match([posts[0]], "noter:#{users[0].name}") assert_tag_match([posts[1]], "noter:#{users[1].name}") end should "return posts for the noter: metatag" do - posts = FactoryGirl.create_list(:post, 2) - FactoryGirl.create(:note, post: posts[0], is_active: true) - FactoryGirl.create(:note, post: posts[1], is_active: false) + posts = FactoryBot.create_list(:post, 2) + FactoryBot.create(:note, post: posts[0], is_active: true) + FactoryBot.create(:note, post: posts[1], is_active: false) assert_tag_match([posts[0]], "noter:any") assert_tag_match([posts[1]], "noter:none") end should "return posts for the artcomm: metatag" do - users = FactoryGirl.create_list(:user, 2) - posts = FactoryGirl.create_list(:post, 2) + users = FactoryBot.create_list(:user, 2) + posts = FactoryBot.create_list(:post, 2) users.zip(posts).map do |u, p| - CurrentUser.scoped(u) { FactoryGirl.create(:artist_commentary, post: p) } + CurrentUser.scoped(u) { FactoryBot.create(:artist_commentary, post: p) } end assert_tag_match([posts[0]], "artcomm:#{users[0].name}") @@ -2090,13 +2089,13 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the date: metatag" do - post = FactoryGirl.create(:post, created_at: Time.parse("2017-01-01")) + post = FactoryBot.create(:post, created_at: Time.parse("2017-01-01")) assert_tag_match([post], "date:2017-01-01") end should "return posts for the age: metatag" do - post = FactoryGirl.create(:post) + post = FactoryBot.create(:post) assert_tag_match([post], "age:<60") assert_tag_match([post], "age:<60s") @@ -2109,17 +2108,17 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the ratio: metatag" do - post = FactoryGirl.create(:post, image_width: 1000, image_height: 500) + post = FactoryBot.create(:post, image_width: 1000, image_height: 500) assert_tag_match([post], "ratio:2:1") assert_tag_match([post], "ratio:2.0") end should "return posts for the status: metatag" do - pending = FactoryGirl.create(:post, is_pending: true) - flagged = FactoryGirl.create(:post, is_flagged: true) - deleted = FactoryGirl.create(:post, is_deleted: true) - banned = FactoryGirl.create(:post, is_banned: true) + pending = FactoryBot.create(:post, is_pending: true) + flagged = FactoryBot.create(:post, is_flagged: true) + deleted = FactoryBot.create(:post, is_deleted: true) + banned = FactoryBot.create(:post, is_banned: true) all = [banned, deleted, flagged, pending] assert_tag_match([pending], "status:pending") @@ -2138,8 +2137,8 @@ class PostTest < ActiveSupport::TestCase end should "respect the 'Deleted post filter' option when using the status:banned metatag" do - deleted = FactoryGirl.create(:post, is_deleted: true, is_banned: true) - undeleted = FactoryGirl.create(:post, is_banned: true) + deleted = FactoryBot.create(:post, is_deleted: true, is_banned: true) + undeleted = FactoryBot.create(:post, is_banned: true) CurrentUser.hide_deleted_posts = true assert_tag_match([undeleted], "status:banned") @@ -2149,15 +2148,15 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the filetype: metatag" do - png = FactoryGirl.create(:post, file_ext: "png") - jpg = FactoryGirl.create(:post, file_ext: "jpg") + png = FactoryBot.create(:post, file_ext: "png") + jpg = FactoryBot.create(:post, file_ext: "jpg") assert_tag_match([png], "filetype:png") assert_tag_match([jpg], "-filetype:png") end should "return posts for the tagcount: metatags" do - post = FactoryGirl.create(:post, tag_string: "artist:wokada copyright:vocaloid char:hatsune_miku twintails") + post = FactoryBot.create(:post, tag_string: "artist:wokada copyright:vocaloid char:hatsune_miku twintails") assert_tag_match([post], "tagcount:4") assert_tag_match([post], "arttags:1") @@ -2167,16 +2166,16 @@ class PostTest < ActiveSupport::TestCase end should "return posts for the md5: metatag" do - post1 = FactoryGirl.create(:post, :md5 => "abcd") - post2 = FactoryGirl.create(:post) + post1 = FactoryBot.create(:post, :md5 => "abcd") + post2 = FactoryBot.create(:post) assert_tag_match([post1], "md5:abcd") end should "return posts for a source search" do - post1 = FactoryGirl.create(:post, :source => "abcd") - post2 = FactoryGirl.create(:post, :source => "abcdefg") - post3 = FactoryGirl.create(:post, :source => "") + post1 = FactoryBot.create(:post, :source => "abcd") + post2 = FactoryBot.create(:post, :source => "abcdefg") + post3 = FactoryBot.create(:post, :source => "") assert_tag_match([post2], "source:abcde") assert_tag_match([post3, post1], "-source:abcde") @@ -2186,15 +2185,15 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a case insensitive source search" do - post1 = FactoryGirl.create(:post, :source => "ABCD") - post2 = FactoryGirl.create(:post, :source => "1234") + post1 = FactoryBot.create(:post, :source => "ABCD") + post2 = FactoryBot.create(:post, :source => "1234") assert_tag_match([post1], "source:abcd") end should "return posts for a pixiv source search" do url = "http://i1.pixiv.net/img123/img/artist-name/789.png" - post = FactoryGirl.create(:post, :source => url) + post = FactoryBot.create(:post, :source => url) assert_tag_match([post], "source:*.pixiv.net/img*/artist-name/*") assert_tag_match([], "source:*.pixiv.net/img*/artist-fake/*") @@ -2206,39 +2205,39 @@ class PostTest < ActiveSupport::TestCase should "return posts for a pixiv id search (type 1)" do url = "http://i1.pixiv.net/img-inf/img/2013/03/14/03/02/36/34228050_s.jpg" - post = FactoryGirl.create(:post, :source => url) + post = FactoryBot.create(:post, :source => url) assert_tag_match([post], "pixiv_id:34228050") end should "return posts for a pixiv id search (type 2)" do url = "http://i1.pixiv.net/img123/img/artist-name/789.png" - post = FactoryGirl.create(:post, :source => url) + post = FactoryBot.create(:post, :source => url) assert_tag_match([post], "pixiv_id:789") end should "return posts for a pixiv id search (type 3)" do url = "http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=19113635&page=0" - post = FactoryGirl.create(:post, :source => url) + post = FactoryBot.create(:post, :source => url) assert_tag_match([post], "pixiv_id:19113635") end should "return posts for a pixiv id search (type 4)" do url = "http://i2.pixiv.net/img70/img/disappearedstump/34551381_p3.jpg?1364424318" - post = FactoryGirl.create(:post, :source => url) + post = FactoryBot.create(:post, :source => url) assert_tag_match([post], "pixiv_id:34551381") end # should "return posts for a pixiv novel id search" do # url = "http://www.pixiv.net/novel/show.php?id=2156088" - # post = FactoryGirl.create(:post, :source => url) + # post = FactoryBot.create(:post, :source => url) # assert_equal(1, Post.tag_match("pixiv_novel_id:2156088").count) # end should "return posts for a search: metatag" do - post1 = FactoryGirl.create(:post, tag_string: "aaa") - post2 = FactoryGirl.create(:post, tag_string: "bbb") - FactoryGirl.create(:saved_search, query: "aaa", labels: ["zzz"], user: CurrentUser.user) - FactoryGirl.create(:saved_search, query: "bbb", user: CurrentUser.user) + post1 = FactoryBot.create(:post, tag_string: "aaa") + post2 = FactoryBot.create(:post, tag_string: "bbb") + FactoryBot.create(:saved_search, query: "aaa", labels: ["zzz"], user: CurrentUser.user) + FactoryBot.create(:saved_search, query: "bbb", user: CurrentUser.user) SavedSearch.expects(:post_ids).with(CurrentUser.id, "zzz").returns([post1.id]) SavedSearch.expects(:post_ids).with(CurrentUser.id, "uncategorized").returns([post2.id]) @@ -2250,9 +2249,9 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a rating: metatag" do - s = FactoryGirl.create(:post, :rating => "s") - q = FactoryGirl.create(:post, :rating => "q") - e = FactoryGirl.create(:post, :rating => "e") + s = FactoryBot.create(:post, :rating => "s") + q = FactoryBot.create(:post, :rating => "q") + e = FactoryBot.create(:post, :rating => "e") all = [e, q, s] assert_tag_match([s], "rating:s") @@ -2265,9 +2264,9 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a locked: metatag" do - rating_locked = FactoryGirl.create(:post, is_rating_locked: true) - note_locked = FactoryGirl.create(:post, is_note_locked: true) - status_locked = FactoryGirl.create(:post, is_status_locked: true) + rating_locked = FactoryBot.create(:post, is_rating_locked: true) + note_locked = FactoryBot.create(:post, is_note_locked: true) + status_locked = FactoryBot.create(:post, is_status_locked: true) all = [status_locked, note_locked, rating_locked] assert_tag_match([rating_locked], "locked:rating") @@ -2280,9 +2279,9 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a upvote:, downvote: metatag" do - CurrentUser.scoped(FactoryGirl.create(:mod_user)) do - upvoted = FactoryGirl.create(:post, tag_string: "upvote:self") - downvoted = FactoryGirl.create(:post, tag_string: "downvote:self") + CurrentUser.scoped(FactoryBot.create(:mod_user)) do + upvoted = FactoryBot.create(:post, tag_string: "upvote:self") + downvoted = FactoryBot.create(:post, tag_string: "downvote:self") assert_tag_match([upvoted], "upvote:#{CurrentUser.name}") assert_tag_match([downvoted], "downvote:#{CurrentUser.name}") @@ -2293,7 +2292,7 @@ class PostTest < ActiveSupport::TestCase posts = (1..2).map do |n| tags = ["tagme", "gentag1 gentag2 artist:arttag char:chartag copy:copytag"] - p = FactoryGirl.create( + p = FactoryBot.create( :post, score: n, fav_count: n, @@ -2304,9 +2303,9 @@ class PostTest < ActiveSupport::TestCase tag_string: tags[n-1], ) - FactoryGirl.create(:artist_commentary, post: p) - FactoryGirl.create(:comment, post: p, do_not_bump_post: false) - FactoryGirl.create(:note, post: p) + FactoryBot.create(:artist_commentary, post: p) + FactoryBot.create(:comment, post: p, do_not_bump_post: false) + FactoryBot.create(:note, post: p) p end @@ -2347,14 +2346,14 @@ class PostTest < ActiveSupport::TestCase end should "return posts for order:comment_bumped" do - post1 = FactoryGirl.create(:post) - post2 = FactoryGirl.create(:post) - post3 = FactoryGirl.create(:post) + post1 = FactoryBot.create(:post) + post2 = FactoryBot.create(:post) + post3 = FactoryBot.create(:post) - CurrentUser.scoped(FactoryGirl.create(:gold_user), "127.0.0.1") do - comment1 = FactoryGirl.create(:comment, :post => post1) - comment2 = FactoryGirl.create(:comment, :post => post2, :do_not_bump_post => true) - comment3 = FactoryGirl.create(:comment, :post => post3) + CurrentUser.scoped(FactoryBot.create(:gold_user), "127.0.0.1") do + comment1 = FactoryBot.create(:comment, :post => post1) + comment2 = FactoryBot.create(:comment, :post => post2, :do_not_bump_post => true) + comment3 = FactoryBot.create(:comment, :post => post3) end assert_tag_match([post3, post1, post2], "order:comment_bumped") @@ -2362,7 +2361,7 @@ class PostTest < ActiveSupport::TestCase end should "return posts for a filesize search" do - post = FactoryGirl.create(:post, :file_size => 1.megabyte) + post = FactoryBot.create(:post, :file_size => 1.megabyte) assert_tag_match([post], "filesize:1mb") assert_tag_match([post], "filesize:1000kb") @@ -2370,14 +2369,14 @@ class PostTest < ActiveSupport::TestCase end should "not perform fuzzy matching for an exact filesize search" do - post = FactoryGirl.create(:post, :file_size => 1.megabyte) + post = FactoryBot.create(:post, :file_size => 1.megabyte) assert_tag_match([], "filesize:1048000b") assert_tag_match([], "filesize:1048000") end should "fail for more than 6 tags" do - post1 = FactoryGirl.create(:post, :rating => "s") + post1 = FactoryBot.create(:post, :rating => "s") assert_raise(::Post::SearchError) do Post.tag_match("a b c rating:s width:10 height:10 user:bob") @@ -2385,7 +2384,7 @@ class PostTest < ActiveSupport::TestCase end should "not count free tags against the user's search limit" do - post1 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:s") + post1 = FactoryBot.create(:post, tag_string: "aaa bbb rating:s") Danbooru.config.expects(:is_unlimited_tag?).with("rating:s").once.returns(true) Danbooru.config.expects(:is_unlimited_tag?).with(anything).twice.returns(false) @@ -2393,14 +2392,14 @@ class PostTest < ActiveSupport::TestCase end should "succeed for exclusive tag searches with no other tag" do - post1 = FactoryGirl.create(:post, :rating => "s", :tag_string => "aaa") + post1 = FactoryBot.create(:post, :rating => "s", :tag_string => "aaa") assert_nothing_raised do relation = Post.tag_match("-aaa") end end should "succeed for exclusive tag searches combined with a metatag" do - post1 = FactoryGirl.create(:post, :rating => "s", :tag_string => "aaa") + post1 = FactoryBot.create(:post, :rating => "s", :tag_string => "aaa") assert_nothing_raised do relation = Post.tag_match("-aaa id:>0") end @@ -2410,9 +2409,9 @@ class PostTest < ActiveSupport::TestCase context "Voting:" do context "with a super voter" do setup do - @user = FactoryGirl.create(:user) - FactoryGirl.create(:super_voter, user: @user) - @post = FactoryGirl.create(:post) + @user = FactoryBot.create(:user) + FactoryBot.create(:super_voter, user: @user) + @post = FactoryBot.create(:post) end should "account for magnitude" do @@ -2427,16 +2426,16 @@ class PostTest < ActiveSupport::TestCase end should "not allow members to vote" do - @user = FactoryGirl.create(:user) - @post = FactoryGirl.create(:post) - CurrentUser.scoped(@user) do + @user = FactoryBot.create(:user) + @post = FactoryBot.create(:post) + as_user do assert_raises(PostVote::Error) { @post.vote!("up") } end end should "not allow duplicate votes" do - user = FactoryGirl.create(:gold_user) - post = FactoryGirl.create(:post) + user = FactoryBot.create(:gold_user) + post = FactoryBot.create(:post) CurrentUser.scoped(user, "127.0.0.1") do assert_nothing_raised {post.vote!("up")} assert_raises(PostVote::Error) {post.vote!("up")} @@ -2447,8 +2446,8 @@ class PostTest < ActiveSupport::TestCase end should "allow undoing of votes" do - user = FactoryGirl.create(:gold_user) - post = FactoryGirl.create(:post) + user = FactoryBot.create(:gold_user) + post = FactoryBot.create(:post) # We deliberately don't call post.reload until the end to verify that # post.unvote! returns the correct score even when not forcibly reloaded. @@ -2479,8 +2478,8 @@ class PostTest < ActiveSupport::TestCase setup do Danbooru.config.stubs(:blank_tag_search_fast_count).returns(nil) Danbooru.config.stubs(:estimate_post_counts).returns(false) - FactoryGirl.create(:tag_alias, :antecedent_name => "alias", :consequent_name => "aaa") - FactoryGirl.create(:post, :tag_string => "aaa", "score" => 42) + FactoryBot.create(:tag_alias, :antecedent_name => "alias", :consequent_name => "aaa") + FactoryBot.create(:post, :tag_string => "aaa", "score" => 42) end context "a single basic tag" do @@ -2492,14 +2491,14 @@ class PostTest < ActiveSupport::TestCase context "a single metatag" do should "return the correct cached count" do - FactoryGirl.build(:tag, name: "score:42", post_count: -100).save(validate: false) + FactoryBot.build(:tag, name: "score:42", post_count: -100).save(validate: false) Post.set_count_in_cache("score:42", 100) assert_equal(100, Post.fast_count("score:42")) end should "return the correct cached count for a pool: search" do - FactoryGirl.build(:tag, name: "pool:1234", post_count: -100).save(validate: false) + FactoryBot.build(:tag, name: "pool:1234", post_count: -100).save(validate: false) Post.set_count_in_cache("pool:1234", 100) assert_equal(100, Post.fast_count("pool:1234")) @@ -2550,7 +2549,7 @@ class PostTest < ActiveSupport::TestCase context "in safe mode" do setup do CurrentUser.stubs(:safe_mode?).returns(true) - FactoryGirl.create(:post, "rating" => "s") + FactoryBot.create(:post, "rating" => "s") end should "work for a blank search" do @@ -2562,8 +2561,8 @@ class PostTest < ActiveSupport::TestCase end should "not fail for a two tag search by a member" do - post1 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:s") - post2 = FactoryGirl.create(:post, tag_string: "aaa bbb rating:e") + post1 = FactoryBot.create(:post, tag_string: "aaa bbb rating:s") + post2 = FactoryBot.create(:post, tag_string: "aaa bbb rating:e") Danbooru.config.expects(:is_unlimited_tag?).with("rating:s").once.returns(true) Danbooru.config.expects(:is_unlimited_tag?).with(anything).twice.returns(false) @@ -2592,9 +2591,9 @@ class PostTest < ActiveSupport::TestCase context "Reverting: " do context "a post that is rating locked" do setup do - @post = FactoryGirl.create(:post, :rating => "s") + @post = FactoryBot.create(:post, :rating => "s") Timecop.travel(2.hours.from_now) do - @post.update({ :rating => "q", :is_rating_locked => true }, :as => :builder) + @post.update(rating: "q", is_rating_locked: true) end end @@ -2608,7 +2607,7 @@ class PostTest < ActiveSupport::TestCase end should "revert the rating after unlocking" do - @post.update({ :rating => "e", :is_rating_locked => false }, :as => :builder) + @post.update(rating: "e", is_rating_locked: false) assert_nothing_raised do @post.revert_to!(@post.versions.first) end @@ -2621,7 +2620,7 @@ class PostTest < ActiveSupport::TestCase context "a post that has been updated" do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post = FactoryGirl.create(:post, :rating => "q", :tag_string => "aaa", :source => "") + @post = FactoryBot.create(:post, :rating => "q", :tag_string => "aaa", :source => "") @post.update_attributes(:tag_string => "aaa bbb ccc ddd") @post.update_attributes(:tag_string => "bbb xxx yyy", :source => "xyz") @post.update_attributes(:tag_string => "bbb mmm yyy", :source => "abc") @@ -2655,19 +2654,19 @@ class PostTest < ActiveSupport::TestCase context "URLs:" do should "generate the correct urls for animated gifs" do - @post = FactoryGirl.build(:post, md5: "deadbeef", file_ext: "gif", tag_string: "animated_gif") + @post = FactoryBot.build(:post, md5: "deadbeef", file_ext: "gif", tag_string: "animated_gif") - assert_equal("http://localhost/data/preview/deadbeef.jpg", @post.preview_file_url) - assert_equal("http://localhost/data/deadbeef.gif", @post.large_file_url) - assert_equal("http://localhost/data/deadbeef.gif", @post.file_url) + assert_equal("http://#{Socket.gethostname}/data/preview/deadbeef.jpg", @post.preview_file_url) + assert_equal("http://#{Socket.gethostname}/data/deadbeef.gif", @post.large_file_url) + assert_equal("http://#{Socket.gethostname}/data/deadbeef.gif", @post.file_url) end end context "Notes:" do context "#copy_notes_to" do setup do - @src = FactoryGirl.create(:post, image_width: 100, image_height: 100, tag_string: "translated partially_translated", has_embedded_notes: true) - @dst = FactoryGirl.create(:post, image_width: 200, image_height: 200, tag_string: "translation_request") + @src = FactoryBot.create(:post, image_width: 100, image_height: 100, tag_string: "translated partially_translated", has_embedded_notes: true) + @dst = FactoryBot.create(:post, image_width: 200, image_height: 200, tag_string: "translation_request") @src.notes.create(x: 10, y: 10, width: 10, height: 10, body: "test") @src.notes.create(x: 10, y: 10, width: 10, height: 10, body: "deleted", is_active: false) @@ -2688,9 +2687,4 @@ class PostTest < ActiveSupport::TestCase end end end - - context "Mass assignment: " do - should_not allow_mass_assignment_of(:last_noted_at).as(:member) - end end - diff --git a/test/unit/post_version_test.rb b/test/unit/post_version_test.rb index 597f10d6f..40c93d55f 100644 --- a/test/unit/post_version_test.rb +++ b/test/unit/post_version_test.rb @@ -4,7 +4,7 @@ class PostVersionTest < ActiveSupport::TestCase context "A post" do setup do Timecop.travel(1.month.ago) do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @@ -18,7 +18,7 @@ class PostVersionTest < ActiveSupport::TestCase context "that has multiple versions: " do setup do PostArchive.sqs_service.stubs(:merge?).returns(false) - @post = FactoryGirl.create(:post, :tag_string => "1") + @post = FactoryBot.create(:post, :tag_string => "1") @post.update_attributes(:tag_string => "1 2") @post.update_attributes(:tag_string => "2 3") end @@ -37,8 +37,8 @@ class PostVersionTest < ActiveSupport::TestCase context "that has been created" do setup do - @parent = FactoryGirl.create(:post) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") + @parent = FactoryBot.create(:post) + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "e", :parent => @parent, :source => "xyz") end should "also create a version" do @@ -53,8 +53,8 @@ class PostVersionTest < ActiveSupport::TestCase context "that should be merged" do setup do - @parent = FactoryGirl.create(:post) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @parent = FactoryBot.create(:post) + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") end should "delete the previous version" do @@ -69,7 +69,7 @@ class PostVersionTest < ActiveSupport::TestCase setup do PostArchive.sqs_service.stubs(:merge?).returns(false) Timecop.travel(1.minute.ago) do - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @post = FactoryBot.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") end @post.update_attributes(:tag_string => "bbb ccc xxx", :source => "") end diff --git a/test/unit/post_view_count_service_test.rb b/test/unit/post_view_count_service_test.rb index a20e8d5e0..e50fbde2f 100644 --- a/test/unit/post_view_count_service_test.rb +++ b/test/unit/post_view_count_service_test.rb @@ -4,12 +4,12 @@ class PostViewCountServiceTest < ActiveSupport::TestCase def setup super - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" PostViewCountService.stubs(:enabled?).returns(true) Danbooru.config.stubs(:reportbooru_server).returns("http://localhost:1234") - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) end def teardown diff --git a/test/unit/post_vote_test.rb b/test/unit/post_vote_test.rb index 593313230..507a89249 100644 --- a/test/unit/post_vote_test.rb +++ b/test/unit/post_vote_test.rb @@ -4,12 +4,12 @@ class PostVoteTest < ActiveSupport::TestCase def setup super - @supervoter = FactoryGirl.create(:user, is_super_voter: true) - @user = FactoryGirl.create(:user) + @supervoter = FactoryBot.create(:user, is_super_voter: true) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) end context "Voting for a post" do diff --git a/test/unit/related_tag_calculator_test.rb b/test/unit/related_tag_calculator_test.rb index d14a479b8..250cb4d47 100644 --- a/test/unit/related_tag_calculator_test.rb +++ b/test/unit/related_tag_calculator_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RelatedTagCalculatorTest < ActiveSupport::TestCase setup do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,9 +15,9 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase context "A related tag calculator" do context "for a post set" do setup do - FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") - FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - FactoryGirl.create(:post, :tag_string => "aaa bbb") + FactoryBot.create(:post, :tag_string => "aaa bbb ccc ddd") + FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + FactoryBot.create(:post, :tag_string => "aaa bbb") @posts = Post.tag_match("aaa") end @@ -28,27 +28,27 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase should "calculate related tags for a tag" do posts = [] - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb") assert_equal({"aaa" => 3, "bbb" => 3, "ccc" => 2, "ddd" => 1}, RelatedTagCalculator.calculate_from_sample("aaa", 10)) end should "calculate related tags for multiple tag" do posts = [] - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << FactoryGirl.create(:post, :tag_string => "aaa eee fff") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryBot.create(:post, :tag_string => "aaa eee fff") assert_equal({"aaa"=>2, "bbb"=>2, "ddd"=>1, "ccc"=>2}, RelatedTagCalculator.calculate_from_sample("aaa bbb", 10)) end should "calculate typed related tags for a tag" do posts = [] - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb art:ccc copy:ddd") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb art:ccc") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb art:ccc copy:ddd") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb art:ccc") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb") assert_equal({"ccc" => 2}, RelatedTagCalculator.calculate_from_sample("aaa", 10, Tag.categories.artist)) assert_equal({"ddd" => 1}, RelatedTagCalculator.calculate_from_sample("aaa", 10, Tag.categories.copyright)) @@ -56,9 +56,9 @@ class RelatedTagCalculatorTest < ActiveSupport::TestCase should "convert a hash into string format" do posts = [] - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc ddd") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - posts << FactoryGirl.create(:post, :tag_string => "aaa bbb") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc ddd") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + posts << FactoryBot.create(:post, :tag_string => "aaa bbb") tag = Tag.find_by_name("aaa") counts = RelatedTagCalculator.calculate_from_sample("aaa", 10) diff --git a/test/unit/related_tag_query_test.rb b/test/unit/related_tag_query_test.rb index 4a65415e7..3ddde7d94 100644 --- a/test/unit/related_tag_query_test.rb +++ b/test/unit/related_tag_query_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class RelatedTagQueryTest < ActiveSupport::TestCase setup do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -11,9 +11,9 @@ class RelatedTagQueryTest < ActiveSupport::TestCase subject { RelatedTagQuery.new("copyright") } setup do - @copyright = FactoryGirl.create(:copyright_tag, name: "copyright") - @wiki = FactoryGirl.create(:wiki_page, title: "copyright", body: "[[list_of_hoges]]") - @list_of_hoges = FactoryGirl.create(:wiki_page, title: "list_of_hoges", body: "[[alpha]] and [[beta]]") + @copyright = FactoryBot.create(:copyright_tag, name: "copyright") + @wiki = FactoryBot.create(:wiki_page, title: "copyright", body: "[[list_of_hoges]]") + @list_of_hoges = FactoryBot.create(:wiki_page, title: "list_of_hoges", body: "[[alpha]] and [[beta]]") end should "return tags from the associated list wiki" do @@ -26,8 +26,8 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "a related tag query without a category constraint" do setup do - @post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - @post_2 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") + @post_1 = FactoryBot.create(:post, :tag_string => "aaa bbb") + @post_2 = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") end context "for a tag that already exists" do @@ -57,8 +57,8 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "for an aliased tag" do setup do - @ta = FactoryGirl.create(:tag_alias, antecedent_name: "xyz", consequent_name: "aaa") - @wp = FactoryGirl.create(:wiki_page, title: "aaa", body: "blah [[foo|blah]] [[FOO]] [[bar]] blah") + @ta = FactoryBot.create(:tag_alias, antecedent_name: "xyz", consequent_name: "aaa") + @wp = FactoryBot.create(:wiki_page, title: "aaa", body: "blah [[foo|blah]] [[FOO]] [[bar]] blah") @query = RelatedTagQuery.new("xyz", "") Tag.named("aaa").first.update_related @@ -85,7 +85,7 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "for a tag with a wiki page" do setup do - @wiki_page = FactoryGirl.create(:wiki_page, :title => "aaa", :body => "[[bbb]] [[ccc]]") + @wiki_page = FactoryBot.create(:wiki_page, :title => "aaa", :body => "[[bbb]] [[ccc]]") @query = RelatedTagQuery.new("aaa", "") end @@ -97,9 +97,9 @@ class RelatedTagQueryTest < ActiveSupport::TestCase context "a related tag query with a category constraint" do setup do - @post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - @post_2 = FactoryGirl.create(:post, :tag_string => "aaa art:ccc") - @post_3 = FactoryGirl.create(:post, :tag_string => "aaa copy:ddd") + @post_1 = FactoryBot.create(:post, :tag_string => "aaa bbb") + @post_2 = FactoryBot.create(:post, :tag_string => "aaa art:ccc") + @post_3 = FactoryBot.create(:post, :tag_string => "aaa copy:ddd") @query = RelatedTagQuery.new("aaa", "artist") end diff --git a/test/unit/saved_search_test.rb b/test/unit/saved_search_test.rb index 89acdffac..535b3c49d 100644 --- a/test/unit/saved_search_test.rb +++ b/test/unit/saved_search_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class SavedSearchTest < ActiveSupport::TestCase def setup super - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" mock_saved_search_service! @@ -17,8 +17,8 @@ class SavedSearchTest < ActiveSupport::TestCase context ".labels_for" do setup do - FactoryGirl.create(:saved_search, user: @user, label_string: "blah", query: "blah") - FactoryGirl.create(:saved_search, user: @user, label_string: "zah", query: "blah") + FactoryBot.create(:saved_search, user: @user, label_string: "blah", query: "blah") + FactoryBot.create(:saved_search, user: @user, label_string: "zah", query: "blah") end should "fetch the labels used by a user" do @@ -27,16 +27,16 @@ class SavedSearchTest < ActiveSupport::TestCase should "expire when a search is updated" do Cache.expects(:delete).once - FactoryGirl.create(:saved_search, user: @user, query: "blah") + FactoryBot.create(:saved_search, user: @user, query: "blah") end end context ".queries_for" do setup do - FactoryGirl.create(:tag_alias, antecedent_name: "bbb", consequent_name: "ccc", creator: @user) - FactoryGirl.create(:saved_search, user: @user, label_string: "blah", query: "aaa") - FactoryGirl.create(:saved_search, user: @user, label_string: "zah", query: "CCC BBB AAA") - FactoryGirl.create(:saved_search, user: @user, label_string: "qux", query: " aaa bbb ccc ") + FactoryBot.create(:tag_alias, antecedent_name: "bbb", consequent_name: "ccc", creator: @user) + FactoryBot.create(:saved_search, user: @user, label_string: "blah", query: "aaa") + FactoryBot.create(:saved_search, user: @user, label_string: "zah", query: "CCC BBB AAA") + FactoryBot.create(:saved_search, user: @user, label_string: "qux", query: " aaa bbb ccc ") end should "fetch the queries used by a user for a label" do @@ -87,7 +87,7 @@ class SavedSearchTest < ActiveSupport::TestCase context "Creating a saved search" do setup do - FactoryGirl.create(:tag_alias, antecedent_name: "zzz", consequent_name: "yyy", creator: @user) + FactoryBot.create(:tag_alias, antecedent_name: "zzz", consequent_name: "yyy", creator: @user) @saved_search = @user.saved_searches.create(:query => " ZZZ xxx ") end @@ -111,7 +111,7 @@ class SavedSearchTest < ActiveSupport::TestCase context "Destroying a saved search" do setup do - @saved_search = @user.saved_searches.create(:tag_query => "xxx") + @saved_search = @user.saved_searches.create(query: "xxx") @saved_search.destroy end @@ -123,7 +123,7 @@ class SavedSearchTest < ActiveSupport::TestCase context "A user with max saved searches" do setup do - @user = FactoryGirl.create(:gold_user) + @user = FactoryBot.create(:gold_user) CurrentUser.user = @user User.any_instance.stubs(:max_saved_searches).returns(0) @saved_search = @user.saved_searches.create(:query => "xxx") diff --git a/test/unit/sources/nijie_test.rb b/test/unit/sources/nijie_test.rb index 3d27609dd..a74772e54 100644 --- a/test/unit/sources/nijie_test.rb +++ b/test/unit/sources/nijie_test.rb @@ -4,7 +4,7 @@ module Sources class NijieTest < ActiveSupport::TestCase context "The source site for a nijie page" do setup do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" @site = Sources::Site.new("http://nijie.info/view.php?id=213043") @@ -29,8 +29,8 @@ module Sources end should "normalize ()characters in tags" do - FactoryGirl.create(:tag, :name => "kaga") - FactoryGirl.create(:wiki_page, :title => "kaga", :other_names => "加賀(艦これ)") + FactoryBot.create(:tag, :name => "kaga") + FactoryBot.create(:wiki_page, :title => "kaga", :other_names => "加賀(艦これ)") @site = Sources::Site.new("http://nijie.info/view.php?id=208316") @site.get diff --git a/test/unit/sources/pawoo_test.rb b/test/unit/sources/pawoo_test.rb index 117f0ffe1..f5a1a30a5 100644 --- a/test/unit/sources/pawoo_test.rb +++ b/test/unit/sources/pawoo_test.rb @@ -4,6 +4,7 @@ module Sources class PawooTest < ActiveSupport::TestCase context "The source site for a https://pawoo.net/web/status/$id url" do setup do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @site = Sources::Site.new("https://pawoo.net/web/statuses/1202176") @site.get end @@ -33,6 +34,7 @@ module Sources context "The source site for a https://pawoo.net/$user/$id url" do setup do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @site = Sources::Site.new("https://pawoo.net/@evazion/19451018") @site.get end @@ -84,6 +86,7 @@ module Sources context "The source site for a https://img.pawoo.net/ url" do setup do + skip "Pawoo keys not set" unless Danbooru.config.pawoo_client_id @url = "https://img.pawoo.net/media_attachments/files/001/298/028/original/55a6fd252778454b.mp4" @ref = "https://pawoo.net/@evazion/19451018" @site = Sources::Site.new(@url, referer_url: @ref) diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index 5a0dcc177..6c10e5e2d 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -160,7 +160,7 @@ module Sources context "translating the tags" do setup do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" tags = { @@ -174,8 +174,8 @@ module Sources } tags.each do |tag, other_names| - FactoryGirl.create(:tag, name: tag, post_count: 1) - FactoryGirl.create(:wiki_page, title: tag, other_names: other_names) + FactoryBot.create(:tag, name: tag, post_count: 1) + FactoryBot.create(:wiki_page, title: tag, other_names: other_names) end @site = get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65981746") @@ -219,12 +219,12 @@ module Sources end should "apply aliases to translated tags" do - tohsaka_rin = FactoryGirl.create(:tag, name: "tohsaka_rin") - toosaka_rin = FactoryGirl.create(:tag, name: "toosaka_rin") + tohsaka_rin = FactoryBot.create(:tag, name: "tohsaka_rin") + toosaka_rin = FactoryBot.create(:tag, name: "toosaka_rin") - FactoryGirl.create(:wiki_page, title: "tohsaka_rin", other_names: "遠坂凛") - FactoryGirl.create(:wiki_page, title: "toosaka_rin", other_names: "遠坂凛") - FactoryGirl.create(:tag_alias, antecedent_name: "tohsaka_rin", consequent_name: "toosaka_rin") + FactoryBot.create(:wiki_page, title: "tohsaka_rin", other_names: "遠坂凛") + FactoryBot.create(:wiki_page, title: "toosaka_rin", other_names: "遠坂凛") + FactoryBot.create(:tag_alias, antecedent_name: "tohsaka_rin", consequent_name: "toosaka_rin") assert_equal([toosaka_rin], @site.translate_tag("遠坂凛")) end diff --git a/test/unit/sources/tumblr_test.rb b/test/unit/sources/tumblr_test.rb index 9a2533988..4bf87d9ef 100644 --- a/test/unit/sources/tumblr_test.rb +++ b/test/unit/sources/tumblr_test.rb @@ -2,6 +2,11 @@ require 'test_helper' module Sources class TumblrTest < ActiveSupport::TestCase + def setup + super + skip "Tumblr key is not configured" unless Danbooru.config.tumblr_consumer_key + end + context "The source for a 'http://*.tumblr.com/post/*' photo post with a single image" do setup do @site = Sources::Site.new("https://noizave.tumblr.com/post/162206271767") @@ -67,10 +72,10 @@ module Sources end should "get the artist" do - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:user) CurrentUser.ip_addr = "127.0.0.1" - @artist = FactoryGirl.create(:artist, name: "noizave", url_string: "https://noizave.tumblr.com/") + @artist = FactoryBot.create(:artist, name: "noizave", url_string: "https://noizave.tumblr.com/") assert_equal([@artist], @site.artists) end end diff --git a/test/unit/sources/twitter_test.rb b/test/unit/sources/twitter_test.rb index f42e1a4b6..6ed8a8173 100644 --- a/test/unit/sources/twitter_test.rb +++ b/test/unit/sources/twitter_test.rb @@ -4,6 +4,7 @@ module Sources class TwitterTest < ActiveSupport::TestCase context "A video" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/CincinnatiZoo/status/859073537713328129") @site.get end @@ -15,6 +16,7 @@ module Sources context "An animated gif" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/DaniStrawberry1/status/859435334765088769") @site.get end @@ -26,6 +28,7 @@ module Sources context "A twitter summary card" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/NatGeo/status/932700115936178177") @site.get end @@ -37,6 +40,7 @@ module Sources context "A twitter summary card from twitter" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/masayasuf/status/870734961778630656/photo/1") @site.get end @@ -48,6 +52,7 @@ module Sources context "A twitter summary card from twitter with a :large image" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/aranobu/status/817736083567820800") @site.get end @@ -59,6 +64,7 @@ module Sources context "An extended tweet" do should "extract the correct image url" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/onsen_musume_jp/status/865534101918330881") @site.get @@ -66,6 +72,7 @@ module Sources end should "extract all the image urls" do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/aoimanabu/status/892370963630743552") @site.get @@ -81,6 +88,7 @@ module Sources context "The source site for a restricted twitter" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://mobile.twitter.com/Strangestone/status/556440271961858051") @site.get end @@ -92,6 +100,7 @@ module Sources context "The source site for twitter" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://mobile.twitter.com/nounproject/status/540944400767922176") @site.get end @@ -125,6 +134,7 @@ module Sources context "The source site for a direct image and a referer" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://pbs.twimg.com/media/B4HSEP5CUAA4xyu.png:large", referer_url: "https://twitter.com/nounproject/status/540944400767922176") @site.get end @@ -140,6 +150,7 @@ module Sources context "The source site for a https://twitter.com/i/web/status/:id url" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/i/web/status/943446161586733056") @site.get end @@ -151,6 +162,7 @@ module Sources context "A tweet" do setup do + skip "Twitter key is not set" unless Danbooru.config.twitter_api_key @site = Sources::Site.new("https://twitter.com/noizave/status/875768175136317440") @site.get end diff --git a/test/unit/storage_manager_test.rb b/test/unit/storage_manager_test.rb index 5b4adc911..e38c818a1 100644 --- a/test/unit/storage_manager_test.rb +++ b/test/unit/storage_manager_test.rb @@ -46,7 +46,7 @@ class StorageManagerTest < ActiveSupport::TestCase context "#store_file and #delete_file methods" do setup do - @post = FactoryGirl.create(:post, file_ext: "png") + @post = FactoryBot.create(:post, file_ext: "png") @storage_manager.store_file(StringIO.new("data"), @post, :preview) @storage_manager.store_file(StringIO.new("data"), @post, :large) @@ -76,7 +76,7 @@ class StorageManagerTest < ActiveSupport::TestCase context "#file_url method" do should "return the correct urls" do - @post = FactoryGirl.create(:post, file_ext: "png") + @post = FactoryBot.create(:post, file_ext: "png") @storage_manager.stubs(:tagged_filenames).returns(false) assert_equal("/data/#{@post.md5}.png", @storage_manager.file_url(@post, :original)) @@ -88,8 +88,8 @@ class StorageManagerTest < ActiveSupport::TestCase context "StorageManager::Hybrid" do setup do - @post1 = FactoryGirl.build(:post, id: 1, file_ext: "png") - @post2 = FactoryGirl.build(:post, id: 2, file_ext: "png") + @post1 = FactoryBot.build(:post, id: 1, file_ext: "png") + @post2 = FactoryBot.build(:post, id: 2, file_ext: "png") @storage_manager = StorageManager::Hybrid.new do |id, md5, file_ext, type| if id.odd? diff --git a/test/unit/tag_alias_correction_test.rb b/test/unit/tag_alias_correction_test.rb index eeff64ec8..b467dbe33 100644 --- a/test/unit/tag_alias_correction_test.rb +++ b/test/unit/tag_alias_correction_test.rb @@ -3,11 +3,11 @@ require 'test_helper' class TagAliasCorrectionTest < ActiveSupport::TestCase context "A tag alias correction" do setup do - @mod = FactoryGirl.create(:moderator_user) + @mod = FactoryBot.create(:moderator_user) CurrentUser.user = @mod CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post, :tag_string => "aaa") - @tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + @post = FactoryBot.create(:post, :tag_string => "aaa") + @tag_alias = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") end teardown do diff --git a/test/unit/tag_alias_request_test.rb b/test/unit/tag_alias_request_test.rb index 23ddff93b..aaea0e91b 100644 --- a/test/unit/tag_alias_request_test.rb +++ b/test/unit/tag_alias_request_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagAliasRequestTest < ActiveSupport::TestCase context "A tag alias request" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end diff --git a/test/unit/tag_alias_test.rb b/test/unit/tag_alias_test.rb index 8b8a2e485..64e6b65ae 100644 --- a/test/unit/tag_alias_test.rb +++ b/test/unit/tag_alias_test.rb @@ -4,7 +4,7 @@ class TagAliasTest < ActiveSupport::TestCase context "A tag alias" do setup do Timecop.travel(1.month.ago) do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) CurrentUser.user = user end CurrentUser.ip_addr = "127.0.0.1" @@ -18,9 +18,9 @@ class TagAliasTest < ActiveSupport::TestCase context "on validation" do subject do - FactoryGirl.create(:tag, :name => "aaa") - FactoryGirl.create(:tag, :name => "bbb") - FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + FactoryBot.create(:tag, :name => "aaa") + FactoryBot.create(:tag, :name => "bbb") + FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") end should allow_value('active').for(:status) @@ -42,27 +42,25 @@ class TagAliasTest < ActiveSupport::TestCase should_not allow_value(nil).for(:creator_id) should_not allow_value(-1).for(:creator_id).with_message("must exist", against: :creator) - - should_not allow_mass_assignment_of(:status).as(:member) end should "populate the creator information" do - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal(CurrentUser.user.id, ta.creator_id) end should "convert a tag to its normalized version" do - tag1 = FactoryGirl.create(:tag, :name => "aaa") - tag2 = FactoryGirl.create(:tag, :name => "bbb") - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + tag1 = FactoryBot.create(:tag, :name => "aaa") + tag2 = FactoryBot.create(:tag, :name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") normalized_tags = TagAlias.to_aliased(["aaa", "ccc"]) assert_equal(["bbb", "ccc"], normalized_tags.sort) end should "update the cache" do - tag1 = FactoryGirl.create(:tag, :name => "aaa") - tag2 = FactoryGirl.create(:tag, :name => "bbb") - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + tag1 = FactoryBot.create(:tag, :name => "aaa") + tag2 = FactoryBot.create(:tag, :name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") assert_nil(Cache.get("ta:#{Cache.hash("aaa")}")) TagAlias.to_aliased(["aaa"]) assert_equal("bbb", Cache.get("ta:#{Cache.hash("aaa")}")) @@ -71,21 +69,21 @@ class TagAliasTest < ActiveSupport::TestCase end should "move saved searches" do - tag1 = FactoryGirl.create(:tag, :name => "...") - tag2 = FactoryGirl.create(:tag, :name => "bbb") - ss = FactoryGirl.create(:saved_search, :query => "123 ... 456", :user => CurrentUser.user) - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "...", :consequent_name => "bbb") + tag1 = FactoryBot.create(:tag, :name => "...") + tag2 = FactoryBot.create(:tag, :name => "bbb") + ss = FactoryBot.create(:saved_search, :query => "123 ... 456", :user => CurrentUser.user) + ta = FactoryBot.create(:tag_alias, :antecedent_name => "...", :consequent_name => "bbb") ss.reload assert_equal(%w(123 456 bbb), ss.query.scan(/\S+/).sort) end should "update any affected posts when saved" do assert_equal(0, TagAlias.count) - post1 = FactoryGirl.create(:post, :tag_string => "aaa bbb") - post2 = FactoryGirl.create(:post, :tag_string => "ccc ddd") + post1 = FactoryBot.create(:post, :tag_string => "aaa bbb") + post2 = FactoryBot.create(:post, :tag_string => "ccc ddd") assert_equal("aaa bbb", post1.tag_string) assert_equal("ccc ddd", post2.tag_string) - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "ccc") post1.reload post2.reload assert_equal("bbb ccc", post1.tag_string) @@ -93,9 +91,9 @@ class TagAliasTest < ActiveSupport::TestCase end should "not validate for transitive relations" do - ta1 = FactoryGirl.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") + ta1 = FactoryBot.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") assert_difference("TagAlias.count", 0) do - ta2 = FactoryGirl.build(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta2 = FactoryBot.build(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") ta2.save assert(ta2.errors.any?, "Tag alias should be invalid") assert_equal("A tag alias for bbb already exists", ta2.errors.full_messages.join) @@ -103,50 +101,50 @@ class TagAliasTest < ActiveSupport::TestCase end should "move existing aliases" do - ta1 = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") - ta2 = FactoryGirl.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") + ta1 = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + ta2 = FactoryBot.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") ta1.reload assert_equal("ccc", ta1.consequent_name) end should "move existing implications" do - ti = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") + ti = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") ti.reload assert_equal("ccc", ti.consequent_name) end should "not push the antecedent's category to the consequent if the antecedent is general" do - tag1 = FactoryGirl.create(:tag, :name => "aaa") - tag2 = FactoryGirl.create(:tag, :name => "bbb", :category => 1) - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + tag1 = FactoryBot.create(:tag, :name => "aaa") + tag2 = FactoryBot.create(:tag, :name => "bbb", :category => 1) + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") tag2.reload assert_equal(1, tag2.category) end should "push the antecedent's category to the consequent" do - tag1 = FactoryGirl.create(:tag, :name => "aaa", :category => 1) - tag2 = FactoryGirl.create(:tag, :name => "bbb") - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") + tag1 = FactoryBot.create(:tag, :name => "aaa", :category => 1) + tag2 = FactoryBot.create(:tag, :name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb") tag2.reload assert_equal(1, tag2.category) end context "with an associated forum topic" do setup do - @admin = FactoryGirl.create(:admin_user) + @admin = FactoryBot.create(:admin_user) CurrentUser.scoped(@admin) do - @topic = FactoryGirl.create(:forum_topic, :title => TagAliasRequest.topic_title("aaa", "bbb")) - @post = FactoryGirl.create(:forum_post, :topic_id => @topic.id, :body => TagAliasRequest.command_string("aaa", "bbb")) - @alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :status => "pending") + @topic = FactoryBot.create(:forum_topic, :title => TagAliasRequest.topic_title("aaa", "bbb")) + @post = FactoryBot.create(:forum_post, :topic_id => @topic.id, :body => TagAliasRequest.command_string("aaa", "bbb")) + @alias = FactoryBot.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :status => "pending") end end context "and conflicting wiki pages" do setup do CurrentUser.scoped(@admin) do - @wiki1 = FactoryGirl.create(:wiki_page, :title => "aaa") - @wiki2 = FactoryGirl.create(:wiki_page, :title => "bbb") + @wiki1 = FactoryBot.create(:wiki_page, :title => "aaa") + @wiki2 = FactoryBot.create(:wiki_page, :title => "bbb") @alias.approve!(approver: @admin) end @admin.reload # reload to get the forum post the approval created. diff --git a/test/unit/tag_implication_request_test.rb b/test/unit/tag_implication_request_test.rb index 2d09a182d..a06a0880a 100644 --- a/test/unit/tag_implication_request_test.rb +++ b/test/unit/tag_implication_request_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TagImplicationRequestTest < ActiveSupport::TestCase context "A tag implication request" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end diff --git a/test/unit/tag_implication_test.rb b/test/unit/tag_implication_test.rb index cbcfba0fc..5060bfccf 100644 --- a/test/unit/tag_implication_test.rb +++ b/test/unit/tag_implication_test.rb @@ -3,10 +3,10 @@ require 'test_helper' class TagImplicationTest < ActiveSupport::TestCase context "A tag implication" do setup do - user = FactoryGirl.create(:admin_user) + user = FactoryBot.create(:admin_user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end teardown do @@ -16,9 +16,9 @@ class TagImplicationTest < ActiveSupport::TestCase context "on validation" do subject do - FactoryGirl.create(:tag, :name => "aaa") - FactoryGirl.create(:tag, :name => "bbb") - FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + FactoryBot.create(:tag, :name => "aaa") + FactoryBot.create(:tag, :name => "bbb") + FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") end should allow_value('active').for(:status) @@ -40,62 +40,58 @@ class TagImplicationTest < ActiveSupport::TestCase should_not allow_value(nil).for(:creator_id) should_not allow_value(-1).for(:creator_id).with_message("must exist", against: :creator) - - should_not allow_mass_assignment_of(:status).as(:member) - should_not allow_mass_assignment_of(:forum_topic).as(:member) - should_not allow_mass_assignment_of(:descendant_names).as(:member) end should "ignore pending implications when building descendant names" do - ti2 = FactoryGirl.build(:tag_implication, :antecedent_name => "b", :consequent_name => "c", :status => "pending") + ti2 = FactoryBot.build(:tag_implication, :antecedent_name => "b", :consequent_name => "c", :status => "pending") ti2.save - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") assert_equal("b", ti1.descendant_names) end should "populate the creator information" do - ti = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal(CurrentUser.user.id, ti.creator_id) end should "not validate when a circular relation is created" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = FactoryGirl.build(:tag_implication, :antecedent_name => "bbb", :consequent_name => "aaa") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryBot.build(:tag_implication, :antecedent_name => "bbb", :consequent_name => "aaa") ti2.save assert(ti2.errors.any?, "Tag implication should not have validated.") assert_equal("Tag implication can not create a circular relation with another tag implication", ti2.errors.full_messages.join("")) end should "not validate when a transitive relation is created" do - ti_ab = FactoryGirl.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") - ti_bc = FactoryGirl.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") - ti_ac = FactoryGirl.build(:tag_implication, :antecedent_name => "a", :consequent_name => "c") + ti_ab = FactoryBot.create(:tag_implication, :antecedent_name => "a", :consequent_name => "b") + ti_bc = FactoryBot.create(:tag_implication, :antecedent_name => "b", :consequent_name => "c") + ti_ac = FactoryBot.build(:tag_implication, :antecedent_name => "a", :consequent_name => "c") ti_ac.save assert_equal("a already implies c through another implication", ti_ac.errors.full_messages.join("")) end should "not allow for duplicates" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = FactoryGirl.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryBot.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti2.save assert(ti2.errors.any?, "Tag implication should not have validated.") assert_includes(ti2.errors.full_messages, "Antecedent name has already been taken") end should "not validate if its consequent is aliased to another tag" do - ta = FactoryGirl.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") - ti = FactoryGirl.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ta = FactoryBot.create(:tag_alias, :antecedent_name => "bbb", :consequent_name => "ccc") + ti = FactoryBot.build(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti.save assert(ti.errors.any?, "Tag implication should not have validated.") assert_equal("Consequent tag must not be aliased to another tag", ti.errors.full_messages.join("")) end should "calculate all its descendants" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") assert_equal("ccc", ti1.descendant_names) assert_equal(["ccc"], ti1.descendant_names_array) - ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") assert_equal("bbb ccc", ti2.descendant_names) assert_equal(["bbb", "ccc"], ti2.descendant_names_array) ti1.reload @@ -104,8 +100,8 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update its descendants on save" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") ti1.reload ti2.reload ti2.update_attributes( @@ -118,10 +114,10 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update the descendants for all of its parents on destroy" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") - ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "xxx", :consequent_name => "bbb") - ti3 = FactoryGirl.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") - ti4 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "xxx", :consequent_name => "bbb") + ti3 = FactoryBot.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") + ti4 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") ti1.reload ti2.reload ti3.reload @@ -140,12 +136,12 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update the descendants for all of its parents on create" do - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb") ti1.reload assert_equal("active", ti1.status) assert_equal("bbb", ti1.descendant_names) - ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") + ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "bbb", :consequent_name => "ccc") ti1.reload ti2.reload assert_equal("active", ti1.status) @@ -153,14 +149,14 @@ class TagImplicationTest < ActiveSupport::TestCase assert_equal("bbb ccc", ti1.descendant_names) assert_equal("ccc", ti2.descendant_names) - ti3 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") + ti3 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd") ti1.reload ti2.reload ti3.reload assert_equal("bbb ccc ddd", ti1.descendant_names) assert_equal("ccc ddd", ti2.descendant_names) - ti4 = FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "eee") + ti4 = FactoryBot.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "eee") ti1.reload ti2.reload ti3.reload @@ -170,7 +166,7 @@ class TagImplicationTest < ActiveSupport::TestCase assert_equal("ddd", ti3.descendant_names) assert_equal("eee", ti4.descendant_names) - ti5 = FactoryGirl.create(:tag_implication, :antecedent_name => "xxx", :consequent_name => "bbb") + ti5 = FactoryBot.create(:tag_implication, :antecedent_name => "xxx", :consequent_name => "bbb") ti1.reload ti2.reload ti3.reload @@ -184,19 +180,19 @@ class TagImplicationTest < ActiveSupport::TestCase end should "update any affected post upon save" do - p1 = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc") - ti1 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") - ti2 = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy") + p1 = FactoryBot.create(:post, :tag_string => "aaa bbb ccc") + ti1 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "xxx") + ti2 = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "yyy") p1.reload assert_equal("aaa bbb ccc xxx yyy", p1.tag_string) end context "with an associated forum topic" do setup do - @admin = FactoryGirl.create(:admin_user) - @topic = FactoryGirl.create(:forum_topic, :title => TagImplicationRequest.topic_title("aaa", "bbb")) - @post = FactoryGirl.create(:forum_post, topic_id: @topic.id, :body => TagImplicationRequest.command_string("aaa", "bbb")) - @implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :status => "pending") + @admin = FactoryBot.create(:admin_user) + @topic = FactoryBot.create(:forum_topic, :title => TagImplicationRequest.topic_title("aaa", "bbb")) + @post = FactoryBot.create(:forum_post, topic_id: @topic.id, :body => TagImplicationRequest.command_string("aaa", "bbb")) + @implication = FactoryBot.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :forum_topic => @topic, :status => "pending") end should "update the topic when processed" do diff --git a/test/unit/tag_test.rb b/test/unit/tag_test.rb index 0a1b32807..6565957e0 100644 --- a/test/unit/tag_test.rb +++ b/test/unit/tag_test.rb @@ -2,7 +2,7 @@ require 'test_helper' class TagTest < ActiveSupport::TestCase setup do - @builder = FactoryGirl.create(:builder_user) + @builder = FactoryBot.create(:builder_user) CurrentUser.user = @builder CurrentUser.ip_addr = "127.0.0.1" end @@ -17,12 +17,12 @@ class TagTest < ActiveSupport::TestCase Tag.stubs(:trending_count_limit).returns(0) Timecop.travel(1.week.ago) do - FactoryGirl.create(:post, :tag_string => "aaa") - FactoryGirl.create(:post, :tag_string => "bbb") + FactoryBot.create(:post, :tag_string => "aaa") + FactoryBot.create(:post, :tag_string => "bbb") end - FactoryGirl.create(:post, :tag_string => "bbb") - FactoryGirl.create(:post, :tag_string => "ccc") + FactoryBot.create(:post, :tag_string => "bbb") + FactoryBot.create(:post, :tag_string => "ccc") end should "order the results by the total post count" do @@ -32,18 +32,18 @@ class TagTest < ActiveSupport::TestCase context "A tag category fetcher" do should "fetch for a single tag" do - FactoryGirl.create(:artist_tag, :name => "test") + FactoryBot.create(:artist_tag, :name => "test") assert_equal(Tag.categories.artist, Tag.category_for("test")) end should "fetch for a single tag with strange markup" do - FactoryGirl.create(:artist_tag, :name => "!@$%") + FactoryBot.create(:artist_tag, :name => "!@$%") assert_equal(Tag.categories.artist, Tag.category_for("!@$%")) end should "fetch for multiple tags" do - FactoryGirl.create(:artist_tag, :name => "aaa") - FactoryGirl.create(:copyright_tag, :name => "bbb") + FactoryBot.create(:artist_tag, :name => "aaa") + FactoryBot.create(:copyright_tag, :name => "bbb") categories = Tag.categories_for(%w(aaa bbb ccc)) assert_equal(Tag.categories.artist, categories["aaa"]) assert_equal(Tag.categories.copyright, categories["bbb"]) @@ -91,27 +91,13 @@ class TagTest < ActiveSupport::TestCase end context "A tag" do - should "be lockable by a moderator" do - @tag = FactoryGirl.create(:tag) - @tag.update_attributes({:is_locked => true}, :as => :moderator) - @tag.reload - assert_equal(true, @tag.is_locked?) - end - - should "not be lockable by a user" do - @tag = FactoryGirl.create(:tag) - @tag.update_attributes({:is_locked => true}, :as => :member) - @tag.reload - assert_equal(false, @tag.is_locked?) - end - should "know its category name" do - @tag = FactoryGirl.create(:artist_tag) + @tag = FactoryBot.create(:artist_tag) assert_equal("Artist", @tag.category_name) end should "reset its category after updating" do - tag = FactoryGirl.create(:artist_tag) + tag = FactoryBot.create(:artist_tag) assert_equal(Tag.categories.artist, Cache.get("tc:#{Cache.hash(tag.name)}")) tag.update_attribute(:category, Tag.categories.copyright) @@ -143,8 +129,8 @@ class TagTest < ActiveSupport::TestCase end should "parse a query" do - tag1 = FactoryGirl.create(:tag, :name => "abc") - tag2 = FactoryGirl.create(:tag, :name => "acb") + tag1 = FactoryBot.create(:tag, :name => "abc") + tag2 = FactoryBot.create(:tag, :name => "acb") assert_equal(["abc"], Tag.parse_query("md5:abc")[:md5]) assert_equal([:between, 1, 2], Tag.parse_query("id:1..2")[:post_id]) @@ -182,14 +168,14 @@ class TagTest < ActiveSupport::TestCase context "A tag" do should "be found when one exists" do - tag = FactoryGirl.create(:tag) + tag = FactoryBot.create(:tag) assert_difference("Tag.count", 0) do Tag.find_or_create_by_name(tag.name) end end should "change the type for an existing tag" do - tag = FactoryGirl.create(:tag) + tag = FactoryBot.create(:tag) assert_difference("Tag.count", 0) do assert_equal(Tag.categories.general, tag.category) Tag.find_or_create_by_name("artist:#{tag.name}") @@ -199,7 +185,7 @@ class TagTest < ActiveSupport::TestCase end should "not change the category is the tag is locked" do - tag = FactoryGirl.create(:tag, :is_locked => true) + tag = FactoryBot.create(:tag, :is_locked => true) assert_equal(true, tag.is_locked?) Tag.find_or_create_by_name("artist:#{tag.name}") tag.reload @@ -207,15 +193,15 @@ class TagTest < ActiveSupport::TestCase end should "not change category when the tag is too large to be changed by a builder" do - tag = FactoryGirl.create(:tag, post_count: 1001) + tag = FactoryBot.create(:tag, post_count: 1001) Tag.find_or_create_by_name("artist:#{tag.name}", creator: @builder) assert_equal(0, tag.reload.category) end should "not change category when the tag is too large to be changed by a member" do - tag = FactoryGirl.create(:tag, post_count: 51) - Tag.find_or_create_by_name("artist:#{tag.name}", creator: FactoryGirl.create(:member_user)) + tag = FactoryBot.create(:tag, post_count: 51) + Tag.find_or_create_by_name("artist:#{tag.name}", creator: FactoryBot.create(:member_user)) assert_equal(0, tag.reload.category) end @@ -265,8 +251,8 @@ class TagTest < ActiveSupport::TestCase context "A tag with a negative post count" do should "be fixed" do - tag = FactoryGirl.create(:tag, name: "touhou", post_count: -10) - post = FactoryGirl.create(:post, tag_string: "touhou") + tag = FactoryBot.create(:tag, name: "touhou", post_count: -10) + post = FactoryBot.create(:post, tag_string: "touhou") Tag.clean_up_negative_post_counts! assert_equal(1, tag.reload.post_count) diff --git a/test/unit/token_bucket_test.rb b/test/unit/token_bucket_test.rb index 01add8ccf..358787329 100644 --- a/test/unit/token_bucket_test.rb +++ b/test/unit/token_bucket_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class TokenBucketTest < ActiveSupport::TestCase context "#add!" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) TokenBucket.create(user_id: @user.id, last_touched_at: 1.minute.ago, token_count: 0) end @@ -17,7 +17,7 @@ class TokenBucketTest < ActiveSupport::TestCase context "#consume!" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) TokenBucket.create(user_id: @user.id, last_touched_at: 1.minute.ago, token_count: 1) end @@ -31,7 +31,7 @@ class TokenBucketTest < ActiveSupport::TestCase context "#throttled?" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) TokenBucket.create(user_id: @user.id, last_touched_at: 1.minute.ago, token_count: 0) end diff --git a/test/unit/upload_test.rb b/test/unit/upload_test.rb index bd45bb403..c3d4d12c1 100644 --- a/test/unit/upload_test.rb +++ b/test/unit/upload_test.rb @@ -1,15 +1,10 @@ require 'test_helper' class UploadTest < ActiveSupport::TestCase - def setup - super - - mock_iqdb_service! - end - context "In all cases" do setup do - user = FactoryGirl.create(:contributor_user) + mock_iqdb_service! + user = FactoryBot.create(:contributor_user) CurrentUser.user = user CurrentUser.ip_addr = "127.0.0.1" end @@ -22,12 +17,12 @@ class UploadTest < ActiveSupport::TestCase context "An upload" do context "from a user that is limited" do setup do - CurrentUser.user = FactoryGirl.create(:user, :created_at => 1.year.ago) + CurrentUser.user = FactoryBot.create(:user, :created_at => 1.year.ago) User.any_instance.stubs(:upload_limit).returns(0) end should "fail creation" do - @upload = FactoryGirl.build(:jpg_upload, :tag_string => "") + @upload = FactoryBot.build(:jpg_upload, :tag_string => "") @upload.save assert_equal(["You have reached your upload limit for the day"], @upload.errors.full_messages) end @@ -35,51 +30,64 @@ class UploadTest < ActiveSupport::TestCase context "image size calculator" do should "discover the dimensions for a compressed SWF" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/compressed.swf")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/compressed.swf")) assert_equal([607, 756], @upload.calculate_dimensions) end should "discover the dimensions for a JPG with JFIF data" do - @upload = FactoryGirl.create(:jpg_upload) + @upload = FactoryBot.create(:jpg_upload) assert_equal([500, 335], @upload.calculate_dimensions) end should "discover the dimensions for a JPG with EXIF data" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test-exif-small.jpg")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test-exif-small.jpg")) assert_equal([529, 600], @upload.calculate_dimensions) end should "discover the dimensions for a JPG with no header data" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test-blank.jpg")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test-blank.jpg")) assert_equal([668, 996], @upload.calculate_dimensions) end should "discover the dimensions for a PNG" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test.png")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test.png")) assert_equal([768, 1024], @upload.calculate_dimensions) end should "discover the dimensions for a GIF" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test.gif")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test.gif")) assert_equal([400, 400], @upload.calculate_dimensions) + @upload = FactoryBot.create(:upload, :file_path => "#{Rails.root}/test/files/compressed.swf") + @upload.calculate_dimensions + assert_equal(607, @upload.image_width) + assert_equal(756, @upload.image_height) end end context "content type calculator" do should "know how to parse jpeg, png, gif, and swf file headers" do - @upload = FactoryGirl.build(:jpg_upload) - assert_equal("jpg", @upload.file_header_to_file_ext(File.open("#{Rails.root}/test/files/test.jpg"))) - assert_equal("gif", @upload.file_header_to_file_ext(File.open("#{Rails.root}/test/files/test.gif"))) - assert_equal("png", @upload.file_header_to_file_ext(File.open("#{Rails.root}/test/files/test.png"))) - assert_equal("swf", @upload.file_header_to_file_ext(File.open("#{Rails.root}/test/files/compressed.swf"))) - assert_equal("bin", @upload.file_header_to_file_ext(File.open("#{Rails.root}/README.md"))) + @upload = FactoryBot.create(:jpg_upload) + assert_equal("image/jpeg", @upload.file_header_to_content_type("#{Rails.root}/test/files/test.jpg")) + assert_equal("image/gif", @upload.file_header_to_content_type("#{Rails.root}/test/files/test.gif")) + assert_equal("image/png", @upload.file_header_to_content_type("#{Rails.root}/test/files/test.png")) + assert_equal("application/x-shockwave-flash", @upload.file_header_to_content_type("#{Rails.root}/test/files/compressed.swf")) + assert_equal("application/octet-stream", @upload.file_header_to_content_type("#{Rails.root}/README.md")) + end + + should "know how to parse jpeg, png, gif, and swf content types" do + @upload = FactoryBot.create(:jpg_upload) + assert_equal("jpg", @upload.content_type_to_file_ext("image/jpeg")) + assert_equal("gif", @upload.content_type_to_file_ext("image/gif")) + assert_equal("png", @upload.content_type_to_file_ext("image/png")) + assert_equal("swf", @upload.content_type_to_file_ext("application/x-shockwave-flash")) + assert_equal("bin", @upload.content_type_to_file_ext("")) end end context "downloader" do context "for a zip that is not an ugoira" do should "not validate" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/invalid_ugoira.zip")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/invalid_ugoira.zip")) @upload.process! assert_equal("error: RuntimeError - missing frame data for ugoira", @upload.status) end @@ -88,7 +96,8 @@ class UploadTest < ActiveSupport::TestCase context "that is a pixiv ugoira" do setup do @url = "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654" - @upload = FactoryGirl.create(:upload, :source => @url, :tag_string => "ugoira") + @upload = FactoryBot.create(:source_upload, :source => @url, :tag_string => "ugoira") + @output_file = Tempfile.new("download") end should "process successfully" do @@ -97,34 +106,43 @@ class UploadTest < ActiveSupport::TestCase assert_equal("zip", @upload.file_header_to_file_ext(output_file)) end end + + should "initialize the final path after downloading a file" do + @upload = FactoryBot.create(:source_upload) + path = "#{Rails.root}/tmp/test.download.jpg" + assert_nothing_raised {@upload.download_from_source(path)} + assert(File.exists?(path)) + assert_equal(8558, File.size(path)) + assert_equal(path, @upload.file_path) + end end context "determining if a file is downloadable" do should "classify HTTP sources as downloadable" do - @upload = FactoryGirl.create(:source_upload, :source => "http://www.example.com/1.jpg") + @upload = FactoryBot.create(:source_upload, :source => "http://www.example.com/1.jpg") assert_not_nil(@upload.is_downloadable?) end should "classify HTTPS sources as downloadable" do - @upload = FactoryGirl.create(:source_upload, :source => "https://www.example.com/1.jpg") + @upload = FactoryBot.create(:source_upload, :source => "https://www.example.com/1.jpg") assert_not_nil(@upload.is_downloadable?) end should "classify non-HTTP/HTTPS sources as not downloadable" do - @upload = FactoryGirl.create(:source_upload, :source => "ftp://www.example.com/1.jpg") + @upload = FactoryBot.create(:source_upload, :source => "ftp://www.example.com/1.jpg") assert_nil(@upload.is_downloadable?) end end context "file processor" do should "parse and process a cgi file representation" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test.jpg")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test.jpg")) assert_nothing_raised {@upload.process_upload} assert_equal(28086, @upload.file_size) end should "process a transparent png" do - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/alpha.png")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/alpha.png")) assert_nothing_raised {@upload.process_upload} assert_equal(1136, @upload.file_size) end @@ -132,23 +150,27 @@ class UploadTest < ActiveSupport::TestCase context "hash calculator" do should "caculate the hash" do - @upload = FactoryGirl.create(:jpg_upload) - @upload.process_upload + @upload = FactoryBot.create(:jpg_upload) + @upload.calculate_hash(@upload.file_path) assert_equal("ecef68c44edb8a0d6a3070b5f8e8ee76", @upload.md5) end end context "resizer" do should "generate several resized versions of the image" do - @upload = FactoryGirl.create(:upload, file_ext: "jpg", image_width: 1356, image_height: 911, file: upload_file("test/files/test-large.jpg")) - preview_file, sample_file = @upload.generate_resizes - assert_operator(preview_file.size, :>, 1_000) - assert_operator(sample_file.size, :>, 1_000) + @upload = FactoryBot.create(:large_jpg_upload) + @upload.calculate_hash(@upload.file_path) + @upload.calculate_dimensions(@upload.file_path) + assert_nothing_raised {@upload.generate_resizes(@upload.file_path)} + assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.small_image_width))) + assert(File.size(@upload.resized_file_path_for(Danbooru.config.small_image_width)) > 0) + assert(File.exists?(@upload.resized_file_path_for(Danbooru.config.large_image_width))) + assert(File.size(@upload.resized_file_path_for(Danbooru.config.large_image_width)) > 0) end end should "increment the uploaders post_upload_count" do - @upload = FactoryGirl.create(:source_upload) + @upload = FactoryBot.create(:source_upload) assert_difference("CurrentUser.user.post_upload_count", 1) do @upload.process! CurrentUser.user.reload @@ -157,11 +179,14 @@ class UploadTest < ActiveSupport::TestCase context "with an artist commentary" do setup do - @upload = FactoryGirl.create(:source_upload, - include_artist_commentary: "1", - artist_commentary_title: "", - artist_commentary_desc: "blah", - ) + @upload = FactoryBot.create(:source_upload, + :rating => "s", + :uploader_ip_addr => "127.0.0.1", + :tag_string => "hoge foo" + ) + @upload.include_artist_commentary = "1" + @upload.artist_commentary_title = "" + @upload.artist_commentary_desc = "blah" end should "create an artist commentary when processed" do @@ -172,7 +197,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a downloaded image" do - @upload = FactoryGirl.create(:source_upload, + @upload = FactoryBot.create(:source_upload, :rating => "s", :uploader_ip_addr => "127.0.0.1", :tag_string => "hoge foo" @@ -198,17 +223,17 @@ class UploadTest < ActiveSupport::TestCase context "automatic tagging" do should "tag animated png files" do - @upload = FactoryGirl.build(:upload, file_ext: "png", file: upload_file("test/files/apng/normal_apng.png")) + @upload = FactoryBot.build(:upload, file_ext: "png", file: upload_file("test/files/apng/normal_apng.png")) assert_equal("animated_png", @upload.automatic_tags) end should "tag animated gif files" do - @upload = FactoryGirl.build(:upload, file_ext: "gif", file: upload_file("test/files/test-animated-86x52.gif")) + @upload = FactoryBot.build(:upload, file_ext: "gif", file: upload_file("test/files/test-animated-86x52.gif")) assert_equal("animated_gif", @upload.automatic_tags) end should "not tag static gif files" do - @upload = FactoryGirl.build(:upload, file_ext: "gif", file: upload_file("test/files/test-static-32x32.gif")) + @upload = FactoryBot.build(:upload, file_ext: "gif", file: upload_file("test/files/test-static-32x32.gif")) assert_equal("", @upload.automatic_tags) end end @@ -216,7 +241,7 @@ class UploadTest < ActiveSupport::TestCase context "that is too large" do should "should fail validation" do Danbooru.config.stubs(:max_image_resolution).returns(31*31) - @upload = FactoryGirl.create(:upload, file: upload_file("test/files/test-static-32x32.gif")) + @upload = FactoryBot.create(:upload, file: upload_file("test/files/test-static-32x32.gif")) @upload.process! assert_match(/image resolution is too large/, @upload.status) end @@ -224,7 +249,14 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a pixiv ugoira" do - @upload = FactoryGirl.create(:source_upload, source: "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654") + skip "ffmpeg is not installed" unless check_ffmpeg + + @upload = FactoryBot.create(:source_upload, + :source => "http://www.pixiv.net/member_illust.php?mode=medium&illust_id=46378654", + :rating => "s", + :uploader_ip_addr => "127.0.0.1", + :tag_string => "hoge foo" + ) assert_difference(["PixivUgoiraFrameData.count", "Post.count"]) do @upload.process! assert_equal([], @upload.errors.full_messages) @@ -241,7 +273,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for an uploaded image" do - @upload = FactoryGirl.create(:jpg_upload, + @upload = FactoryBot.create(:jpg_upload, :rating => "s", :uploader_ip_addr => "127.0.0.1", :tag_string => "hoge foo", @@ -265,7 +297,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a .webm" do - upload = FactoryGirl.create(:upload, rating: "s", file: upload_file("test/files/test-512x512.webm")) + upload = FactoryBot.create(:upload, rating: "s", file: upload_file("test/files/test-512x512.webm")) assert_difference("Post.count") do assert_nothing_raised { upload.process! } @@ -284,7 +316,7 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a .mp4" do - upload = FactoryGirl.create(:upload, rating: "s", file: upload_file("test/files/test-300x300.mp4")) + upload = FactoryBot.create(:upload, rating: "s", file: upload_file("test/files/test-300x300.mp4")) assert_difference("Post.count") do assert_nothing_raised { upload.process! } @@ -303,11 +335,22 @@ class UploadTest < ActiveSupport::TestCase end should "process completely for a null source" do - @upload = FactoryGirl.create(:jpg_upload, :source => nil) + @upload = FactoryBot.create(:jpg_upload, :source => nil) assert_difference("Post.count") do assert_nothing_raised {@upload.process!} end end + + should "delete the temporary file upon completion" do + @upload = FactoryBot.create(:source_upload, + :rating => "s", + :uploader_ip_addr => "127.0.0.1", + :tag_string => "hoge foo" + ) + + @upload.process! + assert(!File.exists?(@upload.temp_file_path)) + end end end diff --git a/test/unit/user_deletion_test.rb b/test/unit/user_deletion_test.rb index 75cb1457b..7c09e2b8d 100644 --- a/test/unit/user_deletion_test.rb +++ b/test/unit/user_deletion_test.rb @@ -4,7 +4,7 @@ class UserDeletionTest < ActiveSupport::TestCase context "an invalid user deletion" do context "for an invalid password" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @deletion = UserDeletion.new(@user, "wrongpassword") @@ -19,7 +19,7 @@ class UserDeletionTest < ActiveSupport::TestCase context "for an admin" do setup do - @user = FactoryGirl.create(:admin_user) + @user = FactoryBot.create(:admin_user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" @deletion = UserDeletion.new(@user, "password") @@ -35,11 +35,11 @@ class UserDeletionTest < ActiveSupport::TestCase context "a valid user deletion" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" - @post = FactoryGirl.create(:post) + @post = FactoryBot.create(:post) Favorite.add(post: @post, user: @user) @user.update_attributes(:email => "ted@danbooru.com") diff --git a/test/unit/user_feedback_test.rb b/test/unit/user_feedback_test.rb index 583b721e9..5476c26ba 100644 --- a/test/unit/user_feedback_test.rb +++ b/test/unit/user_feedback_test.rb @@ -12,9 +12,9 @@ class UserFeedbackTest < ActiveSupport::TestCase end should "create a dmail" do - user = FactoryGirl.create(:user) - gold = FactoryGirl.create(:gold_user) - member = FactoryGirl.create(:user) + user = FactoryBot.create(:user) + gold = FactoryBot.create(:gold_user) + member = FactoryBot.create(:user) dmail = <<~EOS.chomp @#{gold.name} created a "positive record":/user_feedbacks?search[user_id]=#{user.id} for your account: @@ -24,30 +24,30 @@ class UserFeedbackTest < ActiveSupport::TestCase CurrentUser.user = gold assert_difference("Dmail.count", 1) do - FactoryGirl.create(:user_feedback, :user => user, :body => "good job!") + FactoryBot.create(:user_feedback, :user => user, :body => "good job!") assert_equal(dmail, user.dmails.last.body) end end should "not validate if the creator is the user" do - gold_user = FactoryGirl.create(:gold_user) + gold_user = FactoryBot.create(:gold_user) CurrentUser.user = gold_user - feedback = FactoryGirl.build(:user_feedback, :user => gold_user) + feedback = FactoryBot.build(:user_feedback, :user => gold_user) feedback.save assert_equal(["You cannot submit feedback for yourself"], feedback.errors.full_messages) end should "not validate if the creator is not gold" do - user = FactoryGirl.create(:user) - gold = FactoryGirl.create(:gold_user) - member = FactoryGirl.create(:user) + user = FactoryBot.create(:user) + gold = FactoryBot.create(:gold_user) + member = FactoryBot.create(:user) CurrentUser.user = gold - feedback = FactoryGirl.create(:user_feedback, :user => user) + feedback = FactoryBot.create(:user_feedback, :user => user) assert(feedback.errors.empty?) CurrentUser.user = member - feedback = FactoryGirl.build(:user_feedback, :user => user) + feedback = FactoryBot.build(:user_feedback, :user => user) feedback.save assert_equal(["You must be gold"], feedback.errors.full_messages) end diff --git a/test/unit/user_name_change_request_test.rb b/test/unit/user_name_change_request_test.rb index 1d4fb3a02..9b34b8295 100644 --- a/test/unit/user_name_change_request_test.rb +++ b/test/unit/user_name_change_request_test.rb @@ -3,8 +3,8 @@ require 'test_helper' class UserNameChangeRequestTest < ActiveSupport::TestCase context "in all cases" do setup do - @admin = FactoryGirl.create(:admin_user) - @requester = FactoryGirl.create(:user) + @admin = FactoryBot.create(:admin_user) + @requester = FactoryBot.create(:user) CurrentUser.user = @requester CurrentUser.ip_addr = "127.0.0.1" end @@ -93,7 +93,7 @@ class UserNameChangeRequestTest < ActiveSupport::TestCase end should "not convert the desired name to lower case" do - uncr = FactoryGirl.create(:user_name_change_request, user: @requester, original_name: "provence.", desired_name: "Provence") + uncr = FactoryBot.create(:user_name_change_request, user: @requester, original_name: "provence.", desired_name: "Provence") CurrentUser.scoped(@admin) { uncr.approve! } assert_equal("Provence", @requester.name) diff --git a/test/unit/user_password_reset_nonce_test.rb b/test/unit/user_password_reset_nonce_test.rb index 2c49751e6..1aae392c9 100644 --- a/test/unit/user_password_reset_nonce_test.rb +++ b/test/unit/user_password_reset_nonce_test.rb @@ -4,8 +4,8 @@ class UserPasswordResetNonceTest < ActiveSupport::TestCase context "Creating a new nonce" do context "with a valid email" do setup do - @user = FactoryGirl.create(:user, :email => "aaa@b.net") - @nonce = FactoryGirl.create(:user_password_reset_nonce, :email => @user.email) + @user = FactoryBot.create(:user, :email => "aaa@b.net") + @nonce = FactoryBot.create(:user_password_reset_nonce, :email => @user.email) end should "validate" do @@ -24,7 +24,7 @@ class UserPasswordResetNonceTest < ActiveSupport::TestCase context "with a blank email" do setup do - @user = FactoryGirl.create(:user, :email => "") + @user = FactoryBot.create(:user, :email => "") @nonce = UserPasswordResetNonce.new(:email => "") end diff --git a/test/unit/user_revert_test.rb b/test/unit/user_revert_test.rb index f50d51bba..70a1aeec9 100644 --- a/test/unit/user_revert_test.rb +++ b/test/unit/user_revert_test.rb @@ -3,23 +3,18 @@ require 'test_helper' class UserRevertTest < ActiveSupport::TestCase context "Reverting a user's changes" do setup do - @creator = FactoryGirl.create(:user) - @user = FactoryGirl.create(:user) - CurrentUser.user = @user - CurrentUser.ip_addr = "127.0.0.1" + @creator = create(:user) + @user = create(:user) CurrentUser.scoped(@creator) do - @parent = FactoryGirl.create(:post) - @post = FactoryGirl.create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") + @parent = create(:post) + @post = create(:post, :tag_string => "aaa bbb ccc", :rating => "q", :source => "xyz") end @post.stubs(:merge_version?).returns(false) - @post.update_attributes(:tag_string => "bbb ccc xxx", :source => "", :rating => "e") - end - - teardown do - CurrentUser.user = nil - CurrentUser.ip_addr = nil + CurrentUser.scoped(@user) do + @post.update(:tag_string => "bbb ccc xxx", :source => "", :rating => "e") + end end subject { UserRevert.new(@user.id) } @@ -32,7 +27,9 @@ class UserRevertTest < ActiveSupport::TestCase context "when processed" do setup do - subject.process + CurrentUser.as(@user) do + subject.process + end @post.reload end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 985c6f341..951a91291 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase context "A user" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user CurrentUser.ip_addr = "127.0.0.1" end @@ -15,7 +15,7 @@ class UserTest < ActiveSupport::TestCase context "promoting a user" do setup do - CurrentUser.user = FactoryGirl.create(:moderator_user) + CurrentUser.user = FactoryBot.create(:moderator_user) end should "create a neutral feedback" do @@ -27,7 +27,7 @@ class UserTest < ActiveSupport::TestCase end should "send an automated dmail to the user" do - bot = FactoryGirl.create(:user) + bot = FactoryBot.create(:user) User.stubs(:system).returns(bot) assert_difference("Dmail.count", 1) do @@ -40,7 +40,7 @@ class UserTest < ActiveSupport::TestCase context "that has been invited by a mod" do setup do - @mod = FactoryGirl.create(:moderator_user) + @mod = FactoryBot.create(:moderator_user) end should "work" do @@ -60,10 +60,9 @@ class UserTest < ActiveSupport::TestCase end should "not validate if the originating ip address is banned" do - FactoryGirl.create(:ip_ban) - user = FactoryGirl.build(:user) + FactoryBot.create(:ip_ban, ip_addr: '127.0.0.1') + user = FactoryBot.build(:user) user.save - assert(user.errors.any?) assert_equal("IP address is banned", user.errors.full_messages.join) end @@ -74,13 +73,13 @@ class UserTest < ActiveSupport::TestCase assert_equal(10, @user.upload_limit) 9.times do - FactoryGirl.create(:post, :uploader => @user, :is_pending => true) + FactoryBot.create(:post, :uploader => @user, :is_pending => true) end @user = User.find(@user.id) assert_equal(1, @user.upload_limit) assert(@user.can_upload?) - FactoryGirl.create(:post, :uploader => @user, :is_pending => true) + FactoryBot.create(:post, :uploader => @user, :is_pending => true) @user = User.find(@user.id) assert(!@user.can_upload?) end @@ -90,8 +89,8 @@ class UserTest < ActiveSupport::TestCase Danbooru.config.stubs(:member_comment_limit).returns(10) assert(@user.can_comment_vote?) 10.times do - comment = FactoryGirl.create(:comment) - FactoryGirl.create(:comment_vote, :comment_id => comment.id, :score => -1) + comment = FactoryBot.create(:comment) + FactoryBot.create(:comment_vote, :comment_id => comment.id, :score => -1) end assert(!@user.can_comment_vote?) @@ -108,14 +107,14 @@ class UserTest < ActiveSupport::TestCase assert(@user.can_comment?) assert(!@user.is_comment_limited?) (Danbooru.config.member_comment_limit).times do - FactoryGirl.create(:comment) + FactoryBot.create(:comment) end assert(@user.is_comment_limited?) end should "verify" do assert(@user.is_verified?) - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.generate_email_verification_key @user.save assert(!@user.is_verified?) @@ -132,21 +131,21 @@ class UserTest < ActiveSupport::TestCase end should "normalize its level" do - user = FactoryGirl.create(:user, :level => User::Levels::ADMIN) + user = FactoryBot.create(:user, :level => User::Levels::ADMIN) assert(user.is_moderator?) assert(user.is_gold?) - user = FactoryGirl.create(:user, :level => User::Levels::MODERATOR) + user = FactoryBot.create(:user, :level => User::Levels::MODERATOR) assert(!user.is_admin?) assert(user.is_moderator?) assert(user.is_gold?) - user = FactoryGirl.create(:user, :level => User::Levels::GOLD) + user = FactoryBot.create(:user, :level => User::Levels::GOLD) assert(!user.is_admin?) assert(!user.is_moderator?) assert(user.is_gold?) - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) assert(!user.is_admin?) assert(!user.is_moderator?) assert(!user.is_gold?) @@ -159,36 +158,36 @@ class UserTest < ActiveSupport::TestCase should "not contain whitespace" do # U+2007: https://en.wikipedia.org/wiki/Figure_space - user = FactoryGirl.build(:user, :name => "foo\u2007bar") + user = FactoryBot.build(:user, :name => "foo\u2007bar") user.save assert_equal(["Name cannot have whitespace or colons"], user.errors.full_messages) end should "not contain a colon" do - user = FactoryGirl.build(:user, :name => "a:b") + user = FactoryBot.build(:user, :name => "a:b") user.save assert_equal(["Name cannot have whitespace or colons"], user.errors.full_messages) end should "not begin with an underscore" do - user = FactoryGirl.build(:user, :name => "_x") + user = FactoryBot.build(:user, :name => "_x") user.save assert_equal(["Name cannot begin or end with an underscore"], user.errors.full_messages) end should "not end with an underscore" do - user = FactoryGirl.build(:user, :name => "x_") + user = FactoryBot.build(:user, :name => "x_") user.save assert_equal(["Name cannot begin or end with an underscore"], user.errors.full_messages) end should "be fetched given a user id" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) assert_equal(@user.name, User.id_to_name(@user.id)) end should "be updated" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.update_attribute(:name, "danzig") assert_equal(@user.name, User.id_to_name(@user.id)) end @@ -196,7 +195,7 @@ class UserTest < ActiveSupport::TestCase context "ip address" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end context "in the json representation" do @@ -214,7 +213,7 @@ class UserTest < ActiveSupport::TestCase context "password" do should "match the cookie hash" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.password = "zugzug5" @user.password_confirmation = "zugzug5" @user.save @@ -223,7 +222,7 @@ class UserTest < ActiveSupport::TestCase end should "match the confirmation" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.old_password = "password" @user.password = "zugzug5" @user.password_confirmation = "zugzug5" @@ -233,7 +232,7 @@ class UserTest < ActiveSupport::TestCase end should "fail if the confirmation does not match" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.password = "zugzug6" @user.password_confirmation = "zugzug5" @user.save @@ -241,7 +240,7 @@ class UserTest < ActiveSupport::TestCase end should "not be too short" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) @user.password = "x5" @user.password_confirmation = "x5" @user.save @@ -249,38 +248,38 @@ class UserTest < ActiveSupport::TestCase end should "should be reset" do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) new_pass = @user.reset_password assert(User.authenticate(@user.name, new_pass), "Authentication should have succeeded") end should "not change the password if the password and old password are blank" do - @user = FactoryGirl.create(:user, :password => "67890") + @user = FactoryBot.create(:user, :password => "67890") @user.update_attributes(:password => "", :old_password => "") assert(@user.bcrypt_password == User.sha1("67890")) end should "not change the password if the old password is incorrect" do - @user = FactoryGirl.create(:user, :password => "67890") + @user = FactoryBot.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "abcdefg") assert(@user.bcrypt_password == User.sha1("67890")) end should "not change the password if the old password is blank" do - @user = FactoryGirl.create(:user, :password => "67890") + @user = FactoryBot.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "") assert(@user.bcrypt_password == User.sha1("67890")) end should "change the password if the old password is correct" do - @user = FactoryGirl.create(:user, :password => "67890") + @user = FactoryBot.create(:user, :password => "67890") @user.update_attributes(:password => "12345", :old_password => "67890") assert(@user.bcrypt_password == User.sha1("12345")) end context "in the json representation" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end should "not appear" do @@ -290,7 +289,7 @@ class UserTest < ActiveSupport::TestCase context "in the xml representation" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end should "not appear" do @@ -301,13 +300,13 @@ class UserTest < ActiveSupport::TestCase context "that might be a sock puppet" do setup do - @user = FactoryGirl.create(:user, last_ip_addr: "127.0.0.2") + @user = FactoryBot.create(:user, last_ip_addr: "127.0.0.2") Danbooru.config.unstub(:enable_sock_puppet_validation?) end should "not validate" do CurrentUser.scoped(nil, "127.0.0.2") do - @user = FactoryGirl.build(:user) + @user = FactoryBot.build(:user) @user.save assert_equal(["Last ip addr was used recently for another account and cannot be reused for another day"], @user.errors.full_messages) end @@ -316,9 +315,9 @@ class UserTest < ActiveSupport::TestCase context "when searched by name" do should "match wildcards" do - user1 = FactoryGirl.create(:user, :name => "foo") - user2 = FactoryGirl.create(:user, :name => "foo*bar") - user3 = FactoryGirl.create(:user, :name => "bar\*baz") + user1 = FactoryBot.create(:user, :name => "foo") + user2 = FactoryBot.create(:user, :name => "foo*bar") + user3 = FactoryBot.create(:user, :name => "bar\*baz") assert_equal([user2.id, user1.id], User.search(name: "foo*").map(&:id)) assert_equal([user2.id], User.search(name: "foo\*bar").map(&:id)) diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index 7a1f2d933..e37dac810 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -13,17 +13,17 @@ class WikiPageTest < ActiveSupport::TestCase context "A wiki page" do context "that is locked" do should "not be editable by a member" do - CurrentUser.user = FactoryGirl.create(:moderator_user) - @wiki_page = FactoryGirl.create(:wiki_page, :is_locked => true) - CurrentUser.user = FactoryGirl.create(:user) + CurrentUser.user = FactoryBot.create(:moderator_user) + @wiki_page = FactoryBot.create(:wiki_page, :is_locked => true) + CurrentUser.user = FactoryBot.create(:user) @wiki_page.update_attributes(:body => "hello") assert_equal(["Is locked and cannot be updated"], @wiki_page.errors.full_messages) end should "be editable by a moderator" do - CurrentUser.user = FactoryGirl.create(:moderator_user) - @wiki_page = FactoryGirl.create(:wiki_page, :is_locked => true) - CurrentUser.user = FactoryGirl.create(:moderator_user) + CurrentUser.user = FactoryBot.create(:moderator_user) + @wiki_page = FactoryBot.create(:wiki_page, :is_locked => true) + CurrentUser.user = FactoryBot.create(:moderator_user) @wiki_page.update_attributes(:body => "hello") assert_equal([], @wiki_page.errors.full_messages) end @@ -31,9 +31,9 @@ class WikiPageTest < ActiveSupport::TestCase context "updated by a moderator" do setup do - @user = FactoryGirl.create(:moderator_user) + @user = FactoryBot.create(:moderator_user) CurrentUser.user = @user - @wiki_page = FactoryGirl.create(:wiki_page) + @wiki_page = FactoryBot.create(:wiki_page) end should "allow the is_locked attribute to be updated" do @@ -45,14 +45,14 @@ class WikiPageTest < ActiveSupport::TestCase context "updated by a regular user" do setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) CurrentUser.user = @user - @wiki_page = FactoryGirl.create(:wiki_page, :title => "HOT POTATO", :other_names => "foo*bar baz") + @wiki_page = FactoryBot.create(:wiki_page, :title => "HOT POTATO", :other_names => "foo*bar baz") end should "not allow the is_locked attribute to be updated" do @wiki_page.update_attributes(:is_locked => true) - assert_equal(["Is locked can be modified by builders only", "Is locked and cannot be updated"], @wiki_page.errors.full_messages) + assert_equal(["Is locked and cannot be updated"], @wiki_page.errors.full_messages) @wiki_page.reload assert_equal(false, @wiki_page.is_locked?) end @@ -79,7 +79,7 @@ class WikiPageTest < ActiveSupport::TestCase should "create versions" do assert_difference("WikiPageVersion.count") do - @wiki_page = FactoryGirl.create(:wiki_page, :title => "xxx") + @wiki_page = FactoryBot.create(:wiki_page, :title => "xxx") end assert_difference("WikiPageVersion.count") do @@ -102,7 +102,7 @@ class WikiPageTest < ActiveSupport::TestCase end should "differentiate between updater and creator" do - another_user = FactoryGirl.create(:user) + another_user = FactoryBot.create(:user) CurrentUser.scoped(another_user, "127.0.0.1") do @wiki_page.title = "yyy" @wiki_page.save