acts_as_keyed 0.1.0 → 0.1.1
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/acts_as_keyed.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Jeremy Hubert"]
|
10
10
|
s.email = ["jhubert@gmail.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/jhubert/acts-as-keyed"
|
12
12
|
s.summary = %q{Automatically key an active record model with a unique key}
|
13
13
|
s.description = %q{A simple plugin that automatically generates a key for a model on create. It takes care of protecting the key, automatically generating it and making sure it is unique.}
|
14
14
|
|
@@ -10,7 +10,7 @@ module ActsAsKeyed
|
|
10
10
|
|
11
11
|
self.options = options
|
12
12
|
|
13
|
-
raise
|
13
|
+
raise MissingKeyColumnError if ActiveRecord::Base.connection.table_exists?(self.table_name) && columns_hash['key'].nil?
|
14
14
|
|
15
15
|
attr_protected :key
|
16
16
|
|
data/lib/acts_as_keyed/errors.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
module ActsAsKeyed
|
2
|
-
class
|
2
|
+
class NoAvailableKeysError < StandardError
|
3
3
|
def to_s
|
4
4
|
'Very few unique keys are still available. Please change your acts_as_keyed chars or size settings.'
|
5
5
|
end
|
6
6
|
end
|
7
|
+
class MissingKeyColumnError < StandardError
|
8
|
+
def to_s
|
9
|
+
'The table must have a column named "key"'
|
10
|
+
end
|
11
|
+
end
|
7
12
|
end
|
data/test/acts_as_keyed_test.rb
CHANGED
@@ -53,26 +53,19 @@ class ActsAsKeyedTest < ActsAsKeyedBaseTest
|
|
53
53
|
test "should raise an error if no unique keys can be found easily" do
|
54
54
|
owk_setup(:chars => ['a'], :size => 1)
|
55
55
|
|
56
|
-
|
57
|
-
begin
|
56
|
+
assert_raise ActsAsKeyed::NoAvailableKeysError do
|
58
57
|
2.times do
|
59
58
|
o = ObjectWithKey.create
|
60
59
|
end
|
61
|
-
rescue ActsAsKeyed::NoAvailableKeys
|
62
|
-
error = true
|
63
60
|
end
|
64
|
-
|
65
|
-
assert error
|
66
61
|
end
|
67
62
|
|
68
63
|
test "should fail if object doesn't have key column" do
|
69
64
|
output = nil
|
70
|
-
|
65
|
+
|
66
|
+
assert_raise ActsAsKeyed::MissingKeyColumnError do
|
71
67
|
ObjectWithoutKey.acts_as_keyed
|
72
|
-
rescue ArgumentError => e
|
73
|
-
output = e.message
|
74
68
|
end
|
75
|
-
assert_equal "ObjectWithoutKey is missing key column", output
|
76
69
|
end
|
77
70
|
|
78
71
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_keyed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Hubert
|
@@ -56,7 +56,7 @@ files:
|
|
56
56
|
- lib/acts_as_keyed/version.rb
|
57
57
|
- test/acts_as_keyed_test.rb
|
58
58
|
- test/test_helper.rb
|
59
|
-
homepage:
|
59
|
+
homepage: https://github.com/jhubert/acts-as-keyed
|
60
60
|
licenses: []
|
61
61
|
|
62
62
|
post_install_message:
|