tagalong 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tagalong/tagger.rb +3 -3
- data/lib/tagalong/version.rb +1 -1
- data/spec/lib/tagalong/tagger_spec.rb +9 -18
- metadata +17 -17
data/lib/tagalong/tagger.rb
CHANGED
@@ -28,9 +28,9 @@ module Tagalong
|
|
28
28
|
|
29
29
|
def rename_tag(existing_tag, rename_to)
|
30
30
|
if tag = tagalong_tags.find_by_name(existing_tag)
|
31
|
-
tag
|
32
|
-
raise Tagalong::
|
33
|
-
tag.
|
31
|
+
raise Tagalong::TagAlreadyInUse, "A tag already exists with the name '#{rename_to}'" if tagalong_tags.find_by_name(rename_to).present?
|
32
|
+
raise Tagalong::TagCannotBeBlank, "A tag cannot have a blank name" if rename_to.blank?
|
33
|
+
tag.update_attribute(:name, rename_to)
|
34
34
|
else
|
35
35
|
raise Tagalong::TagNotFound, "Tried to rename a tag that does not exist."
|
36
36
|
end
|
data/lib/tagalong/version.rb
CHANGED
@@ -52,6 +52,10 @@ describe "Tagger" do
|
|
52
52
|
it "should return true if rename was successfull" do
|
53
53
|
@user.rename_tag('tag5', 'renamedTag5').should be_true
|
54
54
|
end
|
55
|
+
|
56
|
+
it "should raise a cannot be blank error if the name is blank" do
|
57
|
+
lambda { @user.rename_tag('tag5', '') }.should raise_error(Tagalong::TagCannotBeBlank)
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
context "when the tagger does not own the tag being renamed" do
|
@@ -256,9 +260,8 @@ describe "Tagger" do
|
|
256
260
|
it "should find the tag by its name" do
|
257
261
|
tag = stub('tag', :name => 'tag7')
|
258
262
|
Tagalong::TagalongTag.should_receive(:find_by_name).with('tag7').and_return(tag)
|
259
|
-
|
260
|
-
tag.stub(:
|
261
|
-
tag.stub(:valid?).and_return(true)
|
263
|
+
Tagalong::TagalongTag.stub(:find_by_name).with('renamedTag7').and_return(false)
|
264
|
+
tag.stub(:update_attribute)
|
262
265
|
@user.rename_tag('tag7', 'renamedTag7')
|
263
266
|
end
|
264
267
|
|
@@ -267,23 +270,11 @@ describe "Tagger" do
|
|
267
270
|
lambda { @user.rename_tag('tag7', 'renamedTag7') }.should raise_error(Tagalong::TagNotFound)
|
268
271
|
end
|
269
272
|
|
270
|
-
it "should assign and save the new tag name" do
|
271
|
-
tag8 = mock('tag 8', :name => 'tag8')
|
272
|
-
Tagalong::TagalongTag.stub(:find_by_name).and_return(tag8)
|
273
|
-
@user.stub(:has_tag?).and_return(true)
|
274
|
-
tag8.should_receive(:name=).with('renamedTag8')
|
275
|
-
tag8.stub(:valid?).and_return(true)
|
276
|
-
tag8.stub(:save!)
|
277
|
-
@user.rename_tag('tag8', 'renamedTag8')
|
278
|
-
end
|
279
|
-
|
280
273
|
it "should save the tag if the Tagger owns it" do
|
281
274
|
tag9 = mock('tag 9', :name => 'tag9')
|
282
|
-
Tagalong::TagalongTag.stub(:find_by_name).and_return(tag9)
|
283
|
-
|
284
|
-
tag9.
|
285
|
-
tag9.stub(:valid?).and_return(true)
|
286
|
-
tag9.should_receive(:save!)
|
275
|
+
Tagalong::TagalongTag.stub(:find_by_name).with('tag9').and_return(tag9)
|
276
|
+
Tagalong::TagalongTag.stub(:find_by_name).with('renamedTag9').and_return(false)
|
277
|
+
tag9.should_receive(:update_attribute).with(:name, 'renamedTag9')
|
287
278
|
@user.rename_tag('tag9', 'renamedTag9')
|
288
279
|
end
|
289
280
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagalong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
17
|
-
requirement: &
|
17
|
+
requirement: &70345218560620 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70345218560620
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: sqlite3
|
28
|
-
requirement: &
|
28
|
+
requirement: &70345218559740 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70345218559740
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rspec
|
39
|
-
requirement: &
|
39
|
+
requirement: &70345218558920 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70345218558920
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
|
-
requirement: &
|
50
|
+
requirement: &70345218558100 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70345218558100
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: sunspot_rails
|
61
|
-
requirement: &
|
61
|
+
requirement: &70345218557320 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70345218557320
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sunspot_solr
|
72
|
-
requirement: &
|
72
|
+
requirement: &70345218556880 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70345218556880
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: sunspot_test
|
83
|
-
requirement: &
|
83
|
+
requirement: &70345218556400 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,7 +88,7 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *70345218556400
|
92
92
|
description: A Rails tagging plugin that makes sense.
|
93
93
|
email:
|
94
94
|
- cyphactor@gmail.com
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 1.8.
|
149
|
+
rubygems_version: 1.8.15
|
150
150
|
signing_key:
|
151
151
|
specification_version: 3
|
152
152
|
summary: A Rails tagging plugin that makes sense.
|