diff --git a/app/controllers/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb
similarity index 77%
rename from app/controllers/organizations_controller.rb
rename to app/controllers/admin/organizations_controller.rb
index 619e867..04478c2 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/admin/organizations_controller.rb
@@ -1,4 +1,4 @@
-class OrganizationsController < ApplicationController
+class Admin::OrganizationsController < Admin::ApplicationController
before_action :require_owner
def edit
@@ -9,7 +9,7 @@ def update
@organization = Current.organization
if @organization.update(organization_params)
- redirect_to edit_organization_path, notice: "Organization updated."
+ redirect_to edit_admin_organization_path, notice: "Organization updated."
else
render :edit, status: :unprocessable_entity
end
diff --git a/app/views/admin/dashboards/show.html.erb b/app/views/admin/dashboards/show.html.erb
index 092ad67..a59fd22 100644
--- a/app/views/admin/dashboards/show.html.erb
+++ b/app/views/admin/dashboards/show.html.erb
@@ -26,5 +26,13 @@
View and manage who belongs to the organization.
<% end %>
+
+ <% if owner? %>
+ <%= link_to edit_admin_organization_path,
+ class: "block rounded-lg border border-line bg-surface p-5 hover:bg-surface-soft transition" do %>
+ Update your organization's name and logo.
+ <% end %>
+ <% end %>
diff --git a/app/views/admin/organization_memberships/index.html.erb b/app/views/admin/organization_memberships/index.html.erb
index 2b3efa1..da18fca 100644
--- a/app/views/admin/organization_memberships/index.html.erb
+++ b/app/views/admin/organization_memberships/index.html.erb
@@ -5,9 +5,6 @@
<%= form_with url: admin_organization_memberships_path, method: :get,
diff --git a/app/views/admin/organizations/edit.html.erb b/app/views/admin/organizations/edit.html.erb
new file mode 100644
index 0000000..0743d3c
--- /dev/null
+++ b/app/views/admin/organizations/edit.html.erb
@@ -0,0 +1,38 @@
+<% content_for :title, "Organization settings" %>
+
+
+
Admin
+
Organization settings
+
+ Update the name and logo for <%= Current.organization.name %>. Only owners can make these changes.
+
+
+ <%= form_with model: @organization, url: admin_organization_path, method: :patch, class: "contents" do |form| %>
+ <% if @organization.errors.any? %>
+
+ <%= @organization.errors.full_messages.to_sentence %>
+
+ <% end %>
+
+
+ <%= form.label :name, "Name", class: "block text-ink-soft" %>
+ <%= form.text_field :name,
+ class: "mt-2 block w-full rounded-md border border-line bg-surface px-3 py-2 shadow-sm focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/10" %>
+
+
+
+ <%= form.label :logo, "Logo", class: "block text-ink-soft" %>
+ <% if @organization.logo.attached? %>
+
+ <%= image_tag url_for(@organization.logo), alt: "#{@organization.name} logo", class: "h-12 w-auto" %>
+
+ <% end %>
+ <%= form.file_field :logo, accept: "image/*",
+ class: "mt-2 block w-full text-sm text-ink-soft file:mr-4 file:rounded-md file:border-0 file:bg-accent file:px-3.5 file:py-2 file:font-medium file:text-white hover:file:bg-[#444] file:cursor-pointer" %>
+
+
+
+ <%= form.submit "Save changes", class: "rounded-md px-3.5 py-2.5 bg-accent hover:bg-[#444] text-white font-medium cursor-pointer transition" %>
+
+ <% end %>
+
diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb
deleted file mode 100644
index d57ec65..0000000
--- a/app/views/organizations/edit.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<% content_for :title, "Organization settings" %>
-
-
-
-
Organization settings
-
- Update the name and logo for <%= Current.organization.name %>. Only owners can make these changes.
-
-
-
-
- <%= form_with model: @organization, url: organization_path, method: :patch, class: "flex flex-col gap-6 p-6" do |form| %>
- <% if @organization.errors.any? %>
-
-
- <% @organization.errors.full_messages.each do |message| %>
- - <%= message %>
- <% end %>
-
-
- <% end %>
-
-
- <%= form.label :name, "Name", class: "text-ink-soft" %>
- <%= form.text_field :name,
- class: "block w-full rounded-md border border-line bg-surface-soft px-3 py-2 shadow-sm focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/10" %>
-
-
-
- <%= form.label :logo, "Logo", class: "text-ink-soft" %>
- <% if @organization.logo.attached? %>
-
- <%= image_tag url_for(@organization.logo), alt: "#{@organization.name} logo", class: "h-12 w-auto" %>
-
- <% end %>
- <%= form.file_field :logo, accept: "image/*",
- class: "block w-full text-sm text-ink-soft file:mr-4 file:rounded-md file:border-0 file:bg-accent file:px-3.5 file:py-2 file:font-medium file:text-white hover:file:bg-[#444] file:cursor-pointer" %>
-
-
-
- <%= form.submit "Save changes",
- class: "rounded-md bg-accent px-3.5 py-2 font-medium text-white hover:bg-[#444] transition cursor-pointer" %>
- <%= link_to "Back to members", admin_organization_memberships_path, class: "text-ink-soft hover:text-ink" %>
-
- <% end %>
-
-
diff --git a/config/routes.rb b/config/routes.rb
index f6a6cc8..77a409f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -17,7 +17,6 @@
# Dev-only convenience: sign in as the first user without a password
get "auto_sign_in", to: "auto_sign_in#create" if Rails.env.development?
- resource :organization, only: %i[ edit update ]
resources :scenarios do
resource :name, only: %i[ show edit update ], module: :scenarios
resource :total_giving_amount, only: %i[ show edit update ], module: :scenarios
@@ -26,6 +25,7 @@
namespace :admin do
resource :dashboard, only: :show
+ resource :organization, only: %i[ edit update ]
resources :scenarios, only: :index
resources :allocation_categories, only: %i[ index new create edit update destroy ]
resources :organization_memberships, only: %i[ index update ]
diff --git a/test/controllers/organizations_controller_test.rb b/test/controllers/admin/organizations_controller_test.rb
similarity index 66%
rename from test/controllers/organizations_controller_test.rb
rename to test/controllers/admin/organizations_controller_test.rb
index cbc121b..f38dd17 100644
--- a/test/controllers/organizations_controller_test.rb
+++ b/test/controllers/admin/organizations_controller_test.rb
@@ -1,6 +1,6 @@
require "test_helper"
-class OrganizationsControllerTest < ActionDispatch::IntegrationTest
+class Admin::OrganizationsControllerTest < ActionDispatch::IntegrationTest
setup do
host! "arlington.localhost"
@organization = organizations(:arlington)
@@ -13,19 +13,19 @@ class OrganizationsControllerTest < ActionDispatch::IntegrationTest
test "owners can view the edit form" do
sign_in_as(@owner)
- get edit_organization_path
+ get edit_admin_organization_path
assert_response :success
end
test "admins are redirected away from the edit form" do
sign_in_as(@admin)
- get edit_organization_path
+ get edit_admin_organization_path
assert_redirected_to root_path
end
test "plain members are redirected away from the edit form" do
sign_in_as(@member)
- get edit_organization_path
+ get edit_admin_organization_path
assert_redirected_to root_path
end
@@ -33,22 +33,22 @@ class OrganizationsControllerTest < ActionDispatch::IntegrationTest
test "an owner can change the organization name" do
sign_in_as(@owner)
- patch organization_path, params: { organization: { name: "Renamed Foundation" } }
- assert_redirected_to edit_organization_path
+ patch admin_organization_path, params: { organization: { name: "Renamed Foundation" } }
+ assert_redirected_to edit_admin_organization_path
assert_equal "Renamed Foundation", @organization.reload.name
end
test "an owner can upload a logo" do
sign_in_as(@owner)
logo = fixture_file_upload("logo.png", "image/png")
- patch organization_path, params: { organization: { logo: logo } }
- assert_redirected_to edit_organization_path
+ patch admin_organization_path, params: { organization: { logo: logo } }
+ assert_redirected_to edit_admin_organization_path
assert @organization.reload.logo.attached?
end
test "a non-owner cannot update the organization" do
sign_in_as(@admin)
- patch organization_path, params: { organization: { name: "Hijacked" } }
+ patch admin_organization_path, params: { organization: { name: "Hijacked" } }
assert_redirected_to root_path
assert_not_equal "Hijacked", @organization.reload.name
end
@@ -57,14 +57,14 @@ class OrganizationsControllerTest < ActionDispatch::IntegrationTest
test "a super admin can view the edit form for an org they don't belong to" do
sign_in_as(users(:super_admin))
- get edit_organization_path
+ get edit_admin_organization_path
assert_response :success
end
test "a super admin can update an org they don't belong to" do
sign_in_as(users(:super_admin))
- patch organization_path, params: { organization: { name: "Renamed by super admin" } }
- assert_redirected_to edit_organization_path
+ patch admin_organization_path, params: { organization: { name: "Renamed by super admin" } }
+ assert_redirected_to edit_admin_organization_path
assert_equal "Renamed by super admin", @organization.reload.name
end
end