From a6d2ed9ccd425fda99ebdef7c3fb9c59fcfca532 Mon Sep 17 00:00:00 2001 From: Andrey Bakanovsky Date: Wed, 13 Sep 2023 00:17:39 +0300 Subject: [PATCH] Revert "feat(weekly topup): update tests" This reverts commit d88ebda6f7e66e67af787c7cb9a2f74f8838c78c. --- app/controllers/accounts_controller.rb | 2 +- app/views/accounts/new.html.slim | 1 - spec/controllers/accounts_spec.rb | 18 ++++++------------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 9214ad03..d70b615d 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -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 diff --git a/app/views/accounts/new.html.slim b/app/views/accounts/new.html.slim index 1d9ee1af..e47de358 100644 --- a/app/views/accounts/new.html.slim +++ b/app/views/accounts/new.html.slim @@ -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 diff --git a/spec/controllers/accounts_spec.rb b/spec/controllers/accounts_spec.rb index da4729d5..d2f1b305 100644 --- a/spec/controllers/accounts_spec.rb +++ b/spec/controllers/accounts_spec.rb @@ -7,7 +7,7 @@ let(:user) { create(:user, account: account) } before { sign_in user } - + describe '#show' do subject(:show) { get :show, params: {id: account } } @@ -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) } @@ -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) } @@ -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