mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 15:19:38 +02:00
Add institution management and account editing controls (#868)
* Add institution management * Allow user to select institution on create or edit * Improve redirect behavior * Final cleanup * i18n normalization
This commit is contained in:
parent
8c1a7af37f
commit
9956a9540e
36 changed files with 456 additions and 68 deletions
55
test/controllers/institutions_controller_test.rb
Normal file
55
test/controllers/institutions_controller_test.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require "test_helper"
|
||||
|
||||
class InstitutionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in users(:family_admin)
|
||||
@institution = institutions(:chase)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_institution_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "can create institution" do
|
||||
assert_difference("Institution.count", 1) do
|
||||
post institutions_url, params: {
|
||||
institution: {
|
||||
name: "New institution"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_redirected_to accounts_url
|
||||
assert_equal "Institution created", flash[:notice]
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_institution_url(@institution)
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update institution" do
|
||||
patch institution_url(@institution), params: {
|
||||
institution: {
|
||||
name: "New Institution Name",
|
||||
logo: file_fixture_upload("square-placeholder.png", "image/png", :binary)
|
||||
}
|
||||
}
|
||||
|
||||
assert_redirected_to accounts_url
|
||||
assert_equal "Institution updated", flash[:notice]
|
||||
end
|
||||
|
||||
test "can destroy institution without destroying accounts" do
|
||||
assert @institution.accounts.count > 0
|
||||
|
||||
assert_difference -> { Institution.count } => -1, -> { Account.count } => 0 do
|
||||
delete institution_url(@institution)
|
||||
end
|
||||
|
||||
assert_redirected_to accounts_url
|
||||
assert_equal "Institution deleted", flash[:notice]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue