diff --git a/.travis.yml b/.travis.yml index da4e27666..e4b310171 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ cache: bundler: true directories: - app/assets/images - - tmp/cache/assets/test + - tmp/cache/assets branches: only: diff --git a/Gemfile b/Gemfile index 19f037bb3..c19e6f890 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem "bootstrap-sass", "3.3.7" gem "bootstrap-switch-rails", "3.3.3" gem "compass-rails", "3.0.2" gem "sass-rails", "5.0.6" -gem "sprockets", "2.12.4" +gem "sprockets-rails", "3.2.0" # Database @@ -312,7 +312,4 @@ group :development, :test do gem "jasmine-jquery-rails", "2.0.3" gem "rails-assets-jasmine-ajax", "3.3.1", source: "https://rails-assets.org" gem "sinon-rails", "1.15.0" - - # silence assets - gem "quiet_assets", "1.1.0" end diff --git a/Gemfile.lock b/Gemfile.lock index 50486ca8d..ddea815ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -287,7 +287,6 @@ GEM tilt (>= 1.2) hashdiff (0.3.4) hashie (3.5.6) - hike (1.2.3) hitimes (1.2.5) http (2.2.2) addressable (~> 2.3) @@ -464,8 +463,6 @@ GEM byebug (~> 9.0) pry (~> 0.10) public_suffix (2.0.5) - quiet_assets (1.1.0) - railties (>= 3.1, < 5.0) rack (1.6.8) rack-cors (1.0.1) rack-google-analytics (1.2.0) @@ -657,15 +654,13 @@ GEM spring (>= 0.9.1) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - 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.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) state_machines (0.5.0) string-direction (1.2.0) yard (~> 0.8) @@ -686,7 +681,7 @@ GEM activerecord (>= 3.2) thor (0.19.1) thread_safe (0.3.6) - tilt (1.4.1) + tilt (2.0.8) timecop (0.9.1) timers (4.1.2) hitimes @@ -829,7 +824,6 @@ DEPENDENCIES pronto-scss (= 0.9.1) pry pry-byebug - quiet_assets (= 1.1.0) rack-cors (= 1.0.1) rack-google-analytics (= 1.2.0) rack-piwik (= 0.3.0) @@ -879,7 +873,7 @@ DEPENDENCIES spring (= 2.0.2) spring-commands-cucumber (= 1.0.1) spring-commands-rspec (= 1.0.4) - sprockets (= 2.12.4) + sprockets-rails (= 3.2.0) string-direction (= 1.2.0) test_after_commit (= 1.1.0) thor (= 0.19.1) diff --git a/app/assets/javascripts/jsxc.js b/app/assets/javascripts/jsxc.js index 9e90634ca..66ed5d622 100644 --- a/app/assets/javascripts/jsxc.js +++ b/app/assets/javascripts/jsxc.js @@ -1,5 +1,5 @@ //= require emojione -//= require favico.js +//= require favico.js/favico //= require jquery.ui/ui/resizable //= require jquery.ui/ui/draggable diff --git a/config/environments/development.rb b/config/environments/development.rb index 2d00a9b03..c32bb8287 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -32,6 +32,9 @@ Diaspora::Application.configure do # Expands the lines which load the assets config.assets.debug = true + # No assets request logging + config.assets.quiet = true + # Set the logging destination(s) config.log_to = %w[stdout file] diff --git a/config/environments/test.rb b/config/environments/test.rb index ad12d1620..7df9c1b93 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -16,6 +16,20 @@ Diaspora::Application.configure do config.serve_static_files = true config.static_cache_control = "public, max-age=3600" + # No assets request logging + config.assets.quiet = true + + # Precompile poltergeist_disable_transition.css for tests + config.assets.precompile += %w[poltergeist_disable_transition.css] + + # Don't precompile all themes for tests + config.assets.precompile -= %w[color_themes/*/desktop.css color_themes/*/mobile.css] + config.assets.precompile += %w[ + color_themes/original/desktop.css + color_themes/dark_green/desktop.css + color_themes/original/mobile.css + ] + # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/logging.rb b/config/logging.rb index 57cf39b0a..2c674562d 100644 --- a/config/logging.rb +++ b/config/logging.rb @@ -103,3 +103,10 @@ Logging::Rails.configure do |config| end end end + +# Include LoggerSilence from ActiveSupport. This is needed to silent assets +# requests with `config.assets.quiet`, because the default silence method of +# the logging gem is no-op. See: https://github.com/TwP/logging/issues/11 +Logging::Logger.send :alias_method, :local_level, :level +Logging::Logger.send :alias_method, :local_level=, :level= +Logging::Logger.send :include, LoggerSilence diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 9cbd410e2..0bf591cfb 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -15,7 +15,7 @@ namespace :assets do logger = ::Logging::Logger["assets:non_digest_assets"] non_digest_assets = Diaspora::Application.config.assets.non_digest_assets - manifest_path = Dir.glob(File.join(Rails.root, "public/assets/manifest-*.json")).first + manifest_path = Dir.glob(Rails.root.join("public", "assets", ".sprockets-manifest-*.json")).first JSON.load(File.new(manifest_path))["assets"].each do |logical_path, digested_path| logical_pathname = Pathname.new(logical_path) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1109c2a4c..c7564c5be 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -54,13 +54,13 @@ describe ApplicationHelper, :type => :helper do end it 'includes jquery.js from asset pipeline' do - expect(helper.jquery_include_tag).to match(/jquery3\.js/) + expect(helper.jquery_include_tag).to match(/jquery3-[0-9a-f]{64}\.js/) expect(helper.jquery_include_tag).not_to match(/jquery\.com/) end end it 'inclues jquery_ujs.js' do - expect(helper.jquery_include_tag).to match(/jquery_ujs\.js/) + expect(helper.jquery_include_tag).to match(/jquery_ujs-[0-9a-f]{64}\.js/) end it "disables ajax caching" do diff --git a/spec/presenters/avatar_presenter_spec.rb b/spec/presenters/avatar_presenter_spec.rb index 0a7daea6a..f51b4ef83 100644 --- a/spec/presenters/avatar_presenter_spec.rb +++ b/spec/presenters/avatar_presenter_spec.rb @@ -10,11 +10,10 @@ describe AvatarPresenter do it "returns the default images if no images set" do @profile = FactoryGirl.create(:profile, person: alice.person) @presenter = AvatarPresenter.new(@profile) - expect(@presenter.base_hash).to eq( - small: "/assets/user/default.png", - medium: "/assets/user/default.png", - large: "/assets/user/default.png" - ) + expect(@presenter.base_hash.keys).to eq(%i[small medium large]) + expect(@presenter.base_hash[:small]).to match(%r{/assets/user/default-[0-9a-f]{64}\.png}) + expect(@presenter.base_hash[:medium]).to match(%r{/assets/user/default-[0-9a-f]{64}\.png}) + expect(@presenter.base_hash[:large]).to match(%r{/assets/user/default-[0-9a-f]{64}\.png}) end end end