Skip to content
New issue

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

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

Already on GitHub? # to your account

Make extensions and content types white/blacklists take a string, regexp, or array of values #1825

Merged

Conversation

mehlah
Copy link
Member

@mehlah mehlah commented Jan 5, 2016

Writing

def content_type_whitelist
  [/image\//]
end

isn't very convenient or intuitive due to the array.

This PR suggests to let #content_type_whitelist and extension_whitelist takes either a
string, a regexp, or an array of values (same thing for blacklists).

@@ -14,7 +14,7 @@ module ContentTypeBlacklist
#
# === Returns
#
# [NilClass, Array[String,Regexp]] a blacklist of content types which are not allowed to be uploaded
# [NilClass, String, Regexp, Array[String,Regexp]] a blacklist of content types which are not allowed to be uploaded
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, can you add a space in Array[String,Regexp] so that it becomes Array[String, Regexp].

@thomasfedb
Copy link
Contributor

Can you rename the relevant specs to be in keeping with the names for your new specs, eg: "accepts a single extension string value" would have the counterpart "accepts an array of extension string values".

Or even better, something like:

context "when there is a blacklist" do
  context "when the backlist is a single value" do
    # ...
  end

  context "when the backlist is an array of values" do
    # ...
  end
end

`#content_type_whitelist` and `extension_whitelist` now takes either a
string, a regexp, or an array of values (same thing for blacklists).
@mehlah mehlah force-pushed the refine-white/blacklists-options branch from b6b10f7 to 6bbaa6c Compare January 10, 2016 18:30
@mehlah
Copy link
Member Author

mehlah commented Jan 10, 2016

@thomasfedb Thanks for your comments. I addressed those to make the specs perfectly symmetric and rebased against master.

@thomasfedb
Copy link
Contributor

Thanks @mehlah! ✨

thomasfedb added a commit that referenced this pull request Jan 10, 2016
Allow whitelists and blacklists to accept single values
@thomasfedb thomasfedb merged commit 424f028 into carrierwaveuploader:master Jan 10, 2016
@mehlah mehlah deleted the refine-white/blacklists-options branch January 10, 2016 19:00
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants