- <%= render ImageAttachmentTableComponent.new(images: @page_text.images) %>
+ <%= render ImageAttachmentTableComponent.new(images: @custom_page.images) %>
<% end %>
diff --git a/app/views/organizations/staff/page_texts/edit.html.erb b/app/views/organizations/staff/custom_pages/edit.html.erb
similarity index 53%
rename from app/views/organizations/staff/page_texts/edit.html.erb
rename to app/views/organizations/staff/custom_pages/edit.html.erb
index 4b695f740..61bbb361e 100644
--- a/app/views/organizations/staff/page_texts/edit.html.erb
+++ b/app/views/organizations/staff/custom_pages/edit.html.erb
@@ -1,11 +1,12 @@
-<%= render DashboardPageComponent.new(crumb: :page_text) do |c| %>
- <% c.with_header_title { "Page Text" } %>
+
+<%= render DashboardPageComponent.new(crumb: :custom_page) do |c| %>
+ <% c.with_header_title { "Custom Page" } %>
<% c.with_header_subtitle { "Edit your page" } %>
<% c.with_body do %>
- <%= render "form", page_text: @page_text %>
+ <%= render "form", custom_page: @custom_page %>
diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb
index 348782cb0..6d2303b1f 100644
--- a/config/breadcrumbs.rb
+++ b/config/breadcrumbs.rb
@@ -15,8 +15,8 @@
link "Edit Profile", edit_staff_organization_profile_path(organization)
end
-crumb :page_text do |page_text|
- link "Edit Page Text", edit_staff_page_text_path(page_text)
+crumb :custom_page do |custom_page|
+ link "Edit Custom Page", edit_staff_custom_page_path(custom_page)
end
crumb :staff_index do
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1bb225c41..c7f1f9ce5 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -408,7 +408,7 @@ en:
complete?: "Show Completed"
destroy:
success: "Task was successfully deleted."
- page_texts:
+ custom_pages:
update:
success: "Page text updated successfully!"
matches:
diff --git a/config/routes.rb b/config/routes.rb
index 3eef065b4..abc090e80 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -14,7 +14,7 @@
namespace :staff do
resource :organization_profile, only: %i[edit update]
- resource :page_text, only: %i[edit update]
+ resource :custom_page, only: %i[edit update]
resources :profile_reviews, only: [:show]
resources :pets do
diff --git a/db/migrate/20240225160909_create_page_texts.rb b/db/migrate/20240225160909_create_page_texts.rb
index 5b453a893..774370694 100644
--- a/db/migrate/20240225160909_create_page_texts.rb
+++ b/db/migrate/20240225160909_create_page_texts.rb
@@ -1,4 +1,4 @@
-class CreatePageTexts < ActiveRecord::Migration[7.0]
+class CreateCustomPages < ActiveRecord::Migration[7.0]
def change
create_table :page_texts do |t|
t.references :organization, null: false, foreign_key: true
diff --git a/db/migrate/20240518203140_add_adoptable_pet_info_to_page_texts.rb b/db/migrate/20240518203140_add_adoptable_pet_info_to_page_texts.rb
index d0c17cf3d..f3debda08 100644
--- a/db/migrate/20240518203140_add_adoptable_pet_info_to_page_texts.rb
+++ b/db/migrate/20240518203140_add_adoptable_pet_info_to_page_texts.rb
@@ -1,4 +1,4 @@
-class AddAdoptablePetInfoToPageTexts < ActiveRecord::Migration[7.1]
+class AddAdoptablePetInfoToCustomPages < ActiveRecord::Migration[7.1]
def change
add_column :page_texts, :adoptable_pet_info, :text
end
diff --git a/db/migrate/20240628165551_change_page_texts_to_custom_pages.rb b/db/migrate/20240628165551_change_page_texts_to_custom_pages.rb
new file mode 100644
index 000000000..f31beea4a
--- /dev/null
+++ b/db/migrate/20240628165551_change_page_texts_to_custom_pages.rb
@@ -0,0 +1,5 @@
+class ChangeCustomPagesToCustomPages < ActiveRecord::Migration[7.1]
+ def change
+ rename_table :page_texts, :custom_pages
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index d7d225122..1efb5c8db 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_06_19_203450) do
+ActiveRecord::Schema[7.1].define(version: 2024_06_28_165551) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -109,6 +109,16 @@
t.index ["organization_id"], name: "index_adopter_foster_profiles_on_organization_id"
end
+ create_table "custom_pages", force: :cascade do |t|
+ t.bigint "organization_id", null: false
+ t.string "hero"
+ t.text "about"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.text "adoptable_pet_info"
+ t.index ["organization_id"], name: "index_custom_pages_on_organization_id"
+ end
+
create_table "default_pet_tasks", force: :cascade do |t|
t.string "name", null: false
t.string "description"
@@ -209,16 +219,6 @@
t.index ["slug"], name: "index_organizations_on_slug", unique: true
end
- create_table "page_texts", force: :cascade do |t|
- t.bigint "organization_id", null: false
- t.string "hero"
- t.text "about"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.text "adoptable_pet_info"
- t.index ["organization_id"], name: "index_page_texts_on_organization_id"
- end
-
create_table "people", force: :cascade do |t|
t.bigint "organization_id", null: false
t.string "name", null: false
@@ -356,6 +356,7 @@
add_foreign_key "adopter_foster_accounts", "users"
add_foreign_key "adopter_foster_profiles", "adopter_foster_accounts"
add_foreign_key "adopter_foster_profiles", "locations"
+ add_foreign_key "custom_pages", "organizations"
add_foreign_key "default_pet_tasks", "organizations"
add_foreign_key "faqs", "organizations"
add_foreign_key "form_profiles", "forms"
@@ -367,7 +368,6 @@
add_foreign_key "matches", "pets"
add_foreign_key "organization_profiles", "locations"
add_foreign_key "organization_profiles", "organizations"
- add_foreign_key "page_texts", "organizations"
add_foreign_key "people", "organizations"
add_foreign_key "pets", "organizations"
add_foreign_key "questions", "forms"
diff --git a/db/seeds/01_alta.rb b/db/seeds/01_alta.rb
index 110a27375..e0dd92efa 100644
--- a/db/seeds/01_alta.rb
+++ b/db/seeds/01_alta.rb
@@ -9,7 +9,7 @@
name: "Alta Pet Rescue",
slug: "alta",
profile: OrganizationProfile.new(email: "alta@email.com", phone_number: "250 816 8212", location: orga_location),
- page_text: PageText.new(hero: "Where every paw finds a home", about: "Alta was founded by an incredible group of ladies in April of 2020. Our initial goal was to have both a rescue and a spay/neuter clinic, however, we quickly realized that it would be more efficient to separate into two organizations.")
+ custom_page: CustomPage.new(hero: "Where every paw finds a home", about: "Alta was founded by an incredible group of ladies in April of 2020. Our initial goal was to have both a rescue and a spay/neuter clinic, however, we quickly realized that it would be more efficient to separate into two organizations.")
)
ActsAsTenant.with_tenant(@organization) do
diff --git a/db/seeds/02_baja.rb b/db/seeds/02_baja.rb
index 47ed1dadd..185f1c5ed 100644
--- a/db/seeds/02_baja.rb
+++ b/db/seeds/02_baja.rb
@@ -9,7 +9,7 @@
name: "Baja",
slug: "baja",
profile: OrganizationProfile.new(email: "baja@email.com", phone_number: "250 816 8212", location: orga_location),
- page_text: PageText.new(hero: "hero text", about: "about us text")
+ custom_page: CustomPage.new(hero: "hero text", about: "about us text")
)
ActsAsTenant.with_tenant(@organization) do
diff --git a/test/components/image_attachment_table_component_test.rb b/test/components/image_attachment_table_component_test.rb
index f4c59c094..53958f987 100644
--- a/test/components/image_attachment_table_component_test.rb
+++ b/test/components/image_attachment_table_component_test.rb
@@ -18,9 +18,9 @@ class ImageAttachmentTableComponentTest < ViewComponent::TestCase
setup do
ActiveStorage::Current.url_options = {host: "localhost", port: 3000}
- page_text = create(:page_text, :with_about_us_image)
- @component = ImageAttachmentTableComponent.new(images: page_text.images)
- @image = page_text.images[0]
+ custom_page = create(:custom_page, :with_about_us_image)
+ @component = ImageAttachmentTableComponent.new(images: custom_page.images)
+ @image = custom_page.images[0]
render_inline(@component)
end
diff --git a/test/controllers/organizations/staff/page_texts_controller_test.rb b/test/controllers/organizations/staff/custom_pages_controller_test.rb
similarity index 50%
rename from test/controllers/organizations/staff/page_texts_controller_test.rb
rename to test/controllers/organizations/staff/custom_pages_controller_test.rb
index 5ac7133cb..f97da9522 100644
--- a/test/controllers/organizations/staff/page_texts_controller_test.rb
+++ b/test/controllers/organizations/staff/custom_pages_controller_test.rb
@@ -1,12 +1,12 @@
require "test_helper"
require "action_policy/test_helper"
-class Organizations::Staff::PageTextsControllerTest < ActionDispatch::IntegrationTest
+class Organizations::Staff::CustomPagesControllerTest < ActionDispatch::IntegrationTest
setup do
@org = ActsAsTenant.current_tenant
admin = create(:staff_admin, organization: @org)
sign_in admin
- @page_text = create(:page_text, organization: @org)
+ @custom_page = create(:custom_page, organization: @org)
end
context "authorization" do
@@ -15,43 +15,43 @@ class Organizations::Staff::PageTextsControllerTest < ActionDispatch::Integratio
context "#edit" do
should "be authorized" do
assert_authorized_to(
- :manage?, @page_text, with: Organizations::PageTextPolicy
+ :manage?, @custom_page, with: Organizations::CustomPagePolicy
) do
- get edit_staff_page_text_url(@page_text)
+ get edit_staff_custom_page_url(@custom_page)
end
end
end
context "#update" do
setup do
- @params = {page_text: {hero: "Super Dog", about: "canine caped crusader"}}
+ @params = {custom_page: {hero: "Super Dog", about: "canine caped crusader"}}
end
should "be authorized" do
assert_authorized_to(
- :manage?, @page_text, with: Organizations::PageTextPolicy
+ :manage?, @custom_page, with: Organizations::CustomPagePolicy
) do
- patch staff_page_text_url(@page_text), params: @params
+ patch staff_custom_page_url(@custom_page), params: @params
end
end
end
end
context "GET #edit" do
should "get edit page" do
- get edit_staff_page_text_path
+ get edit_staff_custom_page_path
assert_response :success
end
end
context "PATCH #update" do
should "update page text" do
- patch staff_page_text_path(@page_text), params: {page_text: {hero: "Super Dog", about: "canine caped crusader"}}
- @page_text.reload
+ patch staff_custom_page_path(@custom_page), params: {custom_page: {hero: "Super Dog", about: "canine caped crusader"}}
+ @custom_page.reload
assert_response :redirect
follow_redirect!
assert_response :success
- assert_equal "Super Dog", @page_text.hero
- assert_equal "canine caped crusader", @page_text.about
+ assert_equal "Super Dog", @custom_page.hero
+ assert_equal "canine caped crusader", @custom_page.about
end
end
end
diff --git a/test/factories/page_text.rb b/test/factories/custom_page.rb
similarity index 75%
rename from test/factories/page_text.rb
rename to test/factories/custom_page.rb
index 3f06c937c..2a14b6687 100644
--- a/test/factories/page_text.rb
+++ b/test/factories/custom_page.rb
@@ -1,12 +1,12 @@
FactoryBot.define do
- factory :page_text do
+ factory :custom_page do
hero { "MyString" }
about { Faker::Lorem.sentence }
association :organization, factory: :organization
trait :with_hero_image do
- after(:create) do |page_text|
- page_text.hero_image.attach(
+ after(:create) do |custom_page|
+ custom_page.hero_image.attach(
io: File.open(Rails.root.join("test", "fixtures", "files", "test.png")),
filename: "test.png",
content_type: "image/png"
@@ -15,8 +15,8 @@
end
trait :with_about_us_image do
- after(:create) do |page_text|
- page_text.about_us_images.attach(
+ after(:create) do |custom_page|
+ custom_page.about_us_images.attach(
io: File.open(Rails.root.join("test", "fixtures", "files", "test2.png")),
filename: "test2.png",
content_type: "image/png"
diff --git a/test/factories/organizations.rb b/test/factories/organizations.rb
index eb7411fc3..13d6450fe 100644
--- a/test/factories/organizations.rb
+++ b/test/factories/organizations.rb
@@ -4,9 +4,9 @@
sequence(:slug) { |n| Faker::Internet.domain_word + n.to_s }
profile { association :organization_profile, organization: instance }
- trait :with_page_text do
+ trait :with_custom_page do
after(:create) do |organization|
- create(:page_text, organization: organization) unless organization.page_text
+ create(:custom_page, organization: organization) unless organization.custom_page
end
end
end
diff --git a/test/integration/adoptable_pet_show_test.rb b/test/integration/adoptable_pet_show_test.rb
index 81cd9e34a..030f80ba8 100644
--- a/test/integration/adoptable_pet_show_test.rb
+++ b/test/integration/adoptable_pet_show_test.rb
@@ -129,7 +129,7 @@ class AdoptablePetShowTest < ActionDispatch::IntegrationTest
context "with adoptable pet information" do
should "have important information section" do
- PageText.create(adoptable_pet_info: "some things that should be known")
+ CustomPage.create(adoptable_pet_info: "some things that should be known")
get adoptable_pet_path(@available_pet)
assert_select "h3", text: "Important Information", count: 1
end
diff --git a/test/integration/adoption_application_reviews_test.rb b/test/integration/adoption_application_reviews_test.rb
index ae687d15c..a4e753c38 100644
--- a/test/integration/adoption_application_reviews_test.rb
+++ b/test/integration/adoption_application_reviews_test.rb
@@ -9,7 +9,7 @@ class AdoptionApplicationReviewsTest < ActionDispatch::IntegrationTest
@successful_applicant_app = create(:adopter_application, status: :successful_applicant)
@adoption_made_app = create(:adopter_application, status: :adoption_made)
@organization = create(:organization)
- @page_text = create(:page_text, organization: @organization)
+ @custom_page = create(:custom_page, organization: @organization)
Current.organization = @organization
end
diff --git a/test/models/page_text_test.rb b/test/models/custom_page_test.rb
similarity index 53%
rename from test/models/page_text_test.rb
rename to test/models/custom_page_test.rb
index 40ad7cb8b..54195b1c0 100644
--- a/test/models/page_text_test.rb
+++ b/test/models/custom_page_test.rb
@@ -1,6 +1,6 @@
require "test_helper"
-class PageTextTest < ActiveSupport::TestCase
+class CustomPageTest < ActiveSupport::TestCase
context "validations" do
should validate_presence_of(:hero).allow_nil
should validate_presence_of(:about).allow_nil
@@ -9,33 +9,33 @@ class PageTextTest < ActiveSupport::TestCase
context "#images" do
context "when no images attached" do
setup do
- @page_text = create(:page_text)
+ @custom_page = create(:custom_page)
end
should "return []" do
- assert_equal([], @page_text.images)
+ assert_equal([], @custom_page.images)
end
end
context "when hero image attached" do
setup do
- @page_text = create(:page_text, :with_hero_image)
- @hero_image = @page_text.hero_image
+ @custom_page = create(:custom_page, :with_hero_image)
+ @hero_image = @custom_page.hero_image
end
should "include hero image" do
- assert_includes(@page_text.images, @hero_image)
+ assert_includes(@custom_page.images, @hero_image)
end
end
context "when about us image attached" do
setup do
- @page_text = create(:page_text, :with_about_us_image)
- @about_us_image = @page_text.about_us_images[0]
+ @custom_page = create(:custom_page, :with_about_us_image)
+ @about_us_image = @custom_page.about_us_images[0]
end
should "include about us image" do
- assert_includes(@page_text.images, @about_us_image)
+ assert_includes(@custom_page.images, @about_us_image)
end
end
end
diff --git a/test/models/organization_test.rb b/test/models/organization_test.rb
index 93bdf4717..f09666678 100644
--- a/test/models/organization_test.rb
+++ b/test/models/organization_test.rb
@@ -10,6 +10,6 @@ class OrganizationTest < ActiveSupport::TestCase
should have_many(:faqs)
should have_one(:profile).dependent(:destroy).required
- should have_one(:page_text).dependent(:destroy)
+ should have_one(:custom_page).dependent(:destroy)
end
end
diff --git a/test/policies/organizations/page_text_policy_test.rb b/test/policies/organizations/custom_page_policy_test.rb
similarity index 93%
rename from test/policies/organizations/page_text_policy_test.rb
rename to test/policies/organizations/custom_page_policy_test.rb
index aa68f001e..67eecb651 100644
--- a/test/policies/organizations/page_text_policy_test.rb
+++ b/test/policies/organizations/custom_page_policy_test.rb
@@ -1,13 +1,13 @@
require "test_helper"
# See https://actionpolicy.evilmartians.io/#/testing?id=testing-policies
-class Organizations::PageTextPolicyTest < ActiveSupport::TestCase
+class Organizations::CustomPagePolicyTest < ActiveSupport::TestCase
include PetRescue::PolicyAssertions
setup do
@organization = ActsAsTenant.current_tenant
@policy = -> {
- Organizations::PageTextPolicy.new(Pet, user: @user,
+ Organizations::CustomPagePolicy.new(Pet, user: @user,
organization: @organization)
}
end
diff --git a/test/services/organizations/create_service_test.rb b/test/services/organizations/create_service_test.rb
index 79abf4cdd..8628b9efb 100644
--- a/test/services/organizations/create_service_test.rb
+++ b/test/services/organizations/create_service_test.rb
@@ -1,7 +1,7 @@
require "test_helper"
class Organizations::CreateServiceTest < ActiveSupport::TestCase
- test "it creates page_text when organization is created" do
+ test "it creates custom_page when organization is created" do
args = {
location: {
country: "Mexico",
@@ -20,6 +20,6 @@ class Organizations::CreateServiceTest < ActiveSupport::TestCase
}
Organizations::CreateService.new.signal(args)
- assert_not Organization.last.page_text.nil?
+ assert_not Organization.last.custom_page.nil?
end
end
diff --git a/test/system/adoption_fosterer_test.rb b/test/system/adoption_fosterer_test.rb
index dcbd76dac..d6f089c76 100644
--- a/test/system/adoption_fosterer_test.rb
+++ b/test/system/adoption_fosterer_test.rb
@@ -4,7 +4,7 @@ class AdoptionFostererTest < ApplicationSystemTestCase
setup do
@user = create(:fosterer, :with_profile)
@org = @user.organization
- @page_text = create(:page_text, :with_about_us_image, organization: @org)
+ @custom_page = create(:custom_page, :with_about_us_image, organization: @org)
@pet = create(:pet)
create(:adopter_application, pet: @pet, adopter_foster_account: @user.adopter_foster_account, organization: @org)
diff --git a/test/system/home_page_test.rb b/test/system/home_page_test.rb
index d11d3758f..e52826e66 100644
--- a/test/system/home_page_test.rb
+++ b/test/system/home_page_test.rb
@@ -7,8 +7,8 @@ class HomePageTest < ApplicationSystemTestCase
set_organization(@organization)
end
- test "renders custom hero and about text from PageText or default text" do
- PageText.create(hero: "Super Pets for a good paws", about: "All about us")
+ test "renders custom hero and about text from CustomPage or default text" do
+ CustomPage.create(hero: "Super Pets for a good paws", about: "All about us")
visit home_index_path
assert_text "Super Pets for a good paws"
diff --git a/test/system/login_test.rb b/test/system/login_test.rb
index 02b950ae1..3ca64e73c 100644
--- a/test/system/login_test.rb
+++ b/test/system/login_test.rb
@@ -4,7 +4,7 @@ class LoginTest < ApplicationSystemTestCase
setup do
@user = create(:staff)
@organization = @user.organization
- @page_text = create(:page_text, :with_about_us_image, organization: @organization)
+ @custom_page = create(:custom_page, :with_about_us_image, organization: @organization)
Current.organization = @organization
end
@@ -26,7 +26,7 @@ class LoginTest < ApplicationSystemTestCase
setup do
@user = create(:fosterer, :with_profile)
@organization = @user.organization
- @page_text = create(:page_text, :with_about_us_image, organization: @organization)
+ @custom_page = create(:custom_page, :with_about_us_image, organization: @organization)
Current.organization = @organization
end
diff --git a/test/system/registration_test.rb b/test/system/registration_test.rb
index 92aa907ae..3f0303ead 100644
--- a/test/system/registration_test.rb
+++ b/test/system/registration_test.rb
@@ -4,7 +4,7 @@ class RegistrationTest < ApplicationSystemTestCase
setup do
@user = create(:staff)
@organization = @user.organization
- @page_text = create(:page_text, :with_about_us_image, organization: @organization)
+ @custom_page = create(:custom_page, :with_about_us_image, organization: @organization)
Current.organization = @organization
visit root_url
diff --git a/test/system/users_test.rb b/test/system/users_test.rb
index 0a33af003..bac9e4427 100644
--- a/test/system/users_test.rb
+++ b/test/system/users_test.rb
@@ -4,7 +4,7 @@ class UsersTest < ApplicationSystemTestCase
setup do
@user = create(:staff)
@organization = @user.organization
- @page_text = create(:page_text, :with_about_us_image, organization: @organization, hero: "Where every paw finds a home")
+ @custom_page = create(:custom_page, :with_about_us_image, organization: @organization, hero: "Where every paw finds a home")
Current.organization = @organization
end