domain_neutral 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 783b0093f6eb8b04e3bfb15be2803569798d3f33
4
- data.tar.gz: 05d42b2f362c0755862b03084a20853a0e1ce437
3
+ metadata.gz: 2868d506ab5999b3bdfb949b1486c1a8cef507a9
4
+ data.tar.gz: 9c48bcc5503051b3ace5e5e169ec26dd6fb19edc
5
5
  SHA512:
6
- metadata.gz: 11c4fa755fc8b7815583afc578f3e67b8b4a2c0e12ef8ed7bcfe23d0501e9e0fb02921ed8519abc3937ae2d96660d26e9ebd15487337053ad4806d68bafcf8b6
7
- data.tar.gz: eab4f299c5bd5f047038d0e067a46d415f9a359845560fb5685e8f3a6609bbebf9e2d89d034d490f39d4e35c19bf63be1108be8840058c6b65f0fb69a7ac13c5
6
+ metadata.gz: 28e382c272fc6fbc15b513d5eac723683d97a447405d5d0f64fa58f232b3cdcc92c01572c79b5533951525d737c37ca2e51433fb0ae58f321b7702e0b4722aa4
7
+ data.tar.gz: 244d3890989160739db9f88a809a5cb6076448d732d97d4fcc452196c318476e307fd759aeca8a810b67cc4ef2aa7b02df320d9be3fd62f4ec09a4b104a0d066
@@ -9,7 +9,7 @@ module DomainNeutral
9
9
  r = reflect_on_association(name)
10
10
  class_eval <<-CODE, __FILE__, __LINE__
11
11
  def #{name}
12
- #{r.klass}.find(#{r.foreign_key})
12
+ #{r.foreign_key} && #{r.klass}.find(#{r.foreign_key})
13
13
  end
14
14
  CODE
15
15
  end
@@ -1,3 +1,3 @@
1
1
  module DomainNeutral
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
Binary file
@@ -5131,3 +5131,127 @@ DomainNeutral::DescriptorTest: test_: descriptor validation should require name
5131
5131
  -------------------------------------------------------------------------------------------
5132
5132
  DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" IS NULL AND "descriptors"."type" = 'Bull') LIMIT 1
5133
5133
   (0.0ms) rollback transaction
