enju_circulation 0.0.71 → 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/app/controllers/checked_items_controller.rb +2 -2
  2. data/app/controllers/checkins_controller.rb +4 -4
  3. data/app/controllers/checkouts_controller.rb +2 -2
  4. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -2
  5. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -2
  6. data/app/controllers/user_checkout_stats_controller.rb +2 -2
  7. data/app/controllers/user_reserve_stats_controller.rb +2 -2
  8. data/app/models/checkin.rb +1 -3
  9. data/app/models/checkout.rb +1 -3
  10. data/app/models/checkout_stat_has_manifestation.rb +1 -3
  11. data/app/models/checkout_stat_has_user.rb +1 -3
  12. data/app/models/checkout_type.rb +1 -3
  13. data/app/models/item_has_use_restriction.rb +1 -3
  14. data/app/models/lending_policy.rb +1 -3
  15. data/app/models/manifestation_checkout_stat.rb +1 -3
  16. data/app/models/manifestation_reserve_stat.rb +1 -3
  17. data/app/models/reserve.rb +3 -4
  18. data/app/models/reserve_stat_has_manifestation.rb +1 -3
  19. data/app/models/reserve_stat_has_user.rb +1 -3
  20. data/app/models/user_checkout_stat.rb +1 -3
  21. data/app/models/user_reserve_stat.rb +1 -3
  22. data/app/views/baskets/index.html.erb +1 -1
  23. data/app/views/checked_items/index.html.erb +1 -1
  24. data/app/views/checkins/index.html.erb +1 -1
  25. data/app/views/checkout_stat_has_manifestations/index.html.erb +1 -1
  26. data/app/views/checkout_stat_has_users/index.html.erb +1 -1
  27. data/app/views/checkout_types/index.html.erb +1 -1
  28. data/app/views/checkouts/_list.html.erb +1 -1
  29. data/app/views/item_has_use_restrictions/index.html.erb +1 -1
  30. data/app/views/lending_policies/index.html.erb +1 -1
  31. data/app/views/manifestation_checkout_stats/index.html.erb +1 -1
  32. data/app/views/manifestation_checkout_stats/show.html.erb +1 -1
  33. data/app/views/manifestation_reserve_stats/index.html.erb +1 -1
  34. data/app/views/manifestation_reserve_stats/show.html.erb +1 -1
  35. data/app/views/reserve_stat_has_manifestations/index.html.erb +1 -1
  36. data/app/views/reserve_stat_has_users/index.html.erb +1 -1
  37. data/app/views/reserves/index.html.erb +1 -1
  38. data/app/views/user_checkout_stats/index.html.erb +1 -1
  39. data/app/views/user_checkout_stats/show.html.erb +1 -1
  40. data/app/views/user_reserve_stats/index.html.erb +1 -1
  41. data/app/views/user_reserve_stats/show.html.erb +1 -1
  42. data/lib/enju_circulation/controller.rb +0 -4
  43. data/lib/enju_circulation/version.rb +1 -1
  44. data/lib/generators/enju_circulation/views_generator.rb +38 -0
  45. data/spec/dummy/app/mailers/notifier.rb +5 -4
  46. data/spec/dummy/app/models/ability.rb +0 -2
  47. data/spec/dummy/app/models/local_patron.rb +13 -0
  48. data/spec/dummy/app/models/user.rb +8 -0
  49. data/spec/dummy/config/application.rb +4 -1
  50. data/spec/dummy/db/schema.rb +0 -11
  51. data/spec/dummy/db/test.sqlite3 +0 -0
  52. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  53. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  54. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  55. metadata +46 -64
  56. data/app/controllers/accepts_controller.rb +0 -83
  57. data/app/models/accept.rb +0 -36
  58. data/db/migrate/20120319173203_create_accepts.rb +0 -14
  59. data/spec/controllers/accepts_controller_spec.rb +0 -304
  60. data/spec/dummy/lib/enju_leaf/calculate_stat.rb +0 -30
  61. data/spec/dummy/lib/enju_leaf/expire_editable_fragment.rb +0 -30
  62. data/spec/dummy/lib/enju_leaf/expire_fragment_cache.rb +0 -17
  63. data/spec/dummy/lib/enju_leaf/import_file.rb +0 -13
  64. data/spec/dummy/lib/enju_leaf/localized_name.rb +0 -13
  65. data/spec/dummy/lib/enju_leaf/master_model.rb +0 -19
  66. data/spec/dummy/lib/enju_leaf/url_validator.rb +0 -10
  67. data/spec/dummy/lib/enju_leaf.rb +0 -5
  68. data/spec/dummy/solr/data/test/index/_2r.fdt +0 -0
  69. data/spec/dummy/solr/data/test/index/_2r.fdx +0 -0
  70. data/spec/dummy/solr/data/test/index/_2r.fnm +0 -6
  71. data/spec/dummy/solr/data/test/index/_2r.frq +0 -1
  72. data/spec/dummy/solr/data/test/index/_2r.nrm +0 -1
  73. data/spec/dummy/solr/data/test/index/_2r.prx +0 -0
  74. data/spec/dummy/solr/data/test/index/_2r.tii +0 -0
  75. data/spec/dummy/solr/data/test/index/_2r.tis +0 -0
  76. data/spec/dummy/solr/data/test/index/segments_6n +0 -0
  77. data/spec/factories/accepts.rb +0 -9
  78. data/spec/models/accept_spec.rb +0 -22
  79. data/spec/requests/accepts_spec.rb +0 -11
  80. data/spec/routing/accepts_routing_spec.rb +0 -27
  81. data/spec/views/accepts/edit.html.erb_spec.rb +0 -18
  82. data/spec/views/accepts/index.html.erb_spec.rb +0 -25
  83. data/spec/views/accepts/new.html.erb_spec.rb +0 -29
  84. data/spec/views/accepts/show.html.erb_spec.rb +0 -17
@@ -1,304 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AcceptsController do
4
- fixtures :all
5
-
6
- def mock_user(stubs={})
7
- (@mock_user ||= mock_model(Accept).as_null_object).tap do |user|
8
- user.stub(stubs) unless stubs.empty?
9
- end
10
- end
11
-
12
- describe "GET index" do
13
- describe "When logged in as Administrator" do
14
- login_fixture_admin
15
-
16
- it "assigns all accepts as @accepts" do
17
- get :index
18
- assigns(:accepts).should_not be_nil
19
- response.should be_success
20
- end
21
-
22
- describe "When basket_id is specified" do
23
- it "assigns all accepts as @accepts" do
24
- get :index, :basket_id => 10
25
- assigns(:accepts).should eq Basket.find(10).accepts.page(1)
26
- response.should be_success
27
- end
28
- end
29
- end
30
-
31
- describe "When logged in as Librarian" do
32
- login_fixture_librarian
33
-
34
- it "assigns all accepts as @accepts" do
35
- get :index
36
- assigns(:accepts).should_not be_nil
37
- response.should be_success
38
- end
39
-
40
- describe "When basket_id is specified" do
41
- it "assigns all accepts as @accepts" do
42
- get :index, :basket_id => 9
43
- assigns(:accepts).should eq Basket.find(9).accepts.page(1)
44
- response.should be_success
45
- end
46
- end
47
- end
48
-
49
- describe "When logged in as User" do
50
- login_fixture_user
51
-
52
- it "should not assign all accepts as @accepts" do
53
- get :index
54
- assigns(:accepts).should be_nil
55
- response.should be_forbidden
56
- end
57
- end
58
- end
59
-
60
- describe "GET show" do
61
- describe "When logged in as Administrator" do
62
- login_fixture_admin
63
-
64
- it "assigns the requested accept as @accept" do
65
- accept = FactoryGirl.create(:accept)
66
- get :show, :id => accept.id
67
- assigns(:accept).should eq(accept)
68
- end
69
-
70
- it "should not show missing accept" do
71
- get :show, :id => 'missing'
72
- response.should be_missing
73
- end
74
- end
75
-
76
- describe "When logged in as Librarian" do
77
- login_fixture_librarian
78
-
79
- it "assigns the requested accept as @accept" do
80
- accept = FactoryGirl.create(:accept)
81
- get :show, :id => accept.id
82
- assigns(:accept).should eq(accept)
83
- end
84
- end
85
-
86
- describe "When logged in as User" do
87
- login_fixture_user
88
-
89
- it "assigns the requested accept as @accept" do
90
- accept = FactoryGirl.create(:accept)
91
- get :show, :id => accept.id
92
- assigns(:accept).should eq(accept)
93
- response.should be_forbidden
94
- end
95
- end
96
-
97
- describe "When not logged in" do
98
- it "assigns the requested accept as @accept" do
99
- accept = FactoryGirl.create(:accept)
100
- get :show, :id => accept.id
101
- assigns(:accept).should eq(accept)
102
- response.should redirect_to new_user_session_url
103
- end
104
- end
105
- end
106
-
107
- describe "GET new" do
108
- describe "When logged in as Administrator" do
109
- login_fixture_admin
110
-
111
- it "assigns the requested accept as @accept" do
112
- get :new
113
- assigns(:accept).should_not be_valid
114
- end
115
- end
116
-
117
- describe "When logged in as Librarian" do
118
- login_fixture_librarian
119
-
120
- it "assigns the requested accept as @accept" do
121
- get :new
122
- assigns(:accept).should_not be_valid
123
- end
124
- end
125
-
126
- describe "When logged in as User" do
127
- login_fixture_user
128
-
129
- it "should not assign the requested accept as @accept" do
130
- get :new
131
- assigns(:accept).should_not be_valid
132
- response.should be_forbidden
133
- end
134
- end
135
-
136
- describe "When not logged in" do
137
- it "should not assign the requested accept as @accept" do
138
- get :new
139
- assigns(:accept).should_not be_valid
140
- response.should redirect_to(new_user_session_url)
141
- end
142
- end
143
- end
144
-
145
- describe "POST create" do
146
- before(:each) do
147
- @attrs = {:item_identifier => '00003'}
148
- @invalid_attrs = {:item_identifier => 'invalid'}
149
- end
150
-
151
- describe "When logged in as Administrator" do
152
- login_fixture_admin
153
-
154
- describe "with valid params" do
155
- it "assigns a newly created accept as @accept" do
156
- post :create, :accept => @attrs
157
- assigns(:accept).should_not be_valid
158
- end
159
-
160
- it "should not create a new accept without basket_id" do
161
- post :create, :accept => @attrs
162
- response.should be_forbidden
163
- end
164
-
165
- describe "When basket_id is specified" do
166
- it "redirects to the created accept" do
167
- post :create, :accept => @attrs, :basket_id => 9
168
- response.should redirect_to(basket_accepts_url(assigns(:accept).basket))
169
- assigns(:accept).item.circulation_status.name.should eq 'Available On Shelf'
170
- end
171
- end
172
- end
173
-
174
- describe "with invalid params" do
175
- it "assigns a newly created but unsaved accept as @accept" do
176
- post :create, :accept => @invalid_attrs
177
- assigns(:accept).should_not be_valid
178
- end
179
-
180
- it "should be forbidden" do
181
- post :create, :accept => @invalid_attrs
182
- response.should be_forbidden
183
- end
184
- end
185
-
186
- it "should not create accept without item_id" do
187
- post :create, :accept => {:item_identifier => nil}, :basket_id => 9
188
- assigns(:accept).should_not be_valid
189
- response.should be_success
190
- end
191
- end
192
-
193
- describe "When logged in as Librarian" do
194
- login_fixture_librarian
195
-
196
- describe "with valid params" do
197
- it "assigns a newly created accept as @accept" do
198
- post :create, :accept => @attrs
199
- assigns(:accept).should_not be_valid
200
- end
201
-
202
- it "should not create a new accept without basket_id" do
203
- post :create, :accept => @attrs
204
- response.should be_forbidden
205
- end
206
- end
207
- end
208
-
209
- describe "When logged in as User" do
210
- login_fixture_user
211
-
212
- describe "with valid params" do
213
- it "assigns a newly created accept as @accept" do
214
- post :create, :accept => @attrs
215
- assigns(:accept).should_not be_valid
216
- end
217
-
218
- it "should be forbidden" do
219
- post :create, :accept => @attrs
220
- response.should be_forbidden
221
- end
222
- end
223
- end
224
-
225
- describe "When not logged in" do
226
- before(:each) do
227
- @attrs = {:item_identifier => '00003'}
228
- @invalid_attrs = {:item_identifier => 'invalid'}
229
- end
230
-
231
- describe "with valid params" do
232
- it "assigns a newly created accept as @accept" do
233
- post :create, :accept => @attrs
234
- end
235
-
236
- it "should redirect to new session url" do
237
- post :create, :accept => @attrs
238
- response.should redirect_to new_user_session_url
239
- end
240
- end
241
- end
242
- end
243
-
244
- describe "DELETE destroy" do
245
- before(:each) do
246
- @accept = FactoryGirl.create(:accept)
247
- end
248
-
249
- describe "When logged in as Administrator" do
250
- login_fixture_admin
251
-
252
- it "destroys the requested accept" do
253
- delete :destroy, :id => @accept.id
254
- end
255
-
256
- it "redirects to the accepts list" do
257
- delete :destroy, :id => @accept.id
258
- response.should redirect_to(accepts_url)
259
- end
260
-
261
- it "should not destroy missing accept" do
262
- delete :destroy, :id => 'missing'
263
- response.should be_missing
264
- end
265
- end
266
-
267
- describe "When logged in as Librarian" do
268
- login_fixture_librarian
269
-
270
- it "destroys the requested accept" do
271
- delete :destroy, :id => @accept.id
272
- end
273
-
274
- it "redirects to the accepts list" do
275
- delete :destroy, :id => @accept.id
276
- response.should redirect_to(accepts_url)
277
- end
278
- end
279
-
280
- describe "When logged in as User" do
281
- login_fixture_user
282
-
283
- it "destroys the requested accept" do
284
- delete :destroy, :id => @accept.id
285
- end
286
-
287
- it "should be forbidden" do
288
- delete :destroy, :id => @accept.id
289
- response.should be_forbidden
290
- end
291
- end
292
-
293
- describe "When not logged in" do
294
- it "destroys the requested accept" do
295
- delete :destroy, :id => @accept.id
296
- end
297
-
298
- it "should be forbidden" do
299
- delete :destroy, :id => @accept.id
300
- response.should redirect_to(new_user_session_url)
301
- end
302
- end
303
- end
304
- end
@@ -1,30 +0,0 @@
1
- module CalculateStat
2
-
3
- def self.included(base)
4
- base.extend ClassMethods
5
- base.send :include, InstanceMethods
6
- base.class_eval do
7
- validates_presence_of :start_date, :end_date
8
- validate :check_date
9
- end
10
- end
11
-
12
- module ClassMethods
13
- def calculate_stat
14
- self.not_calculated.each do |stat|
15
- stat.aasm_calculate!
16
- end
17
- end
18
- end
19
-
20
- module InstanceMethods
21
- def check_date
22
- if self.start_date and self.end_date
23
- if self.start_date >= self.end_date
24
- errors.add(:start_date)
25
- errors.add(:end_date)
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- module ExpireEditableFragment
2
- def expire_editable_fragment(record, fragments = [])
3
- fragments.uniq!
4
- if record.is_a?(Manifestation)
5
- if fragments.empty?
6
- fragments = %w[manifestation_html show_detail_user_html show_detail_librarian_html pickup_html title_html title_mobile index_sru]
7
- end
8
- expire_manifestation_cache(record, fragments)
9
- else
10
- I18n.available_locales.each do |locale|
11
- Role.all_cache.each do |role|
12
- fragments.each do |fragment|
13
- expire_fragment(":#{record.class.to_s.downcase}" => record.id, :fragment => fragment, :role => role.name, :locale => locale)
14
- end
15
- end
16
- end
17
- end
18
- end
19
-
20
- private
21
- def expire_manifestation_cache(manifestation, fragments = [])
22
- I18n.available_locales.each do |locale|
23
- Role.all_cache.each do |role|
24
- fragments.uniq.each do |fragment|
25
- expire_fragment([:manifestation => manifestation.id, :fragment => fragment, :role => role.name, :locale => locale])
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- class ExpireFragmentCache
2
- def self.expire_fragment_cache(record, fragments = [])
3
- if record.is_a?(Manifestation)
4
- if fragments.empty?
5
- fragments = %w[manifestation_html show_detail_user_html show_detail_librarian_html pickup_html title_html title_mobile index_sru]
6
- end
7
- end
8
-
9
- I18n.available_locales.each do |locale|
10
- Role.all_cache.each do |role|
11
- fragments.each do |fragment|
12
- Rails.cache.clear([":#{record.class.to_s.downcase}" => record.id, :fragment => fragment, :role => role.name, :locale => locale])
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- module ImportFile
2
- def self.included(base)
3
- base.extend ClassMethods
4
- end
5
-
6
- module ClassMethods
7
- def expire
8
- self.stucked.find_each do |file|
9
- file.destroy
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module LocalizedName
2
- def localize(locale = I18n.locale.to_s)
3
- values = Hash[*self.strip.split("\n").map{|n| n.split(':', 2)}.flatten]
4
- name = values[locale.to_s] || self
5
- name.strip
6
- rescue ArgumentError
7
- self
8
- end
9
- end
10
-
11
- class String
12
- include LocalizedName
13
- end
@@ -1,19 +0,0 @@
1
- module MasterModel
2
- def self.included(base)
3
- #base.extend ClassMethods
4
- base.send :include, InstanceMethods
5
- base.class_eval do
6
- acts_as_list
7
- validates_uniqueness_of :name, :case_sensitive => false
8
- validates_presence_of :name, :display_name
9
- before_validation :set_display_name, :on => :create
10
- normalize_attributes :name
11
- end
12
- end
13
-
14
- module InstanceMethods
15
- def set_display_name
16
- self.display_name = "#{I18n.locale}: #{self.name}" if self.display_name.blank?
17
- end
18
- end
19
- end
@@ -1,10 +0,0 @@
1
- class UrlValidator < ActiveModel::EachValidator
2
- def validate_each(record, attribute, value)
3
- url = ::Addressable::URI.parse(value)
4
- if url
5
- unless ['http', 'https'].include?(url.scheme)
6
- record.errors.add(attribute.to_sym)
7
- end
8
- end
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- require 'nkf'
2
- require 'enju_leaf/calculate_stat'
3
- require 'enju_biblio'
4
- require 'enju_library'
5
- require 'enju_manifestation_viewer'
@@ -1,6 +0,0 @@
1
- ����
2
- idtype
3
- class_name
4
- username_s
5
- due_date_d created_at_d
6
- reserved_bchecked_in_at_d
@@ -1 +0,0 @@
1
- 
@@ -1 +0,0 @@
1
- NRM�
@@ -1,9 +0,0 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
2
-
3
- FactoryGirl.define do
4
- factory :accept do
5
- basket_id{FactoryGirl.create(:basket).id}
6
- item_id{FactoryGirl.create(:item).id}
7
- librarian_id{FactoryGirl.create(:librarian).id}
8
- end
9
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Accept do
4
- fixtures :all
5
-
6
- it "should change circulation_status" do
7
- accept = FactoryGirl.create(:accept)
8
- accept.item.circulation_status.name.should eq 'Available On Shelf'
9
- end
10
- end
11
- # == Schema Information
12
- #
13
- # Table name: accepts
14
- #
15
- # id :integer not null, primary key
16
- # basket_id :integer
17
- # item_id :integer
18
- # librarian_id :integer
19
- # created_at :datetime not null
20
- # updated_at :datetime not null
21
- #
22
-
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Accepts" do
4
- describe "GET /accepts" do
5
- it "works! (now write some real specs)" do
6
- # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
- get accepts_path
8
- response.status.should be(302)
9
- end
10
- end
11
- end
@@ -1,27 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe AcceptsController do
4
- describe "routing" do
5
-
6
- it "routes to #index" do
7
- get("/accepts").should route_to("accepts#index")
8
- end
9
-
10
- it "routes to #new" do
11
- get("/accepts/new").should route_to("accepts#new")
12
- end
13
-
14
- it "routes to #show" do
15
- get("/accepts/1").should route_to("accepts#show", :id => "1")
16
- end
17
-
18
- it "routes to #create" do
19
- post("/accepts").should route_to("accepts#create")
20
- end
21
-
22
- it "routes to #destroy" do
23
- delete("/accepts/1").should route_to("accepts#destroy", :id => "1")
24
- end
25
-
26
- end
27
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "accepts/edit" do
4
- before(:each) do
5
- @accept = assign(:accept, stub_model(Accept,
6
- :item_id => 1
7
- ))
8
- end
9
-
10
- it "renders the edit accept form" do
11
- render
12
-
13
- # Run the generator again with the --webrat flag if you want to use webrat matchers
14
- assert_select "form", :action => accepts_path(@accept), :method => "post" do
15
- assert_select "input#accept_item_id", :name => "accept[item_id]"
16
- end
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "accepts/index" do
4
- before(:each) do
5
- assign(:accepts, [
6
- stub_model(Accept,
7
- :item_id => 1,
8
- :created_at => Time.zone.now
9
- ),
10
- stub_model(Accept,
11
- :item_id => 1,
12
- :created_at => Time.zone.now
13
- )
14
- ].paginate(:page => 1))
15
- basket = FactoryGirl.create(:basket)
16
- assign(:basket, basket)
17
- assign(:accept, basket.accepts.new)
18
- end
19
-
20
- it "renders a list of accepts" do
21
- render
22
- # Run the generator again with the --webrat flag if you want to use webrat matchers
23
- assert_select "tr>td"
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "accepts/new" do
4
- before(:each) do
5
- assign(:accept, stub_model(Accept,
6
- :item_id => 1
7
- ).as_new_record)
8
- assign(:basket, FactoryGirl.create(:basket))
9
- assign(:accepts, [
10
- stub_model(Accept,
11
- :item_id => 1,
12
- :created_at => Time.zone.now
13
- ),
14
- stub_model(Accept,
15
- :item_id => 1,
16
- :created_at => Time.zone.now
17
- )
18
- ].paginate(:page => 1))
19
- end
20
-
21
- it "renders new accept form" do
22
- render
23
-
24
- # Run the generator again with the --webrat flag if you want to use webrat matchers
25
- assert_select "form", :action => accepts_path, :method => "post" do
26
- assert_select "input#accept_item_identifier", :name => "accept[item_identifier]"
27
- end
28
- end
29
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "accepts/show" do
4
- before(:each) do
5
- @accept = assign(:accept, stub_model(Accept,
6
- :item_id => 1,
7
- :librarian_id => 1,
8
- :created_at => Time.zone.now
9
- ))
10
- end
11
-
12
- it "renders attributes in <p>" do
13
- render
14
- # Run the generator again with the --webrat flag if you want to use webrat matchers
15
- rendered.should match(/1/)
16
- end
17
- end