enju_circulation 0.1.0.pre41 → 0.1.0.pre42

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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/carrier_type_has_checkout_types_controller.rb +10 -4
  3. data/app/controllers/checked_items_controller.rb +8 -1
  4. data/app/controllers/checkins_controller.rb +6 -1
  5. data/app/controllers/checkout_types_controller.rb +8 -3
  6. data/app/controllers/checkouts_controller.rb +11 -4
  7. data/app/controllers/circulation_statuses_controller.rb +7 -2
  8. data/app/controllers/demands_controller.rb +85 -0
  9. data/app/controllers/item_has_use_restrictions_controller.rb +9 -3
  10. data/app/controllers/lending_policies_controller.rb +8 -1
  11. data/app/controllers/manifestation_checkout_stats_controller.rb +11 -2
  12. data/app/controllers/manifestation_reserve_stats_controller.rb +9 -2
  13. data/app/controllers/reserves_controller.rb +37 -9
  14. data/app/controllers/use_restrictions_controller.rb +7 -2
  15. data/app/controllers/user_checkout_stats_controller.rb +9 -2
  16. data/app/controllers/user_group_has_checkout_types_controller.rb +12 -2
  17. data/app/controllers/user_reserve_stats_controller.rb +9 -2
  18. data/app/helpers/items_helper.rb +17 -0
  19. data/app/models/carrier_type_has_checkout_type.rb +0 -1
  20. data/app/models/checked_item.rb +1 -2
  21. data/app/models/checkin.rb +0 -1
  22. data/app/models/checkout.rb +0 -1
  23. data/app/models/checkout_stat_has_manifestation.rb +2 -2
  24. data/app/models/checkout_stat_has_user.rb +2 -2
  25. data/app/models/checkout_type.rb +0 -2
  26. data/app/models/circulation_status.rb +0 -1
  27. data/app/models/demand.rb +5 -0
  28. data/app/models/enju_circulation/ability.rb +2 -0
  29. data/app/models/item_has_use_restriction.rb +0 -1
  30. data/app/models/lending_policy.rb +0 -2
  31. data/app/models/manifestation_checkout_stat.rb +5 -2
  32. data/app/models/manifestation_checkout_stat_transition.rb +1 -1
  33. data/app/models/manifestation_reserve_stat.rb +5 -2
  34. data/app/models/manifestation_reserve_stat_transition.rb +1 -1
  35. data/app/models/reserve.rb +24 -27
  36. data/app/models/reserve_stat_has_manifestation.rb +0 -3
  37. data/app/models/reserve_stat_has_user.rb +3 -3
  38. data/app/models/reserve_state_machine.rb +7 -7
  39. data/app/models/reserve_transition.rb +1 -1
  40. data/app/models/use_restriction.rb +0 -2
  41. data/app/models/user_checkout_stat.rb +5 -2
  42. data/app/models/user_checkout_stat_transition.rb +1 -1
  43. data/app/models/user_group_has_checkout_type.rb +0 -5
  44. data/app/models/user_reserve_stat.rb +5 -2
  45. data/app/models/user_reserve_stat_transition.rb +1 -1
  46. data/app/views/checkouts/_index.html.erb +1 -1
  47. data/app/views/checkouts/_index_item.html.erb +1 -1
  48. data/app/views/checkouts/_index_overdue.html.erb +1 -1
  49. data/app/views/checkouts/_index_user.html.erb +1 -1
  50. data/app/views/checkouts/_list.html.erb +2 -4
  51. data/app/views/demands/_form.html.erb +29 -0
  52. data/app/views/demands/edit.html.erb +6 -0
  53. data/app/views/demands/index.html.erb +31 -0
  54. data/app/views/demands/new.html.erb +5 -0
  55. data/app/views/demands/show.html.erb +19 -0
  56. data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +29 -28
  57. data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +29 -28
  58. data/config/locales/translation_en.yml +1 -0
  59. data/config/locales/translation_ja.yml +1 -0
  60. data/config/routes.rb +2 -0
  61. data/db/migrate/20150106001709_create_demands.rb +14 -0
  62. data/lib/enju_circulation/accept.rb +1 -0
  63. data/lib/enju_circulation/carrier_type.rb +15 -0
  64. data/lib/enju_circulation/item.rb +3 -2
  65. data/lib/enju_circulation/profile.rb +0 -3
  66. data/lib/enju_circulation/user.rb +7 -3
  67. data/lib/enju_circulation/user_group.rb +0 -1
  68. data/lib/enju_circulation/version.rb +1 -1
  69. data/lib/enju_circulation.rb +2 -0
  70. data/spec/controllers/checked_items_controller_spec.rb +18 -18
  71. data/spec/controllers/checkouts_controller_spec.rb +3 -3
  72. data/spec/dummy/app/models/user.rb +0 -1
  73. data/spec/dummy/bin/bundle +3 -0
  74. data/spec/dummy/bin/rails +4 -0
  75. data/spec/dummy/bin/rake +4 -0
  76. data/spec/dummy/bin/setup +29 -0
  77. data/spec/dummy/config/application.rb +1 -1
  78. data/spec/dummy/config/environments/development.rb +2 -2
  79. data/spec/dummy/config/routes.rb +2 -0
  80. data/spec/dummy/db/migrate/{20111201155456_devise_create_users.rb → 002_devise_create_users.rb} +6 -2
  81. data/spec/dummy/db/migrate/041_create_roles.rb +13 -0
  82. data/spec/dummy/db/migrate/059_create_libraries.rb +1 -5
  83. data/spec/dummy/db/migrate/069_create_shelves.rb +1 -5
  84. data/spec/dummy/db/migrate/077_create_user_groups.rb +3 -7
  85. data/spec/dummy/db/migrate/080_create_library_groups.rb +2 -10
  86. data/spec/dummy/db/migrate/113_create_events.rb +2 -2
  87. data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
  88. data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -5
  89. data/spec/dummy/db/migrate/131_create_request_types.rb +1 -5
  90. data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
  91. data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
  92. data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
  93. data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +25 -0
  94. data/spec/dummy/db/migrate/20090519203307_create_participates.rb +17 -0
  95. data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
  96. data/spec/dummy/db/migrate/{20111201163718_create_user_has_roles.rb → 20100606065209_create_user_has_roles.rb} +2 -0
  97. data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +15 -0
  98. data/spec/dummy/db/migrate/{20111201121844_create_roles.rb → 20120129014038_create_budget_types.rb} +2 -2
  99. data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
  100. data/spec/dummy/db/migrate/20120413051535_add_event_import_fingerprint_to_event_import_file.rb +5 -0
  101. data/spec/dummy/db/migrate/20120413170734_add_error_message_to_event_import_file.rb +5 -0
  102. data/spec/dummy/db/migrate/20120415060342_rename_event_import_file_imported_at_to_executed_at.rb +9 -0
  103. data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
  104. data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
  105. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +18 -0
  106. data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +11 -0
  107. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +1 -1
  108. data/spec/dummy/db/migrate/20140523171309_create_event_import_file_transitions.rb +18 -0
  109. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +18 -0
  110. data/spec/dummy/db/migrate/20140628071719_add_user_encoding_to_event_import_file.rb +5 -0
  111. data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +5 -0
  112. data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +11 -0
  113. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +18 -0
  114. data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
  115. data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
  116. data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +5 -0
  117. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +11 -0
  118. data/spec/dummy/db/migrate/20140812153137_create_event_export_file_transitions.rb +18 -0
  119. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +5 -0
  120. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
  121. data/spec/dummy/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
  122. data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
  123. data/spec/dummy/db/schema.rb +246 -58
  124. data/spec/fixtures/checkouts.yml +1 -1
  125. data/spec/fixtures/demands.yml +11 -0
  126. data/spec/fixtures/events.yml +13 -39
  127. data/spec/fixtures/library_groups.yml +0 -2
  128. metadata +105 -43
  129. data/db/migrate/20111217234412_add_save_checkout_history_to_user.rb +0 -5
  130. data/db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb +0 -6
  131. data/spec/dummy/db/migrate/20090719201843_create_extents.rb +0 -12
  132. data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +0 -9
  133. data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +0 -9
  134. data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +0 -9
  135. data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +0 -9
  136. data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +0 -13
  137. data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +0 -11
  138. data/spec/dummy/db/migrate/20120224094141_create_delayed_jobs.rb +0 -22
  139. data/spec/dummy/script/delayed_job +0 -5
  140. data/spec/dummy/script/rails +0 -6
@@ -2,7 +2,8 @@
2
2
  <tr>
3
3
  <th>
4
4
  <%= t('activerecord.models.library') %>
5
- -
5
+ </th>
6
+ <th>
6
7
  <%= t('activerecord.models.shelf') %>
7
8
  </th>
8
9
  <% CarrierType.order(:position).each do |carrier_type| %>
@@ -10,39 +11,39 @@
10
11
  <% end %>
11
12
  <th><%= t('page.total') %></th>
12
13
  </tr>
13
- <% (Shelf.order(:position) << nil).each do |shelf| %>
14
- <tr>
15
- <td>
16
- <% if shelf %>
17
- <strong>
18
- <%= shelf.library.display_name.localize %>
19
- -
20
- <%= shelf.display_name.localize %>
21
- </strong>
22
- <% else %>
23
- <strong><%= t('page.unknown') %></strong>
24
- <% end %>
25
- </td>
26
- <% CarrierType.order(:position).each do |carrier_type| %>
14
+ <% Library.order(:position).each do |library| %>
15
+ <% library.shelves.order(:position).each do |shelf| %>
16
+ <tr>
17
+ <td>
18
+ <%= library.display_name.localize %>
19
+ </td>
27
20
  <td>
28
- <% if shelf %>
21
+ <%= shelf.display_name.localize %>
22
+ </td>
23
+ <% CarrierType.order(:position).each do |carrier_type| %>
24
+ <td>
29
25
  <%= @carrier_type_results[[shelf.id, carrier_type.id]] %>
30
- <% else %>
31
- <%= @carrier_type_results[[nil, carrier_type.id]] %>
32
- <% end %>
26
+ </td>
27
+ <% end %>
28
+ <td>
29
+ <%= @carrier_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
33
30
  </td>
34
- <% end %>
31
+ </tr>
32
+ <% end %>
33
+ <% end %>
34
+ <tr>
35
+ <td colspan="2"><%= t('page.unknown') %></td>
36
+ <% CarrierType.order(:position).each do |carrier_type| %>
35
37
  <td>
36
- <% if shelf %>
37
- <%= @carrier_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
38
- <% else %>
39
- <%= @carrier_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
40
- <% end %>
38
+ <%= @carrier_type_results[[nil, carrier_type.id]] %>
41
39
  </td>
42
- </tr>
43
- <% end %>
40
+ <% end %>
41
+ <td>
42
+ <%= @carrier_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
43
+ </td>
44
+ </tr>
44
45
  <tr>
45
- <td><strong><%= t('page.total') %></strong></td>
46
+ <th colspan="2"><%= t('page.total') %></th>
46
47
  <% CarrierType.order(:position).each do |carrier_type| %>
47
48
  <td>
48
49
  <%= @carrier_type_results.select{|r| r[1] == carrier_type.id}.sum{|k, v| v} %>
@@ -2,7 +2,8 @@
2
2
  <tr>
3
3
  <th>
4
4
  <%= t('activerecord.models.library') %>
5
- -
5
+ </th>
6
+ <th>
6
7
  <%= t('activerecord.models.shelf') %>
7
8
  </th>
8
9
  <% CheckoutType.order(:position).each do |checkout_type| %>
@@ -10,39 +11,39 @@
10
11
  <% end %>
11
12
  <th><%= t('page.total') %></th>
12
13
  </tr>
13
- <% (Shelf.order(:position) << nil).each do |shelf| %>
14
- <tr>
15
- <td>
16
- <% if shelf %>
17
- <strong>
18
- <%= shelf.library.display_name.localize %>
19
- -
20
- <%= shelf.display_name.localize %>
21
- </strong>
22
- <% else %>
23
- <strong><%= t('page.unknown') %></strong>
24
- <% end %>
25
- </td>
26
- <% CheckoutType.order(:position).each do |checkout_type| %>
14
+ <% Library.order(:position).each do |library| %>
15
+ <% library.shelves.order(:position).each do |shelf| %>
16
+ <tr>
17
+ <td>
18
+ <%= library.display_name.localize %>
19
+ </td>
27
20
  <td>
