district_cn 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/district_cn/version.rb
CHANGED
@@ -9,16 +9,17 @@ end
|
|
9
9
|
ActiveRecord::Base.connection.instance_eval do
|
10
10
|
create_table :companies do |t|
|
11
11
|
t.string :name
|
12
|
+
t.string :loc_code
|
13
|
+
t.string :another_code
|
12
14
|
t.timestamps
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
class Company < ActiveRecord::Base
|
17
19
|
attr_accessor :region_code
|
18
|
-
attr_accessor :loc_code
|
19
20
|
attr_accessible :region_code
|
20
21
|
|
21
|
-
act_as_area_field :region_code
|
22
|
+
act_as_area_field :region_code,:loc_code
|
22
23
|
validates :region_code, presence: true
|
23
24
|
end
|
24
25
|
|
@@ -38,6 +39,12 @@ describe DistrictCn::ActAsAreaField do
|
|
38
39
|
expect(subject.region_code).to be_instance_of(DistrictCn::Code)
|
39
40
|
end
|
40
41
|
|
42
|
+
it "should return DistrictCn::Code instance" do
|
43
|
+
subject.loc_code = 331002
|
44
|
+
expect(subject.loc_code).to be_instance_of(DistrictCn::Code)
|
45
|
+
end
|
46
|
+
|
47
|
+
|
41
48
|
it "should cached" do
|
42
49
|
subject.region_code = 331002
|
43
50
|
expect(subject.region_code.object_id).to eq(subject.region_code.object_id)
|
@@ -52,9 +59,9 @@ describe DistrictCn::ActAsAreaField do
|
|
52
59
|
end
|
53
60
|
|
54
61
|
it "should return real value without acts_as_area_field" do
|
55
|
-
subject.
|
56
|
-
expect(subject.
|
57
|
-
expect(subject.
|
62
|
+
subject.another_code = 331002
|
63
|
+
expect(subject.another_code).to eq(331002)
|
64
|
+
expect(subject.another_code).not_to be_instance_of(DistrictCn::Code)
|
58
65
|
end
|
59
66
|
|
60
67
|
it "should be unvalid when region_code is blank" do
|