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

Remove archived application functionality #1444

Merged
merged 2 commits into from
Apr 15, 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
8 changes: 1 addition & 7 deletions app/controllers/applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ class ApplicationsController < ApplicationController
ENVIRONMENTS = %w[production staging integration].freeze

def index
@applications = Application.where(archived: false)
@environments = ENVIRONMENTS
end

def archived
@applications = Application.where(archived: true)
@applications = Application.all
@environments = ENVIRONMENTS
end

Expand Down Expand Up @@ -110,7 +105,6 @@ def find_application

def application_params
params.require(:application).permit(
:archived,
:id,
:name,
:default_branch,
Expand Down
1 change: 0 additions & 1 deletion app/controllers/deployments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def create

return if application.nil?

application.archived = false
application.save!
Deployment.create!(deployment_params.merge(application:))
head :ok
Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def navigation_items

items << { text: "Applications", href: applications_path, active: is_current?(applications_path) }
items << { text: "Deploys", href: activity_path, active: is_current?(activity_path) }
items << { text: "Archived", href: archived_applications_path, active: is_current?(archived_applications_path) }
items << { text: "Settings", href: site_path, active: is_current?(site_path) }
items << { text: "Stats", href: stats_path, active: is_current?(stats_path) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def self.cd_statuses
end

def self.out_of_sync
where(archived: false).reject do |app|
all.reject do |app|
app.status == :all_environments_match
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/application_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationSerializer < ActiveModel::Serializer
attributes :name, :shortname, :archived, :deploy_freeze
attributes :name, :shortname, :deploy_freeze
attribute :status_notes, key: :notes
attribute :repo_url, key: :repository_url
attribute :default_branch, key: :repository_default_branch
Expand Down
12 changes: 0 additions & 12 deletions app/views/applications/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@
error_message: @application.errors[:status_notes].first,
} %>

<input type="hidden" name="application[archived]" value="0" />
<%= render "govuk_publishing_components/components/checkboxes", {
name: "application[archived]",
items: [
{
label: "Archived?",
value: "1",
checked: @application.archived
}
]
} %>

<% hint_text = capture do %>
Adds 'Automatic deployments disabled' badge in the Release app.

Expand Down
15 changes: 0 additions & 15 deletions app/views/applications/archived.html.erb

This file was deleted.

7 changes: 0 additions & 7 deletions app/views/applications/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

<%= render partial: "shared/application_header", locals: { application: @application, tab: "status" } %>

<% if @application.archived %>
<%= render "govuk_publishing_components/components/notice", {
title: "This application has been marked as archived.",
margin_bottom: 4,
} %>
<% end %>

<%= render 'status_notes', application: @application %>

<%= render "govuk_publishing_components/components/heading", {
Expand Down
4 changes: 0 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
ReleaseApp::Application.routes.draw do
resources :applications do
collection do
get "archived", to: "applications#archived"
end

member do
get :deploy
get :stats
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20240415132317_remove_archived_from_applications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class RemoveArchivedFromApplications < ActiveRecord::Migration[7.1]
def up
Application.where(archived: true).delete_all

remove_column :applications, :archived
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_02_21_154421) do
ActiveRecord::Schema[7.1].define(version: 2024_04_15_132317) do
create_table "applications", id: :integer, charset: "latin1", force: :cascade do |t|
t.string "name"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.string "status_notes"
t.string "shortname"
t.boolean "archived", default: false, null: false
t.boolean "deploy_freeze", default: false, null: false
t.string "default_branch", default: "main", null: false
t.index ["name"], name: "index_applications_on_name", unique: true
Expand Down
1 change: 0 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
{ name: "Static" },
{ name: "Support" },
{ name: "Whitehall" },
{ name: "Data insight non-govuk reach collector", archived: true },
]

applications.each do |application_hash|
Expand Down
1 change: 0 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Examples:
{
"name": "Smart Answers",
"shortname": "smartanswers",
"archived": false,
"deploy_freeze": true,
"notes": "",
"repository_url": "https://github.com/alphagov/smart-answers",
Expand Down
18 changes: 1 addition & 17 deletions test/functional/applications_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ApplicationsControllerTest < ActionController::TestCase
stub_request(:get, "http://docs.publishing.service.gov.uk/apps.json").to_return(status: 200, body: response_body, headers: {})
@app1 = FactoryBot.create(:application, name: "app1", default_branch: "main")
@app2 = FactoryBot.create(:application, name: "app2")
@app3 = FactoryBot.create(:application, name: "app3", archived: true)
@deploy1 = FactoryBot.create(
:deployment,
application: @app1,
Expand All @@ -21,7 +20,7 @@ class ApplicationsControllerTest < ActionController::TestCase
)
end

should "list unarchived applications" do
should "list applications" do
get :index
assert_select ".release__application-link", count: 2
end
Expand Down Expand Up @@ -231,7 +230,6 @@ class ApplicationsControllerTest < ActionController::TestCase
assert_equal "Application 1", body["name"]
assert_equal "application-1", body["shortname"]
assert_equal "", body["notes"]
assert_equal false, body["archived"]
assert_equal false, body["deploy_freeze"]
assert_equal false, body["continuously_deployed"]
assert_equal "https://github.com/alphagov/application-1", body["repository_url"]
Expand Down Expand Up @@ -335,20 +333,6 @@ class ApplicationsControllerTest < ActionController::TestCase
end
end

context "GET archived" do
setup do
stub_request(:get, "http://docs.publishing.service.gov.uk/apps.json").to_return(status: 200, body: "", headers: {})
@app1 = FactoryBot.create(:application, name: "app1")
@app2 = FactoryBot.create(:application, name: "app2")
@app3 = FactoryBot.create(:application, name: "app3", archived: true)
end

should "show only archived applications" do
get :archived
assert_select ".gem-c-table .govuk-table__body .govuk-table__row", count: 1
end
end

context "GET deploy" do
setup do
stub_request(:get, "http://docs.publishing.service.gov.uk/apps.json").to_return(status: 200, body: "", headers: {})
Expand Down
7 changes: 0 additions & 7 deletions test/functional/deployments_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class DeploymentsControllerTest < ActionController::TestCase
assert_equal "v123", deployment.deployed_sha
end

should "unarchive an archived application" do
app = FactoryBot.create(:application, name: "App", archived: true)
post :create, params: { repo: "org/app", deployment: { version: "release_123", environment: "staging" } }
app.reload
assert_equal false, app.archived
end

context "application doesn't exist" do
should "create an application" do
assert_difference [-> { Deployment.count }, -> { Application.count }], 1 do
Expand Down
16 changes: 0 additions & 16 deletions test/unit/application_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ class ApplicationTest < ActiveSupport::TestCase
assert application.errors[:name].include?("has already been taken")
end

should "default to not being archived" do
application = Application.new(@atts)

assert_equal false, application.archived
end

should "default to not be in deploy freeze" do
application = Application.new(@atts)

Expand Down Expand Up @@ -331,15 +325,5 @@ class ApplicationTest < ActiveSupport::TestCase

assert_equal [app, app2], Application.out_of_sync
end

should "not include apps which have been archived" do
app = FactoryBot.create(:application, name: "Manuals frontend", archived: true)

FactoryBot.create(:deployment, application: app, version: "111", environment: "production")
FactoryBot.create(:deployment, application: app, version: "111", environment: "staging")
FactoryBot.create(:deployment, application: app, version: "222", environment: "integration")

assert_equal [], Application.out_of_sync
end
end
end
Loading