Skip to content

Commit a98de1f

Browse files
committed
fix(tests) test on Rails 3.2, fix no-sprockets test
1 parent 215102e commit a98de1f

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ matrix:
2626
exclude:
2727
- rvm: 2.1
2828
gemfile: gemfiles/rails_3.2.gemfile
29-
- rvm: 2.3.0
30-
gemfile: gemfiles/rails_3.2.gemfile
3129
- rvm: 2.1
3230
gemfile: gemfiles/rails_4.0.gemfile
3331
- rvm: 2.1

Appraisals

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
appraise "rails-3.2" do
22
gem 'rails', '~> 3.2.21'
33
gem 'rack-cache', '~> 1.6.1'
4-
end
5-
6-
appraise "rails-4.0" do
7-
gem 'rails', '~> 4.0.13'
4+
# Modern turbolinks depends on `Rails.application.assets` which no-worky
5+
gem 'turbolinks', '~> 2.0'
86
end
97

108
appraise "rails-4.0.5" do
@@ -51,7 +49,6 @@ end
5149

5250
appraise "rails-5-no_sprockets" do
5351
gem 'rails', '~> 5.0.0'
54-
gem "turbolinks", "~> 5.0.0"
5552
end
5653

5754
appraise "rails-5-sprockets_4" do

gemfiles/rails_3.2.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ source "http://rubygems.org"
44

55
gem "rails", "~> 3.2.21"
66
gem "rack-cache", "~> 1.6.1"
7+
gem "turbolinks", "~> 2.0"
78

89
gemspec :path => "../"

gemfiles/rails_5_no_sprockets.gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
source "http://rubygems.org"
44

5-
gem "rails", "~> 5.0.0"
6-
gem "turbolinks", "~> 5.0.0", require: false
5+
gem "rails", "5.0.0"
76

87
gemspec :path => "../"

lib/react/server_rendering/yaml_manifest_container.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ module ServerRendering
66
# but sometimes, they're compiled to other directories (or other servers)
77
class YamlManifestContainer
88
def initialize
9-
@assets = YAML.load_file(::Rails.root.join("public", ::Rails.application.config.assets.prefix, "manifest.yml"))
9+
@assets = YAML.load_file(public_asset_path("manifest.yml"))
1010
end
1111

1212
def find_asset(logical_path)
1313
asset_path = @assets[logical_path] || raise("No compiled asset for #{logical_path}, was it precompiled?")
14-
asset_full_path = ::Rails.root.join("public", ::Rails.application.config.assets.prefix, asset_path)
15-
File.read(asset_full_path)
14+
File.read(public_asset_path(asset_path))
1615
end
1716

1817
def self.compatible?
1918
::Rails::VERSION::MAJOR == 3
2019
end
20+
21+
private
22+
23+
def public_asset_path(asset_name)
24+
asset_path = File.join("public", ::Rails.application.config.assets.prefix, asset_name)
25+
::Rails.root.join(asset_path)
26+
end
2127
end
2228
end
2329
end

react-rails.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
2525
s.add_development_dependency 'listen', '~> 3.0.0' # support Ruby 2.1
2626
s.add_development_dependency 'poltergeist', '>= 0.3.3'
2727
s.add_development_dependency 'test-unit', '~> 2.5'
28-
s.add_development_dependency 'turbolinks', '>= 2.0.0'
2928
s.add_development_dependency 'rails', '>= 3.2'
3029

3130
s.add_dependency 'coffee-script-source', '~>1.8'

test/react/server_rendering/sprockets_renderer_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class SprocketsRendererTest < ActiveSupport::TestCase
1010

1111
CALLBACKS.each do |callback_name|
1212
test "#render should pass prerender options to ##{callback_name}" do
13-
mocked_method = MiniTest::Mock.new
13+
mocked_method = Minitest::Mock.new
1414
mocked_method.expect :call, '', [
1515
"Todo",
1616
"{\"todo\":\"write tests\"}",

test/react/server_rendering/yaml_manifest_container_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ def test_find_asset_gets_asset_contents
1818
end
1919
end
2020
end
21-

0 commit comments

Comments
 (0)