Commit c7691f4b authored by Dave Pisek's avatar Dave Pisek

Reviewer feedback: comment and specs

parent 0a86046a
......@@ -14,10 +14,9 @@ export default {
},
computed: {
commitPath() {
// search for all occurences of "$COMMIT_SHA" within the given template, eg.: "/base/project/path/-/commit/$COMMIT_SHA"
// Search for all occurences of "$COMMIT_SHA" within the given template, eg.: "/base/project/path/-/commit/$COMMIT_SHA"
// NOTE: This should be swapped to using `String.prototype.replaceAll` and a raw string, once browser supported is wider (https://caniuse.com/?search=replaceAll)
const allCommitShaPlaceHolders = /\$COMMIT_SHA/g;
// Replace it with the actual commit hash
// NOTE: This can be swapped to using `String.prototype.replaceAll` once it's more widely supported (https://caniuse.com/?search=replaceAll)
return this.commitPathTemplate.replace(allCommitShaPlaceHolders, this.value);
},
},
......
......@@ -323,12 +323,11 @@ RSpec.describe CommitsHelper do
end
describe "#commit_path_template" do
let(:project) { create(:project, :repository) }
let(:project) { build(:project) }
let(:expected_path) { "/#{project.full_path}/-/commit/$COMMIT_SHA" }
it "returns the correct path" do
expect(helper.commit_path_template(project))
.to eq("/#{project.namespace.full_path}/#{project.name}/-/commit/$COMMIT_SHA")
end
end
subject { helper.commit_path_template(project) }
it { is_expected.to eq(expected_path) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment