-
-
-
"><%= title || account.name %>
- <% if account.draft? %>
- <%= render LinkComponent.new(
+
+
+
+
"><%= title %>
+ <% if account.draft? %>
+ <%= render LinkComponent.new(
text: "Complete setup",
href: edit_account_path(account),
variant: :outline,
size: :sm,
frame: :modal
) %>
- <% end %>
-
- <% if subtitle.present? %>
-
<%= subtitle %>
<% end %>
+ <% if subtitle.present? %>
+
<%= subtitle %>
+ <% end %>
- <% end %>
+
<% if Rails.env.development? || self_hosted? %>
diff --git a/app/views/credit_cards/show.html.erb b/app/views/credit_cards/show.html.erb
deleted file mode 100644
index 4ba5252b..00000000
--- a/app/views/credit_cards/show.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<%= render "accounts/show/template",
- account: @account,
- tabs: render("accounts/show/tabs", account: @account, tabs: [
- { key: "activity", contents: render("accounts/show/activity", account: @account) },
- { key: "overview", contents: render("credit_cards/overview", account: @account) },
- ]) %>
diff --git a/app/views/cryptos/show.html.erb b/app/views/cryptos/show.html.erb
deleted file mode 100644
index 0c3e6e97..00000000
--- a/app/views/cryptos/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "accounts/show/template", account: @account %>
diff --git a/app/views/depositories/show.html.erb b/app/views/depositories/show.html.erb
deleted file mode 100644
index 0c3e6e97..00000000
--- a/app/views/depositories/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "accounts/show/template", account: @account %>
diff --git a/app/views/investments/show.html.erb b/app/views/investments/show.html.erb
deleted file mode 100644
index 84be8629..00000000
--- a/app/views/investments/show.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<%= render "accounts/show/template",
- account: @account,
- chart_view: @chart_view,
- tabs: render("accounts/show/tabs", account: @account, tabs: [
- { key: "activity", contents: render("accounts/show/activity", account: @account) },
- { key: "holdings", contents: render("investments/holdings_tab", account: @account) },
- ]) %>
diff --git a/app/views/investments/_holdings_tab.html.erb b/app/views/investments/tabs/_holdings.html.erb
similarity index 100%
rename from app/views/investments/_holdings_tab.html.erb
rename to app/views/investments/tabs/_holdings.html.erb
diff --git a/app/views/loans/show.html.erb b/app/views/loans/show.html.erb
deleted file mode 100644
index 55bffa52..00000000
--- a/app/views/loans/show.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<%= render "accounts/show/template",
- account: @account,
- tabs: render("accounts/show/tabs", account: @account, tabs: [
- { key: "activity", contents: render("accounts/show/activity", account: @account) },
- { key: "overview", contents: render("loans/overview", account: @account) },
- ]) %>
diff --git a/app/views/loans/_overview.html.erb b/app/views/loans/tabs/_overview.html.erb
similarity index 100%
rename from app/views/loans/_overview.html.erb
rename to app/views/loans/tabs/_overview.html.erb
diff --git a/app/views/other_assets/show.html.erb b/app/views/other_assets/show.html.erb
deleted file mode 100644
index 0c3e6e97..00000000
--- a/app/views/other_assets/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "accounts/show/template", account: @account %>
diff --git a/app/views/other_liabilities/show.html.erb b/app/views/other_liabilities/show.html.erb
deleted file mode 100644
index 0c3e6e97..00000000
--- a/app/views/other_liabilities/show.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= render "accounts/show/template", account: @account %>
diff --git a/app/views/properties/show.html.erb b/app/views/properties/show.html.erb
deleted file mode 100644
index e6f8c34f..00000000
--- a/app/views/properties/show.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<%= render "accounts/show/template",
- account: @account,
- header: render("accounts/show/header", account: @account, subtitle: @account.property.address),
- tabs: render("accounts/show/tabs", account: @account, tabs: [
- { key: "activity", contents: render("accounts/show/activity", account: @account) },
- { key: "overview", contents: render("properties/overview", account: @account) },
- ]) %>
diff --git a/app/views/properties/_overview.html.erb b/app/views/properties/tabs/_overview.html.erb
similarity index 100%
rename from app/views/properties/_overview.html.erb
rename to app/views/properties/tabs/_overview.html.erb
diff --git a/app/views/vehicles/show.html.erb b/app/views/vehicles/show.html.erb
deleted file mode 100644
index 555cd926..00000000
--- a/app/views/vehicles/show.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-<%= render "accounts/show/template",
- account: @account,
- tabs: render("accounts/show/tabs", account: @account, tabs: [
- { key: "activity", contents: render("accounts/show/activity", account: @account) },
- { key: "overview", contents: render("vehicles/overview", account: @account) },
- ]) %>
diff --git a/app/views/vehicles/_overview.html.erb b/app/views/vehicles/tabs/_overview.html.erb
similarity index 100%
rename from app/views/vehicles/_overview.html.erb
rename to app/views/vehicles/tabs/_overview.html.erb
diff --git a/config/routes.rb b/config/routes.rb
index 3dd1d7f1..0c89bb0b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -150,10 +150,9 @@ Rails.application.routes.draw do
end
end
- resources :accounts, only: %i[index new], shallow: true do
+ resources :accounts, only: %i[index new show destroy], shallow: true do
member do
post :sync
- get :chart
get :sparkline
patch :toggle_active
end
@@ -161,17 +160,13 @@ Rails.application.routes.draw do
# Convenience routes for polymorphic paths
# Example: account_path(Account.new(accountable: Depository.new)) => /depositories/123
- direct :account do |model, options|
- route_for model.accountable_name, model, options
- end
-
direct :edit_account do |model, options|
route_for "edit_#{model.accountable_name}", model, options
end
- resources :depositories, except: :index
- resources :investments, except: :index
- resources :properties, except: :index do
+ resources :depositories, except: [ :index, :show ]
+ resources :investments, except: [ :index, :show ]
+ resources :properties, except: [ :index, :show ] do
member do
get :balances
patch :update_balances
@@ -180,12 +175,12 @@ Rails.application.routes.draw do
patch :update_address
end
end
- resources :vehicles, except: :index
- resources :credit_cards, except: :index
- resources :loans, except: :index
- resources :cryptos, except: :index
- resources :other_assets, except: :index
- resources :other_liabilities, except: :index
+ resources :vehicles, except: [ :index, :show ]
+ resources :credit_cards, except: [ :index, :show ]
+ resources :loans, except: [ :index, :show ]
+ resources :cryptos, except: [ :index, :show ]
+ resources :other_assets, except: [ :index, :show ]
+ resources :other_liabilities, except: [ :index, :show ]
resources :securities, only: :index
diff --git a/test/controllers/accounts_controller_test.rb b/test/controllers/accounts_controller_test.rb
index ba0b937e..ec26ef49 100644
--- a/test/controllers/accounts_controller_test.rb
+++ b/test/controllers/accounts_controller_test.rb
@@ -11,18 +11,25 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
+ test "should get show" do
+ get account_url(@account)
+ assert_response :success
+ end
+
test "should sync account" do
post sync_account_url(@account)
assert_redirected_to account_url(@account)
end
- test "should get chart" do
- get chart_account_url(@account)
- assert_response :success
- end
-
test "should get sparkline" do
get sparkline_account_url(@account)
assert_response :success
end
+
+ test "destroys account" do
+ delete account_url(@account)
+ assert_redirected_to accounts_path
+ assert_enqueued_with job: DestroyJob
+ assert_equal "Account scheduled for deletion", flash[:notice]
+ end
end
diff --git a/test/controllers/credit_cards_controller_test.rb b/test/controllers/credit_cards_controller_test.rb
index 5fb0ec52..d19db651 100644
--- a/test/controllers/credit_cards_controller_test.rb
+++ b/test/controllers/credit_cards_controller_test.rb
@@ -48,7 +48,7 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
test "updates with credit card details" do
assert_no_difference [ "Account.count", "CreditCard.count" ] do
- patch account_path(@account), params: {
+ patch credit_card_path(@account), params: {
account: {
name: "Updated Credit Card",
balance: 2000,
diff --git a/test/controllers/loans_controller_test.rb b/test/controllers/loans_controller_test.rb
index e12a2705..47809400 100644
--- a/test/controllers/loans_controller_test.rb
+++ b/test/controllers/loans_controller_test.rb
@@ -46,7 +46,7 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
test "updates with loan details" do
assert_no_difference [ "Account.count", "Loan.count" ] do
- patch account_path(@account), params: {
+ patch loan_path(@account), params: {
account: {
name: "Updated Loan",
balance: 45000,
diff --git a/test/controllers/vehicles_controller_test.rb b/test/controllers/vehicles_controller_test.rb
index 37cea18d..55aa89cf 100644
--- a/test/controllers/vehicles_controller_test.rb
+++ b/test/controllers/vehicles_controller_test.rb
@@ -45,7 +45,7 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
test "updates with vehicle details" do
assert_no_difference [ "Account.count", "Vehicle.count" ] do
- patch account_path(@account), params: {
+ patch vehicle_path(@account), params: {
account: {
name: "Updated Vehicle",
balance: 28000,
@@ -64,7 +64,7 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
}
end
- assert_redirected_to @account
+ assert_redirected_to account_path(@account)
assert_equal "Vehicle account updated", flash[:notice]
assert_enqueued_with(job: SyncJob)
end
diff --git a/test/interfaces/accountable_resource_interface_test.rb b/test/interfaces/accountable_resource_interface_test.rb
index ad5f5079..ef318cb0 100644
--- a/test/interfaces/accountable_resource_interface_test.rb
+++ b/test/interfaces/accountable_resource_interface_test.rb
@@ -15,15 +15,4 @@ module AccountableResourceInterfaceTest
assert_response :success
end
- test "renders accountable page" do
- get account_url(@account)
- assert_response :success
- end
-
- test "destroys account" do
- delete account_url(@account)
- assert_redirected_to accounts_path
- assert_enqueued_with job: DestroyJob
- assert_equal "#{@account.accountable_name.underscore.humanize} account scheduled for deletion", flash[:notice]
- end
end