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.
- checksums.yaml +4 -4
- data/app/controllers/carrier_type_has_checkout_types_controller.rb +10 -4
- data/app/controllers/checked_items_controller.rb +8 -1
- data/app/controllers/checkins_controller.rb +6 -1
- data/app/controllers/checkout_types_controller.rb +8 -3
- data/app/controllers/checkouts_controller.rb +11 -4
- data/app/controllers/circulation_statuses_controller.rb +7 -2
- data/app/controllers/demands_controller.rb +85 -0
- data/app/controllers/item_has_use_restrictions_controller.rb +9 -3
- data/app/controllers/lending_policies_controller.rb +8 -1
- data/app/controllers/manifestation_checkout_stats_controller.rb +11 -2
- data/app/controllers/manifestation_reserve_stats_controller.rb +9 -2
- data/app/controllers/reserves_controller.rb +37 -9
- data/app/controllers/use_restrictions_controller.rb +7 -2
- data/app/controllers/user_checkout_stats_controller.rb +9 -2
- data/app/controllers/user_group_has_checkout_types_controller.rb +12 -2
- data/app/controllers/user_reserve_stats_controller.rb +9 -2
- data/app/helpers/items_helper.rb +17 -0
- data/app/models/carrier_type_has_checkout_type.rb +0 -1
- data/app/models/checked_item.rb +1 -2
- data/app/models/checkin.rb +0 -1
- data/app/models/checkout.rb +0 -1
- data/app/models/checkout_stat_has_manifestation.rb +2 -2
- data/app/models/checkout_stat_has_user.rb +2 -2
- data/app/models/checkout_type.rb +0 -2
- data/app/models/circulation_status.rb +0 -1
- data/app/models/demand.rb +5 -0
- data/app/models/enju_circulation/ability.rb +2 -0
- data/app/models/item_has_use_restriction.rb +0 -1
- data/app/models/lending_policy.rb +0 -2
- data/app/models/manifestation_checkout_stat.rb +5 -2
- data/app/models/manifestation_checkout_stat_transition.rb +1 -1
- data/app/models/manifestation_reserve_stat.rb +5 -2
- data/app/models/manifestation_reserve_stat_transition.rb +1 -1
- data/app/models/reserve.rb +24 -27
- data/app/models/reserve_stat_has_manifestation.rb +0 -3
- data/app/models/reserve_stat_has_user.rb +3 -3
- data/app/models/reserve_state_machine.rb +7 -7
- data/app/models/reserve_transition.rb +1 -1
- data/app/models/use_restriction.rb +0 -2
- data/app/models/user_checkout_stat.rb +5 -2
- data/app/models/user_checkout_stat_transition.rb +1 -1
- data/app/models/user_group_has_checkout_type.rb +0 -5
- data/app/models/user_reserve_stat.rb +5 -2
- data/app/models/user_reserve_stat_transition.rb +1 -1
- data/app/views/checkouts/_index.html.erb +1 -1
- data/app/views/checkouts/_index_item.html.erb +1 -1
- data/app/views/checkouts/_index_overdue.html.erb +1 -1
- data/app/views/checkouts/_index_user.html.erb +1 -1
- data/app/views/checkouts/_list.html.erb +2 -4
- data/app/views/demands/_form.html.erb +29 -0
- data/app/views/demands/edit.html.erb +6 -0
- data/app/views/demands/index.html.erb +31 -0
- data/app/views/demands/new.html.erb +5 -0
- data/app/views/demands/show.html.erb +19 -0
- data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +29 -28
- data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +29 -28
- data/config/locales/translation_en.yml +1 -0
- data/config/locales/translation_ja.yml +1 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20150106001709_create_demands.rb +14 -0
- data/lib/enju_circulation/accept.rb +1 -0
- data/lib/enju_circulation/carrier_type.rb +15 -0
- data/lib/enju_circulation/item.rb +3 -2
- data/lib/enju_circulation/profile.rb +0 -3
- data/lib/enju_circulation/user.rb +7 -3
- data/lib/enju_circulation/user_group.rb +0 -1
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/enju_circulation.rb +2 -0
- data/spec/controllers/checked_items_controller_spec.rb +18 -18
- data/spec/controllers/checkouts_controller_spec.rb +3 -3
- data/spec/dummy/app/models/user.rb +0 -1
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -2
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/migrate/{20111201155456_devise_create_users.rb → 002_devise_create_users.rb} +6 -2
- data/spec/dummy/db/migrate/041_create_roles.rb +13 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +1 -5
- data/spec/dummy/db/migrate/069_create_shelves.rb +1 -5
- data/spec/dummy/db/migrate/077_create_user_groups.rb +3 -7
- data/spec/dummy/db/migrate/080_create_library_groups.rb +2 -10
- data/spec/dummy/db/migrate/113_create_events.rb +2 -2
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -5
- data/spec/dummy/db/migrate/131_create_request_types.rb +1 -5
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
- data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +25 -0
- data/spec/dummy/db/migrate/20090519203307_create_participates.rb +17 -0
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
- data/spec/dummy/db/migrate/{20111201163718_create_user_has_roles.rb → 20100606065209_create_user_has_roles.rb} +2 -0
- data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +15 -0
- data/spec/dummy/db/migrate/{20111201121844_create_roles.rb → 20120129014038_create_budget_types.rb} +2 -2
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120413051535_add_event_import_fingerprint_to_event_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413170734_add_error_message_to_event_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120415060342_rename_event_import_file_imported_at_to_executed_at.rb +9 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +18 -0
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +11 -0
- data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +1 -1
- data/spec/dummy/db/migrate/20140523171309_create_event_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140628071719_add_user_encoding_to_event_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140812153137_create_event_export_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
- data/spec/dummy/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
- data/spec/dummy/db/schema.rb +246 -58
- data/spec/fixtures/checkouts.yml +1 -1
- data/spec/fixtures/demands.yml +11 -0
- data/spec/fixtures/events.yml +13 -39
- data/spec/fixtures/library_groups.yml +0 -2
- metadata +105 -43
- data/db/migrate/20111217234412_add_save_checkout_history_to_user.rb +0 -5
- data/db/migrate/20111218002349_add_checkout_icalendar_token_to_user.rb +0 -6
- data/spec/dummy/db/migrate/20090719201843_create_extents.rb +0 -12
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +0 -9
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +0 -9
- data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +0 -9
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +0 -9
- data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +0 -13
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +0 -11
- data/spec/dummy/db/migrate/20120224094141_create_delayed_jobs.rb +0 -22
- data/spec/dummy/script/delayed_job +0 -5
- 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
|
-
<%
|
14
|
-
|
15
|
-
<
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
26
|
+
</td>
|
27
|
+
<% end %>
|
28
|
+
<td>
|
29
|
+
<%= @carrier_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
|
33
30
|
</td>
|
34
|
-
|
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
|
-
|
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
|
-
|
43
|
-
|
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
|
-
<
|
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
|
-
<%
|
14
|
-
|
15
|
-
<
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
26
|
+
</td>
|
27
|
+
<% end %>
|
28
|
+
<td>
|
29
|
+
<%= @checkout_type_results.select{|r| r[0] == shelf.id}.sum{|k, v| v} %>
|
33
30
|
</td>
|
34
|
-
|
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
|
-
|
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
|
-
|
43
|
-
|
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
|
-
<
|
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} %>
|
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
|
@@ -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
|
-
|
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
|
-
|
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,
|
data/lib/enju_circulation.rb
CHANGED
@@ -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 = {:
|
201
|
-
@invalid_attrs = {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 => {:
|
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 = {:
|
322
|
-
@invalid_attrs = {:
|
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.
|
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.
|
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.
|
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
|
data/spec/dummy/bin/rake
ADDED
@@ -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
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/dummy/db/migrate/{20111201155456_devise_create_users.rb → 002_devise_create_users.rb}
RENAMED
@@ -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
|
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
|
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
|
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
|
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
|