Remove Address model as unused

#480
This commit is contained in:
Artur Beljajev 2017-05-10 01:36:14 +03:00
parent 3954a7c074
commit f4ddebf5c3
8 changed files with 8 additions and 349 deletions

View file

@ -1,72 +0,0 @@
class Address < ActiveRecord::Base
include Versions # version/address_version.rb
LOCAL_TYPE_SHORT = 'loc'
INTERNATIONAL_TYPE_SHORT = 'int'
LOCAL_TYPE = 'LocalAddress'
TYPES = [
LOCAL_TYPE_SHORT,
INTERNATIONAL_TYPE_SHORT
]
belongs_to :contact
def country
Country.new(country_code)
end
class << self
# def validate_postal_info_types(parsed_frame)
# errors, used = [], []
# parsed_frame.css('postalInfo').each do |pi|
# attr = pi.attributes['type'].try(:value)
# errors << {
# code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')
# } and next unless attr
# unless TYPES.include?(attr)
# errors << {
# code: 2005,
# msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }
# }
# next
# end
# errors << {
# code: 2005,
# msg: I18n.t('errors.messages.repeating_postal_info')
# } and next if used.include?(attr)
# used << attr
# end; errors
# end
def extract_attributes(ah)
address_hash = {}
ah = ah.first if ah.is_a?(Array)
address_hash[:address_attributes] = addr_hash_from_params(ah)
address_hash
end
private
# def local?(postal_info)
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
# :international_address_attributes
# end
def addr_hash_from_params(addr)
return {} if addr.nil?
return {} unless addr[:addr].is_a?(Hash)
{ country_code: Country.new(addr[:addr][:cc]).try(:alpha2),
city: addr[:addr][:city],
street: pretty_street(addr[:addr][:street]), # [0],
# street2: addr[:addr][:street][1],
# street3: addr[:addr][:street][2],
zip: addr[:addr][:pc]
}.delete_if { |_k, v| v.nil? }
end
def pretty_street(param_street)
return param_street.join(',') if param_street.is_a?(Array)
param_street
end
end
end

View file

@ -1,5 +0,0 @@
class AddressVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_addresses
self.sequence_name = :log_addresses_id_seq
end

View file

@ -0,0 +1,6 @@
class RemoveAddressesWithVersions < ActiveRecord::Migration
def change
drop_table :addresses
drop_table :log_addresses
end
end

View file

