-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[1845] prevent assets from being registered multiple times #2139
[1845] prevent assets from being registered multiple times #2139
Conversation
end | ||
|
||
it "should clear all existing stylesheets" do | ||
MockRegistration.register_stylesheet "active_admin.css" | ||
MockRegistration.stylesheets.length.should == 1 | ||
MockRegistration.clear_stylesheets! | ||
MockRegistration.stylesheets.length.should == 0 | ||
MockRegistration.stylesheets.length.should be_empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you want the following instead, as this spec fails:
MockRegistration.stylesheets.should be_empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, yes I did.
JavaScript and CSS registrations are now stored inside a Set and a Hash, respectively, to ensure that no duplicates are created.
Okay, passing now. Look good to you @macfanatic? |
Love it. This was actually one of the first, if not the first, bits of code I contributed to AA. :) |
[1845] prevent assets from being registered multiple times
I've seen set, but didn't know why you would use one over a Hash. |
For practical purposes, a Set is an Array with guaranteed uniqueness. It behaves just like an Array, it's just that the back-end object that everything is stored in is a Hash. |
JavaScript and CSS registrations are now stored inside a Set and a
Hash, respectively, to ensure that no duplicates are created.
For #1845