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

Fix normalising app name for deployments #1404

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/controllers/deployments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create
private

def application_by_repo
existing_apps = Application.where(name: repo_path)
existing_apps = Application.where(name: normalize_app_name(repo_path))

case existing_apps.length
when 0
Expand Down Expand Up @@ -64,8 +64,6 @@ def deployment_params
:deployed_sha,
:environment,
:id,
:jenkins_user_email,
:jenkins_user_name,
:repo,
:version,
)
Expand Down
12 changes: 5 additions & 7 deletions test/functional/deployments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@ class DeploymentsControllerTest < ActionController::TestCase
end
end

context "POST create using deployment information from Argo" do
context "POST create" do
setup do
stub_request(:get, "http://docs.publishing.service.gov.uk/apps.json").to_return(status: 200, body: "", headers: {})
end

should "create a deployment record" do
app = FactoryBot.create(:application, name: "App")
post :create, params: { repo: "org/app", deployment: { version: "release_123", environment: "staging", jenkins_user_email: "user@example.org", jenkins_user_name: "A User", deployed_sha: "02a570885766dc43d5e2432855bbffb342543906" } }
app = FactoryBot.create(:application, name: "App Name")
post :create, params: { repo: "org/app-name", deployment: { version: "v123", environment: "staging", deployed_sha: "v123" } }

deployment = app.reload.deployments.last
assert_not_nil deployment
assert_equal "release_123", deployment.version
assert_equal "v123", deployment.version
assert_equal "staging", deployment.environment
assert_equal "user@example.org", deployment.jenkins_user_email
assert_equal "A User", deployment.jenkins_user_name
assert_equal "02a570885766dc43d5e2432855bbffb342543906", deployment.deployed_sha
assert_equal "v123", deployment.deployed_sha
end

should "unarchive an archived application" do
Expand Down
Loading