@ -357,47 +357,6 @@ CREATE SEQUENCE accounts_id_seq
ALTER SEQUENCE accounts_id_seq OWNED BY accounts.id; ALTER SEQUENCE accounts_id_seq OWNED BY accounts.id;
--
-- Name: addresses; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE addresses (
id integer NOT NULL,
contact_id integer,
city character varying,
street character varying,
zip character varying,
created_at timestamp without time zone,
updated_at timestamp without time zone,
street2 character varying,
street3 character varying,
creator_str character varying,
updator_str character varying,
country_code character varying,
state character varying,
legacy_contact_id integer
);
--
-- Name: addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE addresses_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE addresses_id_seq OWNED BY addresses.id;
-- --
-- Name: api_users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- Name: api_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
-- --
@ -1421,44 +1380,6 @@ CREATE SEQUENCE log_accounts_id_seq
ALTER SEQUENCE log_accounts_id_seq OWNED BY log_accounts.id; ALTER SEQUENCE log_accounts_id_seq OWNED BY log_accounts.id;
--
-- Name: log_addresses; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE log_addresses (
id integer NOT NULL,
item_type character varying NOT NULL,
item_id integer NOT NULL,
event character varying NOT NULL,
whodunnit character varying,
object json,
object_changes json,
created_at timestamp without time zone,
session character varying,
children json,
uuid character varying
);
--
-- Name: log_addresses_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE log_addresses_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: log_addresses_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE log_addresses_id_seq OWNED BY log_addresses.id;
-- --
-- Name: log_api_users; Type: TABLE; Schema: public; Owner: -; Tablespace: -- Name: log_api_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
-- --
@ -2985,13 +2906,6 @@ ALTER TABLE ONLY account_activities ALTER COLUMN id SET DEFAULT nextval('account
ALTER TABLE ONLY accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq'::regclass); ALTER TABLE ONLY accounts ALTER COLUMN id SET DEFAULT nextval('accounts_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY addresses ALTER COLUMN id SET DEFAULT nextval('addresses_id_seq'::regclass);
-- --
-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- Name: id; Type: DEFAULT; Schema: public; Owner: -
-- --
@ -3167,13 +3081,6 @@ ALTER TABLE ONLY log_account_activities ALTER COLUMN id SET DEFAULT nextval('log
ALTER TABLE ONLY log_accounts ALTER COLUMN id SET DEFAULT nextval('log_accounts_id_seq'::regclass); ALTER TABLE ONLY log_accounts ALTER COLUMN id SET DEFAULT nextval('log_accounts_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY log_addresses ALTER COLUMN id SET DEFAULT nextval('log_addresses_id_seq'::regclass);
-- --
-- Name: id; Type: DEFAULT; Schema: public; Owner: - -- Name: id; Type: DEFAULT; Schema: public; Owner: -
-- --
@ -3463,14 +3370,6 @@ ALTER TABLE ONLY accounts
ADD CONSTRAINT accounts_pkey PRIMARY KEY (id); ADD CONSTRAINT accounts_pkey PRIMARY KEY (id);
--
-- Name: addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY addresses
ADD CONSTRAINT addresses_pkey PRIMARY KEY (id);
-- --
-- Name: api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
@ -3671,14 +3570,6 @@ ALTER TABLE ONLY log_accounts
ADD CONSTRAINT log_accounts_pkey PRIMARY KEY (id); ADD CONSTRAINT log_accounts_pkey PRIMARY KEY (id);
--
-- Name: log_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY log_addresses
ADD CONSTRAINT log_addresses_pkey PRIMARY KEY (id);
-- --
-- Name: log_api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- Name: log_api_users_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
-- --
@ -4307,20 +4198,6 @@ CREATE INDEX index_log_accounts_on_item_type_and_item_id ON log_accounts USING b
CREATE INDEX index_log_accounts_on_whodunnit ON log_accounts USING btree (whodunnit); CREATE INDEX index_log_accounts_on_whodunnit ON log_accounts USING btree (whodunnit);
--
-- Name: index_log_addresses_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_addresses_on_item_type_and_item_id ON log_addresses USING btree (item_type, item_id);
--
-- Name: index_log_addresses_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_log_addresses_on_whodunnit ON log_addresses USING btree (whodunnit);
-- --
-- Name: index_log_api_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- Name: index_log_api_users_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
-- --
@ -5257,3 +5134,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170423225333');
INSERT INTO schema_migrations (version) VALUES ('20170424115801'); INSERT INTO schema_migrations (version) VALUES ('20170424115801');
INSERT INTO schema_migrations (version) VALUES ('20170509215614');

View file

@ -216,17 +216,6 @@
<ellipse fill="none" stroke="#012c8d" cx="579.023" cy="-73.4182" rx="4.00001" ry="4.00001"/> <ellipse fill="none" stroke="#012c8d" cx="579.023" cy="-73.4182" rx="4.00001" ry="4.00001"/>
<polygon fill="#012c8d" stroke="#012c8d" points="1479.02,-19.5188 1489.05,-23.9393 1484.02,-19.4791 1489.02,-19.4394 1489.02,-19.4394 1489.02,-19.4394 1484.02,-19.4791 1488.98,-14.9396 1479.02,-19.5188 1479.02,-19.5188"/> <polygon fill="#012c8d" stroke="#012c8d" points="1479.02,-19.5188 1489.05,-23.9393 1484.02,-19.4791 1489.02,-19.4394 1489.02,-19.4394 1489.02,-19.4394 1484.02,-19.4791 1488.98,-14.9396 1479.02,-19.5188 1479.02,-19.5188"/>
</g> </g>
<!-- AddressVersion -->
<g id="node20" class="node"><title>AddressVersion</title>
<ellipse fill="none" stroke="black" cx="3260.99" cy="-91" rx="67.6881" ry="18"/>
<text text-anchor="middle" x="3260.99" y="-87.3" font-family="Times,serif" font-size="14.00">AddressVersion</text>
</g>
<!-- AddressVersion&#45;&gt;VersionAssociation -->
<g id="edge18" class="edge"><title>AddressVersion&#45;&gt;VersionAssociation</title>
<path fill="none" stroke="#9f7cb6" d="M3205.28,-76.4424C3198.15,-75.0787 3190.93,-73.8762 3183.99,-73 2939.13,-42.0435 2875.67,-62.2947 2628.99,-54 2268.68,-41.8838 1839.45,-27.8273 1657.5,-21.8862"/>
<ellipse fill="none" stroke="#9f7cb6" cx="3209.66" cy="-77.3209" rx="4.00001" ry="4.00001"/>
<polygon fill="#9f7cb6" stroke="#9f7cb6" points="1657.45,-21.8844 1647.6,-17.0604 1652.45,-21.7212 1647.45,-21.558 1647.45,-21.558 1647.45,-21.558 1652.45,-21.7212 1647.31,-26.0556 1657.45,-21.8844 1657.45,-21.8844"/>
</g>
<!-- BankStatementVersion --> <!-- BankStatementVersion -->
<g id="node21" class="node"><title>BankStatementVersion</title> <g id="node21" class="node"><title>BankStatementVersion</title>
<ellipse fill="none" stroke="black" cx="612.994" cy="-253" rx="92.8835" ry="18"/> <ellipse fill="none" stroke="black" cx="612.994" cy="-253" rx="92.8835" ry="18"/>
@ -1442,18 +1431,6 @@
<polygon fill="#8b10e0" stroke="#8b10e0" points="832.955,-334.569 833.988,-323.652 831.341,-329.837 829.728,-325.104 829.728,-325.104 829.728,-325.104 831.341,-329.837 825.469,-326.556 832.955,-334.569 832.955,-334.569"/> <polygon fill="#8b10e0" stroke="#8b10e0" points="832.955,-334.569 833.988,-323.652 831.341,-329.837 829.728,-325.104 829.728,-325.104 829.728,-325.104 831.341,-329.837 825.469,-326.556 832.955,-334.569 832.955,-334.569"/>
<text text-anchor="middle" x="860.994" y="-357.3" font-family="Times,serif" font-size="14.00">versions</text> <text text-anchor="middle" x="860.994" y="-357.3" font-family="Times,serif" font-size="14.00">versions</text>
</g> </g>
<!-- Address -->
<g id="node68" class="node"><title>Address</title>
<ellipse fill="none" stroke="black" cx="3518.99" cy="-199" rx="39.7935" ry="18"/>
<text text-anchor="middle" x="3518.99" y="-195.3" font-family="Times,serif" font-size="14.00">Address</text>
</g>
<!-- Address&#45;&gt;AddressVersion -->
<g id="edge174" class="edge"><title>Address&#45;&gt;AddressVersion</title>
<path fill="none" stroke="#3b7ce0" d="M3500.25,-175.77C3485.34,-159.618 3463.05,-138.63 3438.99,-127 3397.55,-106.966 3382.13,-118.027 3336.99,-109 3331.61,-107.923 3326.02,-106.76 3320.42,-105.565"/>
<ellipse fill="none" stroke="#3b7ce0" cx="3503.1" cy="-178.941" rx="4.00002" ry="4.00002"/>
<polygon fill="#3b7ce0" stroke="#3b7ce0" points="3320.17,-105.509 3311.35,-98.9929 3315.28,-104.45 3310.39,-103.391 3310.39,-103.391 3310.39,-103.391 3315.28,-104.45 3309.44,-107.789 3320.17,-105.509 3320.17,-105.509"/>
<text text-anchor="middle" x="3509.99" y="-141.3" font-family="Times,serif" font-size="14.00">versions</text>
</g>
<!-- LegalDocument&#45;&gt;LegalDocumentVersion --> <!-- LegalDocument&#45;&gt;LegalDocumentVersion -->
<g id="edge177" class="edge"><title>LegalDocument&#45;&gt;LegalDocumentVersion</title> <g id="edge177" class="edge"><title>LegalDocument&#45;&gt;LegalDocumentVersion</title>
<path fill="none" stroke="#1c3760" d="M2444.6,-196.382C2359.77,-193.481 2228.05,-185.408 2183.99,-163 2163.9,-152.78 2147.11,-133.415 2135.78,-117.487"/> <path fill="none" stroke="#1c3760" d="M2444.6,-196.382C2359.77,-193.481 2228.05,-185.408 2183.99,-163 2163.9,-152.78 2147.11,-133.415 2135.78,-117.487"/>

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Before After
Before After

View file

@ -423,28 +423,6 @@
<ellipse fill="none" stroke="#2ea726" cx="675.993" cy="-75.322" rx="4.00002" ry="4.00002"/> <ellipse fill="none" stroke="#2ea726" cx="675.993" cy="-75.322" rx="4.00002" ry="4.00002"/>
<polygon fill="#2ea726" stroke="#2ea726" points="1666.82,-18.3546 1676.8,-22.9065 1671.82,-18.3806 1676.82,-18.4066 1676.82,-18.4066 1676.82,-18.4066 1671.82,-18.3806 1676.85,-13.9066 1666.82,-18.3546 1666.82,-18.3546"/> <polygon fill="#2ea726" stroke="#2ea726" points="1666.82,-18.3546 1676.8,-22.9065 1671.82,-18.3806 1676.82,-18.4066 1676.82,-18.4066 1676.82,-18.4066 1671.82,-18.3806 1676.85,-13.9066 1666.82,-18.3546 1666.82,-18.3546"/>
</g> </g>
<!-- AddressVersion -->
<g id="node20" class="node"><title>AddressVersion</title>
<path fill="none" stroke="black" d="M3306,-73.5C3306,-73.5 3412,-73.5 3412,-73.5 3418,-73.5 3424,-79.5 3424,-85.5 3424,-85.5 3424,-242.5 3424,-242.5 3424,-248.5 3418,-254.5 3412,-254.5 3412,-254.5 3306,-254.5 3306,-254.5 3300,-254.5 3294,-248.5 3294,-242.5 3294,-242.5 3294,-85.5 3294,-85.5 3294,-79.5 3300,-73.5 3306,-73.5"/>
<text text-anchor="middle" x="3359" y="-239.3" font-family="Times,serif" font-size="14.00">AddressVersion</text>
<polyline fill="none" stroke="black" points="3294,-231.5 3424,-231.5 "/>
<text text-anchor="start" x="3302" y="-216.3" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="3302" y="-201.3" font-family="Times,serif" font-size="14.00">item_type :string</text>
<text text-anchor="start" x="3302" y="-186.3" font-family="Times,serif" font-size="14.00">item_id :integer</text>
<text text-anchor="start" x="3302" y="-171.3" font-family="Times,serif" font-size="14.00">event :string</text>
<text text-anchor="start" x="3302" y="-156.3" font-family="Times,serif" font-size="14.00">whodunnit :string</text>
<text text-anchor="start" x="3302" y="-141.3" font-family="Times,serif" font-size="14.00">object :json</text>
<text text-anchor="start" x="3302" y="-126.3" font-family="Times,serif" font-size="14.00">object_changes :json</text>
<text text-anchor="start" x="3302" y="-111.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="3302" y="-96.3" font-family="Times,serif" font-size="14.00">session :string</text>
<text text-anchor="start" x="3302" y="-81.3" font-family="Times,serif" font-size="14.00">children :json</text>
</g>
<!-- AddressVersion&#45;&gt;VersionAssociation -->
<g id="edge18" class="edge"><title>AddressVersion&#45;&gt;VersionAssociation</title>
<path fill="none" stroke="#798c06" d="M3287.01,-74.0397C3286.34,-73.6842 3285.67,-73.3375 3285,-73 3127.13,6.24968 3064.51,-60.9544 2888,-54 2500.09,-38.7165 2037.12,-26.1729 1846.12,-21.2463"/>
<ellipse fill="none" stroke="#798c06" cx="3290.53" cy="-76.1313" rx="4.00002" ry="4.00002"/>
<polygon fill="#798c06" stroke="#798c06" points="1845.86,-21.2395 1835.97,-16.4836 1840.86,-21.1108 1835.86,-20.9821 1835.86,-20.9821 1835.86,-20.9821 1840.86,-21.1108 1835.74,-25.4806 1845.86,-21.2395 1845.86,-21.2395"/>
</g>
<!-- BankStatementVersion --> <!-- BankStatementVersion -->
<g id="node21" class="node"><title>BankStatementVersion</title> <g id="node21" class="node"><title>BankStatementVersion</title>
<path fill="none" stroke="black" d="M606.5,-733.5C606.5,-733.5 725.5,-733.5 725.5,-733.5 731.5,-733.5 737.5,-739.5 737.5,-745.5 737.5,-745.5 737.5,-902.5 737.5,-902.5 737.5,-908.5 731.5,-914.5 725.5,-914.5 725.5,-914.5 606.5,-914.5 606.5,-914.5 600.5,-914.5 594.5,-908.5 594.5,-902.5 594.5,-902.5 594.5,-745.5 594.5,-745.5 594.5,-739.5 600.5,-733.5 606.5,-733.5"/> <path fill="none" stroke="black" d="M606.5,-733.5C606.5,-733.5 725.5,-733.5 725.5,-733.5 731.5,-733.5 737.5,-739.5 737.5,-745.5 737.5,-745.5 737.5,-902.5 737.5,-902.5 737.5,-908.5 731.5,-914.5 725.5,-914.5 725.5,-914.5 606.5,-914.5 606.5,-914.5 600.5,-914.5 594.5,-908.5 594.5,-902.5 594.5,-902.5 594.5,-745.5 594.5,-745.5 594.5,-739.5 600.5,-733.5 606.5,-733.5"/>
@ -2276,33 +2254,6 @@
<polygon fill="#3b5255" stroke="#3b5255" points="933.283,-1372.03 937.019,-1361.72 932.908,-1367.04 932.532,-1362.06 932.532,-1362.06 932.532,-1362.06 932.908,-1367.04 928.045,-1362.39 933.283,-1372.03 933.283,-1372.03"/> <polygon fill="#3b5255" stroke="#3b5255" points="933.283,-1372.03 937.019,-1361.72 932.908,-1367.04 932.532,-1362.06 932.532,-1362.06 932.532,-1362.06 932.908,-1367.04 928.045,-1362.39 933.283,-1372.03 933.283,-1372.03"/>
<text text-anchor="middle" x="1000" y="-1707.8" font-family="Times,serif" font-size="14.00">versions</text> <text text-anchor="middle" x="1000" y="-1707.8" font-family="Times,serif" font-size="14.00">versions</text>
</g> </g>
<!-- Address -->
<g id="node68" class="node"><title>Address</title>
<path fill="none" stroke="black" d="M3937,-473.5C3937,-473.5 4073,-473.5 4073,-473.5 4079,-473.5 4085,-479.5 4085,-485.5 4085,-485.5 4085,-702.5 4085,-702.5 4085,-708.5 4079,-714.5 4073,-714.5 4073,-714.5 3937,-714.5 3937,-714.5 3931,-714.5 3925,-708.5 3925,-702.5 3925,-702.5 3925,-485.5 3925,-485.5 3925,-479.5 3931,-473.5 3937,-473.5"/>
<text text-anchor="middle" x="4005" y="-699.3" font-family="Times,serif" font-size="14.00">Address</text>
<polyline fill="none" stroke="black" points="3925,-691.5 4085,-691.5 "/>
<text text-anchor="start" x="3933" y="-676.3" font-family="Times,serif" font-size="14.00">id :integer</text>
<text text-anchor="start" x="3933" y="-661.3" font-family="Times,serif" font-size="14.00">contact_id :integer</text>
<text text-anchor="start" x="3933" y="-646.3" font-family="Times,serif" font-size="14.00">city :string</text>
<text text-anchor="start" x="3933" y="-631.3" font-family="Times,serif" font-size="14.00">street :string</text>
<text text-anchor="start" x="3933" y="-616.3" font-family="Times,serif" font-size="14.00">zip :string</text>
<text text-anchor="start" x="3933" y="-601.3" font-family="Times,serif" font-size="14.00">created_at :datetime</text>
<text text-anchor="start" x="3933" y="-586.3" font-family="Times,serif" font-size="14.00">updated_at :datetime</text>
<text text-anchor="start" x="3933" y="-571.3" font-family="Times,serif" font-size="14.00">street2 :string</text>
<text text-anchor="start" x="3933" y="-556.3" font-family="Times,serif" font-size="14.00">street3 :string</text>
<text text-anchor="start" x="3933" y="-541.3" font-family="Times,serif" font-size="14.00">creator_str :string</text>
<text text-anchor="start" x="3933" y="-526.3" font-family="Times,serif" font-size="14.00">updator_str :string</text>
<text text-anchor="start" x="3933" y="-511.3" font-family="Times,serif" font-size="14.00">country_code :string</text>
<text text-anchor="start" x="3933" y="-496.3" font-family="Times,serif" font-size="14.00">state :string</text>
<text text-anchor="start" x="3933" y="-481.3" font-family="Times,serif" font-size="14.00">legacy_contact_id :integer</text>
</g>
<!-- Address&#45;&gt;AddressVersion -->
<g id="edge174" class="edge"><title>Address&#45;&gt;AddressVersion</title>
<path fill="none" stroke="#a84372" d="M3983.67,-465.242C3965.08,-396.369 3930.6,-316.747 3867,-273 3827.24,-245.647 3476.2,-276.515 3433,-255 3432.9,-254.952 3432.81,-254.904 3432.71,-254.856"/>
<ellipse fill="none" stroke="#a84372" cx="3984.73" cy="-469.286" rx="4.00001" ry="4.00001"/>
<polygon fill="#a84372" stroke="#a84372" points="3432.68,-254.84 3426.26,-245.953 3428.35,-252.347 3424.02,-249.854 3424.02,-249.854 3424.02,-249.854 3428.35,-252.347 3421.77,-253.754 3432.68,-254.84 3432.68,-254.84"/>
<text text-anchor="middle" x="4002" y="-360.3" font-family="Times,serif" font-size="14.00">versions</text>
</g>
<!-- LegalDocument&#45;&gt;LegalDocumentVersion --> <!-- LegalDocument&#45;&gt;LegalDocumentVersion -->
<g id="edge177" class="edge"><title>LegalDocument&#45;&gt;LegalDocumentVersion</title> <g id="edge177" class="edge"><title>LegalDocument&#45;&gt;LegalDocumentVersion</title>
<path fill="none" stroke="#109cef" d="M2781.55,-559.812C2709.48,-533.654 2604.67,-497.607 2511,-473 2470.28,-462.304 2447.06,-485.466 2418,-455 2370.61,-405.307 2361.52,-327.39 2363.51,-264.829"/> <path fill="none" stroke="#109cef" d="M2781.55,-559.812C2709.48,-533.654 2604.67,-497.607 2511,-473 2470.28,-462.304 2447.06,-485.466 2418,-455 2370.61,-405.307 2361.52,-327.39 2363.51,-264.829"/>

Before

Width:  |  Height:  |  Size: 244 KiB

After

Width:  |  Height:  |  Size: 239 KiB

Before After
Before After

View file

@ -1,6 +0,0 @@
Fabricator(:address) do
city 'test city'
street 'test street'
street2 'test street'
zip 12345
end

View file

@ -1,71 +0,0 @@
require 'rails_helper'
describe Address do
context 'about class' do
it 'should have versioning enabled?' do
Address.paper_trail_enabled_for_model?.should == true
end
it 'should have custom log prexied table name for versions table' do
AddressVersion.table_name.should == 'log_addresses'
end
end
context 'with invalid attribute' do
before :all do
@address = Address.new
end
it 'should not be valid' do
@address.valid?
@address.errors.full_messages.should match_array([
])
end
it 'should not have any versions' do
@address.versions.should == []
end
end
context 'with valid attributes' do
before :all do
@address = Fabricate(:address)
end
it 'should be valid' do
@address.valid?
@address.errors.full_messages.should match_array([])
end
it 'should be valid twice' do
@address = Fabricate(:address)
@address.valid?
@address.errors.full_messages.should match_array([])
end
it 'should have one version' do
with_versioning do
@address.versions.should == []
@address.zip = 'New zip'
@address.save
@address.errors.full_messages.should match_array([])
@address.versions.size.should == 1
end
end
end
end
# TODO: country issue
# describe Address, '.extract_params' do
# it 'returns params hash' do
# Fabricate(:country, iso: 'EE')
# ph = { postalInfo: { name: 'fred', addr: { cc: 'EE', city: 'Village', street: 'street1' } } }
# expect(Address.extract_attributes(ph[:postalInfo])).to eq({
# address_attributes: {
# country_id: Country.find_by(iso: 'EE').id,
# city: 'Village',
# street: 'street1'
# }
# })
# end
# end