enju_circulation 0.3.9 → 0.4.0.beta.1
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/README.md +2 -3
- data/app/controllers/checkins_controller.rb +2 -2
- data/app/controllers/user_group_has_checkout_types_controller.rb +1 -1
- data/app/helpers/items_helper.rb +3 -3
- data/app/models/checked_item.rb +7 -17
- data/app/models/checkin.rb +3 -2
- data/app/models/checkout.rb +2 -2
- data/app/models/checkout_stat_has_user.rb +1 -1
- data/app/models/checkout_type.rb +9 -7
- data/app/models/circulation_status.rb +9 -8
- data/app/models/concerns/enju_circulation/enju_item.rb +2 -46
- data/app/models/concerns/enju_circulation/enju_user_group.rb +0 -1
- data/app/models/concerns/enju_circulation/enju_withdraw.rb +1 -7
- data/app/models/manifestation_checkout_stat_transition.rb +1 -1
- data/app/models/manifestation_reserve_stat_transition.rb +1 -1
- data/app/models/reserve.rb +5 -5
- data/app/models/reserve_state_machine.rb +3 -2
- data/app/models/reserve_transition.rb +1 -1
- data/app/models/retain.rb +15 -0
- data/app/models/user_checkout_stat_transition.rb +1 -1
- data/app/models/user_group_has_checkout_type.rb +15 -37
- data/app/models/user_reserve_stat_transition.rb +1 -1
- data/app/views/carrier_type_has_checkout_types/_form.html.erb +2 -2
- data/app/views/carrier_type_has_checkout_types/index.html.erb +2 -2
- data/app/views/carrier_type_has_checkout_types/show.html.erb +2 -2
- data/app/views/carrier_types/_carrier_type_has_checkout_type_fields.html.erb +1 -1
- data/app/views/checked_items/new.html.erb +1 -1
- data/app/views/checkins/_checkin.html.erb +1 -1
- data/app/views/checkout_types/_form.html.erb +1 -1
- data/app/views/checkout_types/index.html.erb +1 -1
- data/app/views/checkout_types/show.html.erb +2 -2
- data/app/views/checkouts/_index_user.html.erb +1 -1
- data/app/views/checkouts/_list.html.erb +2 -9
- data/app/views/checkouts/index.atom.builder +1 -1
- data/app/views/checkouts/index.ics.erb +1 -1
- data/app/views/checkouts/index.rss.builder +1 -1
- data/app/views/circulation_statuses/_form.html.erb +1 -1
- data/app/views/circulation_statuses/index.html.erb +1 -1
- data/app/views/circulation_statuses/show.html.erb +1 -1
- data/app/views/item_has_use_restrictions/index.html.erb +1 -1
- data/app/views/item_has_use_restrictions/show.html.erb +1 -1
- data/app/views/manifestation_checkout_stats/_group_by_carrier_type.html.erb +3 -3
- data/app/views/manifestation_checkout_stats/_group_by_checkout_type.html.erb +3 -3
- data/app/views/manifestations/_circulation_status.html.erb +3 -3
- data/app/views/profiles/_submenu_checkout.html.erb +1 -1
- data/app/views/reserves/_new.html.erb +1 -1
- data/app/views/reserves/_new_user.html.erb +1 -1
- data/app/views/reserves/edit.html.erb +1 -1
- data/app/views/reserves/index.atom.builder +1 -1
- data/app/views/reserves/index.html.erb +1 -1
- data/app/views/reserves/index.rss.builder +1 -1
- data/app/views/reserves/show.html.erb +1 -1
- data/app/views/use_restrictions/_form.html.erb +1 -1
- data/app/views/use_restrictions/index.html.erb +1 -1
- data/app/views/use_restrictions/show.html.erb +1 -1
- data/app/views/user_group_has_checkout_types/edit.html.erb +4 -4
- data/app/views/user_group_has_checkout_types/index.html.erb +2 -2
- data/app/views/user_group_has_checkout_types/new.html.erb +4 -4
- data/app/views/user_group_has_checkout_types/show.html.erb +4 -4
- data/app/views/user_groups/_user_group_has_checkout_type_fields.html.erb +2 -2
- data/config/locales/translation_en.yml +1 -14
- data/config/locales/translation_ja.yml +1 -14
- data/config/routes.rb +1 -2
- data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +3 -3
- data/db/migrate/20190508160525_create_retains.rb +10 -0
- data/db/migrate/20190629134017_rename_user_group_has_checkout_type_due_date_before_to_due_date_after.rb +5 -0
- data/db/migrate/20190706052525_add_display_name_translations_to_circulation_status.rb +5 -0
- data/db/migrate/20190713114724_add_checkout_id_to_checkin.rb +5 -0
- data/db/migrate/20190814120827_add_display_name_translations_to_checkout_type.rb +5 -0
- data/lib/enju_circulation/version.rb +1 -1
- data/lib/generators/enju_circulation/setup/templates/db/fixtures/checkout_types.yml +3 -5
- data/lib/generators/enju_circulation/setup/templates/db/fixtures/circulation_statuses.yml +16 -48
- data/lib/tasks/enju_circulation_tasks.rake +7 -1
- data/spec/concerns/enju_accept_spec.rb +14 -14
- data/spec/controllers/accepts_controller_spec.rb +294 -0
- data/spec/controllers/baskets_controller_spec.rb +379 -0
- data/spec/controllers/checkins_controller_spec.rb +8 -130
- data/spec/controllers/items_controller_spec.rb +23 -43
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/bin/bundle +1 -1
- data/spec/dummy/bin/setup +1 -3
- data/spec/dummy/bin/update +4 -2
- data/spec/dummy/bin/yarn +3 -3
- data/spec/dummy/config/database.yml +70 -9
- data/spec/dummy/config/initializers/assets.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/113_create_events.rb +2 -4
- data/spec/dummy/db/migrate/20081028093607_create_event_import_files.rb +2 -4
- data/spec/dummy/db/migrate/20090519203307_create_participates.rb +2 -4
- data/spec/dummy/db/migrate/20100925074639_create_event_import_results.rb +2 -2
- data/spec/dummy/db/migrate/20140720192418_add_default_library_id_to_event_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +1 -1
- data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20151128142913_create_places.rb +14 -0
- data/spec/dummy/db/migrate/20151201163718_add_place_id_to_event.rb +5 -0
- data/spec/dummy/db/migrate/20160703184258_add_most_recent_to_event_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184311_add_most_recent_to_event_export_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107164558_add_constraints_to_most_recent_for_event_import_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107164617_add_constraints_to_most_recent_for_event_export_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20181119170645_add_foreign_key_to_events_referencing_event_categories.rb +5 -0
- data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
- data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
- data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
- data/spec/dummy/db/migrate/20190630153136_add_display_name_translations_to_event.rb +6 -0
- data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
- data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
- data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
- data/spec/dummy/db/schema.rb +221 -184
- data/spec/dummy/db/test.sqlite3 +0 -0
- 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/factories/accept.rb +1 -1
- data/spec/factories/item.rb +4 -4
- data/spec/factories/reserve.rb +1 -5
- data/spec/fixtures/carrier_types.yml +16 -15
- data/spec/fixtures/checkins.yml +2 -1
- data/spec/fixtures/checkout_stat_has_users.yml +1 -1
- data/spec/fixtures/checkout_types.yml +11 -10
- data/spec/fixtures/checkouts.yml +2 -2
- data/spec/fixtures/circulation_statuses.yml +26 -34
- data/spec/fixtures/content_types.yml +20 -31
- data/spec/fixtures/event_categories.yml +23 -23
- data/spec/fixtures/frequencies.yml +17 -25
- data/spec/fixtures/items.yml +1 -1
- data/spec/fixtures/libraries.yml +30 -31
- data/spec/fixtures/library_groups.yml +43 -20
- data/spec/fixtures/request_status_types.yml +14 -14
- data/spec/fixtures/request_types.yml +13 -13
- data/spec/fixtures/reserve_transitions.yml +1 -1
- data/spec/fixtures/reserves.yml +3 -3
- data/spec/fixtures/roles.yml +22 -5
- data/spec/fixtures/shelves.yml +16 -15
- data/spec/fixtures/user_group_has_checkout_types.yml +24 -24
- data/spec/fixtures/user_groups.yml +23 -3
- data/spec/helpers/items_helper_spec.rb +1 -1
- data/spec/models/checkin_spec.rb +2 -1
- data/spec/models/checkout_spec.rb +2 -2
- data/spec/models/checkout_stat_has_user_spec.rb +1 -1
- data/spec/models/checkout_type_spec.rb +8 -7
- data/spec/models/circulation_status_spec.rb +8 -7
- data/spec/models/item_spec.rb +6 -8
- data/spec/models/manifestation_spec.rb +15 -18
- data/spec/models/reserve_spec.rb +3 -3
- data/spec/models/resource_export_file_spec.rb +0 -15
- data/spec/models/retain_spec.rb +16 -0
- data/spec/models/user_group_has_checkout_type_spec.rb +15 -32
- data/spec/models/withdraw_spec.rb +4 -6
- data/spec/policies/manifestation_policy_spec.rb +2 -1
- data/spec/rails_helper.rb +10 -3
- data/spec/views/items/index.html.erb_spec.rb +1 -4
- metadata +396 -446
- data/app/controllers/lending_policies_controller.rb +0 -106
- data/app/models/lending_policy.rb +0 -30
- data/app/views/lending_policies/_form.html.erb +0 -41
- data/app/views/lending_policies/edit.html.erb +0 -13
- data/app/views/lending_policies/index.html.erb +0 -42
- data/app/views/lending_policies/new.html.erb +0 -12
- data/app/views/lending_policies/show.html.erb +0 -50
- data/db/migrate/20090831220301_create_lending_policies.rb +0 -21
- data/spec/controllers/lending_policies_controller_spec.rb +0 -444
- data/spec/controllers/withdraws_controller_spec.rb +0 -26
- data/spec/dummy/config/locales/en.yml +0 -208
- data/spec/dummy/config/locales/ja.yml +0 -200
- data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
- data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
- data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
- data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
- data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
- data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
- data/spec/fixtures/accepts.yml +0 -9
- data/spec/fixtures/bookstores.yml +0 -99
- data/spec/fixtures/budget_types.yml +0 -30
- data/spec/fixtures/exemplifies.yml +0 -168
- data/spec/fixtures/lending_policies.yml +0 -98
- data/spec/models/lending_policy_spec.rb +0 -23
- data/spec/system/items_spec.rb +0 -21
- data/spec/system/user_group_has_checkout_types.rb +0 -14
@@ -1,129 +1,97 @@
|
|
1
1
|
---
|
2
2
|
circulation_status_00001:
|
3
3
|
name: Available For Pickup
|
4
|
-
|
5
|
-
en: Available For Pickup
|
6
|
-
ja: 持ち出し可能
|
4
|
+
display_name_translations: {"en": "Available For Pickup", "ja": "持ち出し可能"}
|
7
5
|
id: 1
|
8
6
|
note: ""
|
9
7
|
position: 1
|
10
8
|
circulation_status_00002:
|
11
9
|
name: Available On Shelf
|
12
|
-
|
13
|
-
en: Available On Shelf
|
14
|
-
ja: 在架(利用可能)
|
10
|
+
display_name_translations: {"en": "Available on Shelf", "ja": "在架(利用可能)"}
|
15
11
|
id: 2
|
16
12
|
note: ""
|
17
13
|
position: 2
|
18
14
|
circulation_status_00003:
|
19
15
|
name: Circulation Status Undefined
|
20
|
-
|
21
|
-
en: Circulation Status Undefined
|
22
|
-
ja: 貸出状態未定義
|
16
|
+
display_name_translations: {"en": "Circulation Status Undefined", "ja": "貸出状態未定義"}
|
23
17
|
id: 3
|
24
18
|
note: ""
|
25
19
|
position: 3
|
26
20
|
circulation_status_00004:
|
27
21
|
name: Claimed Returned Or Never Borrowed
|
28
|
-
|
29
|
-
en: Claimed Returned Or Never Borrowed
|
30
|
-
ja: 利用者が返却済み、または未貸出と主張
|
22
|
+
display_name_translations: {"en": "Claimed Returned Or Never Borrowed", "ja": "利用者が返却済み、または未貸出と主張"}
|
31
23
|
id: 4
|
32
24
|
note: ""
|
33
25
|
position: 4
|
34
26
|
circulation_status_00005:
|
35
27
|
name: In Process
|
36
|
-
|
37
|
-
en: In Process
|
38
|
-
ja: 作業中
|
28
|
+
display_name_translations: {"en": "In Process", "ja": "作業中"}
|
39
29
|
id: 5
|
40
30
|
note: ""
|
41
31
|
position: 5
|
42
32
|
circulation_status_00006:
|
43
33
|
name: In Transit Between Library Locations
|
44
|
-
|
45
|
-
en: In Transit Between Library Locations
|
46
|
-
ja: 移動中
|
34
|
+
display_name_translations: {"en": "In Transit Between Library Locations", "ja": "移動中"}
|
47
35
|
id: 6
|
48
36
|
note: ""
|
49
37
|
position: 6
|
50
38
|
circulation_status_00007:
|
51
39
|
name: Lost
|
52
|
-
|
53
|
-
en: Lost
|
54
|
-
ja: 紛失
|
40
|
+
display_name_translations: {"en": "Lost", "ja": "紛失"}
|
55
41
|
id: 7
|
56
42
|
note: ""
|
57
43
|
position: 7
|
58
44
|
circulation_status_00008:
|
59
45
|
name: Missing
|
60
|
-
|
61
|
-
en: Missing
|
62
|
-
ja: 行方不明
|
46
|
+
display_name_translations: {"en": "Missing", "ja": "行方不明"}
|
63
47
|
id: 8
|
64
48
|
note: ""
|
65
49
|
position: 8
|
66
50
|
circulation_status_00009:
|
67
51
|
name: Not Available
|
68
|
-
|
69
|
-
en: Not Available
|
70
|
-
ja: 利用不可
|
52
|
+
display_name_translations: {"en": "Not Available", "ja": "利用不可"}
|
71
53
|
id: 9
|
72
54
|
note: ""
|
73
55
|
position: 9
|
74
56
|
circulation_status_00010:
|
75
57
|
name: On Loan
|
76
|
-
|
77
|
-
en: On Loan
|
78
|
-
ja: 貸出中
|
58
|
+
display_name_translations: {"en": "On Loan", "ja": "貸出中"}
|
79
59
|
id: 10
|
80
60
|
note: ""
|
81
61
|
position: 10
|
82
62
|
circulation_status_00011:
|
83
63
|
name: On Order
|
84
|
-
|
85
|
-
en: On Order
|
86
|
-
ja: 発注中
|
64
|
+
display_name_translations: {"en": "On Order", "ja": "発注中"}
|
87
65
|
id: 11
|
88
66
|
note: ""
|
89
67
|
position: 11
|
90
68
|
circulation_status_00012:
|
91
69
|
name: Pending Transfer
|
92
|
-
|
93
|
-
en: Pending Transfer
|
94
|
-
ja: 移動予定
|
70
|
+
display_name_translations: {"en": "Pending Transfer", "ja": "移動予定"}
|
95
71
|
id: 12
|
96
72
|
note: ""
|
97
73
|
position: 12
|
98
74
|
circulation_status_00013:
|
99
75
|
name: Recalled
|
100
|
-
|
101
|
-
en: Recalled
|
102
|
-
ja: 返却依頼中
|
76
|
+
display_name_translations: {"en": "Recalled", "ja": "返却依頼中"}
|
103
77
|
id: 13
|
104
78
|
note: ""
|
105
79
|
position: 13
|
106
80
|
circulation_status_00014:
|
107
81
|
name: Waiting To Be Reshelved
|
108
|
-
|
109
|
-
en: Waiting To Be Reshelved
|
110
|
-
ja: 再配架待ち
|
82
|
+
display_name_translations: {"en": "Waiting To Be Reshelved", "ja": "再配架待ち"}
|
111
83
|
id: 14
|
112
84
|
note: ""
|
113
85
|
position: 14
|
114
86
|
circulation_status_00015:
|
115
87
|
name: Not arrived
|
116
|
-
|
117
|
-
en: Not arrived
|
118
|
-
ja: 未着
|
88
|
+
display_name_translations: {"en": "Not arrived", "ja": "未着"}
|
119
89
|
id: 15
|
120
90
|
note: ""
|
121
91
|
position: 15
|
122
92
|
circulation_status_00016:
|
123
93
|
name: Removed
|
124
|
-
|
125
|
-
en: Removed
|
126
|
-
ja: 除籍済み
|
94
|
+
display_name_translations: {"en": "Removed", "ja": "除籍済み"}
|
127
95
|
id: 16
|
128
96
|
note: ""
|
129
97
|
position: 16
|
@@ -74,8 +74,14 @@ namespace :enju_circulation do
|
|
74
74
|
c.user.try(:profile).try(:full_name),
|
75
75
|
c.user.try(:profile).try(:user_number),
|
76
76
|
].join("\t")
|
77
|
-
|
77
|
+
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
desc "upgrade enju_circulation to enju_leaf 2.0"
|
83
|
+
task upgrade_20: :environment do
|
84
|
+
sql = 'UPDATE checkins SET checkout_id = checkouts.id FROM checkouts WHERE checkouts.checkin_id = checkins.id;'
|
85
|
+
ActiveRecord::Base.connection.execute(sql)
|
86
|
+
end
|
81
87
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
|
+
class MyAccept < Accept
|
4
|
+
include EnjuCirculation::EnjuAccept
|
5
|
+
end
|
6
|
+
|
3
7
|
describe EnjuCirculation::EnjuAccept do
|
4
8
|
fixtures :all
|
5
9
|
|
6
10
|
it "should successfully accept" do
|
7
|
-
accept =
|
8
|
-
accept.item
|
11
|
+
accept = MyAccept.new(FactoryBot.attributes_for(:accept))
|
12
|
+
expect(accept.item).to be_truthy
|
13
|
+
expect(accept.item.circulation_status.name).to eq "In Process"
|
9
14
|
accept.save!
|
10
15
|
expect(accept.item.circulation_status.name).to eq "Available On Shelf"
|
11
16
|
expect(accept.item.use_restriction.name).to eq "Limited Circulation, Normal Loan Period"
|
12
17
|
end
|
13
18
|
|
14
19
|
it "should reflect to items list", solr: true do
|
15
|
-
Item.reindex
|
16
|
-
|
17
20
|
3.times do
|
18
|
-
FactoryBot.create(:item
|
21
|
+
FactoryBot.create(:item)
|
19
22
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
accept = Accept.new(FactoryBot.attributes_for(:accept))
|
26
|
-
accept.item = FactoryBot.create(:item)
|
23
|
+
result = Item.count
|
24
|
+
inprocess_count = Item.where(circulation_status: CirculationStatus.find_by(name: "In Process")).count
|
25
|
+
onshelf_count = Item.where(circulation_status: CirculationStatus.find_by(name: "Available On Shelf")).count
|
26
|
+
accept = MyAccept.new(FactoryBot.attributes_for(:accept))
|
27
27
|
accept.save!
|
28
28
|
result = Item.search.build { facet :circulation_status }.execute
|
29
|
-
expect(
|
30
|
-
expect(
|
29
|
+
expect(Item.where(circulation_status: CirculationStatus.find_by(name: "In Process")).count).to eq inprocess_count
|
30
|
+
expect(Item.where(circulation_status: CirculationStatus.find_by(name: "Available On Shelf")).count).to eq onshelf_count + 1
|
31
31
|
end
|
32
32
|
end
|
@@ -0,0 +1,294 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe AcceptsController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
def mock_user(stubs = {})
|
7
|
+
(@mock_user ||= mock_model(Accept).as_null_object).tap do |user|
|
8
|
+
user.stub(stubs) unless stubs.empty?
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'GET index' do
|
13
|
+
describe 'When logged in as Administrator' do
|
14
|
+
login_fixture_admin
|
15
|
+
|
16
|
+
it 'assigns all accepts as @accepts' do
|
17
|
+
get :index
|
18
|
+
assigns(:accepts).should_not be_nil
|
19
|
+
response.should be_successful
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'When basket_id is specified' do
|
23
|
+
it 'assigns all accepts as @accepts' do
|
24
|
+
get :index, params: { basket_id: baskets(:basket_00010).id }
|
25
|
+
assigns(:accepts).should eq baskets(:basket_00010).accepts.order('accepts.created_at DESC').page(1)
|
26
|
+
response.should be_successful
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'When logged in as Librarian' do
|
32
|
+
login_fixture_librarian
|
33
|
+
|
34
|
+
it 'assigns all accepts as @accepts' do
|
35
|
+
get :index
|
36
|
+
assigns(:accepts).should_not be_nil
|
37
|
+
response.should be_successful
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'When basket_id is specified' do
|
41
|
+
it 'assigns all accepts as @accepts' do
|
42
|
+
get :index, params: { basket_id: baskets(:basket_00009).id }
|
43
|
+
assigns(:accepts).should eq baskets(:basket_00009).accepts.order('accepts.created_at DESC').page(1)
|
44
|
+
response.should be_successful
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'When logged in as User' do
|
50
|
+
login_fixture_user
|
51
|
+
|
52
|
+
it 'should not assign all accepts as @accepts' do
|
53
|
+
get :index
|
54
|
+
assigns(:accepts).should be_nil
|
55
|
+
response.should be_forbidden
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'GET show' do
|
61
|
+
describe 'When logged in as Administrator' do
|
62
|
+
login_fixture_admin
|
63
|
+
|
64
|
+
it 'assigns the requested accept as @accept' do
|
65
|
+
accept = FactoryBot.create(:accept)
|
66
|
+
get :show, params: { id: accept.id }
|
67
|
+
assigns(:accept).should eq(accept)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'When logged in as Librarian' do
|
72
|
+
login_fixture_librarian
|
73
|
+
|
74
|
+
it 'assigns the requested accept as @accept' do
|
75
|
+
accept = FactoryBot.create(:accept)
|
76
|
+
get :show, params: { id: accept.id }
|
77
|
+
assigns(:accept).should eq(accept)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'When logged in as User' do
|
82
|
+
login_fixture_user
|
83
|
+
|
84
|
+
it 'assigns the requested accept as @accept' do
|
85
|
+
accept = FactoryBot.create(:accept)
|
86
|
+
get :show, params: { id: accept.id }
|
87
|
+
assigns(:accept).should eq(accept)
|
88
|
+
response.should be_forbidden
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe 'When not logged in' do
|
93
|
+
it 'assigns the requested accept as @accept' do
|
94
|
+
accept = FactoryBot.create(:accept)
|
95
|
+
get :show, params: { id: accept.id }
|
96
|
+
assigns(:accept).should eq(accept)
|
97
|
+
response.should redirect_to new_user_session_url
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'GET new' do
|
103
|
+
describe 'When logged in as Administrator' do
|
104
|
+
login_fixture_admin
|
105
|
+
|
106
|
+
it 'assigns the requested accept as @accept' do
|
107
|
+
get :new
|
108
|
+
assigns(:accept).should_not be_valid
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'When logged in as Librarian' do
|
113
|
+
login_fixture_librarian
|
114
|
+
|
115
|
+
it 'assigns the requested accept as @accept' do
|
116
|
+
get :new
|
117
|
+
assigns(:accept).should_not be_valid
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'When logged in as User' do
|
122
|
+
login_fixture_user
|
123
|
+
|
124
|
+
it 'should not assign the requested accept as @accept' do
|
125
|
+
get :new
|
126
|
+
assigns(:accept).should be_nil
|
127
|
+
response.should be_forbidden
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'When not logged in' do
|
132
|
+
it 'should not assign the requested accept as @accept' do
|
133
|
+
get :new
|
134
|
+
assigns(:accept).should be_nil
|
135
|
+
response.should redirect_to(new_user_session_url)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe 'POST create' do
|
141
|
+
before(:each) do
|
142
|
+
@attrs = { item_identifier: '00003' }
|
143
|
+
@invalid_attrs = { item_identifier: 'invalid' }
|
144
|
+
end
|
145
|
+
|
146
|
+
describe 'When logged in as Administrator' do
|
147
|
+
login_fixture_admin
|
148
|
+
|
149
|
+
describe 'with valid params' do
|
150
|
+
it 'assigns a newly created accept as @accept' do
|
151
|
+
post :create, params: { accept: @attrs }
|
152
|
+
assigns(:accept).should be_nil
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should not create a new accept without basket_id' do
|
156
|
+
post :create, params: { accept: @attrs }
|
157
|
+
response.should be_forbidden
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'When basket_id is specified' do
|
161
|
+
it 'redirects to the created accept' do
|
162
|
+
post :create, params: { accept: @attrs, basket_id: baskets(:basket_00009).id }
|
163
|
+
response.should redirect_to(accepts_url(basket_id: assigns(:accept).basket.id))
|
164
|
+
assigns(:accept).item.circulation_status.name.should eq 'Available On Shelf'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe 'with invalid params' do
|
170
|
+
it 'assigns a newly created but unsaved accept as @accept' do
|
171
|
+
post :create, params: { accept: @invalid_attrs }
|
172
|
+
assigns(:accept).should be_nil
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should be forbidden' do
|
176
|
+
post :create, params: { accept: @invalid_attrs }
|
177
|
+
response.should be_forbidden
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should not create accept without item_id' do
|
182
|
+
post :create, params: { accept: { item_identifier: nil }, basket_id: baskets(:basket_00009).id }
|
183
|
+
assigns(:accept).should_not be_valid
|
184
|
+
response.should be_successful
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe 'When logged in as Librarian' do
|
189
|
+
login_fixture_librarian
|
190
|
+
|
191
|
+
describe 'with valid params' do
|
192
|
+
it 'assigns a newly created accept as @accept' do
|
193
|
+
post :create, params: { accept: @attrs }
|
194
|
+
assigns(:accept).should be_nil
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should not create a new accept without basket_id' do
|
198
|
+
post :create, params: { accept: @attrs }
|
199
|
+
response.should be_forbidden
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe 'When logged in as User' do
|
205
|
+
login_fixture_user
|
206
|
+
|
207
|
+
describe 'with valid params' do
|
208
|
+
it 'assigns a newly created accept as @accept' do
|
209
|
+
post :create, params: { accept: @attrs }
|
210
|
+
assigns(:accept).should be_nil
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should be forbidden' do
|
214
|
+
post :create, params: { accept: @attrs }
|
215
|
+
response.should be_forbidden
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
describe 'When not logged in' do
|
221
|
+
before(:each) do
|
222
|
+
@attrs = { item_identifier: '00003' }
|
223
|
+
@invalid_attrs = { item_identifier: 'invalid' }
|
224
|
+
end
|
225
|
+
|
226
|
+
describe 'with valid params' do
|
227
|
+
it 'assigns a newly created accept as @accept' do
|
228
|
+
post :create, params: { accept: @attrs }
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should redirect to new session url' do
|
232
|
+
post :create, params: { accept: @attrs }
|
233
|
+
response.should redirect_to new_user_session_url
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe 'DELETE destroy' do
|
240
|
+
before(:each) do
|
241
|
+
@accept = FactoryBot.create(:accept)
|
242
|
+
end
|
243
|
+
|
244
|
+
describe 'When logged in as Administrator' do
|
245
|
+
login_fixture_admin
|
246
|
+
|
247
|
+
it 'destroys the requested accept' do
|
248
|
+
delete :destroy, params: { id: @accept.id }
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'redirects to the accepts list' do
|
252
|
+
delete :destroy, params: { id: @accept.id }
|
253
|
+
response.should redirect_to(accepts_url)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe 'When logged in as Librarian' do
|
258
|
+
login_fixture_librarian
|
259
|
+
|
260
|
+
it 'destroys the requested accept' do
|
261
|
+
delete :destroy, params: { id: @accept.id }
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'redirects to the accepts list' do
|
265
|
+
delete :destroy, params: { id: @accept.id }
|
266
|
+
response.should redirect_to(accepts_url)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
describe 'When logged in as User' do
|
271
|
+
login_fixture_user
|
272
|
+
|
273
|
+
it 'destroys the requested accept' do
|
274
|
+
delete :destroy, params: { id: @accept.id }
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should be forbidden' do
|
278
|
+
delete :destroy, params: { id: @accept.id }
|
279
|
+
response.should be_forbidden
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe 'When not logged in' do
|
284
|
+
it 'destroys the requested accept' do
|
285
|
+
delete :destroy, params: { id: @accept.id }
|
286
|
+
end
|
287
|
+
|
288
|
+
it 'should be forbidden' do
|
289
|
+
delete :destroy, params: { id: @accept.id }
|
290
|
+
response.should redirect_to(new_user_session_url)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|