Remove model RegionalOffice
This commit is contained in:
parent
9128f1d93c
commit
9d940fcc48
21 changed files with 67 additions and 297 deletions
|
@ -1,16 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module RegionalOfficesHelper
|
|
||||||
def regional_office_link_or_none(regional_office)
|
|
||||||
if regional_office.nil?
|
|
||||||
none
|
|
||||||
elsif policy(regional_office.federal_subject).show?
|
|
||||||
link_to regional_office.federal_subject.display_name,
|
|
||||||
regional_office.federal_subject
|
|
||||||
else
|
|
||||||
regional_office.federal_subject.display_name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
alias staff_regional_office_link_or_none regional_office_link_or_none
|
|
||||||
end
|
|
|
@ -13,12 +13,6 @@ class FederalSubject < ApplicationRecord
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
################
|
|
||||||
# Associations #
|
|
||||||
################
|
|
||||||
|
|
||||||
has_one :regional_office
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# Validations #
|
# Validations #
|
||||||
###############
|
###############
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class RegionalOffice < ApplicationRecord
|
|
||||||
################
|
|
||||||
# Associations #
|
|
||||||
################
|
|
||||||
|
|
||||||
belongs_to :federal_subject
|
|
||||||
|
|
||||||
###############
|
|
||||||
# Validations #
|
|
||||||
###############
|
|
||||||
|
|
||||||
validates :federal_subject, uniqueness: true
|
|
||||||
|
|
||||||
validates :name, good_small_text: true, uniqueness: true
|
|
||||||
end
|
|
|
@ -9,8 +9,6 @@ class Relationship < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :person, inverse_of: :all_relationships
|
belongs_to :person, inverse_of: :all_relationships
|
||||||
|
|
||||||
belongs_to :regional_office
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# Validations #
|
# Validations #
|
||||||
###############
|
###############
|
||||||
|
|
|
@ -21,16 +21,6 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="mt-2">
|
|
||||||
<% if @account.person&.current_relationship&.regional_office %>
|
|
||||||
<div>
|
|
||||||
<i class="fas fa-map-marker-alt fa-fw"></i>
|
|
||||||
<%= regional_office_link_or_none \
|
|
||||||
@account.person.current_relationship.regional_office %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<% if @account.biography %>
|
<% if @account.biography %>
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
<%= FederalSubject.human_attribute_name :timezone %>
|
<%= FederalSubject.human_attribute_name :timezone %>
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
|
||||||
<%= FederalSubject.human_attribute_name :regional_office %>
|
|
||||||
</th>
|
|
||||||
<th scope="col"></th>
|
<th scope="col"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -27,13 +24,6 @@
|
||||||
<td><%= truncate federal_subject.display_name, length: 25 %></td>
|
<td><%= truncate federal_subject.display_name, length: 25 %></td>
|
||||||
<td><%= truncate federal_subject.centre, length: 15 %></td>
|
<td><%= truncate federal_subject.centre, length: 15 %></td>
|
||||||
<td><%= federal_subject.timezone %></td>
|
<td><%= federal_subject.timezone %></td>
|
||||||
<td>
|
|
||||||
<% if federal_subject.regional_office.nil? %>
|
|
||||||
<%= translate :no %>
|
|
||||||
<% else %>
|
|
||||||
<%= translate :yes %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<% if policy(federal_subject).show? %>
|
<% if policy(federal_subject).show? %>
|
||||||
<%= open_action federal_subject %>
|
<%= open_action federal_subject %>
|
||||||
|
|
|
@ -21,14 +21,5 @@
|
||||||
|
|
||||||
<dt><%= FederalSubject.human_attribute_name :timezone %></dt>
|
<dt><%= FederalSubject.human_attribute_name :timezone %></dt>
|
||||||
<dd><%= @federal_subject.timezone %></dd>
|
<dd><%= @federal_subject.timezone %></dd>
|
||||||
|
|
||||||
<dt><%= FederalSubject.human_attribute_name :regional_office %></dt>
|
|
||||||
<dd>
|
|
||||||
<% if @federal_subject.regional_office.nil? %>
|
|
||||||
<%= translate :no %>
|
|
||||||
<% else %>
|
|
||||||
<%= translate :yes %>
|
|
||||||
<% end %>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
<th scope="col">
|
<th scope="col">
|
||||||
<%= Relationship.human_attribute_name :from_date %>
|
<%= Relationship.human_attribute_name :from_date %>
|
||||||
</th>
|
</th>
|
||||||
<th scope="col">
|
|
||||||
<%= Relationship.human_attribute_name :regional_office %>
|
|
||||||
</th>
|
|
||||||
<th scope="col"></th>
|
<th scope="col"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -19,10 +16,6 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td scope="row"><%= relationship.id %></td>
|
<td scope="row"><%= relationship.id %></td>
|
||||||
<td><%= relationship_from_date_or_none relationship %></td>
|
<td><%= relationship_from_date_or_none relationship %></td>
|
||||||
<td>
|
|
||||||
<%= staff_regional_office_link_or_none \
|
|
||||||
relationship.regional_office %>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -62,12 +62,6 @@
|
||||||
<dd>
|
<dd>
|
||||||
<%= relationship_from_date_or_none @person.current_relationship %>
|
<%= relationship_from_date_or_none @person.current_relationship %>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><%= Relationship.human_attribute_name :regional_office %></dt>
|
|
||||||
<dd>
|
|
||||||
<%= staff_regional_office_link_or_none \
|
|
||||||
@person.current_relationship&.regional_office %>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,9 +27,6 @@ en:
|
||||||
person_comment:
|
person_comment:
|
||||||
one: Comment
|
one: Comment
|
||||||
many: Comments
|
many: Comments
|
||||||
regional_office:
|
|
||||||
one: Regional office
|
|
||||||
many: Regional offices
|
|
||||||
relation_status:
|
relation_status:
|
||||||
one: Relation status
|
one: Relation status
|
||||||
few: Relation statuses
|
few: Relation statuses
|
||||||
|
@ -65,7 +62,6 @@ en:
|
||||||
name: Name
|
name: Name
|
||||||
federal_subject:
|
federal_subject:
|
||||||
id: ID
|
id: ID
|
||||||
regional_office: Regional department
|
|
||||||
english_name: Name
|
english_name: Name
|
||||||
native_name: Name
|
native_name: Name
|
||||||
display_name: Name
|
display_name: Name
|
||||||
|
@ -105,8 +101,6 @@ en:
|
||||||
id: ID
|
id: ID
|
||||||
attachment: Attachment
|
attachment: Attachment
|
||||||
text: Text
|
text: Text
|
||||||
regional_office:
|
|
||||||
id: ID
|
|
||||||
relation_status:
|
relation_status:
|
||||||
id: ID
|
id: ID
|
||||||
codename: Codename
|
codename: Codename
|
||||||
|
@ -114,7 +108,6 @@ en:
|
||||||
transitions: Transitions
|
transitions: Transitions
|
||||||
relationship:
|
relationship:
|
||||||
id: ID
|
id: ID
|
||||||
regional_office: Regional department
|
|
||||||
from_date: From date
|
from_date: From date
|
||||||
session:
|
session:
|
||||||
id: ID
|
id: ID
|
||||||
|
|
|
@ -27,9 +27,6 @@ ru:
|
||||||
person_comment:
|
person_comment:
|
||||||
one: Комментарий
|
one: Комментарий
|
||||||
many: Комментарии
|
many: Комментарии
|
||||||
regional_office:
|
|
||||||
one: Региональное отделение
|
|
||||||
many: Региональные отделения
|
|
||||||
relation_status:
|
relation_status:
|
||||||
one: Статус отношения
|
one: Статус отношения
|
||||||
few: Статусы отношения
|
few: Статусы отношения
|
||||||
|
@ -65,7 +62,6 @@ ru:
|
||||||
name: Название
|
name: Название
|
||||||
federal_subject:
|
federal_subject:
|
||||||
id: ID
|
id: ID
|
||||||
regional_office: Региональное отделение
|
|
||||||
english_name: Название
|
english_name: Название
|
||||||
native_name: Название
|
native_name: Название
|
||||||
display_name: Название
|
display_name: Название
|
||||||
|
@ -105,8 +101,6 @@ ru:
|
||||||
id: ID
|
id: ID
|
||||||
attachment: Приложение
|
attachment: Приложение
|
||||||
text: Текст
|
text: Текст
|
||||||
regional_office:
|
|
||||||
id: ID
|
|
||||||
relation_status:
|
relation_status:
|
||||||
id: ID
|
id: ID
|
||||||
codename: Кодовое имя
|
codename: Кодовое имя
|
||||||
|
@ -114,7 +108,6 @@ ru:
|
||||||
transitions: Переходы
|
transitions: Переходы
|
||||||
relationship:
|
relationship:
|
||||||
id: ID
|
id: ID
|
||||||
regional_office: Региональное отделение
|
|
||||||
from_date: Дата начала
|
from_date: Дата начала
|
||||||
session:
|
session:
|
||||||
id: ID
|
id: ID
|
||||||
|
|
28
db/migrate/20190930210852_remove_regional_offices.rb
Normal file
28
db/migrate/20190930210852_remove_regional_offices.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RemoveRegionalOffices < ActiveRecord::Migration[6.0]
|
||||||
|
include Partynest::Migration
|
||||||
|
|
||||||
|
def change
|
||||||
|
remove_reference :relationships,
|
||||||
|
:regional_office,
|
||||||
|
null: false,
|
||||||
|
index: true,
|
||||||
|
foreign_key: true
|
||||||
|
|
||||||
|
drop_constraint :regional_offices, :name, <<~SQL
|
||||||
|
is_good_small_text(name)
|
||||||
|
SQL
|
||||||
|
|
||||||
|
drop_table :regional_offices do |t|
|
||||||
|
t.timestamps null: false
|
||||||
|
|
||||||
|
t.references :federal_subject,
|
||||||
|
null: false,
|
||||||
|
index: { unique: true },
|
||||||
|
foreign_key: true
|
||||||
|
|
||||||
|
t.string :name, null: false, index: { unique: true }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -643,39 +643,6 @@ CREATE SEQUENCE public.person_comments_id_seq
|
||||||
ALTER SEQUENCE public.person_comments_id_seq OWNED BY public.person_comments.id;
|
ALTER SEQUENCE public.person_comments_id_seq OWNED BY public.person_comments.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices; Type: TABLE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE TABLE public.regional_offices (
|
|
||||||
id bigint NOT NULL,
|
|
||||||
created_at timestamp(6) without time zone NOT NULL,
|
|
||||||
updated_at timestamp(6) without time zone NOT NULL,
|
|
||||||
federal_subject_id bigint NOT NULL,
|
|
||||||
name character varying NOT NULL,
|
|
||||||
CONSTRAINT name CHECK (public.is_good_small_text((name)::text))
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE SEQUENCE public.regional_offices_id_seq
|
|
||||||
START WITH 1
|
|
||||||
INCREMENT BY 1
|
|
||||||
NO MINVALUE
|
|
||||||
NO MAXVALUE
|
|
||||||
CACHE 1;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER SEQUENCE public.regional_offices_id_seq OWNED BY public.regional_offices.id;
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: relation_statuses; Type: TABLE; Schema: public; Owner: -
|
-- Name: relation_statuses; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -754,7 +721,6 @@ CREATE TABLE public.relationships (
|
||||||
created_at timestamp(6) without time zone NOT NULL,
|
created_at timestamp(6) without time zone NOT NULL,
|
||||||
updated_at timestamp(6) without time zone NOT NULL,
|
updated_at timestamp(6) without time zone NOT NULL,
|
||||||
person_id bigint NOT NULL,
|
person_id bigint NOT NULL,
|
||||||
regional_office_id bigint NOT NULL,
|
|
||||||
from_date date NOT NULL,
|
from_date date NOT NULL,
|
||||||
status_id bigint NOT NULL
|
status_id bigint NOT NULL
|
||||||
);
|
);
|
||||||
|
@ -983,13 +949,6 @@ ALTER TABLE ONLY public.people ALTER COLUMN id SET DEFAULT nextval('public.peopl
|
||||||
ALTER TABLE ONLY public.person_comments ALTER COLUMN id SET DEFAULT nextval('public.person_comments_id_seq'::regclass);
|
ALTER TABLE ONLY public.person_comments ALTER COLUMN id SET DEFAULT nextval('public.person_comments_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices id; Type: DEFAULT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.regional_offices ALTER COLUMN id SET DEFAULT nextval('public.regional_offices_id_seq'::regclass);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: relation_statuses id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: relation_statuses id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1128,14 +1087,6 @@ ALTER TABLE ONLY public.person_comments
|
||||||
ADD CONSTRAINT person_comments_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT person_comments_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices regional_offices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.regional_offices
|
|
||||||
ADD CONSTRAINT regional_offices_pkey PRIMARY KEY (id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: relation_statuses relation_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: relation_statuses relation_statuses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1360,20 +1311,6 @@ CREATE INDEX index_person_comments_on_account_id ON public.person_comments USING
|
||||||
CREATE INDEX index_person_comments_on_person_id ON public.person_comments USING btree (person_id);
|
CREATE INDEX index_person_comments_on_person_id ON public.person_comments USING btree (person_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_regional_offices_on_federal_subject_id; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX index_regional_offices_on_federal_subject_id ON public.regional_offices USING btree (federal_subject_id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_regional_offices_on_name; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE UNIQUE INDEX index_regional_offices_on_name ON public.regional_offices USING btree (name);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_relation_statuses_on_codename; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_relation_statuses_on_codename; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1430,13 +1367,6 @@ CREATE INDEX index_relationships_on_from_date ON public.relationships USING btre
|
||||||
CREATE UNIQUE INDEX index_relationships_on_person_id_and_from_date ON public.relationships USING btree (person_id, from_date);
|
CREATE UNIQUE INDEX index_relationships_on_person_id_and_from_date ON public.relationships USING btree (person_id, from_date);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_relationships_on_regional_office_id; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE INDEX index_relationships_on_regional_office_id ON public.relationships USING btree (regional_office_id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_relationships_on_status_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_relationships_on_status_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1521,14 +1451,6 @@ CREATE TRIGGER ensure_contact_list_id_remains_unchanged BEFORE UPDATE OF contact
|
||||||
CREATE TRIGGER ensure_superuser_has_related_user BEFORE INSERT OR UPDATE ON public.accounts FOR EACH ROW EXECUTE PROCEDURE public.ensure_superuser_has_related_user();
|
CREATE TRIGGER ensure_superuser_has_related_user BEFORE INSERT OR UPDATE ON public.accounts FOR EACH ROW EXECUTE PROCEDURE public.ensure_superuser_has_related_user();
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: relationships fk_rails_100235139c; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.relationships
|
|
||||||
ADD CONSTRAINT fk_rails_100235139c FOREIGN KEY (regional_office_id) REFERENCES public.regional_offices(id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: people fk_rails_4f02f930eb; Type: FK CONSTRAINT; Schema: public; Owner: -
|
-- Name: people fk_rails_4f02f930eb; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1585,14 +1507,6 @@ ALTER TABLE ONLY public.accounts
|
||||||
ADD CONSTRAINT fk_rails_77a360a20e FOREIGN KEY (contact_list_id) REFERENCES public.contact_lists(id);
|
ADD CONSTRAINT fk_rails_77a360a20e FOREIGN KEY (contact_list_id) REFERENCES public.contact_lists(id);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: regional_offices fk_rails_7a6d5fdd9a; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
ALTER TABLE ONLY public.regional_offices
|
|
||||||
ADD CONSTRAINT fk_rails_7a6d5fdd9a FOREIGN KEY (federal_subject_id) REFERENCES public.federal_subjects(id);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: relationships fk_rails_87a7339f1f; Type: FK CONSTRAINT; Schema: public; Owner: -
|
-- Name: relationships fk_rails_87a7339f1f; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1689,6 +1603,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20190928171705'),
|
('20190928171705'),
|
||||||
('20190929131544'),
|
('20190929131544'),
|
||||||
('20190930154031'),
|
('20190930154031'),
|
||||||
('20190930205337');
|
('20190930205337'),
|
||||||
|
('20190930210852');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :initial_person, class: Person do
|
factory :initial_person, class: Person do
|
||||||
transient do
|
transient do
|
||||||
regional_office { create :regional_office }
|
regional_office { nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
association :contact_list, factory: :empty_contact_list
|
association :contact_list, factory: :empty_contact_list
|
||||||
|
@ -17,66 +17,66 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :supporter_person, parent: :initial_person do
|
factory :supporter_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :supporter_relationship,
|
create :supporter_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :member_person, parent: :initial_person do
|
factory :member_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :member_relationship,
|
create :member_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :excluded_person, parent: :initial_person do
|
factory :excluded_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :excluded_relationship,
|
create :excluded_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :federal_manager_person, parent: :initial_person do
|
factory :federal_manager_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :federal_manager_relationship,
|
create :federal_manager_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :federal_supervisor_person, parent: :initial_person do
|
factory :federal_supervisor_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :federal_supervisor_relationship,
|
create :federal_supervisor_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :regional_manager_person, parent: :initial_person do
|
factory :regional_manager_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :regional_manager_relationship,
|
create :regional_manager_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :regional_supervisor_person, parent: :initial_person do
|
factory :regional_supervisor_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :regional_supervisor_relationship,
|
create :regional_supervisor_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :regional_secretary_person, parent: :initial_person do
|
factory :regional_secretary_person, parent: :initial_person do
|
||||||
after :create do |person, evaluator|
|
after :create do |person, _evaluator|
|
||||||
create :regional_secretary_relationship,
|
create :regional_secretary_relationship,
|
||||||
person: person,
|
person: person # ,
|
||||||
regional_office: evaluator.regional_office
|
# regional_office: evaluator.regional_office
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
FactoryBot.define do
|
|
||||||
factory :regional_office do
|
|
||||||
initialize_with do
|
|
||||||
RegionalOffice.find_or_initialize_by federal_subject: federal_subject
|
|
||||||
end
|
|
||||||
|
|
||||||
association :federal_subject
|
|
||||||
|
|
||||||
name { federal_subject&.native_name }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -4,7 +4,6 @@ FactoryBot.define do
|
||||||
factory :supporter_relationship, class: Relationship do
|
factory :supporter_relationship, class: Relationship do
|
||||||
association :status, factory: :some_relation_status
|
association :status, factory: :some_relation_status
|
||||||
association :person, factory: :initial_person
|
association :person, factory: :initial_person
|
||||||
association :regional_office
|
|
||||||
|
|
||||||
sequence :from_date do |n|
|
sequence :from_date do |n|
|
||||||
Date.new rand((10 * n)...(11 * n)), rand(1..12), rand(1..28)
|
Date.new rand((10 * n)...(11 * n)), rand(1..12), rand(1..28)
|
||||||
|
|
|
@ -21,10 +21,10 @@ end
|
||||||
When 'there is a supporter account with the following data:' do |table|
|
When 'there is a supporter account with the following data:' do |table|
|
||||||
options = table.raw.map { |(k, v)| [k.to_sym, v] }.to_h
|
options = table.raw.map { |(k, v)| [k.to_sym, v] }.to_h
|
||||||
|
|
||||||
federal_subject =
|
# federal_subject =
|
||||||
create :federal_subject, english_name: options[:federal_subject]
|
# create :federal_subject, english_name: options[:federal_subject]
|
||||||
regional_office = create :regional_office, federal_subject: federal_subject
|
# regional_office = create :regional_office, federal_subject: federal_subject
|
||||||
person = create :supporter_person, regional_office: regional_office
|
person = create :supporter_person # , regional_office: regional_office
|
||||||
|
|
||||||
create :personal_account,
|
create :personal_account,
|
||||||
nickname: options[:nickname],
|
nickname: options[:nickname],
|
||||||
|
@ -36,10 +36,10 @@ end
|
||||||
When 'there is an excluded member account with the following data:' do |table|
|
When 'there is an excluded member account with the following data:' do |table|
|
||||||
options = table.raw.map { |(k, v)| [k.to_sym, v] }.to_h
|
options = table.raw.map { |(k, v)| [k.to_sym, v] }.to_h
|
||||||
|
|
||||||
federal_subject =
|
# federal_subject =
|
||||||
create :federal_subject, english_name: options[:federal_subject]
|
# create :federal_subject, english_name: options[:federal_subject]
|
||||||
regional_office = create :regional_office, federal_subject: federal_subject
|
# regional_office = create :regional_office, federal_subject: federal_subject
|
||||||
person = create :excluded_person, regional_office: regional_office
|
person = create :excluded_person # , regional_office: regional_office
|
||||||
|
|
||||||
create :personal_account,
|
create :personal_account,
|
||||||
nickname: options[:nickname],
|
nickname: options[:nickname],
|
||||||
|
@ -53,10 +53,10 @@ When 'there is a member account with the following data:' do |table|
|
||||||
|
|
||||||
person_factory = options[:factory].presence || :member_person
|
person_factory = options[:factory].presence || :member_person
|
||||||
|
|
||||||
federal_subject =
|
# federal_subject =
|
||||||
create :federal_subject, english_name: options[:federal_subject]
|
# create :federal_subject, english_name: options[:federal_subject]
|
||||||
regional_office = create :regional_office, federal_subject: federal_subject
|
# regional_office = create :regional_office, federal_subject: federal_subject
|
||||||
person = create person_factory, regional_office: regional_office
|
person = create person_factory # , regional_office: regional_office
|
||||||
|
|
||||||
create :personal_account,
|
create :personal_account,
|
||||||
nickname: options[:nickname],
|
nickname: options[:nickname],
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe RegionalOfficesHelper do
|
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
|
|
@ -5,16 +5,6 @@ require 'rails_helper'
|
||||||
RSpec.describe FederalSubject do
|
RSpec.describe FederalSubject do
|
||||||
subject { create :federal_subject }
|
subject { create :federal_subject }
|
||||||
|
|
||||||
describe '#regional_office' do
|
|
||||||
it do
|
|
||||||
is_expected.to \
|
|
||||||
have_one(:regional_office)
|
|
||||||
.dependent(:restrict_with_exception)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to validate_presence_of :regional_office }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#to_param' do
|
describe '#to_param' do
|
||||||
specify do
|
specify do
|
||||||
expect(subject.to_param).to be_instance_of String
|
expect(subject.to_param).to be_instance_of String
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe RegionalOffice do
|
|
||||||
subject { create :regional_office }
|
|
||||||
|
|
||||||
describe '#federal_subject' do
|
|
||||||
it { is_expected.to belong_to :federal_subject }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.to \
|
|
||||||
validate_presence_of(:federal_subject)
|
|
||||||
.with_message(:required)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to validate_uniqueness_of :federal_subject }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#name' do
|
|
||||||
def allow_value(*)
|
|
||||||
super.for :name
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to validate_presence_of :name }
|
|
||||||
it { is_expected.to validate_uniqueness_of :name }
|
|
||||||
|
|
||||||
it do
|
|
||||||
is_expected.to validate_length_of(:name).is_at_least(1).is_at_most(255)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.not_to allow_value ' Foo' }
|
|
||||||
it { is_expected.not_to allow_value 'Foo ' }
|
|
||||||
it { is_expected.not_to allow_value "\tFoo" }
|
|
||||||
it { is_expected.not_to allow_value "Foo\t" }
|
|
||||||
it { is_expected.not_to allow_value "\nFoo" }
|
|
||||||
it { is_expected.not_to allow_value "Foo\n" }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -17,12 +17,6 @@ RSpec.describe Relationship do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#regional_office' do
|
|
||||||
it do
|
|
||||||
is_expected.to belong_to(:regional_office).required
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#from_date' do
|
describe '#from_date' do
|
||||||
it { is_expected.to validate_presence_of :from_date }
|
it { is_expected.to validate_presence_of :from_date }
|
||||||
|
|
||||||
|
|
Reference in a new issue