-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add PageTexts model, table * update factory, add validations and validation tests * update seed files to create page text for organization * add dependent destroy to page text association * add association test for page text * update organizations create service to create page text when organization is created, and add test
- Loading branch information
1 parent
dd4b5be
commit 25ce9ae
Showing
11 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# == Schema Information | ||
# | ||
# Table name: page_texts | ||
# | ||
# id :bigint not null, primary key | ||
# about :text | ||
# hero :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organization_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_page_texts_on_organization_id (organization_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (organization_id => organizations.id) | ||
# | ||
class PageText < ApplicationRecord | ||
acts_as_tenant(:organization) | ||
|
||
validates :hero, presence: true, allow_nil: true | ||
validates :about, presence: true, allow_nil: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreatePageTexts < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :page_texts do |t| | ||
t.references :organization, null: false, foreign_key: true | ||
t.string :hero | ||
t.text :about | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,4 +279,6 @@ | |
end | ||
|
||
@match.assign_checklist_template(@checklist_template) | ||
|
||
PageText.create!(hero: nil, about: nil) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,4 +279,6 @@ | |
end | ||
|
||
@match.assign_checklist_template(@checklist_template) | ||
|
||
PageText.create!(hero: nil, about: nil) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "test_helper" | ||
|
||
class PageTextTest < ActiveSupport::TestCase | ||
context "validations" do | ||
should validate_presence_of(:hero).allow_nil | ||
should validate_presence_of(:about).allow_nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "test_helper" | ||
|
||
class Organizations::CreateServiceTest < ActiveSupport::TestCase | ||
test "it creates page_text when organization is created" do | ||
args = { | ||
location: { | ||
country: "Mexico", | ||
city_town: "La Ventana", | ||
province_state: "Baja" | ||
}, | ||
organization: { | ||
name: "Baja Pet Rescue", | ||
slug: "baja" | ||
}, | ||
user: { | ||
email: "[email protected]", | ||
first_name: "Jimmy", | ||
last_name: "Hendrix" | ||
} | ||
} | ||
|
||
Organizations::CreateService.new.signal(args) | ||
assert_not Organization.last.page_text.nil? | ||
end | ||
end |