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

(PDK-1354) Default template ref for custom templates should always be master #677

Merged
merged 1 commit into from
Jun 13, 2019

Conversation

rodjek
Copy link
Contributor

@rodjek rodjek commented Jun 7, 2019

No description provided.

@coveralls
Copy link

coveralls commented Jun 7, 2019

Coverage Status

Coverage increased (+0.002%) to 93.071% when pulling cb4574b on rodjek:pdk-1354 into 87dbc6c on puppetlabs:master.

@@ -207,11 +207,14 @@ def self.templates(opts)
end

# @returns String
def self.default_template_ref
def self.default_template_ref(uri = nil)
Copy link
Contributor

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

Copy link
Contributor

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')
Copy link
Contributor

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) }
Copy link
Contributor

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?

Copy link
Contributor

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)

Copy link
Contributor

@scotje scotje left a 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)
Copy link
Contributor

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.

@rodjek rodjek merged commit fa41bb0 into puppetlabs:master Jun 13, 2019
@rodjek rodjek deleted the pdk-1354 branch June 13, 2019 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants