enju_circulation 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/reserves_controller.rb +6 -0
- data/app/controllers/user_group_has_checkout_types_controller.rb +1 -1
- data/app/jobs/manifestation_checkout_stat_job.rb +1 -1
- data/app/jobs/manifestation_reserve_stat_job.rb +1 -1
- data/app/jobs/user_checkout_stat_job.rb +1 -1
- data/app/jobs/user_reserve_stat_job.rb +1 -1
- data/app/models/carrier_type_has_checkout_type.rb +1 -1
- data/app/models/checked_item.rb +2 -2
- data/app/models/checkin.rb +1 -1
- data/app/models/checkout.rb +1 -1
- data/app/models/checkout_stat_has_manifestation.rb +1 -1
- data/app/models/checkout_stat_has_user.rb +1 -1
- data/app/models/checkout_type.rb +1 -1
- data/app/models/circulation_status.rb +1 -1
- data/app/models/demand.rb +1 -1
- data/app/models/item_has_use_restriction.rb +1 -1
- data/app/models/lending_policy.rb +1 -1
- data/app/models/manifestation_checkout_stat.rb +1 -1
- data/app/models/manifestation_checkout_stat_transition.rb +1 -1
- data/app/models/manifestation_reserve_stat.rb +1 -1
- data/app/models/manifestation_reserve_stat_transition.rb +1 -1
- data/app/models/reserve.rb +1 -1
- data/app/models/reserve_stat_has_manifestation.rb +1 -1
- data/app/models/reserve_stat_has_user.rb +1 -1
- data/app/models/reserve_transition.rb +1 -1
- data/app/models/use_restriction.rb +1 -1
- data/app/models/user_checkout_stat.rb +1 -1
- data/app/models/user_checkout_stat_transition.rb +1 -1
- data/app/models/user_group_has_checkout_type.rb +1 -1
- data/app/models/user_reserve_stat.rb +1 -1
- data/app/models/user_reserve_stat_transition.rb +1 -1
- data/app/views/checkouts/_index_overdue.html.erb +4 -4
- data/app/views/checkouts/_list.html.erb +2 -4
- data/app/views/checkouts/edit.html.erb +9 -0
- data/app/views/reserves/_state_facet.html.erb +2 -2
- data/app/views/reserves/index.html.erb +10 -10
- data/app/views/reserves/index.txt.ruby +22 -0
- data/app/views/user_group_has_checkout_types/edit.html.erb +2 -2
- data/app/views/user_group_has_checkout_types/new.html.erb +2 -2
- data/app/views/user_group_has_checkout_types/show.html.erb +2 -2
- data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +2 -2
- data/config/locales/translation_en.yml +1 -1
- data/config/locales/translation_ja.yml +1 -1
- data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +2 -2
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/generators/enju_circulation/setup/templates/db/fixtures/circulation_statuses.yml +1 -1
- data/spec/concerns/enju_accept_spec.rb +11 -11
- data/spec/controllers/items_controller_spec.rb +62 -0
- data/spec/dummy/app/assets/images/icons/book.png +0 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/user.rb +2 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/db/migrate/005_create_manifestations.rb +3 -3
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +5 -4
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -0
- data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +1 -0
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +1 -0
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +1 -0
- data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
- data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +1 -1
- data/spec/dummy/db/schema.rb +6 -4
- data/spec/dummy/private/system/carrier_types/attachments/000/000/001/original/book.png +0 -0
- data/spec/dummy/private/system/carrier_types/attachments/000/000/001/thumb/book.png +0 -0
- data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-29715-1ca6cab.txt +150 -0
- data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-30258-1menuu9.txt +150 -0
- data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-30590-jfx9wk.txt +150 -0
- data/spec/dummy/private/system/resource_export_files/resource_exports/000/000/001/original/resource_export_file_20190804-31207-1f5iuud.txt +148 -0
- data/spec/factories/accept.rb +1 -1
- data/spec/factories/item.rb +3 -3
- data/spec/factories/profile.rb +1 -1
- data/spec/fixtures/accepts.yml +9 -0
- data/spec/fixtures/carrier_types.yml +27 -24
- data/spec/fixtures/circulation_statuses.yml +1 -1
- data/spec/fixtures/items.yml +11 -0
- data/spec/helpers/items_helper_spec.rb +1 -1
- data/spec/models/item_spec.rb +47 -0
- data/spec/models/manifestation_spec.rb +38 -0
- data/spec/models/resource_export_file_spec.rb +42 -0
- data/spec/policies/manifestation_policy_spec.rb +16 -0
- data/spec/rails_helper.rb +1 -0
- data/spec/system/checkouts_spec.rb +33 -0
- data/spec/system/reserves_spec.rb +15 -0
- data/spec/views/checkouts/edit.html.erb_spec.rb +1 -1
- data/spec/views/items/index.html.erb_spec.rb +35 -0
- data/spec/views/manifestations/show.html.erb_spec.rb +24 -0
- data/spec/views/reserves/index.html.erb_spec.rb +1 -1
- metadata +412 -356
- data/app/views/reserves/index.txt.erb +0 -4
- data/spec/support/resque.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0b9972d6bbdc83978dfe89ade80938501efaf2b3ebb5276b8c8735bb72dfc1
|
4
|
+
data.tar.gz: '094bb7364db3cd6210ae9f3c6746ba6111d85e700c790ae442b186a63d6299ff'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f809ad8fc660f27838d8fc0b39fc7a02ada4bca1a3a6b80a6f394dd38993d0918900733722692dac2537c0e15eb0275912979d795e8669212a9cbb6a7eea95
|
7
|
+
data.tar.gz: d2fd2702f0df03077ed417236d32c5b42c446c6c0c09545af9a61e9b9bb400aa111efd6b57d45db34b9a77757ddac7791f362b140bcb3f71cdca744b564692fc
|
@@ -296,4 +296,10 @@ class ReservesController < ApplicationController
|
|
296
296
|
def prepare_options
|
297
297
|
@libraries = Library.real.order(:position)
|
298
298
|
end
|
299
|
+
|
300
|
+
def filtered_params
|
301
|
+
params.permit([:user_id, :reserved_from, :reserved_until, :query, :sort_by, :state])
|
302
|
+
end
|
303
|
+
|
304
|
+
helper_method :filtered_params
|
299
305
|
end
|
@@ -101,7 +101,7 @@ class UserGroupHasCheckoutTypesController < ApplicationController
|
|
101
101
|
:user_group_id, :checkout_type_id,
|
102
102
|
:checkout_limit, :checkout_period, :checkout_renewal_limit,
|
103
103
|
:reservation_limit, :reservation_expired_period,
|
104
|
-
:
|
104
|
+
:set_due_date_after_closing_day, :fixed_due_date, :note, :position,
|
105
105
|
:user_group, :checkout_type
|
106
106
|
)
|
107
107
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CarrierTypeHasCheckoutType <
|
1
|
+
class CarrierTypeHasCheckoutType < ApplicationRecord
|
2
2
|
scope :available_for_carrier_type, lambda {|carrier_type| includes(:carrier_type).where('carrier_types.name = ?', carrier_type.name)}
|
3
3
|
scope :available_for_user_group, lambda {|user_group| includes(checkout_type: :user_groups).where('user_groups.name = ?', user_group.name)}
|
4
4
|
|
data/app/models/checked_item.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class CheckedItem <
|
1
|
+
class CheckedItem < ApplicationRecord
|
2
2
|
belongs_to :item
|
3
3
|
belongs_to :basket
|
4
4
|
belongs_to :librarian, class_name: 'User', optional: true
|
@@ -94,7 +94,7 @@ class CheckedItem < ActiveRecord::Base
|
|
94
94
|
end
|
95
95
|
# 返却期限日が閉館日の場合
|
96
96
|
while item.shelf.library.closed?(due_date)
|
97
|
-
if item_checkout_type.
|
97
|
+
if item_checkout_type.set_due_date_after_closing_day
|
98
98
|
self.due_date = due_date.yesterday.end_of_day
|
99
99
|
else
|
100
100
|
self.due_date = due_date.tomorrow.end_of_day
|
data/app/models/checkin.rb
CHANGED
data/app/models/checkout.rb
CHANGED
data/app/models/checkout_type.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class CheckoutType <
|
1
|
+
class CheckoutType < ApplicationRecord
|
2
2
|
include MasterModel
|
3
3
|
scope :available_for_carrier_type, lambda {|carrier_type| includes(:carrier_types).where('carrier_types.name = ?', carrier_type.name).order('carrier_types.position')}
|
4
4
|
scope :available_for_user_group, lambda {|user_group| includes(:user_groups).where('user_groups.name = ?', user_group.name).order('user_group.position')}
|
data/app/models/demand.rb
CHANGED
data/app/models/reserve.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class UserGroupHasCheckoutType <
|
1
|
+
class UserGroupHasCheckoutType < ApplicationRecord
|
2
2
|
scope :available_for_item, lambda{|item| where(checkout_type_id: item.checkout_type.id)}
|
3
3
|
scope :available_for_carrier_type, lambda{|carrier_type| includes(checkout_type: :carrier_types).where('carrier_types.id' => carrier_type.id)}
|
4
4
|
|
@@ -27,12 +27,12 @@
|
|
27
27
|
<h4><%= t('page.other_format') %></h4>
|
28
28
|
<ul>
|
29
29
|
<li>
|
30
|
-
<%= link_to 'RSS',
|
31
|
-
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: 'RSS'),
|
30
|
+
<%= link_to 'RSS', url_for(filtered_params.merge(format: :rss, days_overdue: params[:days_overdue])) -%>
|
31
|
+
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: 'RSS'), url_for(filtered_params.merge(format: :rss, days_overdue: params[:days_overdue])) -%>
|
32
32
|
</li>
|
33
33
|
<li>
|
34
|
-
<%= link_to 'TSV',
|
35
|
-
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'),
|
34
|
+
<%= link_to 'TSV', url_for(filtered_params.merge(format: :txt, days_overdue: params[:days_overdue], locale: @locale.to_s)) -%>
|
35
|
+
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(format: :txt, days_overdue: params[:days_overdue], locale: @locale.to_s)) -%>
|
36
36
|
</li>
|
37
37
|
</ul>
|
38
38
|
</div>
|
@@ -3,7 +3,6 @@
|
|
3
3
|
<th><%= t('activerecord.models.user') %></th>
|
4
4
|
<th class="checked_item_title"><%= t('page.title') %></th>
|
5
5
|
<th><%= t('activerecord.attributes.checkout.due_date') %></th>
|
6
|
-
<th></th>
|
7
6
|
</tr>
|
8
7
|
|
9
8
|
<%- checkouts.each_with_index do |checkout, i| %>
|
@@ -28,12 +27,11 @@
|
|
28
27
|
</td>
|
29
28
|
<td>
|
30
29
|
<%= l(checkout.due_date, format: :only_date) -%>
|
31
|
-
<br />
|
32
30
|
<% if checkout.checkin %>
|
31
|
+
<br />
|
33
32
|
<strong><%= t('checkout.returned') %></strong>
|
34
33
|
<% end %>
|
35
|
-
|
36
|
-
<td>
|
34
|
+
<br />
|
37
35
|
<%- if policy(checkout).update? -%>
|
38
36
|
<% unless checkout.checkin %>
|
39
37
|
<%= link_to t('checkout.extend'), edit_checkout_path(checkout) -%>
|
@@ -4,6 +4,15 @@
|
|
4
4
|
|
5
5
|
<%= render 'manifestations/title', manifestation: @checkout.item.manifestation if @checkout.item -%>
|
6
6
|
|
7
|
+
<h3><%= t('item.current_checkout') %></h3>
|
8
|
+
|
9
|
+
<ul>
|
10
|
+
<li><%= t('activerecord.attributes.user.username') %>:
|
11
|
+
<%= @checkout.user.username %></li>
|
12
|
+
<li><%= t('activerecord.attributes.profile.user_number') %>:
|
13
|
+
<%= @checkout.user.profile.user_number %></li>
|
14
|
+
</ul>
|
15
|
+
|
7
16
|
<h3><%= t('checkout.renewal') -%></h3>
|
8
17
|
<%- if @checkout.renewable? -%>
|
9
18
|
<%= form_for(@checkout) do |f| -%>
|
@@ -4,12 +4,12 @@
|
|
4
4
|
<% @state_facet.each do |state| %>
|
5
5
|
<li>
|
6
6
|
<% if state.value == params[:state].to_s.downcase %><strong><% end %>
|
7
|
-
<%= link_to "#{i18n_state(state.value)} (#{state.count})", url_for(
|
7
|
+
<%= link_to "#{i18n_state(state.value)} (#{state.count})", url_for(filtered_params.merge(state: state.value, page: nil, view: nil, only_path: true)) %>
|
8
8
|
<% if state.value == params[:state].to_s.downcase %></strong><% end %>
|
9
9
|
</li>
|
10
10
|
<% end %>
|
11
11
|
<%- if params[:state] -%>
|
12
|
-
<li><%= link_to t('page.remove_this_facet'), url_for(
|
12
|
+
<li><%= link_to t('page.remove_this_facet'), url_for(filtered_params.merge(state: nil, page: nil, view: nil, only_path: true)) -%></li>
|
13
13
|
<%- end -%>
|
14
14
|
</ul>
|
15
15
|
<%- end -%>
|
@@ -21,12 +21,12 @@
|
|
21
21
|
<%- if @sort_by == :created_at -%>
|
22
22
|
<strong><%= t('activerecord.attributes.reserve.created_at') -%></strong>
|
23
23
|
<%- else -%>
|
24
|
-
<%= link_to t('activerecord.attributes.reserve.created_at'), url_for(
|
24
|
+
<%= link_to t('activerecord.attributes.reserve.created_at'), url_for(filtered_params.merge(sort_by: nil, only_path: true)) -%>
|
25
25
|
<% end %>
|
26
26
|
<%- if @sort_by == :title -%>
|
27
27
|
<strong><%= t('page.title') -%></strong>
|
28
28
|
<%- else -%>
|
29
|
-
<%= link_to t('page.title'), url_for(
|
29
|
+
<%= link_to t('page.title'), url_for(filtered_params.merge(sort_by: 'title', only_path: true)) -%>
|
30
30
|
<%- end -%>
|
31
31
|
</p>
|
32
32
|
|
@@ -103,15 +103,15 @@
|
|
103
103
|
|
104
104
|
<p>
|
105
105
|
<%- if @user -%>
|
106
|
-
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')),
|
107
|
-
(<%= link_to 'RSS',
|
108
|
-
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'),
|
109
|
-
(<%= link_to 'TSV',
|
106
|
+
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), url_for(filtered_params.merge(user_id: @user.username, format: :rss)) -%>
|
107
|
+
(<%= link_to 'RSS', url_for(filtered_params.merge(user_id: @user.username, format: :rss)) -%>)
|
108
|
+
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(user_id: @user.username, format: :txt, locale: @locale.to_s)) -%>
|
109
|
+
(<%= link_to 'TSV', url_for(filtered_params.merge(user_id: @user.username, format: :txt, locale: @locale.to_s)) -%>)
|
110
110
|
<%- else -%>
|
111
|
-
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')),
|
112
|
-
(<%= link_to 'RSS',
|
113
|
-
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'),
|
114
|
-
(<%= link_to 'TSV',
|
111
|
+
<%= link_to image_tag('icons/feed.png', size: '16x16', class: 'enju_icon', alt: t('page.feed')), url_for(filtered_params.merge(format: :rss)) -%>
|
112
|
+
(<%= link_to 'RSS', url_for(filtered_params.merge(format: :rss)) -%>)
|
113
|
+
<%= link_to image_tag('icons/page_white_excel.png', size: '16x16', class: 'enju_icon', alt: 'TSV'), url_for(filtered_params.merge(format: :txt, locale: @locale.to_s)) -%>
|
114
|
+
(<%= link_to 'TSV', url_for(filtered_params.merge(format: :txt, locale: @locale.to_s)) -%>)
|
115
115
|
<%- end -%>
|
116
116
|
</p>
|
117
117
|
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
CSV.generate(col_sep: "\t", row_sep: "\r\n") do |csv|
|
2
|
+
csv << %w(id state maniestation_id title creator publisher pub_date isbn item_identifier call_number user_number username library created_at expired_at)
|
3
|
+
@reserves.each do |reserve|
|
4
|
+
csv << [
|
5
|
+
reserve.id,
|
6
|
+
reserve.current_state,
|
7
|
+
reserve.manifestation_id,
|
8
|
+
reserve.manifestation.original_title,
|
9
|
+
reserve.manifestation.creators.pluck(:full_name).join('//'),
|
10
|
+
reserve.manifestation.publishers.pluck(:full_name).join('//'),
|
11
|
+
reserve.manifestation.pub_date,
|
12
|
+
reserve.manifestation.identifier_contents(:isbn).join('//'),
|
13
|
+
reserve.item.try(:item_identifier),
|
14
|
+
reserve.item.try(:call_number),
|
15
|
+
reserve.user.profile.try(:user_number),
|
16
|
+
reserve.user.try(:username),
|
17
|
+
reserve.pickup_location.try(:name),
|
18
|
+
reserve.created_at,
|
19
|
+
reserve.updated_at
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
@@ -34,8 +34,8 @@
|
|
34
34
|
</div>
|
35
35
|
|
36
36
|
<div class="field">
|
37
|
-
<%= f.label :
|
38
|
-
<%= f.check_box :
|
37
|
+
<%= f.label :set_due_date_after_closing_day -%>
|
38
|
+
<%= f.check_box :set_due_date_after_closing_day -%>
|
39
39
|
</div>
|
40
40
|
|
41
41
|
<div class="field">
|
@@ -34,8 +34,8 @@
|
|
34
34
|
</div>
|
35
35
|
|
36
36
|
<div class="field">
|
37
|
-
<%= f.label :
|
38
|
-
<%= f.check_box :
|
37
|
+
<%= f.label :set_due_date_after_closing_day -%>
|
38
|
+
<%= f.check_box :set_due_date_after_closing_day -%>
|
39
39
|
</div>
|
40
40
|
|
41
41
|
<div class="field">
|
@@ -39,8 +39,8 @@
|
|
39
39
|
</p>
|
40
40
|
|
41
41
|
<p>
|
42
|
-
<strong><%= t('activerecord.attributes.user_group_has_checkout_type.
|
43
|
-
<%= localized_boolean(@user_group_has_checkout_type.
|
42
|
+
<strong><%= t('activerecord.attributes.user_group_has_checkout_type.set_due_date_after_closing_day') -%>:</strong>
|
43
|
+
<%= localized_boolean(@user_group_has_checkout_type.set_due_date_after_closing_day) -%>
|
44
44
|
</p>
|
45
45
|
|
46
46
|
<p>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<br />
|
9
9
|
<%= f.label :reservation_limit -%>
|
10
10
|
<%= f.text_field :reservation_limit, class: 'resource_integer' %>
|
11
|
-
<%= f.label :
|
12
|
-
<%= f.check_box :
|
11
|
+
<%= f.label :set_due_date_after_closing_day -%>
|
12
|
+
<%= f.check_box :set_due_date_after_closing_day %>
|
13
13
|
<%= link_to_remove_association t('page.remove'), f, data: {confirm: t('page.are_you_sure')} %>
|
14
14
|
</div>
|
@@ -72,7 +72,7 @@ en:
|
|
72
72
|
checkout_renewal_limit: Checkout renewal limit
|
73
73
|
reservation_limit: Reservation limit
|
74
74
|
reservation_expired_period: Reservation expired period
|
75
|
-
|
75
|
+
set_due_date_after_closing_day: Set due date before the closing day
|
76
76
|
fixed_due_date: Fixed due date
|
77
77
|
note: Note
|
78
78
|
position: Position
|
@@ -70,7 +70,7 @@ ja:
|
|
70
70
|
checkout_renewal_limit: 貸出更新回数の上限
|
71
71
|
reservation_limit: 予約数の上限
|
72
72
|
reservation_expired_period: 予約の期限切れまでの期間
|
73
|
-
|
73
|
+
set_due_date_after_closing_day: 返却日を閉館日の翌日にする
|
74
74
|
fixed_due_date: 固定貸出期限
|
75
75
|
note: 注記
|
76
76
|
position: 位置
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AddNumberOfDayToNotifyOverdueToUserGroup < ActiveRecord::Migration[4.2]
|
2
2
|
def self.up
|
3
|
-
add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default:
|
4
|
-
add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default:
|
3
|
+
add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default: 7, null: false
|
4
|
+
add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default: 3, null: false
|
5
5
|
add_column :user_groups, :number_of_time_to_notify_overdue, :integer, default: 3, null: false
|
6
6
|
end
|
7
7
|
|
@@ -1,29 +1,29 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
-
class MyAccept < Accept
|
4
|
-
include EnjuCirculation::EnjuAccept
|
5
|
-
end
|
6
|
-
|
7
3
|
describe EnjuCirculation::EnjuAccept do
|
8
4
|
fixtures :all
|
9
5
|
|
10
6
|
it "should successfully accept" do
|
11
|
-
accept =
|
12
|
-
|
13
|
-
expect(accept.item.circulation_status.name).to eq "In Process"
|
7
|
+
accept = Accept.new(FactoryBot.attributes_for(:accept))
|
8
|
+
accept.item = FactoryBot.create(:item)
|
14
9
|
accept.save!
|
15
10
|
expect(accept.item.circulation_status.name).to eq "Available On Shelf"
|
16
11
|
expect(accept.item.use_restriction.name).to eq "Limited Circulation, Normal Loan Period"
|
17
12
|
end
|
18
13
|
|
19
14
|
it "should reflect to items list", solr: true do
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
Item.reindex
|
16
|
+
|
17
|
+
3.times do
|
18
|
+
FactoryBot.create(:item, circulation_status: CirculationStatus.find_by(name: 'In Process'))
|
19
|
+
end
|
20
|
+
|
23
21
|
result = Item.search.build { facet :circulation_status }.execute
|
24
22
|
inprocess_count = result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count
|
25
23
|
onshelf_count = result.facet(:circulation_status).rows.find{|e| e.value == "Available On Shelf" }.try(:count) || 0
|
26
|
-
|
24
|
+
|
25
|
+
accept = Accept.new(FactoryBot.attributes_for(:accept))
|
26
|
+
accept.item = FactoryBot.create(:item)
|
27
27
|
accept.save!
|
28
28
|
result = Item.search.build { facet :circulation_status }.execute
|
29
29
|
expect(result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count).to eq inprocess_count
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ItemsController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
describe 'POST create' do
|
7
|
+
before(:each) do
|
8
|
+
manifestation = FactoryBot.create(:manifestation)
|
9
|
+
@attrs = FactoryBot.attributes_for(:item, manifestation_id: manifestation.id)
|
10
|
+
@invalid_attrs = { item_identifier: '無効なID', manifestation_id: manifestation.id }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'When logged in as Administrator' do
|
14
|
+
login_fixture_admin
|
15
|
+
|
16
|
+
describe 'with valid params' do
|
17
|
+
it 'should create reserved item' do
|
18
|
+
post :create, params: { item: { circulation_status_id: 1, manifestation_id: 2 } }
|
19
|
+
expect(assigns(:item)).to be_valid
|
20
|
+
|
21
|
+
expect(response).to redirect_to item_url(assigns(:item))
|
22
|
+
flash[:message].should eq I18n.t('item.this_item_is_reserved')
|
23
|
+
assigns(:item).manifestation.should eq Manifestation.find(2)
|
24
|
+
assigns(:item).should be_retained
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should create another item with already retained" do
|
28
|
+
reserve = FactoryBot.create(:reserve)
|
29
|
+
reserve.transition_to!(:requested)
|
30
|
+
post :create, params: { item: FactoryBot.attributes_for(:item, manifestation_id: reserve.manifestation.id) }
|
31
|
+
expect(assigns(:item)).to be_valid
|
32
|
+
expect(response).to redirect_to item_url(assigns(:item))
|
33
|
+
post :create, params: { item: FactoryBot.attributes_for(:item, manifestation_id: reserve.manifestation.id) }
|
34
|
+
expect(assigns(:item)).to be_valid
|
35
|
+
expect(response).to redirect_to item_url(assigns(:item))
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should create a lending policy' do
|
39
|
+
old_lending_policy_count = LendingPolicy.count
|
40
|
+
post :create, params: { item: @attrs }
|
41
|
+
LendingPolicy.count.should eq old_lending_policy_count
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'DELETE destroy' do
|
48
|
+
describe 'When logged in as Administrator' do
|
49
|
+
login_fixture_admin
|
50
|
+
|
51
|
+
it 'should not destroy item if not checked in' do
|
52
|
+
delete :destroy, params: { id: 1 }
|
53
|
+
expect(response).to be_forbidden
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should not destroy a removed item' do
|
57
|
+
delete :destroy, params: { id: 26 }
|
58
|
+
expect(response).to be_forbidden
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ApplicationJob < ActiveJob::Base
|
2
|
+
# Automatically retry jobs that encountered a deadlock
|
3
|
+
# retry_on ActiveRecord::Deadlocked
|
4
|
+
|
5
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
6
|
+
# discard_on ActiveJob::DeserializationError
|
7
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class User <
|
1
|
+
class User < ApplicationRecord
|
2
2
|
# Include default devise modules. Others available are:
|
3
3
|
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
4
4
|
devise :database_authenticatable, #:registerable,
|
@@ -9,6 +9,7 @@ class User < ActiveRecord::Base
|
|
9
9
|
include EnjuCirculation::EnjuUser
|
10
10
|
end
|
11
11
|
|
12
|
+
Accept.include(EnjuCirculation::EnjuAccept)
|
12
13
|
Basket.include(EnjuCirculation::EnjuBasket)
|
13
14
|
Manifestation.include(EnjuCirculation::EnjuManifestation)
|
14
15
|
Item.include(EnjuCirculation::EnjuItem)
|