-
Notifications
You must be signed in to change notification settings - Fork 104
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
(PDK-1354) Default template ref for custom templates should always be master #677
Conversation
@@ -207,11 +207,14 @@ def self.templates(opts) | |||
end | |||
|
|||
# @returns String | |||
def self.default_template_ref | |||
def self.default_template_ref(uri = nil) |
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.
This seems a little complex. Maybe this is better (not sure)?
def self.default_template_ref(uri = nil)
return 'master' if PDK::Util.development_mode?
return PDK::TEMPLATE_REF if uri.nil? # The default url always uses PDK::TEMPLATE_REF as the ref
uri = new(uri) unless uri.is_a?(self)
uri.default? ? PDK::TEMPLATE_REF : 'master'
end
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.
Yeah I think @glennsarti 's guard clause version is clearer.
@@ -161,7 +161,7 @@ | |||
|
|||
it 'returns the specified template' do | |||
allow(Gem).to receive(:win_platform?).and_return(true) | |||
expect(template_uri.to_s).to eq("C:\\cli-templates##{described_class.default_template_ref}") | |||
expect(template_uri.to_s).to eq('C:\cli-templates#master') |
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.
nit: Although it's not required, I've found just always using double slash makes it far less confusing e.g. \'
and \\
is still are valid escape sequences in single quoted strings.
@@ -302,37 +302,45 @@ | |||
end | |||
|
|||
describe '.default_template_ref' do | |||
subject { described_class.default_template_ref } | |||
subject { described_class.default_template_ref(uri) } |
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.
I don't see any tests for described_class.default_template_ref()
anywhere. Should these be added?
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.
The only thing I would be looking for is:
expect(described_class.default_template_ref()).to eq(PDK::TEMPLATE_REF)
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.
Overall looks good to me, I like the directness of the test cases.
Agreed with @glennsarti's feedback about simplifying the default_template_ref
class method using guard clauses and adding a test for the nil
arg case.
@@ -207,11 +207,14 @@ def self.templates(opts) | |||
end | |||
|
|||
# @returns String | |||
def self.default_template_ref | |||
def self.default_template_ref(uri = nil) |
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.
Yeah I think @glennsarti 's guard clause version is clearer.
No description provided.