diff --git a/Gemfile b/Gemfile index e571e2c30..1a059f91b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,10 @@ source 'https://rubygems.org' +git_source(:github) do |repo_name| + repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") + "https://github.com/#{repo_name}.git" +end + gem "rails", "5.0.5" gem "actionpack-page_caching", "~>1.1" @@ -9,9 +14,9 @@ gem "bitfields", "~>0.4" gem "canable", "~>0.1" gem "carrierwave", "~>1.1" gem "devise", "~>4.3" -gem "diff_match_patch", git: "https://github.com/nono/diff_match_patch-ruby.git", require: "diff_match_patch" -gem "doorkeeper", "~>2.1" -gem "ffi-hunspell", git: "https://github.com/postmodern/ffi-hunspell.git" +gem "diff_match_patch", github: "nono/diff_match_patch-ruby", require: "diff_match_patch" +gem "doorkeeper", "~>4.2" +gem "ffi-hunspell", github: "postmodern/ffi-hunspell" gem "french_rails", "~>0.4" gem "friendly_id", "~>5.1" gem "haml", "~>4.0" @@ -46,16 +51,17 @@ group :development do gem "annotate" gem "better_errors" gem "binding_of_caller" - gem "byebug" - gem "capistrano", "~>2.15", git: 'https://github.com/capistrano/capistrano.git', branch: 'legacy-v2' + gem "byebug", platform: :mri + gem "capistrano", "~>2.15", github: 'capistrano', branch: 'legacy-v2' gem "capistrano-maintenance" gem "letter_opener" + gem "listen" gem "mo" gem "pry-rails" gem "spring" gem "sushi" gem "thin" - gem "web-console", "~> 2.1" + gem "web-console" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 370994a31..272c7773e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,9 +18,9 @@ GIT GIT remote: https://github.com/postmodern/ffi-hunspell.git - revision: c5c98da6f39dace66ef2522ab75bb147dd7ddd27 + revision: d3dcb5d17ef12c955e957573ca98a0fbaf655e14 specs: - ffi-hunspell (0.3.1) + ffi-hunspell (0.4.0) ffi (~> 1.0) GEM @@ -75,10 +75,11 @@ GEM ansi (1.5.0) arel (7.1.4) bcrypt (3.1.11) - better_errors (2.1.1) + better_errors (2.3.0) coderay (>= 1.0.0) - erubis (>= 2.6.6) + erubi (>= 1.0.0) rack (>= 0.9.0) + bindex (0.5.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) bitfields (0.7.0) @@ -119,11 +120,12 @@ GEM responders warden (~> 1.2.3) diff-lcs (1.3) - doorkeeper (2.2.2) - railties (>= 3.2) + doorkeeper (4.2.6) + railties (>= 4.2) + erubi (1.6.1) erubis (2.7.0) escape_utils (1.2.1) - eventmachine (1.2.1) + eventmachine (1.2.5) execjs (2.7.0) factory_girl (2.6.4) activesupport (>= 2.3.9) @@ -156,8 +158,8 @@ GEM pygments.rb (~> 1.1) redcarpet (~> 3.4) sanitize (~> 4.0) - html_spellchecker (0.1.8) - ffi-hunspell (= 0.3.1) + html_spellchecker (0.1.9) + ffi-hunspell (~> 0.4) nokogiri (~> 1.4) html_truncator (0.4.1) nokogiri (~> 1.5) @@ -182,6 +184,9 @@ GEM letter_opener (1.4.1) launchy (~> 2.2) libv8 (3.16.14.19) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.6) @@ -198,7 +203,7 @@ GEM mo (1.4.0) boson multi_json (1.12.2) - mysql2 (0.4.5) + mysql2 (0.4.9) net-scp (1.2.1) net-ssh (>= 2.6.5) net-sftp (2.1.2) @@ -217,8 +222,8 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry-rails (0.3.4) - pry (>= 0.9.10) + pry-rails (0.3.6) + pry (>= 0.10.4) public_suffix (2.0.5) multi_json (>= 1.0.0) pygments.rb (1.2.1) @@ -249,7 +254,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - raindrops (0.17.0) + raindrops (0.19.0) rake (12.0.0) rb-fsevent (0.10.2) rb-inotify (0.9.10) @@ -316,7 +321,7 @@ GEM therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thin (1.7.0) + thin (1.7.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) @@ -327,16 +332,16 @@ GEM thread_safe (~> 0.1) uglifier (3.2.0) execjs (>= 0.3.0, < 3) - unicorn (5.2.0) + unicorn (5.3.0) kgio (~> 2.6) raindrops (~> 0.7) warden (1.2.7) rack (>= 1.0) - web-console (2.3.0) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) + web-console (3.5.1) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) @@ -364,7 +369,7 @@ DEPENDENCIES database_cleaner (~> 1.2) devise (~> 4.3) diff_match_patch! - doorkeeper (~> 2.1) + doorkeeper (~> 4.2) factory_girl_rails (~> 1.6) ffi-hunspell! french_rails (~> 0.4) @@ -381,6 +386,7 @@ DEPENDENCIES jquery-rails (~> 4.0) kaminari (~> 0.15) letter_opener + listen mini_magick (~> 3.8) mo mysql2 (~> 0.3) @@ -400,7 +406,7 @@ DEPENDENCIES thin uglifier unicorn (~> 5.1) - web-console (~> 2.1) + web-console BUNDLED WITH 1.15.4 diff --git a/README.md b/README.md index 6d456b007..f666e1d60 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ $ bundle install 5) Finish to configure: ``` -$ bin/rake db:setup +$ bin/rails db:setup (if you're updating, you'll need an other step: redis-cli flushdb) ``` diff --git a/Rakefile b/Rakefile index 9efee5221..e85f91391 100755 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require "rake" -require File.expand_path('../config/application', __FILE__) +require_relative 'config/application' Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..21a78805c --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,2 @@ +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index d488dd727..ccdfb1ecc 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -42,10 +42,10 @@ def karma def update if @account.inactive? @account.reactivate! - redirect_to :back, notice: "Compte réactivé" + redirect_back notice: "Compte réactivé", fallback_location: admin_accounts_url else @account.inactivate! - redirect_to :back, notice: "Compte désactivé" + redirect_back notice: "Compte désactivé", fallback_location: admin_accounts_url end end diff --git a/app/controllers/api/v1/board_controller.rb b/app/controllers/api/v1/board_controller.rb index dea36984d..6db19dc30 100644 --- a/app/controllers/api/v1/board_controller.rb +++ b/app/controllers/api/v1/board_controller.rb @@ -17,7 +17,7 @@ def create protected def board_params - params.slice(:object_type, :object_id, :message) + params.permit(:object_type, :object_id, :message) end def expire_cache diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f392c958a..630ff5cd6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -49,14 +49,14 @@ def dont_index? end def configure_permitted_parameters - devise_parameter_sanitizer.for(:sign_up) << :email - devise_parameter_sanitizer.for(:account_update) do |u| - u.permit(:login, :email, :password, :password_confirmation, :current_password, - :hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home, - :polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home, - :sort_by_date_on_home, :hide_signature, :show_negative_nodes, - user_attributes: [:id, :name, :homesite, :jabber_id, :signature, :avatar, :custom_avatar_url]) - end + devise_parameter_sanitizer.permit(:sign_up, keys: [:email]) + devise_parameter_sanitizer.permit(:account_update, keys: [ + :login, :email, :password, :password_confirmation, :current_password, + :hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home, + :polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home, + :sort_by_date_on_home, :hide_signature, :show_negative_nodes, + user_attributes: [:id, :name, :homesite, :jabber_id, :signature, :avatar, :custom_avatar_url] + ]) end ### Content ### diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 5b412891e..c6508f076 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -20,7 +20,7 @@ def create board.save board.news.tap {|news| news.node.read_by current_account.id if news } respond_to do |wants| - wants.html { redirect_to :back rescue redirect_to root_url } + wants.html { redirect_back fallback_location: root_url } wants.js { render nothing: true } wants.xml { render nothing: true } wants.tsv { render nothing: true } diff --git a/app/controllers/moderation/news_controller.rb b/app/controllers/moderation/news_controller.rb index c359d991c..5cbe3a9d4 100644 --- a/app/controllers/moderation/news_controller.rb +++ b/app/controllers/moderation/news_controller.rb @@ -52,7 +52,7 @@ def accept elsif @news.unlocked? @news.moderator_id = current_user.id @news.accept! - NewsNotifications.accept(@news).deliver + NewsNotifications.accept(@news).deliver_now redirect_to @news, alert: "Dépêche acceptée" else redirect_to [:moderation, @news], alert: "Impossible de modérer la dépêche tant que quelqu'un est en train de la modifier" @@ -66,7 +66,7 @@ def refuse @news.put_paragraphs_together @news.refuse! notif = NewsNotifications.refuse_with_message(@news, params[:message], params[:template]) - notif.deliver if notif + notif.deliver_now if notif redirect_to '/' elsif @news.unlocked? @boards = Board.all(Board.news, @news.id) @@ -80,7 +80,7 @@ def rewrite if @news.unlocked? @news.moderator_id = current_user.id @news.rewrite! - NewsNotifications.rewrite(@news).deliver + NewsNotifications.rewrite(@news).deliver_now redirect_to @news, alert: "Dépêche renvoyée en rédaction" else redirect_to [:moderation, @news], alert: "Impossible de modérer la dépêche tant que quelqu'un est en train de la modifier" diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index bcb1c1722..dbb1be0b4 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -11,11 +11,9 @@ class PollsController < ApplicationController def index @order = params[:order] @order = "created_at" unless VALID_ORDERS.include?(@order) - @polls = Poll.archived.joins(:node).order("nodes.#{@order} DESC").page(params[:page]) - if on_the_first_page? - poll = Poll.current - @polls.unshift(poll) if poll - end + @polls = Poll.archived + @polls = Poll.published.or(@polls) if on_the_first_page? + @polls = @polls.joins(:node).order("nodes.#{@order} DESC").page(params[:page]) respond_with(@polls) end diff --git a/app/controllers/relevances_controller.rb b/app/controllers/relevances_controller.rb index 6b19681d5..5de1e565d 100644 --- a/app/controllers/relevances_controller.rb +++ b/app/controllers/relevances_controller.rb @@ -14,7 +14,7 @@ def for end respond_to do |wants| wants.json { render json: { notice: notice, nb_votes: current_account.nb_votes } } - wants.html { redirect_to :back rescue redirect_to root_url } + wants.html { redirect_back fallback_location: root_url } end end @@ -27,7 +27,7 @@ def against end respond_to do |wants| wants.json { render json: { notice: notice, nb_votes: current_account.nb_votes } } - wants.html { redirect_to :back rescue redirect_to root_url } + wants.html { redirect_back :back fallback_location: root_url } end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 6edb22a5a..0a6150176 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -12,7 +12,7 @@ def create cookies.permanent[:https] = { value: "1", secure: false } if request.ssl? @account = warden.authenticate!(scope: :account, recall: "#{controller_path}#new") sign_in :account, @account - redirect_to stored_location_for(:account) || :back, notice: I18n.t("devise.sessions.signed_in") + redirect_to after_sign_in_path_for(:account), notice: I18n.t("devise.sessions.signed_in") rescue ActionController::RedirectBackError redirect_to '/' end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 96873e418..9f6c24f9e 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -78,7 +78,7 @@ def public def hide enforce_update_permission(@tag) @tag.toggle!("public") - redirect_to :back, notice: "La visibilité du tag a bien été modifiée" + redirect_back, fallback_location: root_url, notice: "La visibilité du tag a bien été modifiée" rescue redirect_to root_url end diff --git a/app/helpers/news_helper.rb b/app/helpers/news_helper.rb index 656a44ad7..b90d59080 100644 --- a/app/helpers/news_helper.rb +++ b/app/helpers/news_helper.rb @@ -19,8 +19,9 @@ def news_posted_by(news) end def edited_by(news) - return "" if news.edited_by.none? - users = news.edited_by.map {|u| link_to u.name, u }.to_sentence + editors = news.edited_by.to_a + return "" if editors.none? + users = editors.map {|u| link_to u.name, u }.to_sentence caption = content_tag(:span, "Édité par #{content_tag :span, users.html_safe, class: "edited_by"}.".html_safe, class: "edited_by_spanblock"); caption.html_safe end diff --git a/app/models/diary.rb b/app/models/diary.rb index c3ff9f30a..a69624ab8 100644 --- a/app/models/diary.rb +++ b/app/models/diary.rb @@ -94,7 +94,7 @@ def move_to_forum(attrs) ELSE 'Diary' END WHERE id=#{node.id} OR id=#{@post.node.id} EOS - Node.connection.update_sql(stmt) + Node.connection.update(stmt) node.compute_interest end end diff --git a/app/models/news.rb b/app/models/news.rb index 2b61541d2..ba85fcf69 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -140,7 +140,7 @@ def self.create_for_redaction(account) end def followup(message, user) - NewsNotifications.followup(self, message).deliver + NewsNotifications.followup(self, message).deliver_now msg = "Relance : #{message}" Board.new(object_type: Board.news, object_id: self.id, message: msg, user_name: user.name).save end diff --git a/app/models/node.rb b/app/models/node.rb index 5c74293f5..89d8935c2 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -63,7 +63,7 @@ def on_ppp? def compute_interest coeff = content_type.constantize.interest_coefficient stmt = "UPDATE nodes SET interest=(score * #{coeff} + UNIX_TIMESTAMP(created_at) / 1000) WHERE id=#{self.id}" - Node.connection.update_sql(stmt) + Node.connection.update(stmt) end def make_visible diff --git a/config.ru b/config.ru index fffd61808..547e0f794 100644 --- a/config.ru +++ b/config.ru @@ -1,6 +1,6 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' if defined?(Unicorn::HttpRequest) require 'gctools/oobgc' diff --git a/config/application.rb b/config/application.rb index d103054fb..f824026c3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -26,7 +26,5 @@ class Application < Rails::Application config.to_prepare do Doorkeeper::AuthorizationsController.layout "doorkeeper" end - - config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 76ee7fb82..5cea2ab21 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' diff --git a/config/environment.rb b/config/environment.rb index 31a8b9e81..8fb6325a8 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/alpha.rb b/config/environments/alpha.rb index a3dbc3f2e..880feb80d 100644 --- a/config/environments/alpha.rb +++ b/config/environments/alpha.rb @@ -16,13 +16,9 @@ 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 - - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_files = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -34,9 +30,6 @@ # Set the page cache directory config.action_controller.page_cache_directory = "#{Rails.public_path}/pages" - # Generate digests for assets URLs. - config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' @@ -57,16 +50,12 @@ config.log_level = :info # 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 = :redis_store, "redis://localhost:6379/1/cache", { expires_in: 1.hour } - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" + config.action_mailer.perform_caching = false # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. diff --git a/config/environments/development.rb b/config/environments/development.rb index 9a0b3b35e..68eb9c808 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,12 +11,14 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true + # Show full error reports. + config.consider_all_requests_local = true config.action_controller.perform_caching = false + config.cache_store = :null_store # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false config.action_mailer.delivery_method = :letter_opener config.action_mailer.default_url_options = { host: MY_DOMAIN } @@ -26,16 +28,13 @@ # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load - config.assets.quiet = true - # 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 = 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 + # 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. @@ -45,5 +44,9 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + # 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 + config.action_controller.action_on_unpermitted_parameters = :raise end diff --git a/config/environments/production.rb b/config/environments/production.rb index 2d56ff371..b15cb567a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -16,13 +16,9 @@ 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 - - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_files = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -34,9 +30,6 @@ # Set the page cache directory config.action_controller.page_cache_directory = "#{Rails.public_path}/pages" - # Generate digests for assets URLs. - config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' @@ -57,16 +50,12 @@ config.log_level = :info # 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 = :redis_store, "redis://localhost:6379/1/cache", { expires_in: 1.hour } - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" + config.action_mailer.perform_caching = false # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. diff --git a/config/environments/test.rb b/config/environments/test.rb index cc54eaf0c..6eb6bad93 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,8 +15,7 @@ config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -27,6 +26,7 @@ # 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 @@ -40,9 +40,6 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - # Randomize the order test cases are executed. - config.active_support.test_order = :random - unless ENV['RAILS_ENABLE_TEST_LOG'] config.logger = Logger.new(nil) config.log_level = :fatal diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 146b7e501..0fe4e797b 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -3,10 +3,10 @@ # 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. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/spec/api/accounts_spec.rb b/spec/api/accounts_spec.rb index c94a78984..d6413d9e2 100644 --- a/spec/api/accounts_spec.rb +++ b/spec/api/accounts_spec.rb @@ -8,12 +8,12 @@ let!(:token) { Factory :access_token, application: application, resource_owner_id: account.id } it 'responds with 200' do - get '/api/v1/me', access_token: token.token + get '/api/v1/me', params: { access_token: token.token } response.status.should eq(200) end it 'returns the account as json' do - get '/api/v1/me', access_token: token.token + get '/api/v1/me', params: { access_token: token.token } response.body.should == account.to_json JSON.parse(response.body).keys.should == %w(login email created_at) end diff --git a/spec/api/board_spec.rb b/spec/api/board_spec.rb index 4246d6ad5..fd27ef5de 100644 --- a/spec/api/board_spec.rb +++ b/spec/api/board_spec.rb @@ -9,17 +9,17 @@ let!(:message) { "Un message très intéressant... ou pas" } it 'responds with 200' do - post '/api/v1/board', access_token: token.token, message: message + post '/api/v1/board', params: { access_token: token.token, message: message } response.status.should eq(200) end it 'returns the id as json' do - post '/api/v1/board', access_token: token.token, message: message + post '/api/v1/board', params: { access_token: token.token, message: message } response.body.should == { id: Board.last(Board.free).id }.to_json end it 'sets the attributes correctly' do - post '/api/v1/board', access_token: token.token, message: message + post '/api/v1/board', params: { access_token: token.token, message: message } board = Board.last(Board.free) board.message.should == message board.user_agent.should == application.name @@ -28,7 +28,7 @@ end it 'can post on the redaction board' do - post '/api/v1/board', access_token: token.token, message: message, object_type: Board.writing + post '/api/v1/board', params: { access_token: token.token, message: message, object_type: Board.writing } board = Board.last(Board.writing) board.message.should == message board.user_agent.should == application.name