Skip to content

Commit

Permalink
🦋 Buyer accounts edit (#3626)
Browse files Browse the repository at this point in the history
🦋 updates buyer accounts edit page
  • Loading branch information
josemigallas authored Nov 28, 2023
1 parent c4d6a8e commit 3c951b9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/controllers/buyers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions app/views/buyers/accounts/edit.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions features/buyers/accounts/edit.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@javascript
Feature: Audience > Accounts > New
Feature: Audience > Accounts > Edit

Background:
Given a provider is logged in
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion features/buyers/accounts/new.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 3c951b9

Please sign in to comment.