Skip to content

Commit

Permalink
Merge pull request #86 from alphagov/allow-changes-to-package-json
Browse files Browse the repository at this point in the history
Allow changes to package.json
  • Loading branch information
ChrisBAshton authored Oct 18, 2024
2 parents 3853081 + ceff476 commit 130ff53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pull_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def validate_single_commit
def validate_files_changed
commit = GitHubClient.instance.commit("alphagov/#{@api_response.base.repo.name}", @api_response.head.sha)
files_changed = commit.files.map(&:filename)
allowed_files = ["yarn.lock", "Gemfile.lock", "Gemfile", "#{@api_response.base.repo.name}.gemspec"]
allowed_files = ["yarn.lock", "package.json", "Gemfile.lock", "Gemfile", "#{@api_response.base.repo.name}.gemspec"]
(files_changed - allowed_files).empty?
end

Expand Down
10 changes: 10 additions & 0 deletions spec/lib/pull_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ def create_pull_request_instance
expect(pr.validate_files_changed).to eq(true)
end

it "returns true if PR changes package.json" do
pkg_json = head_commit_api_response[:files].first.dup
pkg_json[:filename] = "package.json"
head_commit_api_response[:files] << pkg_json
stub_remote_commit(head_commit_api_response)

pr = PullRequest.new(pull_request_api_response)
expect(pr.validate_files_changed).to eq(true)
end

it "returns false if PR changes anything else" do
head_commit_api_response[:files][0][:filename] = "something_else.rb"
stub_remote_commit(head_commit_api_response)
Expand Down

0 comments on commit 130ff53

Please sign in to comment.