enju_library 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/enju_library/controller.rb +12 -3
- data/app/controllers/libraries_controller.rb +1 -0
- data/app/controllers/shelves_controller.rb +2 -1
- data/app/models/library.rb +1 -1
- data/app/models/library_group.rb +22 -17
- data/app/models/shelf.rb +1 -1
- data/app/views/libraries/_form.html.erb +1 -0
- data/app/views/library_groups/_color_fields.html.erb +0 -1
- data/app/views/library_groups/_form.html.erb +1 -4
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/config/routes.rb +1 -0
- data/lib/enju_library/version.rb +1 -1
- data/lib/tasks/enju_library_tasks.rake +2 -2
- data/spec/controllers/accepts_controller_spec.rb +96 -96
- data/spec/controllers/baskets_controller_spec.rb +126 -126
- data/spec/controllers/bookstores_controller_spec.rb +152 -152
- data/spec/controllers/budget_types_controller_spec.rb +48 -49
- data/spec/controllers/libraries_controller_spec.rb +183 -183
- data/spec/controllers/library_groups_controller_spec.rb +47 -47
- data/spec/controllers/request_status_types_controller_spec.rb +152 -152
- data/spec/controllers/request_types_controller_spec.rb +152 -152
- data/spec/controllers/search_engines_controller_spec.rb +152 -152
- data/spec/controllers/shelves_controller_spec.rb +152 -152
- data/spec/controllers/subscribes_controller_spec.rb +151 -151
- data/spec/controllers/subscriptions_controller_spec.rb +152 -152
- data/spec/controllers/user_export_files_controller_spec.rb +75 -75
- data/spec/controllers/user_groups_controller_spec.rb +108 -108
- data/spec/controllers/user_import_files_controller_spec.rb +73 -73
- data/spec/controllers/user_import_results_controller_spec.rb +33 -34
- data/spec/controllers/withdraws_controller_spec.rb +42 -45
- data/spec/fixtures/libraries.yml +1 -1
- data/spec/fixtures/library_groups.yml +22 -17
- data/spec/fixtures/shelves.yml +1 -1
- data/spec/models/library_group_spec.rb +22 -17
- data/spec/models/library_spec.rb +1 -1
- data/spec/models/shelf_spec.rb +1 -1
- data/spec/views/library_groups/edit.html.erb_spec.rb +8 -0
- metadata +11 -25
@@ -29,114 +29,114 @@ describe BudgetTypesController do
|
|
29
29
|
FactoryGirl.attributes_for(:budget_type)
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it
|
32
|
+
describe 'GET index' do
|
33
|
+
it 'assigns all budget_types as @budget_types' do
|
34
34
|
budget_type = BudgetType.create! valid_attributes
|
35
35
|
get :index
|
36
36
|
assigns(:budget_types).should eq(BudgetType.order(:position))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
41
|
-
it
|
40
|
+
describe 'GET show' do
|
41
|
+
it 'assigns the requested budget_type as @budget_type' do
|
42
42
|
budget_type = BudgetType.create! valid_attributes
|
43
|
-
get :show, :
|
43
|
+
get :show, id: budget_type.id
|
44
44
|
assigns(:budget_type).should eq(budget_type)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
describe
|
49
|
-
it
|
48
|
+
describe 'GET new' do
|
49
|
+
it 'assigns a new budget_type as @budget_type' do
|
50
50
|
get :new
|
51
51
|
assigns(:budget_type).should be_a_new(BudgetType)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe
|
56
|
-
it
|
55
|
+
describe 'GET edit' do
|
56
|
+
it 'assigns the requested budget_type as @budget_type' do
|
57
57
|
budget_type = BudgetType.create! valid_attributes
|
58
|
-
get :edit, :
|
58
|
+
get :edit, id: budget_type.id
|
59
59
|
assigns(:budget_type).should eq(budget_type)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
describe
|
64
|
-
describe
|
65
|
-
it
|
66
|
-
expect
|
67
|
-
post :create, :
|
68
|
-
|
63
|
+
describe 'POST create' do
|
64
|
+
describe 'with valid params' do
|
65
|
+
it 'creates a new BudgetType' do
|
66
|
+
expect do
|
67
|
+
post :create, budget_type: valid_attributes
|
68
|
+
end.to change(BudgetType, :count).by(1)
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
post :create, :
|
71
|
+
it 'assigns a newly created budget_type as @budget_type' do
|
72
|
+
post :create, budget_type: valid_attributes
|
73
73
|
assigns(:budget_type).should be_a(BudgetType)
|
74
74
|
assigns(:budget_type).should be_persisted
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
78
|
-
post :create, :
|
77
|
+
it 'redirects to the created budget_type' do
|
78
|
+
post :create, budget_type: valid_attributes
|
79
79
|
response.should redirect_to(BudgetType.last)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
describe
|
84
|
-
it
|
83
|
+
describe 'with invalid params' do
|
84
|
+
it 'assigns a newly created but unsaved budget_type as @budget_type' do
|
85
85
|
# Trigger the behavior that occurs when invalid params are submitted
|
86
86
|
BudgetType.any_instance.stub(:save).and_return(false)
|
87
|
-
post :create, :
|
87
|
+
post :create, budget_type: { note: 'test' }
|
88
88
|
assigns(:budget_type).should be_a_new(BudgetType)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "re-renders the 'new' template" do
|
92
92
|
# Trigger the behavior that occurs when invalid params are submitted
|
93
93
|
BudgetType.any_instance.stub(:save).and_return(false)
|
94
|
-
post :create, :
|
95
|
-
#response.should render_template("new")
|
94
|
+
post :create, budget_type: { note: 'test' }
|
95
|
+
# response.should render_template("new")
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe
|
101
|
-
describe
|
102
|
-
it
|
100
|
+
describe 'PUT update' do
|
101
|
+
describe 'with valid params' do
|
102
|
+
it 'updates the requested budget_type' do
|
103
103
|
budget_type = BudgetType.create! valid_attributes
|
104
104
|
# Assuming there are no other budget_types in the database, this
|
105
105
|
# specifies that the BudgetType created on the previous line
|
106
106
|
# receives the :update_attributes message with whatever params are
|
107
107
|
# submitted in the request.
|
108
|
-
BudgetType.any_instance.should_receive(:update_attributes).with(
|
109
|
-
put :update, :
|
108
|
+
BudgetType.any_instance.should_receive(:update_attributes).with('note' => 'test')
|
109
|
+
put :update, id: budget_type.id, budget_type: { note: 'test' }
|
110
110
|
end
|
111
111
|
|
112
|
-
it
|
112
|
+
it 'assigns the requested budget_type as @budget_type' do
|
113
113
|
budget_type = BudgetType.create! valid_attributes
|
114
|
-
put :update, :
|
114
|
+
put :update, id: budget_type.id, budget_type: valid_attributes
|
115
115
|
assigns(:budget_type).should eq(budget_type)
|
116
116
|
end
|
117
117
|
|
118
|
-
it
|
118
|
+
it 'redirects to the budget_type' do
|
119
119
|
budget_type = BudgetType.create! valid_attributes
|
120
|
-
put :update, :
|
120
|
+
put :update, id: budget_type.id, budget_type: valid_attributes
|
121
121
|
response.should redirect_to(budget_type)
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
124
|
+
it 'moves its position when specified' do
|
125
125
|
budget_type = BudgetType.create! valid_attributes
|
126
126
|
position = budget_type.position
|
127
|
-
put :update, :
|
127
|
+
put :update, id: budget_type.id, move: 'higher'
|
128
128
|
response.should redirect_to budget_types_url
|
129
129
|
budget_type.reload
|
130
130
|
budget_type.position.should eq position - 1
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe
|
135
|
-
it
|
134
|
+
describe 'with invalid params' do
|
135
|
+
it 'assigns the budget_type as @budget_type' do
|
136
136
|
budget_type = BudgetType.create! valid_attributes
|
137
137
|
# Trigger the behavior that occurs when invalid params are submitted
|
138
138
|
BudgetType.any_instance.stub(:save).and_return(false)
|
139
|
-
put :update, :
|
139
|
+
put :update, id: budget_type.id, budget_type: { note: 'test' }
|
140
140
|
assigns(:budget_type).should eq(budget_type)
|
141
141
|
end
|
142
142
|
|
@@ -144,25 +144,24 @@ describe BudgetTypesController do
|
|
144
144
|
budget_type = BudgetType.create! valid_attributes
|
145
145
|
# Trigger the behavior that occurs when invalid params are submitted
|
146
146
|
BudgetType.any_instance.stub(:save).and_return(false)
|
147
|
-
put :update, :
|
148
|
-
#response.should render_template("edit")
|
147
|
+
put :update, id: budget_type.id, budget_type: { note: 'test' }
|
148
|
+
# response.should render_template("edit")
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
describe
|
154
|
-
it
|
153
|
+
describe 'DELETE destroy' do
|
154
|
+
it 'destroys the requested budget_type' do
|
155
155
|
budget_type = BudgetType.create! valid_attributes
|
156
|
-
expect
|
157
|
-
delete :destroy, :
|
158
|
-
|
156
|
+
expect do
|
157
|
+
delete :destroy, id: budget_type.id
|
158
|
+
end.to change(BudgetType, :count).by(-1)
|
159
159
|
end
|
160
160
|
|
161
|
-
it
|
161
|
+
it 'redirects to the budget_types list' do
|
162
162
|
budget_type = BudgetType.create! valid_attributes
|
163
|
-
delete :destroy, :
|
163
|
+
delete :destroy, id: budget_type.id
|
164
164
|
response.should redirect_to(budget_types_url)
|
165
165
|
end
|
166
166
|
end
|
167
|
-
|
168
167
|
end
|
@@ -3,119 +3,119 @@ require 'rails_helper'
|
|
3
3
|
describe LibrariesController do
|
4
4
|
fixtures :all
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe 'GET index', solr: true do
|
7
7
|
before do
|
8
8
|
Library.reindex
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe 'When logged in as Administrator' do
|
12
12
|
login_fixture_admin
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'assigns all libraries as @libraries' do
|
15
15
|
get :index
|
16
16
|
assigns(:libraries).should_not be_empty
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe 'When logged in as Librarian' do
|
21
21
|
login_fixture_librarian
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'assigns all libraries as @libraries' do
|
24
24
|
get :index
|
25
25
|
assigns(:libraries).should_not be_empty
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe 'When logged in as User' do
|
30
30
|
login_fixture_user
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'assigns all libraries as @libraries' do
|
33
33
|
get :index
|
34
34
|
assigns(:libraries).should_not be_empty
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
39
|
-
it
|
38
|
+
describe 'When not logged in' do
|
39
|
+
it 'assigns all libraries as @libraries' do
|
40
40
|
get :index
|
41
41
|
assigns(:libraries).should_not be_empty
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
45
|
-
get :index, :
|
44
|
+
it 'should get index with query' do
|
45
|
+
get :index, query: 'kamata'
|
46
46
|
response.should be_success
|
47
47
|
assigns(:libraries).include?(Library.friendly.find('kamata')).should be_truthy
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
describe
|
52
|
+
describe 'GET show', solr: true do
|
53
|
+
describe 'When logged in as Administrator' do
|
54
54
|
login_fixture_admin
|
55
55
|
|
56
|
-
it
|
57
|
-
get :show, :
|
56
|
+
it 'assigns the requested library as @library' do
|
57
|
+
get :show, id: 1
|
58
58
|
assigns(:library).should eq(libraries(:library_00001))
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
describe
|
62
|
+
describe 'When logged in as Librarian' do
|
63
63
|
login_fixture_librarian
|
64
64
|
|
65
|
-
it
|
66
|
-
get :show, :
|
65
|
+
it 'assigns the requested library as @library' do
|
66
|
+
get :show, id: 1
|
67
67
|
assigns(:library).should eq(libraries(:library_00001))
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
71
|
+
describe 'When logged in as User' do
|
72
72
|
login_fixture_user
|
73
73
|
|
74
|
-
it
|
75
|
-
get :show, :
|
74
|
+
it 'assigns the requested library as @library' do
|
75
|
+
get :show, id: 1
|
76
76
|
assigns(:library).should eq(libraries(:library_00001))
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
describe
|
81
|
-
it
|
82
|
-
get :show, :
|
80
|
+
describe 'When not logged in' do
|
81
|
+
it 'assigns the requested library as @library' do
|
82
|
+
get :show, id: 1
|
83
83
|
assigns(:library).should eq(libraries(:library_00001))
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
describe
|
89
|
-
describe
|
88
|
+
describe 'GET new' do
|
89
|
+
describe 'When logged in as Administrator' do
|
90
90
|
login_fixture_admin
|
91
91
|
|
92
|
-
it
|
92
|
+
it 'assigns the requested library as @library' do
|
93
93
|
get :new
|
94
94
|
assigns(:library).should_not be_valid
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
describe
|
98
|
+
describe 'When logged in as Librarian' do
|
99
99
|
login_fixture_librarian
|
100
100
|
|
101
|
-
it
|
101
|
+
it 'assigns the requested library as @library' do
|
102
102
|
get :new
|
103
103
|
assigns(:library).should be_nil
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
describe
|
107
|
+
describe 'When logged in as User' do
|
108
108
|
login_fixture_user
|
109
109
|
|
110
|
-
it
|
110
|
+
it 'should not assign the requested library as @library' do
|
111
111
|
get :new
|
112
112
|
assigns(:library).should be_nil
|
113
113
|
response.should be_forbidden
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
describe
|
118
|
-
it
|
117
|
+
describe 'When not logged in' do
|
118
|
+
it 'should not assign the requested library as @library' do
|
119
119
|
get :new
|
120
120
|
assigns(:library).should be_nil
|
121
121
|
response.should redirect_to(new_user_session_url)
|
@@ -123,386 +123,386 @@ describe LibrariesController do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
127
|
-
describe
|
126
|
+
describe 'GET edit' do
|
127
|
+
describe 'When logged in as Administrator' do
|
128
128
|
login_fixture_admin
|
129
129
|
|
130
|
-
it
|
130
|
+
it 'assigns the requested library as @library' do
|
131
131
|
library = FactoryGirl.create(:library)
|
132
|
-
get :edit, :
|
132
|
+
get :edit, id: library.id
|
133
133
|
assigns(:library).should eq(library)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe
|
137
|
+
describe 'When logged in as Librarian' do
|
138
138
|
login_fixture_librarian
|
139
139
|
|
140
|
-
it
|
140
|
+
it 'assigns the requested library as @library' do
|
141
141
|
library = FactoryGirl.create(:library)
|
142
|
-
get :edit, :
|
142
|
+
get :edit, id: library.id
|
143
143
|
response.should be_forbidden
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
describe
|
147
|
+
describe 'When logged in as User' do
|
148
148
|
login_fixture_user
|
149
149
|
|
150
|
-
it
|
150
|
+
it 'assigns the requested library as @library' do
|
151
151
|
library = FactoryGirl.create(:library)
|
152
|
-
get :edit, :
|
152
|
+
get :edit, id: library.id
|
153
153
|
response.should be_forbidden
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
describe
|
158
|
-
it
|
157
|
+
describe 'When not logged in' do
|
158
|
+
it 'should not assign the requested library as @library' do
|
159
159
|
library = FactoryGirl.create(:library)
|
160
|
-
get :edit, :
|
160
|
+
get :edit, id: library.id
|
161
161
|
response.should redirect_to(new_user_session_url)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
describe
|
166
|
+
describe 'POST create' do
|
167
167
|
before(:each) do
|
168
168
|
@attrs = FactoryGirl.attributes_for(:library)
|
169
|
-
@invalid_attrs = {:
|
169
|
+
@invalid_attrs = { name: '' }
|
170
170
|
end
|
171
171
|
|
172
|
-
describe
|
172
|
+
describe 'When logged in as Administrator' do
|
173
173
|
login_fixture_admin
|
174
174
|
|
175
|
-
describe
|
176
|
-
it
|
177
|
-
post :create, :
|
175
|
+
describe 'with valid params' do
|
176
|
+
it 'assigns a newly created library as @library' do
|
177
|
+
post :create, library: @attrs
|
178
178
|
assigns(:library).should be_valid
|
179
179
|
end
|
180
180
|
|
181
|
-
it
|
182
|
-
post :create, :
|
181
|
+
it 'redirects to the created patron' do
|
182
|
+
post :create, library: @attrs
|
183
183
|
response.should redirect_to(assigns(:library))
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
describe
|
188
|
-
it
|
189
|
-
post :create, :
|
187
|
+
describe 'with invalid params' do
|
188
|
+
it 'assigns a newly created but unsaved library as @library' do
|
189
|
+
post :create, library: @invalid_attrs
|
190
190
|
assigns(:library).should_not be_valid
|
191
191
|
end
|
192
192
|
|
193
|
-
it
|
194
|
-
post :create, :
|
193
|
+
it 'should be successful' do
|
194
|
+
post :create, library: @invalid_attrs
|
195
195
|
response.should be_success
|
196
196
|
end
|
197
197
|
|
198
|
-
it
|
199
|
-
post :create, :
|
198
|
+
it 'should not create library without short_display_name' do
|
199
|
+
post :create, library: { name: 'fujisawa', short_display_name: '' }
|
200
200
|
response.should be_success
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
describe
|
205
|
+
describe 'When logged in as Librarian' do
|
206
206
|
login_fixture_librarian
|
207
207
|
|
208
|
-
describe
|
209
|
-
it
|
210
|
-
post :create, :
|
208
|
+
describe 'with valid params' do
|
209
|
+
it 'assigns a newly created library as @library' do
|
210
|
+
post :create, library: @attrs
|
211
211
|
assigns(:library).should be_nil
|
212
212
|
end
|
213
213
|
|
214
|
-
it
|
215
|
-
post :create, :
|
214
|
+
it 'should be forbidden' do
|
215
|
+
post :create, library: @attrs
|
216
216
|
response.should be_forbidden
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
|
-
describe
|
221
|
-
it
|
222
|
-
post :create, :
|
220
|
+
describe 'with invalid params' do
|
221
|
+
it 'assigns a newly created but unsaved library as @library' do
|
222
|
+
post :create, library: @invalid_attrs
|
223
223
|
assigns(:library).should be_nil
|
224
224
|
end
|
225
225
|
|
226
|
-
it
|
227
|
-
post :create, :
|
226
|
+
it 'should be forbidden' do
|
227
|
+
post :create, library: @invalid_attrs
|
228
228
|
response.should be_forbidden
|
229
229
|
end
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
describe
|
233
|
+
describe 'When logged in as User' do
|
234
234
|
login_fixture_user
|
235
235
|
|
236
|
-
describe
|
237
|
-
it
|
238
|
-
post :create, :
|
236
|
+
describe 'with valid params' do
|
237
|
+
it 'assigns a newly created library as @library' do
|
238
|
+
post :create, library: @attrs
|
239
239
|
assigns(:library).should be_nil
|
240
240
|
end
|
241
241
|
|
242
|
-
it
|
243
|
-
post :create, :
|
242
|
+
it 'should be forbidden' do
|
243
|
+
post :create, library: @attrs
|
244
244
|
response.should be_forbidden
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
248
|
-
describe
|
249
|
-
it
|
250
|
-
post :create, :
|
248
|
+
describe 'with invalid params' do
|
249
|
+
it 'assigns a newly created but unsaved library as @library' do
|
250
|
+
post :create, library: @invalid_attrs
|
251
251
|
assigns(:library).should be_nil
|
252
252
|
end
|
253
253
|
|
254
|
-
it
|
255
|
-
post :create, :
|
254
|
+
it 'should be forbidden' do
|
255
|
+
post :create, library: @invalid_attrs
|
256
256
|
response.should be_forbidden
|
257
257
|
end
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
261
|
-
describe
|
262
|
-
describe
|
263
|
-
it
|
264
|
-
post :create, :
|
261
|
+
describe 'When not logged in' do
|
262
|
+
describe 'with valid params' do
|
263
|
+
it 'assigns a newly created library as @library' do
|
264
|
+
post :create, library: @attrs
|
265
265
|
assigns(:library).should be_nil
|
266
266
|
end
|
267
267
|
|
268
|
-
it
|
269
|
-
post :create, :
|
268
|
+
it 'should be redirected to new session url' do
|
269
|
+
post :create, library: @attrs
|
270
270
|
response.should redirect_to(new_user_session_url)
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
describe
|
275
|
-
it
|
276
|
-
post :create, :
|
274
|
+
describe 'with invalid params' do
|
275
|
+
it 'assigns a newly created but unsaved library as @library' do
|
276
|
+
post :create, library: @invalid_attrs
|
277
277
|
assigns(:library).should be_nil
|
278
278
|
end
|
279
279
|
|
280
|
-
it
|
281
|
-
post :create, :
|
280
|
+
it 'should be redirected to new session url' do
|
281
|
+
post :create, library: @invalid_attrs
|
282
282
|
response.should redirect_to(new_user_session_url)
|
283
283
|
end
|
284
284
|
end
|
285
285
|
end
|
286
286
|
end
|
287
287
|
|
288
|
-
describe
|
288
|
+
describe 'PUT update' do
|
289
289
|
before(:each) do
|
290
290
|
@library = libraries(:library_00001)
|
291
|
-
@attrs = {:
|
292
|
-
@invalid_attrs = {:
|
291
|
+
@attrs = { name: 'example' }
|
292
|
+
@invalid_attrs = { name: '' }
|
293
293
|
end
|
294
294
|
|
295
|
-
describe
|
295
|
+
describe 'When logged in as Administrator' do
|
296
296
|
login_fixture_admin
|
297
297
|
|
298
|
-
describe
|
299
|
-
it
|
300
|
-
put :update, :
|
298
|
+
describe 'with valid params' do
|
299
|
+
it 'updates the requested library' do
|
300
|
+
put :update, id: @library.id, library: @attrs
|
301
301
|
end
|
302
302
|
|
303
|
-
it
|
304
|
-
put :update, :
|
303
|
+
it 'assigns the requested library as @library' do
|
304
|
+
put :update, id: @library.id, library: @attrs
|
305
305
|
assigns(:library).should eq(@library)
|
306
306
|
end
|
307
307
|
|
308
|
-
it
|
309
|
-
put :update, :
|
308
|
+
it 'moves its position when specified' do
|
309
|
+
put :update, id: @library.id, library: @attrs, move: 'lower'
|
310
310
|
response.should redirect_to(libraries_url)
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
314
|
-
describe
|
315
|
-
it
|
316
|
-
put :update, :
|
317
|
-
response.should render_template(
|
314
|
+
describe 'with invalid params' do
|
315
|
+
it 'assigns the requested library as @library' do
|
316
|
+
put :update, id: @library.id, library: @invalid_attrs
|
317
|
+
response.should render_template('edit')
|
318
318
|
end
|
319
319
|
end
|
320
320
|
end
|
321
321
|
|
322
|
-
describe
|
322
|
+
describe 'When logged in as Librarian' do
|
323
323
|
login_fixture_librarian
|
324
324
|
|
325
|
-
describe
|
326
|
-
it
|
327
|
-
put :update, :
|
325
|
+
describe 'with valid params' do
|
326
|
+
it 'updates the requested library' do
|
327
|
+
put :update, id: @library.id, library: @attrs
|
328
328
|
end
|
329
329
|
|
330
|
-
it
|
331
|
-
put :update, :
|
330
|
+
it 'should be forbidden' do
|
331
|
+
put :update, id: @library.id, library: @attrs
|
332
332
|
response.should be_forbidden
|
333
333
|
end
|
334
334
|
end
|
335
335
|
|
336
|
-
describe
|
337
|
-
it
|
338
|
-
put :update, :
|
336
|
+
describe 'with invalid params' do
|
337
|
+
it 'should be forbidden' do
|
338
|
+
put :update, id: @library.id, library: @invalid_attrs
|
339
339
|
response.should be_forbidden
|
340
340
|
end
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
describe
|
344
|
+
describe 'When logged in as User' do
|
345
345
|
login_fixture_user
|
346
346
|
|
347
|
-
describe
|
348
|
-
it
|
349
|
-
put :update, :
|
347
|
+
describe 'with valid params' do
|
348
|
+
it 'updates the requested library' do
|
349
|
+
put :update, id: @library.id, library: @attrs
|
350
350
|
end
|
351
351
|
|
352
|
-
it
|
353
|
-
put :update, :
|
352
|
+
it 'should be forbidden' do
|
353
|
+
put :update, id: @library.id, library: @attrs
|
354
354
|
response.should be_forbidden
|
355
355
|
end
|
356
356
|
end
|
357
357
|
|
358
|
-
describe
|
359
|
-
it
|
360
|
-
put :update, :
|
358
|
+
describe 'with invalid params' do
|
359
|
+
it 'should be forbidden' do
|
360
|
+
put :update, id: @library.id, library: @invalid_attrs
|
361
361
|
response.should be_forbidden
|
362
362
|
end
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
366
|
-
describe
|
367
|
-
describe
|
368
|
-
it
|
369
|
-
put :update, :
|
366
|
+
describe 'When not logged in' do
|
367
|
+
describe 'with valid params' do
|
368
|
+
it 'updates the requested library' do
|
369
|
+
put :update, id: @library.id, library: @attrs
|
370
370
|
end
|
371
371
|
|
372
|
-
it
|
373
|
-
put :update, :
|
372
|
+
it 'should be forbidden' do
|
373
|
+
put :update, id: @library.id, library: @attrs
|
374
374
|
response.should redirect_to(new_user_session_url)
|
375
375
|
end
|
376
376
|
end
|
377
377
|
|
378
|
-
describe
|
379
|
-
it
|
380
|
-
put :update, :
|
378
|
+
describe 'with invalid params' do
|
379
|
+
it 'assigns the requested library as @library' do
|
380
|
+
put :update, id: @library.id, library: @invalid_attrs
|
381
381
|
response.should redirect_to(new_user_session_url)
|
382
382
|
end
|
383
383
|
end
|
384
384
|
end
|
385
385
|
end
|
386
386
|
|
387
|
-
describe
|
388
|
-
describe
|
387
|
+
describe 'DELETE destroy' do
|
388
|
+
describe 'Web' do
|
389
389
|
before(:each) do
|
390
390
|
@library = libraries(:library_00001)
|
391
391
|
end
|
392
392
|
|
393
|
-
describe
|
393
|
+
describe 'When logged in as Administrator' do
|
394
394
|
login_fixture_admin
|
395
395
|
|
396
|
-
it
|
397
|
-
delete :destroy, :
|
396
|
+
it 'destroys the requested library' do
|
397
|
+
delete :destroy, id: @library.id
|
398
398
|
end
|
399
399
|
|
400
|
-
it
|
401
|
-
delete :destroy, :
|
400
|
+
it 'should be forbidden' do
|
401
|
+
delete :destroy, id: @library.id
|
402
402
|
response.should be_forbidden
|
403
403
|
end
|
404
404
|
|
405
|
-
it
|
406
|
-
delete :destroy, :
|
405
|
+
it 'should not destroy library_id 1' do
|
406
|
+
delete :destroy, id: 'web'
|
407
407
|
response.should be_forbidden
|
408
408
|
end
|
409
409
|
|
410
|
-
it
|
411
|
-
delete :destroy, :
|
410
|
+
it 'should not destroy library that contains shelves' do
|
411
|
+
delete :destroy, id: 'kamata'
|
412
412
|
response.should be_forbidden
|
413
413
|
end
|
414
414
|
end
|
415
415
|
|
416
|
-
describe
|
416
|
+
describe 'When logged in as Librarian' do
|
417
417
|
login_fixture_librarian
|
418
418
|
|
419
|
-
it
|
420
|
-
delete :destroy, :
|
419
|
+
it 'destroys the requested library' do
|
420
|
+
delete :destroy, id: @library.id
|
421
421
|
end
|
422
422
|
|
423
|
-
it
|
424
|
-
delete :destroy, :
|
423
|
+
it 'should be forbidden' do
|
424
|
+
delete :destroy, id: @library.id
|
425
425
|
response.should be_forbidden
|
426
426
|
end
|
427
427
|
end
|
428
428
|
|
429
|
-
describe
|
429
|
+
describe 'When logged in as User' do
|
430
430
|
login_fixture_user
|
431
431
|
|
432
|
-
it
|
433
|
-
delete :destroy, :
|
432
|
+
it 'destroys the requested library' do
|
433
|
+
delete :destroy, id: @library.id
|
434
434
|
end
|
435
435
|
|
436
|
-
it
|
437
|
-
delete :destroy, :
|
436
|
+
it 'should be forbidden' do
|
437
|
+
delete :destroy, id: @library.id
|
438
438
|
response.should be_forbidden
|
439
439
|
end
|
440
440
|
end
|
441
441
|
|
442
|
-
describe
|
443
|
-
it
|
444
|
-
delete :destroy, :
|
442
|
+
describe 'When not logged in' do
|
443
|
+
it 'destroys the requested library' do
|
444
|
+
delete :destroy, id: @library.id
|
445
445
|
end
|
446
446
|
|
447
|
-
it
|
448
|
-
delete :destroy, :
|
447
|
+
it 'should be forbidden' do
|
448
|
+
delete :destroy, id: @library.id
|
449
449
|
response.should redirect_to(new_user_session_url)
|
450
450
|
end
|
451
451
|
end
|
452
452
|
end
|
453
453
|
|
454
|
-
describe
|
454
|
+
describe 'Library' do
|
455
455
|
before(:each) do
|
456
456
|
@library = FactoryGirl.create(:library)
|
457
457
|
@library.shelves.first.destroy
|
458
458
|
end
|
459
459
|
|
460
|
-
describe
|
460
|
+
describe 'When logged in as Administrator' do
|
461
461
|
login_fixture_admin
|
462
462
|
|
463
|
-
it
|
464
|
-
delete :destroy, :
|
463
|
+
it 'destroys the requested library' do
|
464
|
+
delete :destroy, id: @library.id
|
465
465
|
end
|
466
466
|
|
467
|
-
it
|
468
|
-
delete :destroy, :
|
467
|
+
it 'redirects to the libraries list' do
|
468
|
+
delete :destroy, id: @library.id
|
469
469
|
response.should redirect_to(libraries_url)
|
470
470
|
end
|
471
471
|
end
|
472
472
|
|
473
|
-
describe
|
473
|
+
describe 'When logged in as Librarian' do
|
474
474
|
login_fixture_librarian
|
475
475
|
|
476
|
-
it
|
477
|
-
delete :destroy, :
|
476
|
+
it 'destroys the requested library' do
|
477
|
+
delete :destroy, id: @library.id
|
478
478
|
end
|
479
479
|
|
480
|
-
it
|
481
|
-
delete :destroy, :
|
480
|
+
it 'should be forbidden' do
|
481
|
+
delete :destroy, id: @library.id
|
482
482
|
response.should be_forbidden
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
describe
|
486
|
+
describe 'When logged in as User' do
|
487
487
|
login_fixture_user
|
488
488
|
|
489
|
-
it
|
490
|
-
delete :destroy, :
|
489
|
+
it 'destroys the requested library' do
|
490
|
+
delete :destroy, id: @library.id
|
491
491
|
end
|
492
492
|
|
493
|
-
it
|
494
|
-
delete :destroy, :
|
493
|
+
it 'should be forbidden' do
|
494
|
+
delete :destroy, id: @library.id
|
495
495
|
response.should be_forbidden
|
496
496
|
end
|
497
497
|
end
|
498
498
|
|
499
|
-
describe
|
500
|
-
it
|
501
|
-
delete :destroy, :
|
499
|
+
describe 'When not logged in' do
|
500
|
+
it 'destroys the requested library' do
|
501
|
+
delete :destroy, id: @library.id
|
502
502
|
end
|
503
503
|
|
504
|
-
it
|
505
|
-
delete :destroy, :
|
504
|
+
it 'should be forbidden' do
|
505
|
+
delete :destroy, id: @library.id
|
506
506
|
response.should redirect_to(new_user_session_url)
|
507
507
|
end
|
508
508
|
end
|