From 3c951b97f4d3def7eee03a5b02eebd0c85c5c569 Mon Sep 17 00:00:00 2001 From: Jose Miguel Gallas Olmedo Date: Tue, 28 Nov 2023 11:35:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=8B=20Buyer=20accounts=20edit=20(#3626?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🦋 updates buyer accounts edit page --- app/controllers/buyers/accounts_controller.rb | 1 + app/views/buyers/accounts/edit.html.slim | 12 +++++------- config/locales/en.yml | 2 ++ features/buyers/accounts/edit.feature | 17 +++++++++++------ features/buyers/accounts/new.feature | 3 ++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/controllers/buyers/accounts_controller.rb b/app/controllers/buyers/accounts_controller.rb index 65d5090452..83cb735511 100644 --- a/app/controllers/buyers/accounts_controller.rb +++ b/app/controllers/buyers/accounts_controller.rb @@ -34,6 +34,7 @@ def update account.vat_rate = vat if vat # vat_rate is protected attribute if account.update(account_params) + flash[:notice] = t('.success') redirect_to admin_buyers_account_path(account) else render :edit diff --git a/app/views/buyers/accounts/edit.html.slim b/app/views/buyers/accounts/edit.html.slim index 2985e8a666..c99005970f 100644 --- a/app/views/buyers/accounts/edit.html.slim +++ b/app/views/buyers/accounts/edit.html.slim @@ -3,15 +3,13 @@ - content_for :page_header_title, "Edit account #{@account.org_name} details" -div - = semantic_form_for @account, - url: admin_buyers_account_path(@account), - builder: Fields::FormBuilder do |form| - = form.inputs name: 'Contact Details', class: 'inputs' do +div class="pf-c-card" + div class="pf-c-card__body" + = semantic_form_for @account, builder: Fields::PatternflyFormBuilder, + url: admin_buyers_account_path(@account), + html: { class: 'pf-c-form pf-m-limit-width' } do |form| = form.user_defined_form - / TODO: remove div and move class to form element - div class='pf-c-form' = form.actions do button class="pf-c-button pf-m-primary" type="submit" Update Account = delete_buyer_link(@account) diff --git a/config/locales/en.yml b/config/locales/en.yml index ab6637e3a0..dbba494246 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -520,6 +520,8 @@ en: success: one: The account's plan was changed successfully. other: Successfully changed the plan of %{count} accounts. + update: + success: Account successfully updated applications: bulk: diff --git a/features/buyers/accounts/edit.feature b/features/buyers/accounts/edit.feature index fec75d512c..bd23e8bc12 100644 --- a/features/buyers/accounts/edit.feature +++ b/features/buyers/accounts/edit.feature @@ -1,5 +1,5 @@ @javascript -Feature: Audience > Accounts > New +Feature: Audience > Accounts > Edit Background: Given a provider is logged in @@ -14,11 +14,16 @@ Feature: Audience > Accounts > New Scenario: Editing an account Given they go to the buyer account edit page for "Pepe" - And fill in "Organization/Group Name" with "Pepito" - And press "Update Account" - Then they should see "Account: Pepito" - # TODO: And they should see the flash message "Account updated or something" - But should not see "Account: Pepe" + When the form is submitted with: + | Organization/Group Name | Pepito | + Then the current page is the buyer account page for "Pepito" + And should see the flash message "Account successfully updated" + + Scenario: Required fields and validation + Given they go to the buyer account edit page for "Pepe" + When the form is submitted with: + | Organization/Group Name | | + Then "Organization/Group Name" shows error "can't be blank" Scenario: Deleting an account Given a buyer "Deleteme" of the provider diff --git a/features/buyers/accounts/new.feature b/features/buyers/accounts/new.feature index d14882b8f6..fcbb6665ac 100644 --- a/features/buyers/accounts/new.feature +++ b/features/buyers/accounts/new.feature @@ -5,6 +5,7 @@ Feature: Audience > Accounts > New Given a provider is logged in Scenario: Navigation + Given they go to the provider dashboard When they follow "0 Accounts" in the audience dashboard widget And follow "Add your first account" Then the current page is the new buyer account page @@ -29,7 +30,7 @@ Feature: Audience > Accounts > New And user "alice" should be active But "alice@web-widgets.com" should receive no emails - Scenario: Require fields and fields validation + Scenario: Required fields and validation Given they go to the new buyer account page When press "Create" Then "Username" shows error "is too short"