Skip to content
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
3 changes: 1 addition & 2 deletions .review_apps/ecs_task_definition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ locals {
{ name = "SETTINGS__ACT_AS_USER_ENABLED", value = "true" },
{ name = "SETTINGS__AUTH_PROVIDER", value = "developer" },
{ name = "SETTINGS__FORMS_ENV", value = "review" },
{ name = "SETTINGS__FORMS_RUNNER__URL", value = "https://forms.service.gov.uk" },
{ name = "SETTINGS__FEATURES__WELSH", value = "true" }
{ name = "SETTINGS__FORMS_RUNNER__URL", value = "https://forms.service.gov.uk" }
]
}

Expand Down
8 changes: 0 additions & 8 deletions app/controllers/forms/welsh_translation_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ module Forms
class WelshTranslationController < FormsController
def new
authorize current_form, :can_edit_form?
return redirect_to form_path(current_form) unless welsh_enabled?

@welsh_translation_input = WelshTranslationInput.new(form: form_with_pages_and_conditions).assign_form_values
@table_presenter = Forms::TranslationTablePresenter.new
end

def create
authorize current_form, :can_edit_form?
return redirect_to form_path(current_form) unless welsh_enabled?

@welsh_translation_input = WelshTranslationInput.new(welsh_translation_params)
@table_presenter = Forms::TranslationTablePresenter.new
Expand All @@ -30,14 +28,12 @@ def create

def delete
authorize current_form, :can_edit_form?
return redirect_to form_path(current_form) unless welsh_enabled?

@delete_welsh_translation_input = Forms::DeleteWelshTranslationInput.new(form: current_form)
end

def destroy
authorize current_form, :can_edit_form?
return redirect_to form_path(current_form) unless welsh_enabled?

@delete_welsh_translation_input = Forms::DeleteWelshTranslationInput.new(delete_welsh_translation_params)

Expand Down Expand Up @@ -66,10 +62,6 @@ def preview_html
GovukFormsMarkdown.render(params[:markdown], locale: "cy")
end

def welsh_enabled?
FeatureService.new(group: current_form.group).enabled?(:welsh)
end

