From 130948ae3f8c0516f0d8a1045edd5e38af5ec63a Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 30 Aug 2014 19:38:47 +0200 Subject: [PATCH] Upgrate to Rails 4.1.5 --- Gemfile | 15 +- Gemfile.lock | 173 ++++++++++-------- Guardfile | 2 +- Rakefile | 2 +- app/models/asciicast.rb | 2 +- config/environment.rb | 2 +- config/environments/development.rb | 12 +- config/environments/production.rb | 16 +- config/environments/test.rb | 5 +- config/initializers/assets.rb | 8 + config/initializers/cookies_serializer.rb | 3 + config/initializers/mime_types.rb | 1 - config/initializers/session_store.rb | 2 +- config/routes.rb | 3 +- .../secret_token.rb => secrets.yml} | 14 +- lib/active_support_json_proxy.rb | 13 ++ spec/api/asciicast_create_spec.rb | 2 +- spec/api/asciicast_show_spec.rb | 2 +- .../account_merges_controller_spec.rb | 2 +- .../api/asciicasts_controller_spec.rb | 2 +- .../controllers/api_tokens_controller_spec.rb | 2 +- .../application_controller_spec.rb | 2 +- .../controllers/asciicasts_controller_spec.rb | 2 +- spec/controllers/docs_controller_spec.rb | 2 +- spec/controllers/home_controller_spec.rb | 2 +- spec/controllers/pages_controller_spec.rb | 2 +- spec/controllers/sessions_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 2 +- spec/decorators/application_decorator_spec.rb | 2 +- spec/decorators/asciicast_decorator_spec.rb | 2 +- spec/decorators/brush_decorator_spec.rb | 2 +- spec/decorators/cell_decorator_spec.rb | 2 +- spec/decorators/helpers/avatar_helper_spec.rb | 2 +- spec/decorators/omni_auth_credentials_spec.rb | 2 +- spec/decorators/snapshot_decorator_spec.rb | 2 +- spec/decorators/user_decorator_spec.rb | 2 +- spec/features/asciicast_spec.rb | 2 +- spec/features/asciicasts_spec.rb | 2 +- spec/features/docs_spec.rb | 2 +- spec/features/example_page_spec.rb | 2 +- spec/features/home_spec.rb | 2 +- spec/features/pages_spec.rb | 2 +- spec/features/playback_spec.rb | 2 +- spec/features/user_spec.rb | 2 +- spec/features/widget_spec.rb | 2 +- spec/helpers/application_helper_spec.rb | 2 +- spec/models/api_token_spec.rb | 2 +- spec/models/asciicast_params_spec.rb | 2 +- spec/models/asciicast_spec.rb | 2 +- spec/models/brush_spec.rb | 2 +- spec/models/buffered_stdout_spec.rb | 2 +- spec/models/cell_spec.rb | 2 +- spec/models/comment_spec.rb | 2 +- spec/models/cursor_spec.rb | 2 +- spec/models/frame_diff_list_spec.rb | 2 +- spec/models/frame_diff_spec.rb | 2 +- spec/models/frame_spec.rb | 2 +- spec/models/grid_spec.rb | 2 +- spec/models/like_spec.rb | 2 +- spec/models/snapshot_spec.rb | 2 +- spec/models/stdout_spec.rb | 2 +- spec/models/terminal_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- spec/policies/asciicast_policy_spec.rb | 2 +- spec/policies/user_policy_spec.rb | 2 +- .../asciicast_page_presenter_spec.rb | 2 +- .../bare_asciicast_page_presenter_spec.rb | 2 +- spec/presenters/browse_page_presenter_spec.rb | 2 +- spec/presenters/home_page_presenter_spec.rb | 2 +- spec/presenters/user_page_presenter_spec.rb | 2 +- spec/rails_helper.rb | 64 +++++++ spec/routing/asciicasts_spec.rb | 2 +- spec/routing/connect_spec.rb | 2 +- spec/serializers/asciicast_serializer_spec.rb | 2 +- spec/services/asciicast_creator_spec.rb | 2 +- .../asciicast_frames_file_updater_spec.rb | 2 +- spec/services/asciicast_processor_spec.rb | 2 +- .../asciicast_snapshot_updater_spec.rb | 2 +- spec/services/film_spec.rb | 2 +- spec/services/json_file_writer_spec.rb | 2 +- spec/services/timing_parser_spec.rb | 2 +- spec/services/view_counter_spec.rb | 2 +- spec/spec_helper.rb | 118 ++++++------ spec/strategies/auth_cookie_strategy_spec.rb | 2 +- spec/support/sidekiq_matchers.rb | 22 ++- spec/uploaders/bzip2_uploader_spec.rb | 2 +- spec/workers/asciicast_worker_spec.rb | 2 +- 87 files changed, 381 insertions(+), 232 deletions(-) create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/cookies_serializer.rb rename config/{initializers/secret_token.rb => secrets.yml} (58%) create mode 100644 lib/active_support_json_proxy.rb create mode 100644 spec/rails_helper.rb diff --git a/Gemfile b/Gemfile index 6f04c39..118d564 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rails', '4.0.9' +gem 'rails', '4.1.5' gem 'sass-rails', '~> 4.0.3' gem 'coffee-rails', '~> 4.0.1' @@ -15,11 +15,11 @@ gem 'omniauth-github', '~> 1.1.0' gem 'omniauth-browserid', git: 'https://github.com/callahad/omniauth-browserid.git' gem 'kaminari', '~> 0.14.1' gem 'bugsnag', '~> 2.2.1' -gem 'draper', '~> 1.2.1' +gem 'draper', '~> 1.3.1' gem 'fog', '~> 1.9.0' gem 'simple_form', '~> 3.0.2' gem 'simple_form_bootstrap3', '~> 0.2.6' -gem 'sidekiq', '~> 2.17' +gem 'sidekiq', '~> 3.2.2' gem 'thin', '~> 1.5.0' gem 'open4', '~> 1.3.0' gem 'redcarpet', '~> 2.2.2' @@ -31,7 +31,7 @@ gem 'yajl-ruby', '~> 1.1.0', :require => 'yajl' gem 'newrelic_rpm' gem 'virtus', '~> 1.0.1' gem 'warden', '~> 1.2.3' -gem 'pundit', '~> 0.2.3' +gem 'pundit', '~> 0.3.0' gem 'rack-robustness', '~> 1.1.0' group :development do @@ -45,7 +45,7 @@ end group :test, :development do gem 'pry-rails', '~> 0.3.2' - gem 'rspec-rails', '~> 3.0.0.beta1' + gem 'rspec-rails', '~> 3.0.2' gem 'cane', '~> 2.5.2' gem 'jasmine-rails', '~> 0.4.5' gem 'timecop', '~> 0.7.1' @@ -54,15 +54,16 @@ end group :test do gem "rake", '~> 10.0.4' gem 'factory_girl_rails', '~> 4.2.0' - gem 'capybara', '~> 2.2.0' + gem 'capybara', '~> 2.4.1' gem 'poltergeist', '~> 1.5.0' gem 'database_cleaner', '~> 1.0.1' gem 'guard' gem 'guard-rspec' gem 'rb-inotify', '~> 0.9.0' gem 'simplecov', '~> 0.7.1', require: false - gem 'shoulda-matchers', '~> 2.4.0' + gem 'shoulda-matchers' gem 'coveralls', require: false + gem 'rspec-activemodel-mocks' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index bac14bb..9484883 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,33 +10,35 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.9) - actionpack (= 4.0.9) + actionmailer (4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) mail (~> 2.5.4) - actionpack (4.0.9) - activesupport (= 4.0.9) - builder (~> 3.1.0) - erubis (~> 2.7.0) + actionpack (4.1.5) + actionview (= 4.1.5) + activesupport (= 4.1.5) rack (~> 1.5.2) rack-test (~> 0.6.2) + actionview (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + erubis (~> 2.7.0) active_model_serializers (0.8.1) activemodel (>= 3.0) - activemodel (4.0.9) - activesupport (= 4.0.9) - builder (~> 3.1.0) - activerecord (4.0.9) - activemodel (= 4.0.9) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.9) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.9) + activemodel (4.1.5) + activesupport (= 4.1.5) + builder (~> 3.1) + activerecord (4.1.5) + activemodel (= 4.1.5) + activesupport (= 4.1.5) + arel (~> 5.0.0) + activesupport (4.1.5) i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.2) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) axiom-types (0.0.5) descendants_tracker (~> 0.0.1) ice_nine (~> 0.9) @@ -45,7 +47,7 @@ GEM bugsnag (2.2.1) httparty (>= 0.6, < 1.0) multi_json (~> 1.0) - builder (3.1.4) + builder (3.2.2) cane (2.5.2) parallel capistrano (2.15.5) @@ -56,7 +58,7 @@ GEM net-ssh-gateway (>= 1.1.0) capistrano-ext (1.2.1) capistrano (>= 1.0.0) - capybara (2.2.0) + capybara (2.4.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -78,7 +80,7 @@ GEM coffee-script-source execjs coffee-script-source (1.6.3) - connection_pool (1.2.0) + connection_pool (2.0.0) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -93,8 +95,9 @@ GEM dotenv (0.8.0) dotenv-rails (0.8.0) dotenv (= 0.8.0) - draper (1.2.1) + draper (1.3.1) actionpack (>= 3.0) + activemodel (>= 3.0) activesupport (>= 3.0) request_store (~> 1.0.3) equalizer (0.0.9) @@ -123,15 +126,16 @@ GEM foreman (0.63.0) dotenv (>= 0.7) thor (>= 0.13.6) - formatador (0.2.4) - guard (2.2.4) + formatador (0.2.5) + guard (2.6.1) formatador (>= 0.2.4) - listen (~> 2.1) + listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) - guard-rspec (1.2.1) - guard (>= 1.1) + guard-rspec (4.3.1) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) hashie (2.0.5) highline (1.6.19) hike (1.2.3) @@ -156,17 +160,17 @@ GEM actionpack (>= 3.0.0) activesupport (>= 3.0.0) kgio (2.8.1) - listen (2.4.0) + listen (2.7.9) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - lumberjack (1.0.4) + lumberjack (1.0.9) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.2) mime-types (1.25.1) - minitest (4.7.5) + minitest (5.4.1) multi_json (1.10.1) multi_xml (0.5.5) multipart-post (1.2.0) @@ -178,7 +182,7 @@ GEM net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) newrelic_rpm (3.7.1.182) - nokogiri (1.5.10) + nokogiri (1.5.11) oauth (0.4.7) oauth2 (0.8.1) faraday (~> 0.8) @@ -210,13 +214,13 @@ GEM multi_json (~> 1.0) websocket-driver (>= 0.2.0) polyglot (0.3.5) - pry (0.9.12.4) - coderay (~> 1.0) - method_source (~> 0.8) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) slop (~> 3.4) pry-rails (0.3.2) pry (>= 0.9.10) - pundit (0.2.3) + pundit (0.3.0) activesupport (>= 3.0.0) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) @@ -226,48 +230,57 @@ GEM rack-robustness (1.1.0) rack-test (0.6.2) rack (>= 1.0) - rails (4.0.9) - actionmailer (= 4.0.9) - actionpack (= 4.0.9) - activerecord (= 4.0.9) - activesupport (= 4.0.9) + rails (4.1.5) + actionmailer (= 4.1.5) + actionpack (= 4.1.5) + actionview (= 4.1.5) + activemodel (= 4.1.5) + activerecord (= 4.1.5) + activesupport (= 4.1.5) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.9) + railties (= 4.1.5) sprockets-rails (~> 2.0) - railties (4.0.9) - actionpack (= 4.0.9) - activesupport (= 4.0.9) + railties (4.1.5) + actionpack (= 4.1.5) + activesupport (= 4.1.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.12.0) rake (10.0.4) - rb-fsevent (0.9.3) - rb-inotify (0.9.2) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) ffi (>= 0.5.0) redcarpet (2.2.2) - redis (3.0.6) - redis-namespace (1.3.2) - redis (~> 3.0.4) - request_store (1.0.5) + redis (3.1.0) + redis-namespace (1.5.1) + redis (~> 3.0, >= 3.0.4) + request_store (1.0.8) rest-client (1.6.7) mime-types (>= 1.16) - rspec-collection_matchers (0.0.2) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.0.0.beta1) - rspec-expectations (3.0.0.beta1) - diff-lcs (>= 1.1.3, < 2.0) - rspec-support (= 3.0.0.beta1) - rspec-mocks (3.0.0.beta1) - rspec-rails (3.0.0.beta1) - actionpack (>= 3.0) + rspec (3.0.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-activemodel-mocks (1.0.1) activemodel (>= 3.0) activesupport (>= 3.0) + rspec-mocks (>= 2.99, < 4.0) + rspec-core (3.0.4) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.4) + rspec-support (~> 3.0.0) + rspec-rails (3.0.2) + actionpack (>= 3.0) + activesupport (>= 3.0) railties (>= 3.0) - rspec-collection_matchers - rspec-core (= 3.0.0.beta1) - rspec-expectations (= 3.0.0.beta1) - rspec-mocks (= 3.0.0.beta1) - rspec-support (3.0.0.beta1) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.4) ruby-hmac (0.4.0) sass (3.2.19) sass-rails (4.0.3) @@ -275,13 +288,13 @@ GEM sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) - shoulda-matchers (2.4.0) + shoulda-matchers (2.6.2) activesupport (>= 3.0.0) - sidekiq (2.17.0) + sidekiq (3.2.2) celluloid (>= 0.15.2) - connection_pool (>= 1.0.0) + connection_pool (>= 2.0.0) json - redis (>= 3.0.4) + redis (>= 3.0.6) redis-namespace (>= 1.3.1) simple_form (3.0.2) actionpack (~> 4.0) @@ -300,7 +313,7 @@ GEM slim (2.0.1) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) - slop (3.4.7) + slop (3.6.0) spring (1.0.0) spring-commands-rspec (1.0.1) spring (>= 0.9.1) @@ -329,7 +342,8 @@ GEM treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.41) + tzinfo (1.2.2) + thread_safe (~> 0.1) uglifier (2.3.1) execjs (>= 0.3.0) json (>= 1.8.0) @@ -360,14 +374,14 @@ DEPENDENCIES cane (~> 2.5.2) capistrano (~> 2.15) capistrano-ext (~> 1.2) - capybara (~> 2.2.0) + capybara (~> 2.4.1) carrierwave (~> 0.8.0) coffee-rails (~> 4.0.1) coveralls dalli (~> 2.6.2) database_cleaner (~> 1.0.1) dotenv-rails (~> 0.8) - draper (~> 1.2.1) + draper (~> 1.3.1) factory_girl_rails (~> 4.2.0) fog (~> 1.9.0) foreman (~> 0.63.0) @@ -385,17 +399,18 @@ DEPENDENCIES pg (~> 0.14) poltergeist (~> 1.5.0) pry-rails (~> 0.3.2) - pundit (~> 0.2.3) + pundit (~> 0.3.0) quiet_assets (~> 1.0.1) rack-robustness (~> 1.1.0) - rails (= 4.0.9) + rails (= 4.1.5) rake (~> 10.0.4) rb-inotify (~> 0.9.0) redcarpet (~> 2.2.2) - rspec-rails (~> 3.0.0.beta1) + rspec-activemodel-mocks + rspec-rails (~> 3.0.2) sass-rails (~> 4.0.3) - shoulda-matchers (~> 2.4.0) - sidekiq (~> 2.17) + shoulda-matchers + sidekiq (~> 3.2.2) simple_form (~> 3.0.2) simple_form_bootstrap3 (~> 0.2.6) simplecov (~> 0.7.1) diff --git a/Guardfile b/Guardfile index 2cbf12f..b27e594 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,7 @@ notification :tmux, :color_location => 'status-right-bg' guard 'rspec', all_on_start: false, cmd: 'spring rspec --fail-fast --tag ~js --tag ~slow' do - watch('spec/spec_helper.rb') { "spec" } + watch('spec/rails_helper.rb') { "spec" } watch('config/routes.rb') { "spec/routing" } watch('app/controllers/application_controller.rb') { "spec/controllers" } watch(%r{^spec/.+_spec\.rb$}) diff --git a/Rakefile b/Rakefile index 180115d..baff551 100644 --- a/Rakefile +++ b/Rakefile @@ -4,4 +4,4 @@ require File.expand_path('../config/application', __FILE__) -Asciinema::Application.load_tasks +Rails.application.load_tasks diff --git a/app/models/asciicast.rb b/app/models/asciicast.rb index 804f9b4..e8b6e16 100644 --- a/app/models/asciicast.rb +++ b/app/models/asciicast.rb @@ -8,7 +8,7 @@ class Asciicast < ActiveRecord::Base mount_uploader :stdout_timing, StdoutTimingUploader mount_uploader :stdout_frames, StdoutFramesUploader - serialize :snapshot, JSON + serialize :snapshot, ActiveSupportJsonProxy validates :stdout_data, :stdout_timing, :presence => true validates :terminal_columns, :terminal_lines, :duration, :presence => true diff --git a/config/environment.rb b/config/environment.rb index 948d7fb..ee8d90d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ require File.expand_path('../application', __FILE__) # Initialize the Rails application. -Asciinema::Application.initialize! +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 8db95f0..ddf0e90 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -Asciinema::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on @@ -19,11 +19,19 @@ Asciinema::Application.configure do # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # 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 + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/environments/production.rb b/config/environments/production.rb index 9b1841a..8c8bb17 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,11 +1,11 @@ -Asciinema::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers + # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true @@ -32,8 +32,7 @@ Asciinema::Application.configure do # 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' + # `config.assets.precompile` has moved to config/initializers/assets.rb # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache @@ -57,16 +56,12 @@ Asciinema::Application.configure do # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" - # Precompile additional assets. - # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - config.assets.precompile += %w( player.css player.js embed.css embed.js ) - # 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. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found). + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. @@ -77,4 +72,7 @@ Asciinema::Application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 4ce9ea9..6bbe9c4 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -Asciinema::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's @@ -33,4 +33,7 @@ Asciinema::Application.configure do # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000..98aa62f --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +Rails.application.config.assets.precompile += %w( player.css player.js embed.css embed.js persona-include.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7f70458 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e..dc18996 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index b84a9db..aca6e5e 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Asciinema::Application.config.session_store :cookie_store, key: '_asciinema_session', secure: CFG.ssl? +Rails.application.config.session_store :cookie_store, key: '_asciinema_session', secure: CFG.ssl? diff --git a/config/routes.rb b/config/routes.rb index 3ec8b17..62a141e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -Asciinema::Application.routes.draw do +Rails.application.routes.draw do get "/browse" => "asciicasts#index", :as => :browse get "/browse/:category" => "asciicasts#index", :as => :category @@ -38,4 +38,5 @@ Asciinema::Application.routes.draw do get '/privacy' => 'pages#show', page: :privacy, as: :privacy get '/tos' => 'pages#show', page: :tos, as: :tos get '/contributing' => 'pages#show', page: :contributing, as: :contributing + end diff --git a/config/initializers/secret_token.rb b/config/secrets.yml similarity index 58% rename from config/initializers/secret_token.rb rename to config/secrets.yml index f45254c..dcc988b 100644 --- a/config/initializers/secret_token.rb +++ b/config/secrets.yml @@ -7,6 +7,16 @@ # no regular words or you'll be exposed to dictionary attacks. # You can use `rake secret` to generate a secure secret key. -# Make sure your secret_key_base is kept private +# Make sure the secrets in this file are kept private # if you're sharing your code publicly. -Asciinema::Application.config.secret_key_base = CFG.secret_token + +development: + secret_key_base: <%= CFG.secret_token %> + +test: + secret_key_base: <%= CFG.secret_token %> + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= CFG.secret_token %> diff --git a/lib/active_support_json_proxy.rb b/lib/active_support_json_proxy.rb new file mode 100644 index 0000000..177018b --- /dev/null +++ b/lib/active_support_json_proxy.rb @@ -0,0 +1,13 @@ +# Remove this and replace with `JSON` after upgrading to Rails 4.2 + +class ActiveSupportJsonProxy + + def self.dump(object) + ActiveSupport::JSON.encode(object) unless object.nil? + end + + def self.load(string) + ActiveSupport::JSON.decode(string) if string.present? + end + +end diff --git a/spec/api/asciicast_create_spec.rb b/spec/api/asciicast_create_spec.rb index 6e3516e..47aaf64 100644 --- a/spec/api/asciicast_create_spec.rb +++ b/spec/api/asciicast_create_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe "Asciicast creation" do diff --git a/spec/api/asciicast_show_spec.rb b/spec/api/asciicast_show_spec.rb index c3f7182..5e3315a 100644 --- a/spec/api/asciicast_show_spec.rb +++ b/spec/api/asciicast_show_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe "Asciicast retrieval" do diff --git a/spec/controllers/account_merges_controller_spec.rb b/spec/controllers/account_merges_controller_spec.rb index 224b71a..3558a93 100644 --- a/spec/controllers/account_merges_controller_spec.rb +++ b/spec/controllers/account_merges_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AccountMergesController do diff --git a/spec/controllers/api/asciicasts_controller_spec.rb b/spec/controllers/api/asciicasts_controller_spec.rb index c24228a..a1a082e 100644 --- a/spec/controllers/api/asciicasts_controller_spec.rb +++ b/spec/controllers/api/asciicasts_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' module Api describe AsciicastsController do diff --git a/spec/controllers/api_tokens_controller_spec.rb b/spec/controllers/api_tokens_controller_spec.rb index b3a9458..96f3d74 100644 --- a/spec/controllers/api_tokens_controller_spec.rb +++ b/spec/controllers/api_tokens_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe ApiTokensController do diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 30b0dab..8fac9f5 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' class FakesController < ApplicationController diff --git a/spec/controllers/asciicasts_controller_spec.rb b/spec/controllers/asciicasts_controller_spec.rb index 36ce561..72bc35e 100644 --- a/spec/controllers/asciicasts_controller_spec.rb +++ b/spec/controllers/asciicasts_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' shared_examples_for 'guest user trying to modify' do it { should redirect_to(login_path) } diff --git a/spec/controllers/docs_controller_spec.rb b/spec/controllers/docs_controller_spec.rb index 37dbfa8..6f5c235 100644 --- a/spec/controllers/docs_controller_spec.rb +++ b/spec/controllers/docs_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe DocsController do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 5ddea24..99a0745 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe HomeController do diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index d86637a..1195677 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe PagesController do diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index f5c454e..505b53f 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe SessionsController do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 69ce4bd..89d5b46 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe UsersController do diff --git a/spec/decorators/application_decorator_spec.rb b/spec/decorators/application_decorator_spec.rb index 729c80a..9aa4d47 100644 --- a/spec/decorators/application_decorator_spec.rb +++ b/spec/decorators/application_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe ApplicationDecorator do end diff --git a/spec/decorators/asciicast_decorator_spec.rb b/spec/decorators/asciicast_decorator_spec.rb index 7d9244b..edafc31 100644 --- a/spec/decorators/asciicast_decorator_spec.rb +++ b/spec/decorators/asciicast_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastDecorator do include Draper::ViewHelpers diff --git a/spec/decorators/brush_decorator_spec.rb b/spec/decorators/brush_decorator_spec.rb index fc54e65..1ad5819 100644 --- a/spec/decorators/brush_decorator_spec.rb +++ b/spec/decorators/brush_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe BrushDecorator do let(:decorator) { described_class.new(brush) } diff --git a/spec/decorators/cell_decorator_spec.rb b/spec/decorators/cell_decorator_spec.rb index f177015..c9caa8d 100644 --- a/spec/decorators/cell_decorator_spec.rb +++ b/spec/decorators/cell_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe CellDecorator do diff --git a/spec/decorators/helpers/avatar_helper_spec.rb b/spec/decorators/helpers/avatar_helper_spec.rb index 50f41dc..9029c3c 100644 --- a/spec/decorators/helpers/avatar_helper_spec.rb +++ b/spec/decorators/helpers/avatar_helper_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AvatarHelper do diff --git a/spec/decorators/omni_auth_credentials_spec.rb b/spec/decorators/omni_auth_credentials_spec.rb index de3ab58..91b4e00 100644 --- a/spec/decorators/omni_auth_credentials_spec.rb +++ b/spec/decorators/omni_auth_credentials_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe OmniAuthCredentials do diff --git a/spec/decorators/snapshot_decorator_spec.rb b/spec/decorators/snapshot_decorator_spec.rb index 54d032f..dadf65d 100644 --- a/spec/decorators/snapshot_decorator_spec.rb +++ b/spec/decorators/snapshot_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe SnapshotDecorator do diff --git a/spec/decorators/user_decorator_spec.rb b/spec/decorators/user_decorator_spec.rb index 45482e4..abef228 100644 --- a/spec/decorators/user_decorator_spec.rb +++ b/spec/decorators/user_decorator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe UserDecorator do diff --git a/spec/features/asciicast_spec.rb b/spec/features/asciicast_spec.rb index 3428047..a6d02b4 100644 --- a/spec/features/asciicast_spec.rb +++ b/spec/features/asciicast_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Asciicast page", :js => true do diff --git a/spec/features/asciicasts_spec.rb b/spec/features/asciicasts_spec.rb index f21c72c..d63cd53 100644 --- a/spec/features/asciicasts_spec.rb +++ b/spec/features/asciicasts_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Asciicast lists" do diff --git a/spec/features/docs_spec.rb b/spec/features/docs_spec.rb index a361bfd..b5b7e0b 100644 --- a/spec/features/docs_spec.rb +++ b/spec/features/docs_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Docs" do diff --git a/spec/features/example_page_spec.rb b/spec/features/example_page_spec.rb index c79fa4a..ffa1f19 100644 --- a/spec/features/example_page_spec.rb +++ b/spec/features/example_page_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Example page with embedded player", :js => true do diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 0ab69be..d9c9b6c 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Homepage", :js => true do diff --git a/spec/features/pages_spec.rb b/spec/features/pages_spec.rb index 3ab6ca0..907efbf 100644 --- a/spec/features/pages_spec.rb +++ b/spec/features/pages_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "Static pages" do diff --git a/spec/features/playback_spec.rb b/spec/features/playback_spec.rb index 0a7300c..20177d9 100644 --- a/spec/features/playback_spec.rb +++ b/spec/features/playback_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe 'Asciicast playback', :js => true, :slow => true do diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 6918d76..df9e667 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' feature "User's profile" do diff --git a/spec/features/widget_spec.rb b/spec/features/widget_spec.rb index 69487ac..3aa6b72 100644 --- a/spec/features/widget_spec.rb +++ b/spec/features/widget_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' routes = proc do get '/test/widget/:id' => 'test_widget#show' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index ca1f43b..44b85fe 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe ApplicationHelper do diff --git a/spec/models/api_token_spec.rb b/spec/models/api_token_spec.rb index 730c893..77b49fd 100644 --- a/spec/models/api_token_spec.rb +++ b/spec/models/api_token_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe ApiToken do diff --git a/spec/models/asciicast_params_spec.rb b/spec/models/asciicast_params_spec.rb index 8a00d2d..bdd6925 100644 --- a/spec/models/asciicast_params_spec.rb +++ b/spec/models/asciicast_params_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' require 'stringio' describe AsciicastParams do diff --git a/spec/models/asciicast_spec.rb b/spec/models/asciicast_spec.rb index 36dbfc6..59dec8c 100644 --- a/spec/models/asciicast_spec.rb +++ b/spec/models/asciicast_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' require 'tempfile' describe Asciicast do diff --git a/spec/models/brush_spec.rb b/spec/models/brush_spec.rb index 0ec6957..92a5afe 100644 --- a/spec/models/brush_spec.rb +++ b/spec/models/brush_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Brush do let(:brush) { Brush.new(attributes) } diff --git a/spec/models/buffered_stdout_spec.rb b/spec/models/buffered_stdout_spec.rb index 511c5c8..c2a10d0 100644 --- a/spec/models/buffered_stdout_spec.rb +++ b/spec/models/buffered_stdout_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe BufferedStdout do diff --git a/spec/models/cell_spec.rb b/spec/models/cell_spec.rb index e85998f..25c4b1c 100644 --- a/spec/models/cell_spec.rb +++ b/spec/models/cell_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Cell do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 428c39b..a8163ed 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Comment do diff --git a/spec/models/cursor_spec.rb b/spec/models/cursor_spec.rb index 7e64dd1..c8364f0 100644 --- a/spec/models/cursor_spec.rb +++ b/spec/models/cursor_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Cursor do diff --git a/spec/models/frame_diff_list_spec.rb b/spec/models/frame_diff_list_spec.rb index 6fe0bd0..31c771b 100644 --- a/spec/models/frame_diff_list_spec.rb +++ b/spec/models/frame_diff_list_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe FrameDiffList do diff --git a/spec/models/frame_diff_spec.rb b/spec/models/frame_diff_spec.rb index ce56a69..ae709d3 100644 --- a/spec/models/frame_diff_spec.rb +++ b/spec/models/frame_diff_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe FrameDiff do diff --git a/spec/models/frame_spec.rb b/spec/models/frame_spec.rb index 6b43b21..5245eec 100644 --- a/spec/models/frame_spec.rb +++ b/spec/models/frame_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Frame do diff --git a/spec/models/grid_spec.rb b/spec/models/grid_spec.rb index e1fbf30..f8db015 100644 --- a/spec/models/grid_spec.rb +++ b/spec/models/grid_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Grid do diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index 3022944..0093ea4 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Like do end diff --git a/spec/models/snapshot_spec.rb b/spec/models/snapshot_spec.rb index 8084f42..1a42acb 100644 --- a/spec/models/snapshot_spec.rb +++ b/spec/models/snapshot_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Snapshot do diff --git a/spec/models/stdout_spec.rb b/spec/models/stdout_spec.rb index 817060e..1c2f6ca 100644 --- a/spec/models/stdout_spec.rb +++ b/spec/models/stdout_spec.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -require 'spec_helper' +require 'rails_helper' describe Stdout do let(:stdout) { Stdout.new('spec/fixtures/stdout.decompressed', diff --git a/spec/models/terminal_spec.rb b/spec/models/terminal_spec.rb index f8ce82e..ab91503 100644 --- a/spec/models/terminal_spec.rb +++ b/spec/models/terminal_spec.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -require 'spec_helper' +require 'rails_helper' describe Terminal do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 60c6dec..785fc8b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe User do diff --git a/spec/policies/asciicast_policy_spec.rb b/spec/policies/asciicast_policy_spec.rb index a2bc432..bd8a7d3 100644 --- a/spec/policies/asciicast_policy_spec.rb +++ b/spec/policies/asciicast_policy_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastPolicy do diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb index 381939f..18ee0d3 100644 --- a/spec/policies/user_policy_spec.rb +++ b/spec/policies/user_policy_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe UserPolicy do diff --git a/spec/presenters/asciicast_page_presenter_spec.rb b/spec/presenters/asciicast_page_presenter_spec.rb index 81b7584..8cca0ea 100644 --- a/spec/presenters/asciicast_page_presenter_spec.rb +++ b/spec/presenters/asciicast_page_presenter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastPagePresenter do diff --git a/spec/presenters/bare_asciicast_page_presenter_spec.rb b/spec/presenters/bare_asciicast_page_presenter_spec.rb index a114408..3264319 100644 --- a/spec/presenters/bare_asciicast_page_presenter_spec.rb +++ b/spec/presenters/bare_asciicast_page_presenter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe BareAsciicastPagePresenter do diff --git a/spec/presenters/browse_page_presenter_spec.rb b/spec/presenters/browse_page_presenter_spec.rb index 2008dfa..01d841f 100644 --- a/spec/presenters/browse_page_presenter_spec.rb +++ b/spec/presenters/browse_page_presenter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe BrowsePagePresenter do diff --git a/spec/presenters/home_page_presenter_spec.rb b/spec/presenters/home_page_presenter_spec.rb index ad2bd90..f87bc2b 100644 --- a/spec/presenters/home_page_presenter_spec.rb +++ b/spec/presenters/home_page_presenter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe HomePagePresenter do diff --git a/spec/presenters/user_page_presenter_spec.rb b/spec/presenters/user_page_presenter_spec.rb index 6ba1b08..f14724c 100644 --- a/spec/presenters/user_page_presenter_spec.rb +++ b/spec/presenters/user_page_presenter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe UserPagePresenter do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..3df3c98 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,64 @@ +if ENV["CI"] && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") + require 'simplecov' + require 'coveralls' + + SimpleCov.formatter = Coveralls::SimpleCov::Formatter + SimpleCov.start 'rails' do + add_group "Decorators", "app/decorators" + add_group "Presenters", "app/presenters" + end +end + +ENV["RAILS_ENV"] ||= 'test' +ENV['CARRIERWAVE_STORAGE_DIR_PREFIX'] ||= 'uploads/test/' + +require File.expand_path("../../config/environment", __FILE__) +ActiveRecord::Migration.maintain_test_schema! + +require 'rspec/rails' +require 'capybara/rspec' +require 'capybara/poltergeist' +require 'sidekiq/testing' +require 'pundit/rspec' + +Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } +Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f } + +Capybara.javascript_driver = :poltergeist + +OmniAuth.config.test_mode = true + +CarrierWave.configure do |config| + config.storage = :file + config.enable_processing = false +end + +RSpec.configure do |config| + config.use_transactional_fixtures = false + config.infer_base_class_for_anonymous_controllers = false + config.infer_spec_type_from_file_location! + + config.include FactoryGirl::Syntax::Methods + config.include Asciinema::FixtureHelpers + config.include Asciinema::FeatureHelpers + + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + end + + config.before(:each) do + DatabaseCleaner.strategy = :transaction + end + + config.before(:each, :js => true) do + DatabaseCleaner.strategy = :truncation + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end +end diff --git a/spec/routing/asciicasts_spec.rb b/spec/routing/asciicasts_spec.rb index 0bb1747..b27aaf8 100644 --- a/spec/routing/asciicasts_spec.rb +++ b/spec/routing/asciicasts_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe "asciicasts routing" do diff --git a/spec/routing/connect_spec.rb b/spec/routing/connect_spec.rb index 85e8f76..aa12442 100644 --- a/spec/routing/connect_spec.rb +++ b/spec/routing/connect_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe 'connect routing' do it 'routes /connect/:api_token to api_tokens#create for api_token' do diff --git a/spec/serializers/asciicast_serializer_spec.rb b/spec/serializers/asciicast_serializer_spec.rb index 93e1d1d..9ef818c 100644 --- a/spec/serializers/asciicast_serializer_spec.rb +++ b/spec/serializers/asciicast_serializer_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastSerializer do diff --git a/spec/services/asciicast_creator_spec.rb b/spec/services/asciicast_creator_spec.rb index 387562a..217f2c0 100644 --- a/spec/services/asciicast_creator_spec.rb +++ b/spec/services/asciicast_creator_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastCreator do diff --git a/spec/services/asciicast_frames_file_updater_spec.rb b/spec/services/asciicast_frames_file_updater_spec.rb index f4fee69..28996d7 100644 --- a/spec/services/asciicast_frames_file_updater_spec.rb +++ b/spec/services/asciicast_frames_file_updater_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastFramesFileUpdater do diff --git a/spec/services/asciicast_processor_spec.rb b/spec/services/asciicast_processor_spec.rb index 369f052..d35c503 100644 --- a/spec/services/asciicast_processor_spec.rb +++ b/spec/services/asciicast_processor_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastProcessor do diff --git a/spec/services/asciicast_snapshot_updater_spec.rb b/spec/services/asciicast_snapshot_updater_spec.rb index d4c2916..c3c2dc7 100644 --- a/spec/services/asciicast_snapshot_updater_spec.rb +++ b/spec/services/asciicast_snapshot_updater_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastSnapshotUpdater do diff --git a/spec/services/film_spec.rb b/spec/services/film_spec.rb index 7c4e8d9..a8893c9 100644 --- a/spec/services/film_spec.rb +++ b/spec/services/film_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Film do diff --git a/spec/services/json_file_writer_spec.rb b/spec/services/json_file_writer_spec.rb index d303aaa..2829069 100644 --- a/spec/services/json_file_writer_spec.rb +++ b/spec/services/json_file_writer_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe JsonFileWriter do diff --git a/spec/services/timing_parser_spec.rb b/spec/services/timing_parser_spec.rb index ccb0384..34fe399 100644 --- a/spec/services/timing_parser_spec.rb +++ b/spec/services/timing_parser_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe TimingParser do diff --git a/spec/services/view_counter_spec.rb b/spec/services/view_counter_spec.rb index 562b27b..1ff768f 100644 --- a/spec/services/view_counter_spec.rb +++ b/spec/services/view_counter_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe ViewCounter do let(:view_counter) { described_class.new } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4a621f7..7943f24 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,64 +1,78 @@ -if ENV["CI"] && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby") - require 'simplecov' - require 'coveralls' - - SimpleCov.formatter = Coveralls::SimpleCov::Formatter - SimpleCov.start 'rails' do - add_group "Decorators", "app/decorators" - add_group "Presenters", "app/presenters" - end -end - -ENV["RAILS_ENV"] ||= 'test' -ENV['CARRIERWAVE_STORAGE_DIR_PREFIX'] ||= 'uploads/test/' - -require File.expand_path("../../config/environment", __FILE__) - -require 'rspec/rails' -require 'capybara/rspec' -require 'capybara/poltergeist' -require 'sidekiq/testing' -require 'pundit/rspec' - -Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } -Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f } - -Capybara.javascript_driver = :poltergeist +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause this +# file to always be loaded, without a need to explicitly require it in any files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, make a +# separate helper file that requires this one and then use it only in the specs +# that actually need it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # The settings below are suggested to provide a good initial experience + # with RSpec, but feel free to customize to your heart's content. -OmniAuth.config.test_mode = true + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true -CarrierWave.configure do |config| - config.storage = :file - config.enable_processing = false -end + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end -RSpec.configure do |config| - config.mock_with :rspec - config.use_transactional_fixtures = false - config.infer_base_class_for_anonymous_controllers = false - config.order = "random" + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 - config.include FactoryGirl::Syntax::Methods - config.include Asciinema::FixtureHelpers - config.include Asciinema::FeatureHelpers + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random - config.before(:suite) do - DatabaseCleaner.clean_with(:truncation) - end + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed - config.before(:each) do - DatabaseCleaner.strategy = :transaction + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax + expectations.syntax = :expect end - config.before(:each, :js => true) do - DatabaseCleaner.strategy = :truncation - end + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + mocks.syntax = :expect - config.before(:each) do - DatabaseCleaner.start + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended. + mocks.verify_partial_doubles = true end - config.after(:each) do - DatabaseCleaner.clean - end end diff --git a/spec/strategies/auth_cookie_strategy_spec.rb b/spec/strategies/auth_cookie_strategy_spec.rb index a480158..ef27e77 100644 --- a/spec/strategies/auth_cookie_strategy_spec.rb +++ b/spec/strategies/auth_cookie_strategy_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' require 'rack/mock' describe AuthCookieStrategy do diff --git a/spec/support/sidekiq_matchers.rb b/spec/support/sidekiq_matchers.rb index 07d957a..12003d9 100644 --- a/spec/support/sidekiq_matchers.rb +++ b/spec/support/sidekiq_matchers.rb @@ -2,16 +2,28 @@ RSpec::Matchers.define :have_queued_job do |*expected| match do |actual| actual.jobs.any? { |job| Array(expected) == job["args"] } end - - failure_message_for_should do |actual| + failure_message do |actual| "expected that #{actual} would have a job queued with #{expected}" end - - failure_message_for_should_not do |actual| + failure_message_when_negated do |actual| "expected that #{actual} would not a have a job queued with #{expected}" end - description do "have a job queued with #{expected}" end end + +RSpec::Matchers.define :have_queued_job_at do |at,*expected| + match do |actual| + actual.jobs.any? { |job| job["args"] == Array(expected) && job["at"].to_i == at.to_i } + end + failure_message do |actual| + "expected that #{actual} would have a job queued with #{expected} at time #{at}" + end + failure_message_when_negated do |actual| + "expected that #{actual} would not a have a job queued with #{expected} at time #{at}" + end + description do + "have a job queued with #{expected} at time #{at}" + end +end diff --git a/spec/uploaders/bzip2_uploader_spec.rb b/spec/uploaders/bzip2_uploader_spec.rb index 7f496ad..5172258 100644 --- a/spec/uploaders/bzip2_uploader_spec.rb +++ b/spec/uploaders/bzip2_uploader_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe Bzip2Uploader do let(:uploader) { Bzip2Uploader.new(user, :photo) } diff --git a/spec/workers/asciicast_worker_spec.rb b/spec/workers/asciicast_worker_spec.rb index 97344ce..29d3805 100644 --- a/spec/workers/asciicast_worker_spec.rb +++ b/spec/workers/asciicast_worker_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'rails_helper' describe AsciicastWorker do