rails_attr_enum 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +18 -0
- data/lib/rails_attr_enum.rb +8 -4
- data/lib/rails_attr_enum/entry.rb +13 -1
- data/lib/rails_attr_enum/enum.rb +44 -0
- data/lib/rails_attr_enum/enum_accumulator.rb +5 -3
- data/lib/rails_attr_enum/version.rb +1 -1
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +65 -0
- data/test/dummy/log/test.log +400 -0
- data/test/dummy/spec/spec_helper.rb +10 -1
- data/test/dummy/spec/to_h_spec.rb +95 -0
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTZmNmQyMTg3YzVmN2VmYjgyNGFmZDJkYjZiMzhlYzFkYmRjMDRhMg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzUyMTU2NTJhMDIzYzY0NjU4MmJjMGE5MmE5ZGVjYzIwNDJiNTllOQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTM2MDQwMGRmYTU0ZWM5Njg1MTMxMzJjNWM1ZDUwZTFjNDI2MTZhMmZmZTI1
|
10
|
+
ODEwZDMyOWNhZDkyNmJlNDM5MjFiMWI0ZjQ0YmYxNTczNGI1MThkYzlhMDU4
|
11
|
+
NzRmNTQwYjZlM2JlNGU2ZmYzOThlMzhlYzJlYWMzNzI5Y2I3MGM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWVhOTEwNDM0YWJlYTg3ZTc4NGExNmRlNGRiNzhmNDcyNDQyNTY0MzdlZDdk
|
14
|
+
ZGNiM2M3NGQ1Y2QwMDIwNWE2OTU0Zjc1MjZjOTk1NTI0NDJkYWQ5NjYyNzY5
|
15
|
+
Y2ZhNzIxYzRkYmNhOTM5NWFlMmNmOGZmNGRkMmMzNjdhYWZmZTU=
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
### v0.0.6
|
2
|
+
* Added example usage of extending `RailsAttrEnum` and calling
|
3
|
+
`attr_enum` in `User` model in test Rails app.
|
4
|
+
* Fixed a bug that crashed the Rails environment when a model without an
|
5
|
+
existing table used `RailsAttrEnum`. An example of this happening
|
6
|
+
would be when someone tried to run `rake db:schema:load`.
|
7
|
+
* Fixed a bug in `clear_user` in the spec_helper.rb file with calling
|
8
|
+
the private `remove_instance_variable` method on the test model
|
9
|
+
`User`.
|
10
|
+
* Added `default_user_roles` to spec_helper.rb file, so a default usage
|
11
|
+
of extending `RailsAttrEnum` and calling `attr_enum` could be
|
12
|
+
established. This allows other future specs that depend on that
|
13
|
+
default usage to not be messed up by the user_spec.rb file which
|
14
|
+
alters `RailsAttrEnum` usage in `User` for different tests.
|
15
|
+
|
16
|
+
### v0.0.5
|
17
|
+
* Fix a bug with the 'to_json' and 'as_json' methods for a model that
|
18
|
+
has an enum attribute set up.
|
data/lib/rails_attr_enum.rb
CHANGED
@@ -32,7 +32,7 @@ module RailsAttrEnum
|
|
32
32
|
|
33
33
|
@_attr_enums ||= {}
|
34
34
|
|
35
|
-
|
35
|
+
if table_exists? && !column_names.include?(attr.name)
|
36
36
|
raise "Invalid attribute name #{attr.name}"
|
37
37
|
end
|
38
38
|
|
@@ -42,10 +42,14 @@ module RailsAttrEnum
|
|
42
42
|
|
43
43
|
@_attr_enums[attr.name.to_sym] = Module.new { include Enum }.tap do |mod|
|
44
44
|
mod.init_enum(attr.name)
|
45
|
-
entries.each(&mod.method(:add))
|
46
45
|
const_set(attr.enum_name, mod)
|
47
|
-
|
48
|
-
|
46
|
+
validates(attr.name.to_sym, validation_rules.merge(inclusion: { in: mod.values }))
|
47
|
+
|
48
|
+
entries.each do |entry|
|
49
|
+
mod.add(entry)
|
50
|
+
class_eval <<-EOS
|
51
|
+
scope :#{attr.name}_#{entry.key}, -> { where(:#{attr.name} => #{entry.value}) }
|
52
|
+
EOS
|
49
53
|
end
|
50
54
|
end
|
51
55
|
|
@@ -2,5 +2,17 @@ require 'ostruct'
|
|
2
2
|
|
3
3
|
module RailsAttrEnum
|
4
4
|
## Enum entry class
|
5
|
-
Entry = Struct.new(:key, :value, :label)
|
5
|
+
Entry = Struct.new(:const_name, :key, :value, :label) do
|
6
|
+
# Add a to_h method if it doesn't exist (< ruby 2.0)
|
7
|
+
unless nil.respond_to?(:to_h)
|
8
|
+
def to_h
|
9
|
+
# Hash[*(entry.members.flat_map { |key| [key, entry.send(key)] })]
|
10
|
+
Hash[members.map { |key| [key, send(key)] }]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_json(*args)
|
15
|
+
to_h.to_json
|
16
|
+
end
|
17
|
+
end
|
6
18
|
end
|
data/lib/rails_attr_enum/enum.rb
CHANGED
@@ -38,6 +38,50 @@ module RailsAttrEnum
|
|
38
38
|
def values; mapped(:value) end
|
39
39
|
def labels; mapped(:label) end
|
40
40
|
|
41
|
+
def to_h(options = {})
|
42
|
+
default_to_include = [:key, :value, :label]
|
43
|
+
|
44
|
+
[:only, :except].each do |key|
|
45
|
+
if options.include?(key)
|
46
|
+
if options[key].is_a?(Symbol)
|
47
|
+
options[key] = [options[key]]
|
48
|
+
elsif options[key].empty?
|
49
|
+
options[key] = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
unless options[key].nil? || (options[key] - default_to_include).empty?
|
53
|
+
raise 'Unknown keys for enum'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
to_include =
|
59
|
+
if !options[:only].nil?
|
60
|
+
default_to_include & options[:only]
|
61
|
+
elsif !options[:except].nil?
|
62
|
+
default_to_include - options[:except]
|
63
|
+
else
|
64
|
+
default_to_include
|
65
|
+
end
|
66
|
+
|
67
|
+
builder =
|
68
|
+
if to_include.size == 1
|
69
|
+
to_include = to_include.first
|
70
|
+
proc { |entry| [entry.const_name, entry.send(to_include)]}
|
71
|
+
else
|
72
|
+
proc do |entry|
|
73
|
+
value = Hash[entry.to_h.select { |(key, _)| to_include.include?(key) }]
|
74
|
+
[entry.const_name, value]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Hash[@entries.map(&builder)]
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_json(options = {})
|
82
|
+
to_h(options).to_json
|
83
|
+
end
|
84
|
+
|
41
85
|
private
|
42
86
|
|
43
87
|
def get_from_entries(key, value)
|
@@ -31,7 +31,9 @@ module RailsAttrEnum
|
|
31
31
|
label = key.to_s.titleize
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
const_name = key.to_s.upcase
|
35
|
+
|
36
|
+
add_entry(const_name, key, value, label)
|
35
37
|
end
|
36
38
|
|
37
39
|
def validates(rules = {})
|
@@ -40,8 +42,8 @@ module RailsAttrEnum
|
|
40
42
|
|
41
43
|
private
|
42
44
|
|
43
|
-
def add_entry(key, value, label)
|
44
|
-
Entry.new(key, value, label).tap do |entry|
|
45
|
+
def add_entry(const_name, key, value, label)
|
46
|
+
Entry.new(const_name, key, value, label).tap do |entry|
|
45
47
|
revalue_entries!(value)
|
46
48
|
@entries << entry
|
47
49
|
@values << value
|
Binary file
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -32,3 +32,68 @@ Migrating to CreateUsers (20131023212242)
|
|
32
32
|
[1m[35m (0.1ms)[0m begin transaction
|
33
33
|
[1m[36mSQL (0.3ms)[0m [1mDELETE FROM "users" WHERE "users"."id" = ?[0m [["id", 3]]
|
34
34
|
[1m[35m (1.2ms)[0m commit transaction
|
35
|
+
[1m[36mUser Load (0.5ms)[0m [1mSELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1[0m
|
36
|
+
[1m[35m (0.1ms)[0m begin transaction
|
37
|
+
[1m[36mSQL (85.7ms)[0m [1mINSERT INTO "users" ("created_at", "name", "role", "updated_at") VALUES (?, ?, ?, ?)[0m [["created_at", Thu, 31 Oct 2013 16:03:34 UTC +00:00], ["name", "jeremy fairbank"], ["role", 1], ["updated_at", Thu, 31 Oct 2013 16:03:34 UTC +00:00]]
|
38
|
+
[1m[35m (1.7ms)[0m commit transaction
|
39
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1[0m
|
40
|
+
[1m[36mUser Load (23.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2[0m
|
41
|
+
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 0[0m
|
42
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 2
|
43
|
+
[1m[36m (0.3ms)[0m [1mSELECT COUNT(*) FROM "users"[0m
|
44
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 1
|
45
|
+
[1m[36mUser Load (0.4ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1 AND (name like '%j%')[0m
|
46
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 1
|
47
|
+
[1m[36mUser Load (0.4ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1[0m
|
48
|
+
DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. (called from method_missing at /Users/jeremy/Dropbox/projects/rails_attr_enum/lib/rails_attr_enum.rb:83)
|
49
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1[0m
|
50
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2[0m
|
51
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 0
|
52
|
+
[1m[36mUser Load (0.4ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2[0m
|
53
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 1
|
54
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1 AND (name like '%j%')[0m
|
55
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 1 AND (name like '%j%')
|
56
|
+
DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead. (called from irb_binding at (irb):3)
|
57
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users"[0m
|
58
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users"
|
59
|
+
[1m[36mUser Load (0.4ms)[0m [1mSELECT "users".* FROM "users"[0m
|
60
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 2
|
61
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2[0m
|
62
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" LIMIT 2
|
63
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2[0m
|
64
|
+
[1m[35mUser Load (0.2ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 1
|
65
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE (("users"."role" = 2 OR "users"."role" = 1))[0m
|
66
|
+
[1m[35mUser Load (0.4ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" IN (2, 1)
|
67
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE (role = 2 or role = 1)[0m
|
68
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE (("users"."role" = 1 OR "users"."role" = 2))[0m
|
69
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 2
|
70
|
+
[1m[36mUser Load (0.3ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 2 AND "users"."role" = 1[0m
|
71
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 2
|
72
|
+
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1[0m
|
73
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE "users"."role" = 2
|
74
|
+
[1m[36mUser Load (0.2ms)[0m [1mSELECT "users".* FROM "users" WHERE "users"."role" = 1[0m
|
75
|
+
[1m[35mUser Load (0.3ms)[0m SELECT "users".* FROM "users" WHERE (("users"."role" = 1 OR "users"."role" = 2))
|
76
|
+
[1m[36m (3.1ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "role" integer, "created_at" datetime, "updated_at" datetime) [0m
|
77
|
+
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
78
|
+
[1m[36m (1.0ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
79
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
80
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131023212242')[0m
|
81
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
82
|
+
[1m[36m (2.5ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "role" integer, "created_at" datetime, "updated_at" datetime) [0m
|
83
|
+
[1m[35m (1.2ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
84
|
+
[1m[36m (1.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
85
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
86
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131023212242')[0m
|
87
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
88
|
+
[1m[36m (3.7ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "role" integer, "created_at" datetime, "updated_at" datetime) [0m
|
89
|
+
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
90
|
+
[1m[36m (1.2ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
91
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
92
|
+
[1m[36m (1.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131023212242')[0m
|
93
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
94
|
+
[1m[36m (2.8ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "role" integer, "created_at" datetime, "updated_at" datetime) [0m
|
95
|
+
[1m[35m (1.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
96
|
+
[1m[36m (1.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
97
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
98
|
+
[1m[36m (1.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131023212242')[0m
|
99
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
data/test/dummy/log/test.log
CHANGED
@@ -330,3 +330,403 @@ Migrating to CreateUsers (20131023212242)
|
|
330
330
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
331
331
|
[1m[35m (0.1ms)[0m begin transaction
|
332
332
|
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
333
|
+
[1m[36m (1.3ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "role" integer, "created_at" datetime, "updated_at" datetime) [0m
|
334
|
+
[1m[35m (1.1ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
335
|
+
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
336
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
337
|
+
[1m[36m (1.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131023212242')[0m
|
338
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.2ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
339
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
340
|
+
[1m[35m (0.1ms)[0m begin transaction
|
341
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
342
|
+
[1m[35m (0.1ms)[0m begin transaction
|
343
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
344
|
+
[1m[35m (0.1ms)[0m begin transaction
|
345
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
346
|
+
[1m[35m (0.1ms)[0m begin transaction
|
347
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
348
|
+
[1m[35m (0.1ms)[0m begin transaction
|
349
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
350
|
+
[1m[35m (0.1ms)[0m begin transaction
|
351
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
352
|
+
[1m[35m (0.1ms)[0m begin transaction
|
353
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
354
|
+
[1m[35m (0.1ms)[0m begin transaction
|
355
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
356
|
+
[1m[35m (0.1ms)[0m begin transaction
|
357
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
358
|
+
[1m[35m (0.1ms)[0m begin transaction
|
359
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
360
|
+
[1m[35m (0.1ms)[0m begin transaction
|
361
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
362
|
+
[1m[35m (0.1ms)[0m begin transaction
|
363
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
364
|
+
[1m[35m (0.1ms)[0m begin transaction
|
365
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
366
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
367
|
+
[1m[35m (0.1ms)[0m begin transaction
|
368
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
369
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
370
|
+
[1m[35m (0.1ms)[0m begin transaction
|
371
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
372
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
373
|
+
[1m[35m (0.1ms)[0m begin transaction
|
374
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
375
|
+
[1m[35m (0.1ms)[0m begin transaction
|
376
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
377
|
+
[1m[35m (0.1ms)[0m begin transaction
|
378
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
379
|
+
[1m[35m (0.1ms)[0m begin transaction
|
380
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
381
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
382
|
+
[1m[35m (0.1ms)[0m begin transaction
|
383
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
384
|
+
[1m[35m (0.1ms)[0m begin transaction
|
385
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
386
|
+
[1m[35m (0.1ms)[0m begin transaction
|
387
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
388
|
+
[1m[35m (0.1ms)[0m begin transaction
|
389
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
390
|
+
[1m[35m (0.1ms)[0m begin transaction
|
391
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
392
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
393
|
+
[1m[35m (0.1ms)[0m begin transaction
|
394
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
395
|
+
[1m[35m (0.1ms)[0m begin transaction
|
396
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
397
|
+
[1m[35m (0.0ms)[0m begin transaction
|
398
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
399
|
+
[1m[35m (0.1ms)[0m begin transaction
|
400
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
401
|
+
[1m[35m (0.1ms)[0m begin transaction
|
402
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
403
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
404
|
+
[1m[35m (0.1ms)[0m begin transaction
|
405
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
406
|
+
[1m[35m (0.1ms)[0m begin transaction
|
407
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
408
|
+
[1m[35m (0.1ms)[0m begin transaction
|
409
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
410
|
+
[1m[35m (0.1ms)[0m begin transaction
|
411
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
412
|
+
[1m[35m (0.1ms)[0m begin transaction
|
413
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
414
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
415
|
+
[1m[35m (0.1ms)[0m begin transaction
|
416
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
417
|
+
[1m[35m (0.1ms)[0m begin transaction
|
418
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
419
|
+
[1m[35m (0.1ms)[0m begin transaction
|
420
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
421
|
+
[1m[35m (0.1ms)[0m begin transaction
|
422
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
423
|
+
[1m[35m (0.1ms)[0m begin transaction
|
424
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
425
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
426
|
+
[1m[35m (0.1ms)[0m begin transaction
|
427
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
428
|
+
[1m[35m (0.1ms)[0m begin transaction
|
429
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
430
|
+
[1m[35m (0.1ms)[0m begin transaction
|
431
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
432
|
+
[1m[35m (0.1ms)[0m begin transaction
|
433
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
434
|
+
[1m[35m (0.1ms)[0m begin transaction
|
435
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
436
|
+
[1m[35m (0.0ms)[0m begin transaction
|
437
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
438
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
439
|
+
[1m[35m (0.1ms)[0m begin transaction
|
440
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
441
|
+
[1m[35m (0.1ms)[0m begin transaction
|
442
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
443
|
+
[1m[35m (0.1ms)[0m begin transaction
|
444
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
445
|
+
[1m[35m (0.1ms)[0m begin transaction
|
446
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
447
|
+
[1m[35m (0.1ms)[0m begin transaction
|
448
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
449
|
+
[1m[35m (0.0ms)[0m begin transaction
|
450
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
451
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
452
|
+
[1m[35m (0.1ms)[0m begin transaction
|
453
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
454
|
+
[1m[35m (0.1ms)[0m begin transaction
|
455
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
456
|
+
[1m[35m (0.1ms)[0m begin transaction
|
457
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
458
|
+
[1m[35m (0.0ms)[0m begin transaction
|
459
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
460
|
+
[1m[35m (0.0ms)[0m begin transaction
|
461
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
462
|
+
[1m[35m (0.0ms)[0m begin transaction
|
463
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
464
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
465
|
+
[1m[35m (0.1ms)[0m begin transaction
|
466
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
467
|
+
[1m[35m (0.1ms)[0m begin transaction
|
468
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
469
|
+
[1m[35m (0.1ms)[0m begin transaction
|
470
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
471
|
+
[1m[35m (0.1ms)[0m begin transaction
|
472
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
473
|
+
[1m[35m (0.1ms)[0m begin transaction
|
474
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
475
|
+
[1m[35m (0.1ms)[0m begin transaction
|
476
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
477
|
+
[1m[35m (0.1ms)[0m begin transaction
|
478
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
479
|
+
[1m[35m (0.1ms)[0m begin transaction
|
480
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
481
|
+
[1m[35m (0.0ms)[0m begin transaction
|
482
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
483
|
+
[1m[35m (0.0ms)[0m begin transaction
|
484
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
485
|
+
[1m[35m (0.0ms)[0m begin transaction
|
486
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
487
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
488
|
+
[1m[35m (0.1ms)[0m begin transaction
|
489
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
490
|
+
[1m[35m (0.1ms)[0m begin transaction
|
491
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
492
|
+
[1m[35m (0.1ms)[0m begin transaction
|
493
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
494
|
+
[1m[35m (0.1ms)[0m begin transaction
|
495
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
496
|
+
[1m[35m (0.1ms)[0m begin transaction
|
497
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
498
|
+
[1m[35m (0.1ms)[0m begin transaction
|
499
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
500
|
+
[1m[35m (0.0ms)[0m begin transaction
|
501
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
502
|
+
[1m[35m (0.1ms)[0m begin transaction
|
503
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
504
|
+
[1m[35m (0.1ms)[0m begin transaction
|
505
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
506
|
+
[1m[35m (0.1ms)[0m begin transaction
|
507
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
508
|
+
[1m[35m (0.0ms)[0m begin transaction
|
509
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
510
|
+
[1m[35m (0.0ms)[0m begin transaction
|
511
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
512
|
+
[1m[35m (0.1ms)[0m begin transaction
|
513
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
514
|
+
[1m[35m (0.1ms)[0m begin transaction
|
515
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
516
|
+
[1m[35m (0.1ms)[0m begin transaction
|
517
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
518
|
+
[1m[35m (0.1ms)[0m begin transaction
|
519
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
520
|
+
[1m[35m (0.1ms)[0m begin transaction
|
521
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
522
|
+
[1m[35m (0.1ms)[0m begin transaction
|
523
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
524
|
+
[1m[35m (0.1ms)[0m begin transaction
|
525
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
526
|
+
[1m[35m (0.1ms)[0m begin transaction
|
527
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
528
|
+
[1m[35m (0.1ms)[0m begin transaction
|
529
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
530
|
+
[1m[35m (0.1ms)[0m begin transaction
|
531
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
532
|
+
[1m[35m (0.1ms)[0m begin transaction
|
533
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
534
|
+
[1m[35m (0.1ms)[0m begin transaction
|
535
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
536
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
537
|
+
[1m[35m (0.1ms)[0m begin transaction
|
538
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
539
|
+
[1m[35m (0.1ms)[0m begin transaction
|
540
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
541
|
+
[1m[35m (0.1ms)[0m begin transaction
|
542
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
543
|
+
[1m[35m (0.1ms)[0m begin transaction
|
544
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
545
|
+
[1m[35m (0.1ms)[0m begin transaction
|
546
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
547
|
+
[1m[35m (0.1ms)[0m begin transaction
|
548
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
549
|
+
[1m[35m (0.1ms)[0m begin transaction
|
550
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
551
|
+
[1m[35m (0.0ms)[0m begin transaction
|
552
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
553
|
+
[1m[35m (0.0ms)[0m begin transaction
|
554
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
555
|
+
[1m[35m (0.0ms)[0m begin transaction
|
556
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
557
|
+
[1m[35m (0.1ms)[0m begin transaction
|
558
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
559
|
+
[1m[35m (0.0ms)[0m begin transaction
|
560
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
561
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
562
|
+
[1m[35m (0.1ms)[0m begin transaction
|
563
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
564
|
+
[1m[35m (0.1ms)[0m begin transaction
|
565
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
566
|
+
[1m[35m (0.1ms)[0m begin transaction
|
567
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
568
|
+
[1m[35m (0.1ms)[0m begin transaction
|
569
|
+
[1m[36m (0.2ms)[0m [1mrollback transaction[0m
|
570
|
+
[1m[35m (0.1ms)[0m begin transaction
|
571
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
572
|
+
[1m[35m (0.1ms)[0m begin transaction
|
573
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
574
|
+
[1m[35m (0.1ms)[0m begin transaction
|
575
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
576
|
+
[1m[35m (0.1ms)[0m begin transaction
|
577
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
578
|
+
[1m[35m (0.1ms)[0m begin transaction
|
579
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
580
|
+
[1m[35m (0.1ms)[0m begin transaction
|
581
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
582
|
+
[1m[35m (0.0ms)[0m begin transaction
|
583
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
584
|
+
[1m[35m (0.1ms)[0m begin transaction
|
585
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
586
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
587
|
+
[1m[35m (0.1ms)[0m begin transaction
|
588
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
589
|
+
[1m[35m (0.1ms)[0m begin transaction
|
590
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
591
|
+
[1m[35m (0.1ms)[0m begin transaction
|
592
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
593
|
+
[1m[35m (0.1ms)[0m begin transaction
|
594
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
595
|
+
[1m[35m (0.1ms)[0m begin transaction
|
596
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
597
|
+
[1m[35m (0.1ms)[0m begin transaction
|
598
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
599
|
+
[1m[35m (0.1ms)[0m begin transaction
|
600
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
601
|
+
[1m[35m (0.1ms)[0m begin transaction
|
602
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
603
|
+
[1m[35m (0.1ms)[0m begin transaction
|
604
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
605
|
+
[1m[35m (0.0ms)[0m begin transaction
|
606
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
607
|
+
[1m[35m (0.1ms)[0m begin transaction
|
608
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
609
|
+
[1m[35m (0.1ms)[0m begin transaction
|
610
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
611
|
+
[1m[35m (0.1ms)[0m begin transaction
|
612
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
613
|
+
[1m[35m (0.1ms)[0m begin transaction
|
614
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
615
|
+
[1m[35m (0.1ms)[0m begin transaction
|
616
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
617
|
+
[1m[35m (0.1ms)[0m begin transaction
|
618
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
619
|
+
[1m[35m (0.1ms)[0m begin transaction
|
620
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
621
|
+
[1m[35m (0.1ms)[0m begin transaction
|
622
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
623
|
+
[1m[35m (0.1ms)[0m begin transaction
|
624
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
625
|
+
[1m[35m (0.1ms)[0m begin transaction
|
626
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
627
|
+
[1m[35m (0.1ms)[0m begin transaction
|
628
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
629
|
+
[1m[35m (0.1ms)[0m begin transaction
|
630
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
631
|
+
[1m[35m (0.1ms)[0m begin transaction
|
632
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
633
|
+
[1m[35m (0.1ms)[0m begin transaction
|
634
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
635
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
636
|
+
[1m[35m (0.1ms)[0m begin transaction
|
637
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
638
|
+
[1m[35m (0.1ms)[0m begin transaction
|
639
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
640
|
+
[1m[35m (0.1ms)[0m begin transaction
|
641
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
642
|
+
[1m[35m (0.1ms)[0m begin transaction
|
643
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
644
|
+
[1m[35m (0.0ms)[0m begin transaction
|
645
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
646
|
+
[1m[35m (0.0ms)[0m begin transaction
|
647
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
648
|
+
[1m[35m (0.1ms)[0m begin transaction
|
649
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
650
|
+
[1m[35m (0.1ms)[0m begin transaction
|
651
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
652
|
+
[1m[35m (0.1ms)[0m begin transaction
|
653
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
654
|
+
[1m[35m (0.1ms)[0m begin transaction
|
655
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
656
|
+
[1m[35m (0.1ms)[0m begin transaction
|
657
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
658
|
+
[1m[35m (0.1ms)[0m begin transaction
|
659
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
660
|
+
[1m[35m (0.1ms)[0m begin transaction
|
661
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
662
|
+
[1m[35m (0.1ms)[0m begin transaction
|
663
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
664
|
+
[1m[35m (0.1ms)[0m begin transaction
|
665
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
666
|
+
[1m[35m (0.1ms)[0m begin transaction
|
667
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
668
|
+
[1m[35m (0.1ms)[0m begin transaction
|
669
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
670
|
+
[1m[35m (0.1ms)[0m begin transaction
|
671
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
672
|
+
[1m[35m (0.1ms)[0m begin transaction
|
673
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
674
|
+
[1m[35m (0.1ms)[0m begin transaction
|
675
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
676
|
+
[1m[35m (0.1ms)[0m begin transaction
|
677
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
678
|
+
[1m[35m (0.0ms)[0m begin transaction
|
679
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
680
|
+
[1m[35m (0.1ms)[0m begin transaction
|
681
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
682
|
+
[1m[35m (0.1ms)[0m begin transaction
|
683
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
684
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
685
|
+
[1m[35m (0.1ms)[0m begin transaction
|
686
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
687
|
+
[1m[35m (0.1ms)[0m begin transaction
|
688
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
689
|
+
[1m[35m (0.1ms)[0m begin transaction
|
690
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
691
|
+
[1m[35m (0.1ms)[0m begin transaction
|
692
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
693
|
+
[1m[35m (0.1ms)[0m begin transaction
|
694
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
695
|
+
[1m[35m (0.1ms)[0m begin transaction
|
696
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
697
|
+
[1m[35m (0.0ms)[0m begin transaction
|
698
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
699
|
+
[1m[35m (0.1ms)[0m begin transaction
|
700
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
701
|
+
[1m[35m (0.1ms)[0m begin transaction
|
702
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
703
|
+
[1m[35m (0.1ms)[0m begin transaction
|
704
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
705
|
+
[1m[35m (0.0ms)[0m begin transaction
|
706
|
+
[1m[36m (0.0ms)[0m [1mrollback transaction[0m
|
707
|
+
[1m[35m (0.1ms)[0m begin transaction
|
708
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
709
|
+
[1m[35m (0.1ms)[0m begin transaction
|
710
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
711
|
+
[1m[35m (0.0ms)[0m begin transaction
|
712
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
713
|
+
[1m[35m (0.1ms)[0m begin transaction
|
714
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
715
|
+
[1m[35m (0.1ms)[0m begin transaction
|
716
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
717
|
+
[1m[35m (0.0ms)[0m begin transaction
|
718
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
719
|
+
[1m[35m (0.1ms)[0m begin transaction
|
720
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
721
|
+
[1m[35m (0.1ms)[0m begin transaction
|
722
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
723
|
+
[1m[35m (0.1ms)[0m begin transaction
|
724
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
725
|
+
[1m[35m (0.1ms)[0m begin transaction
|
726
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
727
|
+
[1m[35m (0.1ms)[0m begin transaction
|
728
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
729
|
+
[1m[35m (0.1ms)[0m begin transaction
|
730
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
731
|
+
[1m[35m (0.0ms)[0m begin transaction
|
732
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
@@ -47,6 +47,15 @@ def clear_user
|
|
47
47
|
end
|
48
48
|
|
49
49
|
if User.instance_variable_defined?(:@_attr_enums)
|
50
|
-
User.remove_instance_variable
|
50
|
+
User.send(:remove_instance_variable, :@_attr_enums)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_user_roles
|
55
|
+
clear_user
|
56
|
+
|
57
|
+
User.class_eval do
|
58
|
+
extend RailsAttrEnum
|
59
|
+
attr_enum :role, :admin, :editor, :author, :user
|
51
60
|
end
|
52
61
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'User::Role.to_h' do
|
4
|
+
let(:enum) { User::Role }
|
5
|
+
|
6
|
+
before { default_user_roles }
|
7
|
+
|
8
|
+
let :only_value do
|
9
|
+
{
|
10
|
+
'ADMIN' => 0,
|
11
|
+
'EDITOR' => 1,
|
12
|
+
'AUTHOR' => 2,
|
13
|
+
'USER' => 3
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let :value_and_label do
|
18
|
+
{
|
19
|
+
'ADMIN' => { value: 0, label: 'Admin' },
|
20
|
+
'EDITOR' => { value: 1, label: 'Editor' },
|
21
|
+
'AUTHOR' => { value: 2, label: 'Author' },
|
22
|
+
'USER' => { value: 3, label: 'User' }
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
let :all_keys do
|
27
|
+
{
|
28
|
+
'ADMIN' => { key: :admin, label: 'Admin', value: 0 },
|
29
|
+
'EDITOR' => { key: :editor, label: 'Editor', value: 1 },
|
30
|
+
'AUTHOR' => { key: :author, label: 'Author', value: 2 },
|
31
|
+
'USER' => { key: :user, label: 'User', value: 3}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'without options' do
|
36
|
+
subject { enum.to_h }
|
37
|
+
it { should eq all_keys }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with option `only` as a symbol' do
|
41
|
+
subject { enum.to_h(only: :value) }
|
42
|
+
it { should eq only_value }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with option `only` as an array' do
|
46
|
+
context 'with no elements' do
|
47
|
+
subject { enum.to_h(only: []) }
|
48
|
+
it { should eq all_keys }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with one element' do
|
52
|
+
subject { enum.to_h(only: [:value]) }
|
53
|
+
it { should eq only_value }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with more than one element' do
|
57
|
+
subject { enum.to_h(only: [:label, :value]) }
|
58
|
+
it { should eq value_and_label }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with an unknown key' do
|
62
|
+
it 'should raise an error' do
|
63
|
+
expect { enum.to_h(only: :foo) }.to raise_error('Unknown keys for enum')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'with option `except` as a symbol' do
|
69
|
+
subject { enum.to_h(except: :key) }
|
70
|
+
it { should eq value_and_label }
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with option `except` as an array' do
|
74
|
+
context 'with no elements' do
|
75
|
+
subject { enum.to_h(except: []) }
|
76
|
+
it { should eq all_keys }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with one element' do
|
80
|
+
subject { enum.to_h(except: [:key]) }
|
81
|
+
it { should eq value_and_label }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with more than one element' do
|
85
|
+
subject { enum.to_h(except: [:label, :key]) }
|
86
|
+
it { should eq only_value }
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with an unknown key' do
|
90
|
+
it 'should raise an error' do
|
91
|
+
expect { enum.to_h(except: :foo) }.to raise_error('Unknown keys for enum')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_attr_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Fairbank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Create enums for Rails model attributes like enums in C languages
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/rails_attr_enum/version.rb
|
54
54
|
- lib/rails_attr_enum.rb
|
55
55
|
- lib/tasks/rails_attr_enum_tasks.rake
|
56
|
+
- CHANGELOG.md
|
56
57
|
- LICENSE
|
57
58
|
- Rakefile
|
58
59
|
- README.md
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- test/dummy/spec/json_spec.rb
|
98
99
|
- test/dummy/spec/models/user_spec.rb
|
99
100
|
- test/dummy/spec/spec_helper.rb
|
101
|
+
- test/dummy/spec/to_h_spec.rb
|
100
102
|
homepage: https://github.com/jfairbank/rails_attr_enum
|
101
103
|
licenses:
|
102
104
|
- MIT
|
@@ -107,12 +109,12 @@ require_paths:
|
|
107
109
|
- lib
|
108
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
111
|
requirements:
|
110
|
-
- - '>='
|
112
|
+
- - ! '>='
|
111
113
|
- !ruby/object:Gem::Version
|
112
114
|
version: '0'
|
113
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
116
|
requirements:
|
115
|
-
- - '>='
|
117
|
+
- - ! '>='
|
116
118
|
- !ruby/object:Gem::Version
|
117
119
|
version: '0'
|
118
120
|
requirements: []
|
@@ -163,3 +165,4 @@ test_files:
|
|
163
165
|
- test/dummy/spec/json_spec.rb
|
164
166
|
- test/dummy/spec/models/user_spec.rb
|
165
167
|
- test/dummy/spec/spec_helper.rb
|
168
|
+
- test/dummy/spec/to_h_spec.rb
|