5134
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
5135
+  (0.1ms) begin transaction
5136
+ Fixture Delete (1.7ms) DELETE FROM "descriptors"
5137
+ Fixture Insert (0.5ms) INSERT INTO "descriptors" ("type", "symbol", "name", "description", "index", "value", "created_at", "updated_at", "id") VALUES ('Role', 'site_admin', 'Site admin', 'Site administrator', 1, 100, '2016-06-07 14:23:12', '2016-06-07 14:23:12', 206888308)
5138
+ Fixture Insert (0.1ms) INSERT INTO "descriptors" ("type", "symbol", "name", "description", "index", "value", "created_at", "updated_at", "id") VALUES ('Role', 'user_admin', 'User Administrator', 'Administers users and legal entities', 2, 200, '2016-06-07 14:23:12', '2016-06-07 14:23:12', 718075439)
5139
+ Fixture Delete (0.9ms) DELETE FROM "users"
5140
+ Fixture Insert (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at", "id", "role_id") VALUES ('Site boss', '2016-06-07 14:23:12', '2016-06-07 14:23:12', 980190962, 206888308)
5141
+ Fixture Insert (0.1ms) INSERT INTO "users" ("name", "created_at", "updated_at", "id", "role_id") VALUES ('User boss', '2016-06-07 14:23:12', '2016-06-07 14:23:12', 298486374, 718075439)
5142
+  (2.3ms) commit transaction
5143
+  (0.0ms) begin transaction
5144
+ ---------------------------------------------------------------------------------------------------
5145
+ DomainNeutral::DescriptorTest: test_: translation defined should work depending on current locale.
5146
+ ---------------------------------------------------------------------------------------------------
5147
+ Role Load (0.2ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Role') AND "descriptors"."symbol" = ? ORDER BY "descriptors"."id" ASC LIMIT 1 [["symbol", "user_admin"]]
5148
+ Role Load (0.0ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Role') AND "descriptors"."symbol" = ? ORDER BY "descriptors"."id" ASC LIMIT 1 [["symbol", "user_admin"]]
5149
+  (0.0ms) rollback transaction
5150
+  (0.0ms) begin transaction
5151
+ ---------------------------------------------------------------------------------------------------------
5152
+ DomainNeutral::DescriptorTest: test_: association should not try to find record when foreign key is nil.
5153
+ ---------------------------------------------------------------------------------------------------------
5154
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
5155
+  (0.0ms) rollback transaction
5156
+  (0.0ms) begin transaction
5157
+ -------------------------------------------------------------------------------------------
5158
+ DomainNeutral::DescriptorTest: test_: descriptor validation should require name to be set.
5159
+ -------------------------------------------------------------------------------------------
5160
+ DomainNeutral::Descriptor Exists (0.2ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" IS NULL AND "descriptors"."type" = 'Bull') LIMIT 1
5161
+  (0.0ms) rollback transaction
5162
+  (0.0ms) begin transaction
5163
+ ------------------------------------------------------------------------------------
5164
+ DomainNeutral::DescriptorTest: test_: association should override reader with find.
5165
+ ------------------------------------------------------------------------------------
5166
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 980190962]]
5167
+  (0.0ms) rollback transaction
5168
+  (0.0ms) begin transaction
5169
+ -----------------------------------------------------------------------------------
5170
+ DomainNeutral::DescriptorTest: test_: compareable should compare greater on index.
5171
+ -----------------------------------------------------------------------------------
5172
+  (0.0ms) rollback transaction
5173
+  (0.1ms) begin transaction
5174
+ ---------------------------------------------------------------------------------
5175
+ DomainNeutral::DescriptorTest: test_: compareable should compare lower on index.
5176
+ ---------------------------------------------------------------------------------
5177
+  (0.0ms) rollback transaction
5178
+  (0.0ms) begin transaction
5179
+ ----------------------------------------------------------------------------------
5180
+ DomainNeutral::DescriptorTest: test_: compareable should compare equals on index.
5181
+ ----------------------------------------------------------------------------------
5182
+  (0.0ms) rollback transaction
5183
+  (0.0ms) begin transaction
5184
+ ------------------------------------------------------------------------------------------
5185
+ DomainNeutral::DescriptorTest: test_: reference as id should support typecast to integer.
5186
+ ------------------------------------------------------------------------------------------
5187
+  (0.0ms) rollback transaction
5188
+  (0.0ms) begin transaction
5189
+ ----------------------------------------------------------------------------------------------------------------------------------
5190
+ DomainNeutral::DescriptorTest: test_: descriptor validation should require case sensitive unique value for symbol scoped to type.
5191
+ ----------------------------------------------------------------------------------------------------------------------------------
5192
+ Bull Load (0.1ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Bull') ORDER BY "descriptors"."id" ASC LIMIT 1
5193
+  (0.0ms) SAVEPOINT active_record_1
5194
+ SQL (0.3ms) INSERT INTO "descriptors" ("type", "symbol", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["type", "Bull"], ["symbol", "a"], ["created_at", "2016-06-07 14:23:12.678743"], ["updated_at", "2016-06-07 14:23:12.678743"]]
5195
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5196
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'a' AND "descriptors"."type" = 'Bull') LIMIT 1
5197
+ Bull Load (0.1ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Bull')
5198
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'a' AND "descriptors"."type" = 'Bulm') LIMIT 1
5199
+  (0.4ms) rollback transaction
5200
+  (0.0ms) begin transaction
5201
+ ----------------------------------------------------------------------------------------------------------
5202
+ DomainNeutral::DescriptorTest: test_: translation undefined should fall back to entity properties itself.
5203
+ ----------------------------------------------------------------------------------------------------------
5204
+  (0.0ms) rollback transaction
5205
+  (0.0ms) begin transaction
5206
+ ---------------------------------------------------------------------------
5207
+ DomainNeutral::DescriptorTest: test_: relationship should expose children.
5208
+ ---------------------------------------------------------------------------
5209
+  (0.0ms) SAVEPOINT active_record_1
5210
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'cow' AND "descriptors"."type" = 'Bull') LIMIT 1
5211
+ SQL (0.2ms) INSERT INTO "descriptors" ("type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["type", "Bull"], ["symbol", "cow"], ["name", "Cow"], ["created_at", "2016-06-07 14:23:12.688356"], ["updated_at", "2016-06-07 14:23:12.688356"]]
5212
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5213
+  (0.1ms) SAVEPOINT active_record_1
5214
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'calf' AND "descriptors"."type" = 'Bull') LIMIT 1
5215
+ SQL (0.4ms) INSERT INTO "descriptors" ("type", "parent_id", "parent_type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["type", "Bull"], ["parent_id", 718075440], ["parent_type", "DomainNeutral::Descriptor"], ["symbol", "calf"], ["name", "Calf"], ["created_at", "2016-06-07 14:23:12.695941"], ["updated_at", "2016-06-07 14:23:12.695941"]]
5216
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5217
+  (0.2ms) SELECT COUNT(*) FROM "descriptors" WHERE "descriptors"."type" IN ('Bull') AND "descriptors"."parent_id" = ? AND "descriptors"."parent_type" = ? [["parent_id", 718075440], ["parent_type", "DomainNeutral::Descriptor"]]
5218
+ Bull Load (0.1ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Bull') AND "descriptors"."parent_id" = ? AND "descriptors"."parent_type" = ? ORDER BY "descriptors"."id" ASC LIMIT 1 [["parent_id", 718075440], ["parent_type", "DomainNeutral::Descriptor"]]
5219
+  (0.8ms) rollback transaction
5220
+  (0.0ms) begin transaction
5221
+ -------------------------------------------------------------------------
5222
+ DomainNeutral::DescriptorTest: test_: relationship should expose parent.
5223
+ -------------------------------------------------------------------------
5224
+  (0.0ms) SAVEPOINT active_record_1
5225
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'cow' AND "descriptors"."type" = 'Bull') LIMIT 1
5226
+ SQL (0.2ms) INSERT INTO "descriptors" ("type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["type", "Bull"], ["symbol", "cow"], ["name", "Cow"], ["created_at", "2016-06-07 14:23:12.710311"], ["updated_at", "2016-06-07 14:23:12.710311"]]
5227
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5228
+  (0.0ms) SAVEPOINT active_record_1
5229
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'calf' AND "descriptors"."type" = 'Bull') LIMIT 1
5230
+ SQL (0.3ms) INSERT INTO "descriptors" ("type", "parent_id", "parent_type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["type", "Bull"], ["parent_id", 718075440], ["parent_type", "DomainNeutral::Descriptor"], ["symbol", "calf"], ["name", "Calf"], ["created_at", "2016-06-07 14:23:12.712449"], ["updated_at", "2016-06-07 14:23:12.712449"]]
5231
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5232
+  (0.6ms) rollback transaction
5233
+  (0.0ms) begin transaction
5234
+ ---------------------------------------------------------------------------------------------
5235
+ DomainNeutral::DescriptorTest: test_: descriptor validation should require symbol to be set.
5236
+ ---------------------------------------------------------------------------------------------
5237
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = '' AND "descriptors"."type" = 'Bull') LIMIT 1
5238
+  (0.0ms) rollback transaction
5239
+  (0.0ms) begin transaction
5240
+ ----------------------------------------------------------------------------
5241
+ DomainNeutral::DescriptorTest: test_: class methods should include symbols.
5242
+ ----------------------------------------------------------------------------
5243
+ Role Load (0.1ms) SELECT "descriptors".* FROM "descriptors" WHERE "descriptors"."type" IN ('Role')
5244
+  (0.0ms) rollback transaction
5245
+  (0.0ms) begin transaction
5246
+ --------------------------------------------------------------------------------------
5247
+ DomainNeutral::DescriptorTest: test_: relationship should return hash for to_heading.
5248
+ --------------------------------------------------------------------------------------
5249
+  (0.0ms) SAVEPOINT active_record_1
5250
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'cow' AND "descriptors"."type" = 'Bull') LIMIT 1
5251
+ SQL (0.2ms) INSERT INTO "descriptors" ("type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?) [["type", "Bull"], ["symbol", "cow"], ["name", "Cow"], ["created_at", "2016-06-07 14:23:12.720890"], ["updated_at", "2016-06-07 14:23:12.720890"]]
5252
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5253
+  (0.0ms) SAVEPOINT active_record_1
5254
+ DomainNeutral::Descriptor Exists (0.1ms) SELECT 1 AS one FROM "descriptors" WHERE ("descriptors"."symbol" = 'calf' AND "descriptors"."type" = 'Bull') LIMIT 1
5255
+ SQL (0.3ms) INSERT INTO "descriptors" ("type", "parent_id", "parent_type", "symbol", "name", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["type", "Bull"], ["parent_id", 718075440], ["parent_type", "DomainNeutral::Descriptor"], ["symbol", "calf"], ["name", "Calf"], ["created_at", "2016-06-07 14:23:12.722873"], ["updated_at", "2016-06-07 14:23:12.722873"]]
5256
+  (0.0ms) RELEASE SAVEPOINT active_record_1
5257
+  (0.7ms) rollback transaction
@@ -102,10 +102,15 @@ module DomainNeutral
102
102
  setup do
103
103
  @user = users(:one)
104
104
  end
105
- should 'override reader' do
105
+ should 'override reader with find' do
106
106
  Role.expects(:find).with(@user.role_id)
107
107
  @user.role
108
108
  end
109
+ should 'not try to find record when foreign key is nil' do
110
+ @user.role_id = nil
111
+ Role.expects(:find).never
112
+ @user.role
113
+ end
109
114
  end
110
115
  end
111
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domain_neutral
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Knut I. Stenmark