28
- <% if shelf %>
21
+ <%= shelf.display_name.localize %>
22
+ </td>
23
+ <% CheckoutType.order(:position).each do |checkout_type| %>
24
+ <td>
29
25
  <%= @checkout_type_results[[shelf.id, checkout_type.id]] %>
30
- <% else %>
31
- <%= @checkout_type_results[[nil, checkout_type.id]] %>
32
- <% end %>
26
+ </td>
27
+ <% end %>
28
+ <td>
29
+ <%= @checkout_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
33
30
  </td>
34
- <% end %>
31
+ </tr>
32
+ <% end %>
33
+ <% end %>
34
+ <tr>
35
+ <td colspan="2"><%= t('page.unknown') %></th>
36
+ <% CheckoutType.order(:position).each do |checkout_type| %>
35
37
  <td>
36
- <% if shelf %>
37
- <%= @checkout_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
38
- <% else %>
39
- <%= @checkout_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
40
- <% end %>
38
+ <%= @checkout_type_results[[nil, checkout_type.id]] %>
41
39
  </td>
42
- </tr>
43
- <% end %>
40
+ <% end %>
41
+ <td>
42
+ <%= @checkout_type_results.select{|r| r[0].nil?}.sum{|k, v| v} %>
43
+ </td>
44
+ </tr>
44
45
  <tr>
45
- <td><strong><%= t('page.total') %></strong></td>
46
+ <th colspan="2"><%= t('page.total') %></th>
46
47
  <% CheckoutType.order(:position).each do |checkout_type| %>
47
48
  <td>
48
49
  <%= @checkout_type_results.select{|r| r[1] == checkout_type.id}.sum{|k, v| v} %>
@@ -23,6 +23,7 @@ en:
23
23
  reserve_stat_has_user: Reserve stat has user
24
24
  user_group_has_checkout_type: User group has checkout type
25
25
  carrier_type_has_checkout_type: Carrier type and checkout type
26
+ demand: Demand
26
27
 
27
28
  attributes:
28
29
  basket:
@@ -21,6 +21,7 @@ ja:
21
21
  reserve_stat_has_user: 利用者別予約統計
22
22
  user_group_has_checkout_type: 利用者グループと貸出区分の関係
23
23
  carrier_type_has_checkout_type: 資料の形態と貸出区分の関係
24
+ demand: 督促
24
25
 
25
26
  attributes:
26
27
  basket:
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  Rails.application.routes.draw do
2
+ resources :demands
3
+
2
4
  get "/users/:user_id/checkouts" => redirect("/checkouts?user_id=%{user_id}")
3
5
  get "/users/:user_id/reserves" => redirect("/reserves?user_id=%{user_id}")
4
6
  get "/users/:user_id/baskets" => redirect("/baskets?user_id=%{user_id}")
@@ -0,0 +1,14 @@
1
+ class CreateDemands < ActiveRecord::Migration
2
+ def change
3
+ create_table :demands do |t|
4
+ t.integer :user_id
5
+ t.integer :item_id
6
+ t.integer :message_id
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :demands, :user_id
11
+ add_index :demands, :item_id
12
+ add_index :demands, :message_id
13
+ end
14
+ end
@@ -7,6 +7,7 @@ module EnjuCirculation
7
7
  module ClassMethods
8
8
  def enju_circulation_accept_model
9
9
  include InstanceMethods
10
+ before_save :accept!, on: :create
10
11
  end
11
12
  end
12
13
 
@@ -0,0 +1,15 @@
1
+ module EnjuCirculation
2
+ module EnjuCarrierType
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def enju_circulation_carrier_type_model
9
+ has_many :carrier_type_has_checkout_types, dependent: :destroy
10
+ has_many :checkout_types, through: :carrier_type_has_checkout_types
11
+ accepts_nested_attributes_for :carrier_type_has_checkout_types, allow_destroy: true, reject_if: :all_blank
12
+ end
13
+ end
14
+ end
15
+ end
@@ -44,9 +44,10 @@ module EnjuCirculation
44
44
  validates_associated :circulation_status, :checkout_type
45
45
  validates_presence_of :circulation_status, :checkout_type
46
46
  searchable do
47
- integer :circulation_status_id
47
+ string :circulation_status do
48
+ circulation_status.name
49
+ end
48
50
  end
49
- attr_accessible :item_has_use_restriction_attributes
50
51
  accepts_nested_attributes_for :item_has_use_restriction
51
52
 
52
53
  after_create :create_lending_policy
@@ -7,9 +7,6 @@ module EnjuCirculation
7
7
  module ClassMethods
8
8
  def enju_circulation_profile_model
9
9
  include InstanceMethods
10
- attr_accessible :save_checkout_history, :checkout_icalendar_token
11
- attr_accessible :save_checkout_history, :checkout_icalendar_token,
12
- as: :admin
13
10
  end
14
11
  end
15
12
 
@@ -7,9 +7,9 @@ module EnjuCirculation
7
7
  module ClassMethods
8
8
  def enju_circulation_user_model
9
9
  include InstanceMethods
10
- attr_accessible :save_checkout_history, :checkout_icalendar_token
11
- attr_accessible :save_checkout_history, :checkout_icalendar_token,
12
- :as => :admin
10
+ #attr_accessible :save_checkout_history, :checkout_icalendar_token
11
+ #attr_accessible :save_checkout_history, :checkout_icalendar_token,
12
+ # :as => :admin
13
13
 
14
14
  has_many :checkouts, :dependent => :nullify
15
15
  has_many :reserves, :dependent => :destroy
@@ -60,6 +60,10 @@ module EnjuCirculation
60
60
  return true if profile.user_group.user_group_has_checkout_types.available_for_carrier_type(manifestation.carrier_type).where(:user_group_id => profile.user_group.id).collect(&:reservation_limit).max.to_i <= reserves.waiting.size
61
61
  false
62
62
  end
63
+
64
+ def has_overdue?(day = 1)
65
+ true if checkouts.where(checkin_id: nil).where(Checkout.arel_table[:due_date].lt day.days.ago).count >= 1
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -9,7 +9,6 @@ module EnjuCirculation
9
9
  has_many :user_group_has_checkout_types, dependent: :destroy
10
10
  has_many :checkout_types, through: :user_group_has_checkout_types
11
11
  has_many :lending_policies
12
- attr_accessible :user_group_has_checkout_types_attributes
13
12
  accepts_nested_attributes_for :user_group_has_checkout_types, :allow_destroy => true, :reject_if => :all_blank
14
13
 
15
14
  validates_numericality_of :number_of_day_to_notify_due_date,
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.1.0.pre41"
2
+ VERSION = "0.1.0.pre42"
3
3
  end
@@ -6,6 +6,7 @@ require "enju_circulation/user_group"
6
6
  require "enju_circulation/profile"
7
7
  require "enju_circulation/accept"
8
8
  require "enju_circulation/basket"
9
+ require "enju_circulation/carrier_type"
9
10
  require "enju_circulation/controller"
10
11
  require "enju_circulation/helper"
11
12
 
@@ -20,4 +21,5 @@ ActiveRecord::Base.send :include, EnjuCirculation::EnjuUserGroup
20
21
  ActiveRecord::Base.send :include, EnjuCirculation::EnjuProfile
21
22
  ActiveRecord::Base.send :include, EnjuCirculation::EnjuAccept
22
23
  ActiveRecord::Base.send :include, EnjuCirculation::EnjuBasket
24
+ ActiveRecord::Base.send :include, EnjuCirculation::EnjuCarrierType
23
25
  ActionView::Base.send :include, EnjuCirculation::ManifestationsHelper
@@ -197,8 +197,8 @@ describe CheckedItemsController do
197
197
 
198
198
  describe "POST create" do
199
199
  before(:each) do
200
- @attrs = {:item_identifier => '00011'}
201
- @invalid_attrs = {:item_identifier => 'invalid'}
200
+ @attrs = {item_identifier: '00011'}
201
+ @invalid_attrs = {item_identifier: 'invalid'}
202
202
  end
203
203
 
204
204
  describe "When logged in as Administrator" do
@@ -206,7 +206,7 @@ describe CheckedItemsController do
206
206
 
207
207
  describe "When the item is missing" do
208
208
  it "assigns a newly created checked_item as @checked_item" do
209
- post :create, :checked_item => {:item_identifier => 'not found'} , :basket_id => 1
209
+ post :create, :checked_item => {item_identifier: 'not found'} , :basket_id => 1
210
210
  assigns(:checked_item).should_not be_valid
211
211
  assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.item_not_found')).should be_truthy
212
212
  end
@@ -214,7 +214,7 @@ describe CheckedItemsController do
214
214
 
215
215
  describe "When the item is not for checkout" do
216
216
  it "assigns a newly created checked_item as @checked_item" do
217
- post :create, :checked_item => {:item_identifier => '00017'} , :basket_id => 1
217
+ post :create, :checked_item => {item_identifier: '00017'} , :basket_id => 1
218
218
  assigns(:checked_item).should_not be_valid
219
219
  assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.not_available_for_checkout')).should be_truthy
220
220
  end
@@ -222,7 +222,7 @@ describe CheckedItemsController do
222
222
 
223
223
  describe "When the item is already checked out" do
224
224
  it "assigns a newly created checked_item as @checked_item" do
225
- post :create, :checked_item => {:item_identifier => '00013'} , :basket_id => 8
225
+ post :create, :checked_item => {item_identifier: '00013'} , :basket_id => 8
226
226
  assigns(:checked_item).should_not be_valid
227
227
  assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.already_checked_out')).should be_truthy
228
228
  end
@@ -231,7 +231,7 @@ describe CheckedItemsController do
231
231
  describe "When the item is reserved" do
232
232
  it "assigns a newly created checked_item as @checked_item" do
233
233
  old_count = items(:item_00021).manifestation.reserves.waiting.count
234
- post :create, :checked_item => {:item_identifier => '00021'} , :basket_id => 11
234
+ post :create, :checked_item => {item_identifier: '00021'} , :basket_id => 11
235
235
  assigns(:checked_item).should be_valid
236
236
  assigns(:checked_item).item.manifestation.reserves.waiting.count.should eq old_count - 1
237
237
  assigns(:checked_item).librarian.should eq users(:admin)
@@ -239,12 +239,12 @@ describe CheckedItemsController do
239
239
  end
240
240
 
241
241
  it "should not create checked_item without basket_id" do
242
- post :create, :checked_item => {:item_identifier => '00004'}
242
+ post :create, :checked_item => {item_identifier: '00004'}
243
243
  response.should be_forbidden
244
244
  end
245
245
 
246
246
  it "should not create checked_item without item_id" do
247
- post :create, :checked_item => { }, :basket_id => 1
247
+ post :create, :checked_item => {item_identifier: '00004' }, :basket_id => 1
248
248
  response.should be_success
249
249
  end
250
250
  end
@@ -259,41 +259,41 @@ describe CheckedItemsController do
259
259
  end
260
260
 
261
261
  it "should create checked_item with item_identifier" do
262
- post :create, :checked_item => {:item_identifier => '00011'}, :basket_id => 3
262
+ post :create, :checked_item => {item_identifier: '00011'}, :basket_id => 3
263
263
  assigns(:checked_item).should be_truthy
264
264
  assigns(:checked_item).due_date.should_not be_nil
265
265
  response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
266
266
  end
267
267
 
268
268
  it "should override due_date" do
269
- post :create, :checked_item => {:item_identifier => '00011', :due_date_string => 1.year.from_now.strftime('%Y-%m-%d')}, :basket_id => 3
269
+ post :create, :checked_item => {item_identifier: '00011', :due_date_string => 1.year.from_now.strftime('%Y-%m-%d')}, :basket_id => 3
270
270
  assigns(:checked_item).should be_truthy
271
271
  assigns(:checked_item).due_date.should eq 1.year.from_now.end_of_day
272
272
  response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
273
273
  end
274
274
 
275
275
  it "should not create checked_item with an invalid due_date" do
276
- post :create, :checked_item => {:item_identifier => '00011', :due_date_string => "invalid"}, :basket_id => 3
276
+ post :create, :checked_item => {item_identifier: '00011', :due_date_string => "invalid"}, :basket_id => 3
277
277
  assigns(:checked_item).should_not be_valid
278
278
  assigns(:checked_item).due_date.should be_nil
279
279
  response.should be_success
280
280
  end
281
281
 
282
282
  it "should not create checked_item if excessed checkout_limit" do
283
- post :create, :checked_item => {:item_identifier => '00011'}, :basket_id => 1
283
+ post :create, :checked_item => {item_identifier: '00011'}, :basket_id => 1
284
284
  response.should be_success
285
285
  assigns(:checked_item).errors["base"].include?(I18n.t('activerecord.errors.messages.checked_item.excessed_checkout_limit')).should be_truthy
286
286
  end
287
287
 
288
288
  it "should show message when the item includes supplements" do
289
- post :create, :checked_item => {:item_identifier => '00006'}, :basket_id => 3
289
+ post :create, :checked_item => {item_identifier: '00006'}, :basket_id => 3
290
290
  assigns(:checked_item).due_date.should_not be_nil
291
291
  response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
292
292
  flash[:message].index(I18n.t('item.this_item_include_supplement')).should be_truthy
293
293
  end
294
294
 
295
295
  it "should create checked_item when ignore_restriction is checked" do
296
- post :create, :checked_item => {:item_identifier => '00011', :ignore_restriction => "1"}, :basket_id => 2
296
+ post :create, :checked_item => {item_identifier: '00011', :ignore_restriction => "1"}, :basket_id => 2
297
297
  assigns(:checked_item).due_date.should_not be_nil
298
298
  response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
299
299
  end
@@ -303,14 +303,14 @@ describe CheckedItemsController do
303
303
  login_fixture_user
304
304
 
305
305
  it "should not create checked_item" do
306
- post :create, :checked_item => {:item_identifier => '00004'}, :basket_id => 3
306
+ post :create, :checked_item => {item_identifier: '00004'}, :basket_id => 3
307
307
  response.should be_forbidden
308
308
  end
309
309
  end
310
310
 
311
311
  describe "When not logged in as" do
312
312
  it "should not create checked_item" do
313
- post :create, :checked_item => {:item_identifier => '00004'}, :basket_id => 1
313
+ post :create, :checked_item => {item_identifier: '00004'}, :basket_id => 1
314
314
  response.should redirect_to new_user_session_url
315
315
  end
316
316
  end
@@ -318,8 +318,8 @@ describe CheckedItemsController do
318
318
 
319
319
  describe "PUT update" do
320
320
  before(:each) do
321
- @attrs = {:item_identifier => '00011'}
322
- @invalid_attrs = {:item_identifier => 'invalid'}
321
+ @attrs = {item_identifier: '00011'}
322
+ @invalid_attrs = {item_identifier: 'invalid'}
323
323
  end
324
324
 
325
325
  describe "When logged in as Administrator" do
@@ -17,7 +17,7 @@ describe CheckoutsController do
17
17
 
18
18
  it "assigns all checkouts as @checkouts" do
19
19
  get :index
20
- assigns(:checkouts).should eq Checkout.not_returned.order('checkouts.id DESC').page(1)
20
+ assigns(:checkouts).should eq Checkout.order('checkouts.created_at DESC').page(1)
21
21
  end
22
22
 
23
23
  it "should get other user's index" do
@@ -81,7 +81,7 @@ describe CheckoutsController do
81
81
 
82
82
  it "assigns all checkouts as @checkouts" do
83
83
  get :index
84
- assigns(:checkouts).should eq(users(:user1).checkouts.not_returned.order('checkouts.id DESC').page(1))
84
+ assigns(:checkouts).should eq(users(:user1).checkouts.order('checkouts.created_at DESC').page(1))
85
85
  response.should be_success
86
86
  end
87
87
 
@@ -95,7 +95,7 @@ describe CheckoutsController do
95
95
  it "should get my index feed" do
96
96
  get :index, :format => 'rss'
97
97
  response.should be_success
98
- assigns(:checkouts).should eq(users(:user1).checkouts.not_returned.order('checkouts.id DESC').page(1))
98
+ assigns(:checkouts).should eq(users(:user1).checkouts.order('checkouts.created_at DESC').page(1))
99
99
  end
100
100
 
101
101
  it "should get my index with user_id" do
@@ -5,7 +5,6 @@ class User < ActiveRecord::Base
5
5
  :recoverable, :rememberable, :trackable, :validatable
6
6
 
7
7
  # Setup accessible (or protected) attributes for your model
8
- attr_accessible :email, :password, :password_confirmation, :remember_me
9
8
 
10
9
  enju_leaf_user_model
11
10
  enju_circulation_user_model
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -44,7 +44,7 @@ module Dummy
44
44
  # This will create an empty whitelist of attributes available for mass-assignment for all models
45
45
  # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
46
46
  # parameters by using an attr_accessible or attr_protected declaration.
47
- config.active_record.whitelist_attributes = true
47
+ #config.active_record.whitelist_attributes = true
48
48
 
49
49
  # Enable the asset pipeline
50
50
  config.assets.enabled = true
@@ -23,11 +23,11 @@ Dummy::Application.configure do
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
25
  # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
26
+ #config.active_record.mass_assignment_sanitizer = :strict
27
27
 
28
28
  # Log the query plan for queries taking more than this (works
29
29
  # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
30
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
31
31
 
32
32
  # Do not compress assets
33
33
  config.assets.compress = false
@@ -1,4 +1,6 @@
1
1
  Dummy::Application.routes.draw do
2
+ resources :demands
3
+
2
4
  devise_for :users
3
5
 
4
6
  # The priority is based upon order of creation:
@@ -13,7 +13,7 @@ class DeviseCreateUsers < ActiveRecord::Migration
13
13
  t.datetime :remember_created_at
14
14
 
15
15
  ## Trackable
16
- t.integer :sign_in_count, :default => 0, :null => false
16
+ t.integer :sign_in_count, :default => 0
17
17
  t.datetime :current_sign_in_at
18
18
  t.datetime :last_sign_in_at
19
19
  t.string :current_sign_in_ip
@@ -26,10 +26,13 @@ class DeviseCreateUsers < ActiveRecord::Migration
26
26
  # t.string :unconfirmed_email # Only if using reconfirmable
27
27
 
28
28
  ## Lockable
29
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
29
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
30
30
  # t.string :unlock_token # Only if unlock strategy is :email or :both
31
31
  # t.datetime :locked_at
32
32
 
33
+ ## Token authenticatable
34
+ # t.string :authentication_token
35
+
33
36
 
34
37
  t.timestamps
35
38
  end
@@ -38,5 +41,6 @@ class DeviseCreateUsers < ActiveRecord::Migration
38
41
  add_index :users, :reset_password_token, :unique => true
39
42
  # add_index :users, :confirmation_token, :unique => true
40
43
  # add_index :users, :unlock_token, :unique => true
44
+ # add_index :users, :authentication_token, :unique => true
41
45
  end
42
46
  end
@@ -0,0 +1,13 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table "roles" do |t|
4
+ t.column :name, :string, :null => false
5
+ t.column :display_name, :string
6
+ t.column :note, :text
7
+ t.column :created_at, :datetime
8
+ t.column :updated_at, :datetime
9
+ t.integer :score, :default => 0, :null => false
10
+ t.integer :position
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  class CreateLibraries < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  create_table :libraries do |t|
4
4
  t.string :name, :null => false
5
5
  t.text :display_name
@@ -25,8 +25,4 @@ class CreateLibraries < ActiveRecord::Migration
25
25
  add_index :libraries, :library_group_id
26
26
  add_index :libraries, :name, :unique => true
27
27
  end
28
-
29
- def self.down
30
- drop_table :libraries
31
- end
32
28
  end
@@ -1,5 +1,5 @@
1
1
  class CreateShelves < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  create_table :shelves do |t|
4
4
  t.string :name, :null => false
5
5
  t.text :display_name
@@ -12,8 +12,4 @@ class CreateShelves < ActiveRecord::Migration
12
12
  end
13
13
  add_index :shelves, :library_id
14
14
  end
15
-
16
- def self.down
17
- drop_table :shelves
18
- end
19
15
  end