enju_circulation 0.1.0.pre11 → 0.1.0.pre12

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/checked_items_controller.rb +0 -5
  3. data/app/controllers/checkins_controller.rb +0 -11
  4. data/app/controllers/reserves_controller.rb +73 -15
  5. data/app/helpers/reserves_helper.rb +2 -0
  6. data/app/models/checked_item.rb +9 -0
  7. data/app/models/checkin.rb +13 -0
  8. data/app/models/reserve.rb +186 -42
  9. data/app/views/baskets/new.html.erb +1 -1
  10. data/app/views/checked_items/_list.html.erb +1 -1
  11. data/app/views/checkins/_checkin.html.erb +1 -1
  12. data/app/views/checkins/_list.html.erb +1 -1
  13. data/app/views/manifestations/_show_detail_librarian.html.erb +141 -0
  14. data/app/views/manifestations/_show_detail_user.html.erb +136 -0
  15. data/app/views/reserves/_new.html.erb +1 -1
  16. data/app/views/reserves/_state_facet.html.erb +15 -0
  17. data/app/views/reserves/_title.html.erb +2 -1
  18. data/app/views/reserves/edit.html.erb +20 -2
  19. data/app/views/reserves/index.csv.erb +2 -2
  20. data/app/views/reserves/index.html.erb +30 -6
  21. data/app/views/reserves/show.html.erb +18 -3
  22. data/config/locales/translation_en.yml +10 -1
  23. data/config/locales/translation_ja.yml +10 -1
  24. data/db/migrate/20130303104849_add_state_index_to_reserve.rb +5 -0
  25. data/db/migrate/20130303124821_add_retained_at_to_reserve.rb +5 -0
  26. data/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +5 -0
  27. data/lib/enju_circulation/item.rb +4 -0
  28. data/lib/enju_circulation/version.rb +1 -1
  29. data/spec/controllers/checkins_controller_spec.rb +2 -2
  30. data/spec/controllers/reserves_controller_spec.rb +29 -5
  31. data/spec/dummy/db/schema.rb +4 -1
  32. data/spec/dummy/db/test.sqlite3 +0 -0
  33. data/spec/dummy/solr/data/test/index/_5d.fdt +0 -0
  34. data/spec/dummy/solr/data/test/index/_5d.fdx +0 -0
  35. data/spec/dummy/solr/data/test/index/_5d.fnm +4 -0
  36. data/spec/dummy/solr/data/test/index/_5d.frq +1 -0
  37. data/spec/dummy/solr/data/test/index/_5d.nrm +1 -0
  38. data/spec/dummy/solr/data/test/index/_5d.prx +0 -0
  39. data/spec/dummy/solr/data/test/index/_5d.tii +0 -0
  40. data/spec/dummy/solr/data/test/index/_5d.tis +0 -0
  41. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  42. data/spec/dummy/solr/data/test/index/segments_at +0 -0
  43. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  44. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  45. data/spec/fixtures/message_templates.yml +14 -0
  46. data/spec/fixtures/reserves.yml +39 -38
  47. data/spec/models/reserve_spec.rb +25 -1
  48. metadata +65 -72
@@ -3,7 +3,11 @@ require 'spec_helper'
3
3
  describe ReservesController do
4
4
  fixtures :all
5
5
 
6
- describe "GET index" do
6
+ describe "GET index", :solr => true do
7
+ before do
8
+ Reserve.reindex
9
+ end
10
+
7
11
  describe "When logged in as Administrator" do
8
12
  login_fixture_admin
9
13
 
@@ -30,13 +34,13 @@ describe ReservesController do
30
34
  it "should get index feed without user_id" do
31
35
  get :index, :format => 'rss'
32
36
  response.should be_success
33
- assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation).page(1))
37
+ assigns(:reserves).collect(&:id).should eq Reserve.order('reserves.id DESC').includes(:manifestation).page(1).collect(&:id)
34
38
  end
35
39
 
36
40
  it "should get index csv without user_id" do
37
41
  get :index, :format => 'csv'
38
42
  response.should be_success
39
- assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation).page(1))
43
+ assigns(:reserves).should eq(Reserve.order('reserves.id DESC').includes(:manifestation))
40
44
  end
41
45
 
42
46
  it "should get index feed with user_id" do
@@ -48,7 +52,7 @@ describe ReservesController do
48
52
  it "should get index csv with user_id" do
49
53
  get :index, :user_id => users(:user1).username, :format => 'csv'
50
54
  response.should be_success
51
- assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation).page(1))
55
+ assigns(:reserves).should eq(users(:user1).reserves.order('reserves.id DESC').includes(:manifestation))
52
56
  end
53
57
 
54
58
  it "should get other user's index" do
@@ -519,7 +523,7 @@ describe ReservesController do
519
523
  before(:each) do
520
524
  @reserve = FactoryGirl.create(:reserve)
521
525
  @attrs = FactoryGirl.attributes_for(:reserve)
522
- @invalid_attrs = {:manifestation_id => ''}
526
+ @invalid_attrs = {:manifestation_id => 'invalid'}
523
527
  end
524
528
 
525
529
  describe "When logged in as Administrator" do
@@ -559,6 +563,26 @@ describe ReservesController do
559
563
  assigns(:reserve).should be_valid
560
564
  response.should redirect_to reserve_url(assigns(:reserve))
561
565
  end
566
+
567
+ it "should not update retained reservations if item_identifier is invalid" do
568
+ put :update, :id => 14, :reserve => {:item_identifier => 'invalid'}
569
+ assigns(:reserve).should_not be_valid
570
+ response.should be_success
571
+ end
572
+
573
+ it "should not update retained reservations if force_retaining is disabled" do
574
+ put :update, :id => 15, :reserve => {:item_identifier => '00021'}
575
+ assigns(:reserve).should_not be_valid
576
+ response.should be_success
577
+ reserves(:reserve_00014).state.should eq 'retained'
578
+ end
579
+
580
+ it "should update retained reservations if force_retaining is enabled" do
581
+ put :update, :id => 15, :reserve => {:item_identifier => '00021', :force_retaining => '1'}
582
+ assigns(:reserve).should be_valid
583
+ response.should redirect_to reserve_url(assigns(:reserve))
584
+ reserves(:reserve_00014).state.should eq 'postponed'
585
+ end
562
586
  end
563
587
 
564
588
  describe "When logged in as Librarian" do
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20121119153944) do
14
+ ActiveRecord::Schema.define(:version => 20130304015019) do
15
15
 
16
16
  create_table "baskets", :force => true do |t|
17
17
  t.integer "user_id"
@@ -713,11 +713,14 @@ ActiveRecord::Schema.define(:version => 20121119153944) do
713
713
  t.string "state"
714
714
  t.boolean "expiration_notice_to_patron", :default => false
715
715
  t.boolean "expiration_notice_to_library", :default => false
716
+ t.datetime "retained_at"
717
+ t.datetime "postponed_at"
716
718
  end
717
719
 
718
720
  add_index "reserves", ["item_id"], :name => "index_reserves_on_item_id"
719
721
  add_index "reserves", ["manifestation_id"], :name => "index_reserves_on_manifestation_id"
720
722
  add_index "reserves", ["request_status_type_id"], :name => "index_reserves_on_request_status_type_id"
723
+ add_index "reserves", ["state"], :name => "index_reserves_on_state"
721
724
  add_index "reserves", ["user_id"], :name => "index_reserves_on_user_id"
722
725
 
723
726
  create_table "roles", :force => true do |t|
Binary file
@@ -0,0 +1,4 @@
1
+ ���� idtype
2
+ class_name
3
+ username_s
4
+ title_textitem_identifier_text
@@ -0,0 +1 @@
1
+ 
@@ -0,0 +1 @@
1
+ NRM�|||||||||||||||xtuxuxuuxuxuttt||||||v|||||xxx
@@ -68,3 +68,17 @@ message_template_00010:
68
68
  body: Item received
69
69
  position: 10
70
70
  locale: ja
71
+ message_template_00011:
72
+ id: 11
73
+ status: reservation_postponed_for_patron
74
+ title: Reservation postponed
75
+ body: Reservation postponed
76
+ position: 11
77
+ locale: ja
78
+ message_template_00012:
79
+ id: 12
80
+ status: reservation_postponed_for_library
81
+ title: Reservation postponed
82
+ body: Reservation postponed
83
+ position: 12
84
+ locale: ja
@@ -1,4 +1,22 @@
1
1
  ---
2
+ reserve_00001:
3
+ updated_at: 2007-09-02 17:51:54.887849 +09:00
4
+ manifestation_id: 4
5
+ user_id: 1
6
+ request_status_type_id: 4
7
+ id: 1
8
+ created_at: 2007-09-01 14:14:52.356803 +09:00
9
+ expired_at: <%= 1.week.from_now %>
10
+ state: requested
11
+ reserve_00002:
12
+ updated_at: 2007-09-01 14:20:05.530854 +09:00
13
+ manifestation_id: 5
14
+ user_id: 2
15
+ request_status_type_id: 4
16
+ id: 2
17
+ created_at: 2007-09-01 14:20:05.530854 +09:00
18
+ expired_at: <%= 1.week.from_now %>
19
+ state: requested
2
20
  reserve_00003:
3
21
  updated_at: 2007-09-02 17:46:52.791614 +09:00
4
22
  manifestation_id: 6
@@ -26,114 +44,97 @@ reserve_00005:
26
44
  created_at: 2007-09-02 19:16:55.714812 +09:00
27
45
  expired_at: <%= 1.week.from_now %>
28
46
  state: requested
29
- reserve_00001:
30
- updated_at: 2007-09-02 17:51:54.887849 +09:00
31
- manifestation_id: 4
32
- user_id: 1
33
- request_status_type_id: 4
34
- id: 1
35
- created_at: 2007-09-01 14:14:52.356803 +09:00
36
- expired_at: <%= 1.week.from_now %>
37
- state: requested
38
- reserve_00002:
39
- updated_at: 2007-09-01 14:20:05.530854 +09:00
40
- manifestation_id: 5
41
- user_id: 2
42
- request_status_type_id: 4
43
- id: 2
44
- created_at: 2007-09-01 14:20:05.530854 +09:00
45
- expired_at: <%= 1.week.from_now %>
46
- state: requested
47
47
  reserve_00006:
48
- updated_at: 2007-09-01 14:20:05.530854 +09:00
48
+ updated_at: 2007-09-02 19:20:06.530854 +09:00
49
49
  manifestation_id: 4
50
50
  user_id: 2
51
51
  request_status_type_id: 4
52
52
  id: 6
53
- created_at: 2007-09-01 14:20:05.530854 +09:00
53
+ created_at: 2007-09-02 19:20:06.530854 +09:00
54
54
  expired_at: <%= 1.week.from_now %>
55
55
  state: requested
56
56
  reserve_00007:
57
- updated_at: 2007-09-01 14:20:05.530854 +09:00
57
+ updated_at: 2007-09-02 19:20:07.530854 +09:00
58
58
  manifestation_id: 2
59
59
  user_id: 4
60
60
  request_status_type_id: 4
61
61
  id: 7
62
- created_at: 2007-09-01 14:20:05.530854 +09:00
62
+ created_at: 2007-09-02 19:20:07.530854 +09:00
63
63
  expired_at: <%= 1.week.from_now %>
64
64
  state: requested
65
65
  reserve_00008:
66
- updated_at: 2007-09-02 17:46:52.791614 +09:00
66
+ updated_at: 2007-09-02 19:46:53.791614 +09:00
67
67
  manifestation_id: 6
68
68
  user_id: 3
69
69
  request_status_type_id: 3
70
70
  id: 8
71
- created_at: 2007-09-02 17:46:52.791614 +09:00
71
+ created_at: 2007-09-02 19:46:53.791614 +09:00
72
72
  expired_at: <%= 1.week.ago %>
73
73
  state: expired
74
74
  reserve_00009:
75
- updated_at: 2007-09-02 17:46:52.791614 +09:00
75
+ updated_at: 2007-09-02 19:46:54.791614 +09:00
76
76
  manifestation_id: 7
77
77
  user_id: 5
78
78
  request_status_type_id: 3
79
79
  id: 9
80
- created_at: 2007-09-02 17:46:52.791614 +09:00
80
+ created_at: 2007-09-02 19:46:54.791614 +09:00
81
81
  expired_at: <%= 1.day.ago %>
82
82
  state: requested
83
83
  reserve_00010:
84
- updated_at: 2007-09-02 17:46:52.791614 +09:00
84
+ updated_at: 2007-09-02 19:46:55.791614 +09:00
85
85
  manifestation_id: 8
86
86
  user_id: 5
87
87
  request_status_type_id: 3
88
88
  id: 10
89
- created_at: 2007-09-02 17:46:52.791614 +09:00
89
+ created_at: 2007-09-02 19:46:55.791614 +09:00
90
90
  expired_at: <%= 1.hour.ago %>
91
91
  checked_out_at: <%= 1.week.ago %>
92
92
  state: completed
93
93
  reserve_00011:
94
- updated_at: 2007-09-01 14:20:05.530854 +09:00
94
+ updated_at: 2007-09-03 14:20:05.530854 +09:00
95
95
  manifestation_id: 7
