enju_bookmark 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/app/models/tag.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Tag < ActiveRecord::Base
2
- attr_accessible
2
+ attr_accessible :name, :name_transcription
3
3
  has_many :taggings, :dependent => :destroy, :class_name => 'ActsAsTaggableOn::Tagging'
4
4
  validates :name, :presence => true
5
5
  after_save :save_taggings
@@ -1,3 +1,3 @@
1
1
  module EnjuBookmark
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -0,0 +1,282 @@
1
+ require 'spec_helper'
2
+
3
+ describe TagsController do
4
+
5
+ describe "GET index" do
6
+ describe "When logged in as Administrator" do
7
+ login_admin
8
+
9
+ it "assigns all tags as @tags" do
10
+ get :index
11
+ assigns(:tags).should_not be_nil
12
+ end
13
+ end
14
+
15
+ describe "When logged in as Librarian" do
16
+ login_librarian
17
+
18
+ it "assigns all tags as @tags" do
19
+ get :index
20
+ assigns(:tags).should_not be_nil
21
+ end
22
+ end
23
+
24
+ describe "When logged in as User" do
25
+ login_user
26
+
27
+ it "assigns all tags as @tags" do
28
+ get :index
29
+ assigns(:tags).should_not be_nil
30
+ end
31
+ end
32
+
33
+ describe "When not logged in" do
34
+ it "assigns all tags as @tags" do
35
+ get :index
36
+ assigns(:tags).should_not be_nil
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "GET show" do
42
+ describe "When logged in as Administrator" do
43
+ login_admin
44
+
45
+ it "assigns the requested tag as @tag" do
46
+ tag = FactoryGirl.create(:tag)
47
+ get :show, :id => tag.id
48
+ assigns(:tag).should eq(tag)
49
+ end
50
+ end
51
+
52
+ describe "When logged in as Librarian" do
53
+ login_librarian
54
+
55
+ it "assigns the requested tag as @tag" do
56
+ tag = FactoryGirl.create(:tag)
57
+ get :show, :id => tag.id
58
+ assigns(:tag).should eq(tag)
59
+ end
60
+ end
61
+
62
+ describe "When logged in as User" do
63
+ login_user
64
+
65
+ it "assigns the requested tag as @tag" do
66
+ tag = FactoryGirl.create(:tag)
67
+ get :show, :id => tag.id
68
+ assigns(:tag).should eq(tag)
69
+ end
70
+ end
71
+
72
+ describe "When not logged in" do
73
+ it "assigns the requested tag as @tag" do
74
+ tag = FactoryGirl.create(:tag)
75
+ get :show, :id => tag.id
76
+ assigns(:tag).should eq(tag)
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "GET edit" do
82
+ describe "When logged in as Administrator" do
83
+ login_admin
84
+
85
+ it "assigns the requested tag as @tag" do
86
+ tag = FactoryGirl.create(:tag)
87
+ get :edit, :id => tag.id
88
+ assigns(:tag).should eq(tag)
89
+ end
90
+ end
91
+
92
+ describe "When logged in as Librarian" do
93
+ login_librarian
94
+
95
+ it "assigns the requested tag as @tag" do
96
+ tag = FactoryGirl.create(:tag)
97
+ get :edit, :id => tag.id
98
+ assigns(:tag).should eq(tag)
99
+ end
100
+ end
101
+
102
+ describe "When logged in as User" do
103
+ login_user
104
+
105
+ it "assigns the requested tag as @tag" do
106
+ tag = FactoryGirl.create(:tag)
107
+ get :edit, :id => tag.id
108
+ response.should be_forbidden
109
+ end
110
+ end
111
+
112
+ describe "When not logged in" do
113
+ it "should not assign the requested tag as @tag" do
114
+ tag = FactoryGirl.create(:tag)
115
+ get :edit, :id => tag.id
116
+ response.should redirect_to(new_user_session_url)
117
+ end
118
+ end
119
+ end
120
+
121
+ describe "PUT update" do
122
+ before(:each) do
123
+ @tag = FactoryGirl.create(:tag)
124
+ @attrs = FactoryGirl.attributes_for(:tag)
125
+ @invalid_attrs = {:name => ''}
126
+ end
127
+
128
+ describe "When logged in as Administrator" do
129
+ login_admin
130
+
131
+ describe "with valid params" do
132
+ it "updates the requested tag" do
133
+ put :update, :id => @tag.id, :tag => @attrs
134
+ end
135
+
136
+ it "assigns the requested tag as @tag" do
137
+ put :update, :id => @tag.id, :tag => @attrs
138
+ assigns(:tag).should eq(@tag)
139
+ response.should redirect_to(assigns(:tag))
140
+ end
141
+ end
142
+
143
+ describe "with invalid params" do
144
+ it "assigns the requested tag as @tag" do
145
+ put :update, :id => @tag.id, :tag => @invalid_attrs
146
+ end
147
+
148
+ it "re-renders the 'edit' template" do
149
+ put :update, :id => @tag.id, :tag => @invalid_attrs
150
+ response.should render_template("edit")
151
+ end
152
+ end
153
+ end
154
+
155
+ describe "When logged in as Librarian" do
156
+ login_librarian
157
+
158
+ describe "with valid params" do
159
+ it "updates the requested tag" do
160
+ put :update, :id => @tag.id, :tag => @attrs
161
+ end
162
+
163
+ it "assigns the requested tag as @tag" do
164
+ put :update, :id => @tag.id, :tag => @attrs
165
+ assigns(:tag).should eq(@tag)
166
+ response.should redirect_to(assigns(:tag))
167
+ end
168
+ end
169
+
170
+ describe "with invalid params" do
171
+ it "assigns the tag as @tag" do
172
+ put :update, :id => @tag.id, :tag => @invalid_attrs
173
+ assigns(:tag).should_not be_valid
174
+ end
175
+
176
+ it "re-renders the 'edit' template" do
177
+ put :update, :id => @tag.id, :tag => @invalid_attrs
178
+ response.should render_template("edit")
179
+ end
180
+ end
181
+ end
182
+
183
+ describe "When logged in as User" do
184
+ login_user
185
+
186
+ describe "with valid params" do
187
+ it "updates the requested tag" do
188
+ put :update, :id => @tag.id, :tag => @attrs
189
+ end
190
+
191
+ it "assigns the requested tag as @tag" do
192
+ put :update, :id => @tag.id, :tag => @attrs
193
+ assigns(:tag).should eq(@tag)
194
+ response.should be_forbidden
195
+ end
196
+ end
197
+
198
+ describe "with invalid params" do
199
+ it "assigns the requested tag as @tag" do
200
+ put :update, :id => @tag.id, :tag => @invalid_attrs
201
+ response.should be_forbidden
202
+ end
203
+ end
204
+ end
205
+
206
+ describe "When not logged in" do
207
+ describe "with valid params" do
208
+ it "updates the requested tag" do
209
+ put :update, :id => @tag.id, :tag => @attrs
210
+ end
211
+
212
+ it "should be forbidden" do
213
+ put :update, :id => @tag.id, :tag => @attrs
214
+ response.should redirect_to(new_user_session_url)
215
+ end
216
+ end
217
+
218
+ describe "with invalid params" do
219
+ it "assigns the requested tag as @tag" do
220
+ put :update, :id => @tag.id, :tag => @invalid_attrs
221
+ response.should redirect_to(new_user_session_url)
222
+ end
223
+ end
224
+ end
225
+ end
226
+
227
+ describe "DELETE destroy" do
228
+ before(:each) do
229
+ @tag = FactoryGirl.create(:tag)
230
+ end
231
+
232
+ describe "When logged in as Administrator" do
233
+ login_admin
234
+
235
+ it "destroys the requested tag" do
236
+ delete :destroy, :id => @tag.name
237
+ end
238
+
239
+ it "redirects to the tags list" do
240
+ delete :destroy, :id => @tag.name
241
+ response.should redirect_to(tags_url)
242
+ end
243
+ end
244
+
245
+ describe "When logged in as Librarian" do
246
+ login_librarian
247
+
248
+ it "destroys the requested tag" do
249
+ delete :destroy, :id => @tag.name
250
+ end
251
+
252
+ it "redirects to the tags list" do
253
+ delete :destroy, :id => @tag.name
254
+ response.should redirect_to(tags_url)
255
+ end
256
+ end
257
+
258
+ describe "When logged in as User" do
259
+ login_user
260
+
261
+ it "destroys the requested tag" do
262
+ delete :destroy, :id => @tag.name
263
+ end
264
+
265
+ it "should be forbidden" do
266
+ delete :destroy, :id => @tag.name
267
+ response.should be_forbidden
268
+ end
269
+ end
270
+
271
+ describe "When not logged in" do
272
+ it "destroys the requested tag" do
273
+ delete :destroy, :id => @tag.name
274
+ end
275
+
276
+ it "should be forbidden" do
277
+ delete :destroy, :id => @tag.name
278
+ response.should redirect_to(new_user_session_url)
279
+ end
280
+ end
281
+ end
282
+ end
Binary file
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :tag do |f|
3
+ f.sequence(:name){|n| "tag_#{n}"}
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_bookmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -331,6 +331,7 @@ files:
331
331
  - spec/controllers/bookmark_stat_has_manifestations_controller_spec.rb
