Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprockets to use config.assets.prefix, with tests #3092

Merged
merged 1 commit into from Sep 23, 2011

Conversation

docunext
Copy link

A simple change to actionpack/lib/sprockets/helpers/rails_helpers.rb, based off this previous commit:

2684f17

which I found when encountering this problem:

http://www.ruby.code-experiments.com/blog/2011/09/a-problem-with-the-rails-31-asset-pipeline.html

I would appreciate feedback on the tests, specifically the "alternate asset prefix" test on line 345 of the updated sprockets_helper_test.rb.

Albert

@spastorino
Copy link
Contributor

I think just one test like ...

test "custom_asset_path" do
  @config.assets.prefix = '/s'
  assert_match %r{/s/logo-[0-9a-f]+.png},
  asset_path("logo.png")
end

is enough.

assert_match %r{<link href="/s/style-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />\n<link href="/s/application-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />},
stylesheet_link_tag(:application, :media => "print")
end

test "alternate asset prefix" do
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with the difference between stubs(:asset_prefix).returns("/themes/test") and @config.assets.prefix = '/s'. They appear to be the same, however it is not clear why the former apparently worked prior to this commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stubs method generate a stub for asset_prefix method, so when you invoke this method will always return "/themes/test". Using @config.assets.prefix = '/s' you're just configuring the prefix and using it you're testing properly without stubs, so go with @config.assets.prefix = '/s'

@docunext
Copy link
Author

Great! I will simplify the test later today and recommit.

@spastorino
Copy link
Contributor

Remember to squash all the commits into one and push -f to your master branch

@docunext
Copy link
Author

OK, that is done. Let me know if anything further is required, and thank you for the collaboration.

@docunext
Copy link
Author

Do I need to close the pull request to indicate that its ready to go, or does that cancel the request?

spastorino added a commit that referenced this pull request Sep 23, 2011
Sprockets to use config.assets.prefix, with tests
@spastorino spastorino merged commit 5dcb269 into rails:master Sep 23, 2011
spastorino added a commit that referenced this pull request Sep 23, 2011
Sprockets to use config.assets.prefix, with tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants