Skip to content

Commit

Permalink
Revert "feat(weekly topup): update tests"
Browse files Browse the repository at this point in the history
This reverts commit d88ebda.
  • Loading branch information
andreybakanovsky committed Sep 12, 2023
1 parent e76c630 commit a6d2ed9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def show

def new
@account = Account.new
@account.automatic_topup_configs.build(from_account_id: current_user.account.id)
@account.automatic_topup_configs.build
end

def edit
Expand Down
1 change: 0 additions & 1 deletion app/views/accounts/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
.field
= f.fields_for :automatic_topup_configs do |auto_topup_form|
= auto_topup_form.text_field :amount, class: "input", placeholder: "Weekly amount (optional)"
= auto_topup_form.hidden_field :from_account_id
.notification.is-light
| This amount will be automatically added to the account every week. You will receive an email notification about that
.buttons.is-flex.is-justify-content-flex-end
Expand Down
18 changes: 6 additions & 12 deletions spec/controllers/accounts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let(:user) { create(:user, account: account) }

before { sign_in user }

describe '#show' do
subject(:show) { get :show, params: {id: account } }

Expand All @@ -25,13 +25,7 @@
end

describe '#create' do
let(:valid_params) do
{ account: { parent: account, name: account.name,
automatic_topup_configs_attributes: {
'0': {amount: 10}
}}}
end
subject { post :create, params: valid_params}
subject { post :create, params: { parent: account, name: account.name } }

it { is_expected.to redirect_to(my_account_path) }
it { is_expected.to have_http_status(302) }
Expand All @@ -41,7 +35,7 @@

describe '#edit' do
subject(:edit) { get :edit, params: { id: account }}

it { is_expected.to have_http_status(:success) }
it { is_expected.to render_template(:edit) }
it { is_expected.to_not render_template(:new) }
Expand All @@ -53,9 +47,9 @@

subject(:bad_update) { patch :update, params: { id: user.account, account: { name: nil }} }
subject(:update) { patch :update, params: { id: user.account, account: { name: name }} }

it { is_expected.to have_http_status(:redirect) }
it { expect(bad_update).not_to be_redirect }
it { is_expected.to have_http_status(:redirect) }
it { expect(bad_update).not_to be_redirect }
it 'name changed' do
expect(Account.where(id: account.id).name).not_to eq(old_name)
end
Expand Down

0 comments on commit a6d2ed9

Please sign in to comment.