96
96
  user_id: 2
97
97
  request_status_type_id: 3
98
98
  id: 11
99
- created_at: 2007-09-01 14:20:05.530854 +09:00
99
+ created_at: 2007-09-03 14:20:05.530854 +09:00
100
100
  expired_at: <%= 1.day.ago %>
101
101
  state: expired
102
102
  reserve_00012:
103
- updated_at: 2007-09-01 14:20:05.530854 +09:00
103
+ updated_at: 2007-09-03 14:20:06.530854 +09:00
104
104
  manifestation_id: 8
105
105
  user_id: 2
106
106
  request_status_type_id: 4
107
107
  id: 12
108
- created_at: 2007-09-01 14:20:05.530854 +09:00
108
+ created_at: 2007-09-03 14:20:06.530854 +09:00
109
109
  expired_at: <%= 1.day.ago %>
110
110
  state: retained
111
111
  reserve_00013:
112
- updated_at: 2007-09-01 14:20:05.530854 +09:00
112
+ updated_at: 2007-09-03 14:20:07.530854 +09:00
113
113
  manifestation_id: 11
114
114
  user_id: 4
115
115
  request_status_type_id: 3
116
116
  id: 13
117
- created_at: 2007-09-01 14:20:05.530854 +09:00
117
+ created_at: 2007-09-03 14:20:07.530854 +09:00
118
118
  expired_at: <%= 1.day.ago %>
119
119
  state: requested
120
120
  reserve_00014:
121
- updated_at: 2007-09-01 14:20:05.530854 +09:00
121
+ updated_at: 2007-09-03 14:20:08.530854 +09:00
122
122
  manifestation_id: 11
123
123
  user_id: 4
124
124
  request_status_type_id: 3
125
125
  id: 14
126
- created_at: 2007-09-01 14:20:05.530854 +09:00
126
+ created_at: 2007-09-03 14:20:08.530854 +09:00
127
+ retained_at: <%= 1.hour.from_now %>
127
128
  expired_at: <%= 1.day.from_now %>
128
129
  state: retained
129
130
  item_id: 21
130
131
  reserve_00015:
131
- updated_at: 2007-09-01 14:20:05.530854 +09:00
132
+ updated_at: 2007-09-03 14:20:09.530854 +09:00
132
133
  manifestation_id: 11
133
134
  user_id: 4
134
135
  request_status_type_id: 3
135
136
  id: 15
136
- created_at: 2007-09-01 14:20:05.530854 +09:00
137
+ created_at: 2007-09-03 14:20:09.530854 +09:00
137
138
  expired_at: <%= 1.day.from_now %>
138
139
  state: requested
139
140
 
@@ -11,9 +11,10 @@ describe Reserve do
11
11
  it "should notify a next reservation" do
12
12
  old_count = Message.count
13
13
  reserve = reserves(:reserve_00014)
14
+ item = reserve.next_reservation.item
14
15
  reserve.sm_expire!
15
16
  reserve.state.should eq 'expired'
16
- reserve.next_reservation.item.should eq reserve.item
17
+ item.should eq reserve.item
17
18
  Message.count.should eq old_count + 2
18
19
  end
19
20
 
@@ -66,6 +67,29 @@ describe Reserve do
66
67
  it "should send accepted notification" do
67
68
  assert Reserve.expire.should be_true
68
69
  end
70
+
71
+ it "should nullify the first reservation's item_id if the second reservation is retained" do
72
+ reservation = reserves(:reserve_00015)
73
+ old_reservation = reserves(:reserve_00014)
74
+ old_count = MessageRequest.count
75
+
76
+ reservation.item = old_reservation.item
77
+ reservation.sm_retain!
78
+ old_reservation.reload
79
+ assert old_reservation.item.should be_nil
80
+ assert reservation.retained_at.should be_true
81
+ assert old_reservation.retained_at.should be_nil
82
+ assert old_reservation.postponed_at.should be_true
83
+ assert old_reservation.state.should eq 'postponed'
84
+ assert MessageRequest.count.should eq old_count + 4
85
+ end
86
+
87
+ it "should not be valid if item_identifier is invalid" do
88
+ reservation = reserves(:reserve_00014)
89
+ reservation.item_identifier = 'invalid'
90
+ reservation.save
91
+ assert reservation.valid?.should eq false
92
+ end
69
93
  end
70
94
 
71
95
  # == Schema Information