332
332
  - spec/controllers/bookmark_stats_controller_spec.rb
333
333
  - spec/controllers/bookmarks_controller_spec.rb
334
+ - spec/controllers/tags_controller_spec.rb
334
335
  - spec/dummy/app/assets/javascripts/application.js
335
336
  - spec/dummy/app/assets/stylesheets/application.css
336
337
  - spec/dummy/app/controllers/application_controller.rb
@@ -454,6 +455,7 @@ files:
454
455
  - spec/factories/bookmark_stat.rb
455
456
  - spec/factories/bookmark_stat_has_manifestation.rb
456
457
  - spec/factories/manifestation.rb
458
+ - spec/factories/tag.rb
457
459
  - spec/factories/user.rb
458
460
  - spec/fixtures/bookmark_stat_has_manifestations.yml
459
461
  - spec/fixtures/bookmark_stats.yml
@@ -513,6 +515,7 @@ test_files:
513
515
  - spec/controllers/bookmark_stat_has_manifestations_controller_spec.rb
514
516
  - spec/controllers/bookmark_stats_controller_spec.rb
515
517
  - spec/controllers/bookmarks_controller_spec.rb
518
+ - spec/controllers/tags_controller_spec.rb
516
519
  - spec/dummy/app/assets/javascripts/application.js
517
520
  - spec/dummy/app/assets/stylesheets/application.css
518
521
  - spec/dummy/app/controllers/application_controller.rb
@@ -636,6 +639,7 @@ test_files:
636
639
  - spec/factories/bookmark_stat.rb
637
640
  - spec/factories/bookmark_stat_has_manifestation.rb
638
641
  - spec/factories/manifestation.rb
642
+ - spec/factories/tag.rb
639
643
  - spec/factories/user.rb
640
644
  - spec/fixtures/bookmark_stat_has_manifestations.yml
641
645
  - spec/fixtures/bookmark_stats.yml