def welsh_translation_params
params.require(:forms_welsh_translation_input).permit(
*WelshTranslationInput.attribute_names,
Expand Down
2 changes: 0 additions & 2 deletions app/models/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ def as_form_document(live_at: nil, language: :en)
end

def has_welsh_translation?
return false unless FeatureService.new(group: group).enabled?(:welsh)

available_languages.include?("cy")
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Group < ApplicationRecord
self.ignored_columns += [:welsh_enabled]

belongs_to :organisation

belongs_to :creator, class_name: "User", optional: true
Expand Down
15 changes: 3 additions & 12 deletions app/services/form_task_list_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,15 @@ def initialize(form:, current_user:)
end

def all_sections
sections = [
[
create_form_section(section_number: 1),
payment_link_subsection,
how_you_get_completed_forms_section(section_number: 2),
how_you_get_completed_forms_optional_subsection,
privacy_and_contact_details_section(section_number: 3),
translations_section(section_number: 4),
make_form_live_section(section_number: 5),
].compact

last_sections = [make_form_live_section(section_number: 4)]

if FeatureService.new(group: @form.group).enabled?(:welsh)
last_sections = [
translations_section(section_number: 4),
make_form_live_section(section_number: 5),
]
end

sections + last_sections
end

private
Expand Down
9 changes: 2 additions & 7 deletions app/services/task_status_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def incomplete_tasks
end

def task_statuses
statuses = {
{
name_status:,
pages_status:,
declaration_status:,
Expand All @@ -31,13 +31,8 @@ def task_statuses
daily_submission_batch_status:,
share_preview_status:,
make_live_status:,
welsh_language_status:,
}

if FeatureService.new(group: @form.group).enabled?(:welsh)
statuses.merge!({ welsh_language_status: })
end

statuses
end

private
Expand Down
2 changes: 0 additions & 2 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
features:
exit_pages:
enabled_by_group: true
welsh:
enabled_by_group: true
org_admin_alerts_enabled: false

forms_api:
Expand Down
3 changes: 1 addition & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
test_group = Group.create! name: "Test Group", organisation: gds, creator: default_user, status: :active
Group.create! name: "Ministry of Tests forms", organisation: mot_org
Group.create! name: "Ministry of Tests forms - secret!", organisation: mot_org, creator: mot_user
welsh_group = Group.create! name: "Welsh enabled", organisation: gds, welsh_enabled: true, status: :active

Membership.create! user: default_user, group: end_to_end_group, added_by: default_user, role: :group_admin

Expand Down Expand Up @@ -468,5 +467,5 @@
GroupForm.create! group: end_to_end_group, form_id: e2e_s3_forms.id # s3 submission test form
GroupForm.create! group: test_group, form_id: branch_route_form.id # Branch routing form
GroupForm.create! group: test_group, form_id: none_of_the_above_form.id # None of the above form
GroupForm.create! group: welsh_group, form_id: welsh_form.id # Welsh form
GroupForm.create! group: test_group, form_id: welsh_form.id # Welsh form
end
33 changes: 0 additions & 33 deletions lib/tasks/groups.rake
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,6 @@ namespace :groups do
raise ActiveRecord::Rollback
end
end

desc "List enabled features for groups"
task features: :environment do
feature_flags = %i[welsh_enabled]
query = feature_flags.map { "#{it} IS TRUE" }.join(" OR ")

Group.where(query).find_each do |group|
puts({
id: group.external_id,
name: group.name,
organisation: group.organisation.name,
**group.slice(feature_flags),
}.to_json)
end
end

desc "Enable welsh feature for group"
task :enable_welsh, %i[group_id] => :environment do |_, args|
usage_message = "usage: rake groups:enable_welsh[<group_external_id>]".freeze
abort usage_message if args[:group_id].blank?

Group.find_by(external_id: args[:group_id]).update!(welsh_enabled: true)
Rails.logger.info("Updated welsh_enabled to true for group #{args[:group_id]}")
end

desc "Disable Welsh feature for group"
task :disable_welsh, %i[group_id] => :environment do |_, args|
usage_message = "usage: rake groups:disable_welsh[<group_external_id>]".freeze
abort usage_message if args[:group_id].blank?

Group.find_by(external_id: args[:group_id]).update!(welsh_enabled: false)
Rails.logger.info("Updated welsh_enabled to false for group #{args[:group_id]}")
end
end

def run_task(task_name, args, rollback:)
Expand Down
1 change: 0 additions & 1 deletion spec/config/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
describe ".features" do
features = settings[:features]

include_examples expected_value_test, :welsh, features, { "enabled_by_group" => true }
include_examples expected_value_test, :org_admin_alerts_enabled, features, false
end

Expand Down
5 changes: 0 additions & 5 deletions spec/factories/models/groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
organisation { association :organisation, id: 1, slug: "test-org" }
creator { association :user, organisation: }
status { :trial }
welsh_enabled { false }
external_id { SecureRandom.base58(8) }

trait :org_has_org_admin do
organisation { association :organisation, :with_org_admin, id: 1, slug: "test-org" }
end

trait :with_welsh_enabled do
welsh_enabled { true }
end
end
end
2 changes: 1 addition & 1 deletion spec/features/form/create_a_welsh_form_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

feature "Create a form with a welsh version", type: :feature do
let(:group) { create(:group, name: "Welsh enabled", organisation: standard_user.organisation, status: "active", welsh_enabled: true) }
let(:group) { create(:group, name: "Welsh enabled", organisation: standard_user.organisation, status: "active") }

before do
GroupForm.create!(group:, form_id: form.id)
Expand Down
26 changes: 8 additions & 18 deletions spec/models/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@
end

describe "#all_task_statuses" do
let(:group) { create :group, :with_welsh_enabled }
let(:group) { create :group }
let(:completed_form) { build :form, :live, :with_group, group: }

it "returns a hash with each of the task statuses" do
Expand Down Expand Up @@ -1264,29 +1264,19 @@
GroupForm.create!(group:, form:)
end

context "when the Welsh feature is not enabled for the form's group" do
context "when the available_languages array does not include Welsh" do
let(:form) { create :form, :ready_for_live, available_languages: %w[en] }

it "returns false" do
expect(form.has_welsh_translation?).to be false
end
end

context "when the Welsh feature is enabled for the form's group" do
let(:group) { create :group, :with_welsh_enabled }

context "when the available_languages array does not include Welsh" do
let(:form) { create :form, :ready_for_live, available_languages: %w[en] }
context "when the available_languages field does includes Welsh" do
let(:form) { create :form, :ready_for_live, available_languages: %w[en cy] }

it "returns false" do
expect(form.has_welsh_translation?).to be false
end
end

context "when the available_languages field does includes Welsh" do
let(:form) { create :form, :ready_for_live, available_languages: %w[en cy] }

it "returns true" do
expect(form.has_welsh_translation?).to be true
end
it "returns true" do
expect(form.has_welsh_translation?).to be true
end
end
end
Expand Down
12 changes: 0 additions & 12 deletions spec/models/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,6 @@
end
end

describe "welsh_enabled" do
it "has a default welsh_enabled of false" do
group = described_class.build(name: "Test Group")
expect(group.welsh_enabled).to be(false)
end

it "can be set to true" do
group = build :group, welsh_enabled: true
expect(group).to be_valid
end
end

describe "ordering" do
it "orders groups by name" do
user = create :user
Expand Down
52 changes: 1 addition & 51 deletions spec/requests/forms/welsh_translation_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
let(:condition) { create :condition, routing_page: form.pages.first, answer_value: "No", exit_page_heading: "You are ineligible", exit_page_markdown: "Sorry, you are ineligible for this service." }

let(:current_user) { standard_user }
let(:group) { create(:group, organisation: standard_user.organisation, welsh_enabled:) }

let(:welsh_enabled) { true }
let(:group) { create(:group, organisation: standard_user.organisation) }

before do
Membership.create!(group_id: group.id, user: standard_user, added_by: standard_user)
Expand All @@ -34,14 +32,6 @@
expect(response).to have_http_status(:forbidden)
end
end

context "when the welsh feature is not enabled for the group" do
let(:welsh_enabled) { false }

it "redirects to the form" do
expect(response).to redirect_to(form_path(id))
end
end
end

describe "#create" do
Expand Down Expand Up @@ -120,23 +110,6 @@
expect(response).to have_http_status(:forbidden)
end
end

context "when the welsh feature is not enabled for the group" do
let(:welsh_enabled) { false }

it "does not update the form, pages or conditions" do
expect {
post(welsh_translation_create_path(id), params:)
}.to not_change { form.reload.welsh_completed }
.and not_change { form.pages.first.reload.question_text_cy }
.and(not_change { condition.reload.exit_page_markdown_cy })
end

it "redirects to the form" do
post(welsh_translation_create_path(id), params:)
expect(response).to redirect_to(form_path(id))
end
end
end

describe "#delete" do
Expand All @@ -156,14 +129,6 @@
expect(response).to have_http_status(:forbidden)
end
end

context "when the welsh feature is not enabled for the group" do
let(:welsh_enabled) { false }

it "redirects to the form" do
expect(response).to redirect_to(form_path(id))
end
end
end

describe "#destroy" do
Expand Down Expand Up @@ -232,21 +197,6 @@
expect(response).to have_http_status(:forbidden)
end
end

context "when the welsh feature is not enabled for the group" do
let(:welsh_enabled) { false }

it "does not change the form" do
expect {
delete(welsh_translation_destroy_path(id), params:)
}.not_to(change(form, :reload))
end

it "redirects to the form" do
delete(welsh_translation_destroy_path(id), params:)
expect(response).to redirect_to(form_path(id))
end
end
end

describe "#render_preview" do
Expand Down
Loading
Loading