much-slug 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/much-slug/activerecord.rb +7 -0
- data/lib/much-slug/has_slug_registry.rb +6 -0
- data/lib/much-slug/version.rb +1 -1
- data/much-slug.gemspec +2 -1
- data/test/unit/activerecord_tests.rb +20 -0
- data/test/unit/has_slug_registry_tests.rb +40 -1
- metadata +2 -7
- data/.gitignore +0 -19
- data/.l.yml +0 -8
- data/.rubocop.yml +0 -3
- data/.ruby-version +0 -1
- data/.t.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe42cdcdaafd6505b00426cd011ac984a56939d6654cafed64f54df72a46615
|
4
|
+
data.tar.gz: 6bf1b4aae86da836b8a637e32da79e1b53fe8de30710cd6dc5a9af8b9d7f2388
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ba93e73c2437bddf33b920bfaeedcd27e96db540201364e252418a7e7e279788b61b3f849240e55864797c953f132094b89cf0eff8cfc8ec713d36e7e3f9506
|
7
|
+
data.tar.gz: cf311ed407e9517c282363082b29a28ad828f180ede3e27c898219777bd2d4a3092e8aefa0c55205d805f6a842324796c1ed1caa92d503a9b78bde05a4de4655
|
@@ -9,6 +9,13 @@ module MuchSlug::ActiveRecord
|
|
9
9
|
include MuchMixin
|
10
10
|
|
11
11
|
mixin_class_methods do
|
12
|
+
def inherited(child_class)
|
13
|
+
super
|
14
|
+
child_class.much_slug_has_slug_registry.copy_from(
|
15
|
+
much_slug_has_slug_registry,
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
12
19
|
def much_slug_has_slug_registry
|
13
20
|
@much_slug_has_slug_registry ||= MuchSlug::HasSlugRegistry.new
|
14
21
|
end
|
data/lib/much-slug/version.rb
CHANGED
data/much-slug.gemspec
CHANGED
@@ -15,7 +15,8 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.homepage = "https://github.com/redding/much-slug"
|
16
16
|
gem.license = "MIT"
|
17
17
|
|
18
|
-
gem.files
|
18
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
|
19
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
22
|
gem.require_paths = ["lib"]
|
@@ -144,6 +144,26 @@ module MuchSlug::ActiveRecord
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
class ReceiverInheritedTests < ReceiverTests
|
148
|
+
desc "is inherited from"
|
149
|
+
|
150
|
+
setup do
|
151
|
+
subject.has_slug(source: :name)
|
152
|
+
|
153
|
+
Assert.stub_tap(MuchSlug::HasSlugRegistry, :new) do |has_slug_registry|
|
154
|
+
Assert.stub_on_call(has_slug_registry, :copy_from) do |call|
|
155
|
+
@has_slug_registry_copy_from_call = call
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
should "copy its MuchSlug::HasSlugRegistry to the child class" do
|
161
|
+
Class.new(receiver_class)
|
162
|
+
assert_that(@has_slug_registry_copy_from_call.args)
|
163
|
+
.equals([subject.much_slug_has_slug_registry])
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
147
167
|
class ReceiverInitTests < ReceiverTests
|
148
168
|
desc "when init"
|
149
169
|
subject{ receiver }
|
@@ -25,7 +25,7 @@ class MuchSlug::HasSlugRegistry
|
|
25
25
|
let(:separator){ "|" }
|
26
26
|
let(:allow_underscores){ Factory.boolean }
|
27
27
|
|
28
|
-
should have_imeths :register
|
28
|
+
should have_imeths :register, :copy_from
|
29
29
|
|
30
30
|
should "default empty entries for unregisterd attributes" do
|
31
31
|
assert_that(subject[Factory.string]).is_an_instance_of(unit_class::Entry)
|
@@ -74,6 +74,45 @@ class MuchSlug::HasSlugRegistry
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
class CopyFromTests < InitTests
|
78
|
+
desc "#copy_from"
|
79
|
+
|
80
|
+
setup do
|
81
|
+
parent_has_slug_registry.register(
|
82
|
+
attribute: attribute,
|
83
|
+
source: source,
|
84
|
+
preprocessor: nil,
|
85
|
+
separator: nil,
|
86
|
+
allow_underscores: nil,
|
87
|
+
)
|
88
|
+
parent_has_slug_registry.register(
|
89
|
+
attribute: other_attribute,
|
90
|
+
source: other_source,
|
91
|
+
preprocessor: nil,
|
92
|
+
separator: nil,
|
93
|
+
allow_underscores: nil,
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
let(:other_attribute){ Factory.symbol }
|
98
|
+
let(:other_source){ :to_s }
|
99
|
+
|
100
|
+
let(:parent_has_slug_registry){ unit_class.new }
|
101
|
+
|
102
|
+
should "copy entries from the passed MuchSlug::HasSlugRegistry" do
|
103
|
+
subject.copy_from(parent_has_slug_registry)
|
104
|
+
|
105
|
+
assert_that(subject[attribute])
|
106
|
+
.equals(parent_has_slug_registry[attribute])
|
107
|
+
assert_that(subject[attribute])
|
108
|
+
.is_not(parent_has_slug_registry[attribute])
|
109
|
+
assert_that(subject[other_attribute])
|
110
|
+
.equals(parent_has_slug_registry[other_attribute])
|
111
|
+
assert_that(subject[other_attribute])
|
112
|
+
.is_not(parent_has_slug_registry[other_attribute])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
77
116
|
class EntryUnitTests < UnitTests
|
78
117
|
desc "Entry"
|
79
118
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: much-slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ardb
|
@@ -75,11 +75,6 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- ".gitignore"
|
79
|
-
- ".l.yml"
|
80
|
-
- ".rubocop.yml"
|
81
|
-
- ".ruby-version"
|
82
|
-
- ".t.yml"
|
83
78
|
- Gemfile
|
84
79
|
- LICENSE
|
85
80
|
- README.md
|
data/.gitignore
DELETED
data/.l.yml
DELETED
data/.rubocop.yml
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.8
|
data/.t.yml
DELETED