enju_purchase_request 0.2.1 → 0.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +4 -4
- data/app/assets/config/enju_purchase_request_manifest.js +0 -0
- data/app/models/purchase_request.rb +1 -1
- data/app/views/order_lists/index.rss.builder +5 -5
- data/app/views/orders/index.rss.builder +5 -5
- data/app/views/purchase_requests/index.rss.builder +5 -5
- data/db/migrate/123_create_purchase_requests.rb +1 -1
- data/db/migrate/126_create_orders.rb +1 -1
- data/db/migrate/20081009062129_create_order_lists.rb +1 -1
- data/db/migrate/20140528155058_create_order_list_transitions.rb +1 -1
- data/db/migrate/20160703190738_add_most_recent_to_order_list_transitions.rb +1 -1
- data/db/migrate/20180107155817_add_constraints_to_most_recent_for_order_list_transitions.rb +1 -1
- data/lib/enju_purchase_request/version.rb +1 -1
- data/spec/controllers/order_lists_controller_spec.rb +152 -152
- data/spec/controllers/orders_controller_spec.rb +159 -159
- data/spec/controllers/purchase_requests_controller_spec.rb +185 -185
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/bin/setup +21 -12
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config/application.rb +6 -16
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +9 -9
- data/spec/dummy/config/environment.rb +4 -4
- data/spec/dummy/config/environments/development.rb +24 -11
- data/spec/dummy/config/environments/production.rb +28 -16
- data/spec/dummy/config/environments/test.rb +6 -8
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +9 -3
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +5 -5
- data/spec/dummy/config/locales/en.yml +30 -2
- data/spec/dummy/config/puma.rb +56 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/sunspot.yml +23 -0
- data/spec/dummy/db/migrate/001_create_agents.rb +1 -1
- data/spec/dummy/db/migrate/002_devise_create_users.rb +1 -1
- data/spec/dummy/db/migrate/005_create_manifestations.rb +1 -1
- data/spec/dummy/db/migrate/006_create_items.rb +1 -1
- data/spec/dummy/db/migrate/012_create_owns.rb +1 -1
- data/spec/dummy/db/migrate/015_create_creates.rb +1 -1
- data/spec/dummy/db/migrate/041_create_roles.rb +1 -1
- data/spec/dummy/db/migrate/047_create_produces.rb +1 -1
- data/spec/dummy/db/migrate/055_create_bookmarks.rb +1 -1
- data/spec/dummy/db/migrate/059_create_libraries.rb +1 -1
- data/spec/dummy/db/migrate/069_create_shelves.rb +1 -1
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +1 -1
- data/spec/dummy/db/migrate/077_create_user_groups.rb +1 -1
- data/spec/dummy/db/migrate/080_create_library_groups.rb +1 -1
- data/spec/dummy/db/migrate/112_create_frequencies.rb +1 -1
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +1 -1
- data/spec/dummy/db/migrate/120_create_baskets.rb +1 -1
- data/spec/dummy/db/migrate/124_create_bookstores.rb +1 -1
- data/spec/dummy/db/migrate/125_create_donates.rb +1 -1
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -1
- data/spec/dummy/db/migrate/131_create_request_types.rb +1 -1
- data/spec/dummy/db/migrate/133_create_agent_merges.rb +1 -1
- data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +1 -1
- data/spec/dummy/db/migrate/149_create_message_templates.rb +1 -1
- data/spec/dummy/db/migrate/154_create_messages.rb +1 -1
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +1 -1
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +1 -1
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +1 -1
- data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +1 -1
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +1 -1
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +1 -1
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +1 -1
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +1 -1
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -1
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +1 -1
- data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20081212151614_create_bookmark_stats.rb +1 -1
- data/spec/dummy/db/migrate/20081212151820_create_bookmark_stat_has_manifestations.rb +1 -1
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20090719201843_create_extents.rb +1 -1
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +1 -1
- data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +1 -1
- data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +1 -1
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +1 -1
- data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +1 -1
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +1 -1
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +1 -1
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +1 -1
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +1 -1
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +1 -1
- data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +1 -1
- data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +1 -1
- data/spec/dummy/db/migrate/20100606073747_create_agent_relationships.rb +1 -1
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +1 -1
- data/spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb +1 -1
- data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
- data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +1 -1
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +1 -1
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +1 -1
- data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +1 -1
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +1 -1
- data/spec/dummy/db/migrate/20111231145823_add_share_bookmarks_to_user.rb +1 -1
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +1 -1
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +1 -1
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +1 -1
- data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120413170720_add_error_message_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
- data/spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20121116031206_add_fulltext_content_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20121116033446_add_doi_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -1
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb +1 -1
- data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +1 -1
- data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +1 -1
- data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +1 -1
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140524135607_create_bookmark_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140524142813_add_taggings_count_to_tag.rb +1 -1
- data/spec/dummy/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +1 -1
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +1 -1
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +1 -1
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20140720140916_add_binding_item_identifier_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140721151416_add_default_shelf_id_to_resource_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140802082007_add_manifestation_id_to_item.rb +1 -1
- data/spec/dummy/db/migrate/20140811031145_add_expired_at_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140812093836_add_share_bookmarks_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +1 -1
- data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +1 -1
- data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +1 -1
- data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +1 -1
- data/spec/dummy/db/migrate/20141013152011_add_missing_unique_indices.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/migrate/20141013152013_add_missing_taggable_index.acts_as_taggable_on_engine.rb +1 -1
- data/spec/dummy/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +1 -1
- data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +1 -1
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +1 -1
- data/spec/dummy/db/migrate/20151125004028_add_profile_id_to_agent.rb +1 -1
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb +1 -1
- data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160815045420_add_most_recent_to_bookmark_stat_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160820004638_add_attachment_attachment_to_carrier_types.rb +1 -1
- data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20171119051258_set_not_null_to_manifestation_id_on_items.rb +1 -1
- data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +1 -1
- data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +1 -1
- data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +1 -1
- data/spec/dummy/db/schema.rb +695 -754
- data/spec/rails_helper.rb +0 -13
- metadata +38 -29
@@ -3,91 +3,91 @@ require 'rails_helper'
|
|
3
3
|
describe PurchaseRequestsController do
|
4
4
|
fixtures :all
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe 'GET index', solr: true do
|
7
7
|
before do
|
8
8
|
PurchaseRequest.reindex
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe 'When logged in as Administrator' do
|
12
12
|
login_fixture_admin
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'assigns all purchase_requests as @purchase_requests' do
|
15
15
|
get :index
|
16
16
|
assigns(:purchase_requests).should_not be_empty
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe 'When logged in as Librarian' do
|
21
21
|
login_fixture_librarian
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'assigns all purchase_requests as @purchase_requests' do
|
24
24
|
get :index
|
25
25
|
assigns(:purchase_requests).total_entries.should eq PurchaseRequest.count
|
26
26
|
assigns(:purchase_requests).should_not be_empty
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should get other user's index with user_id" do
|
30
|
-
get :index, user_id: users(:user1).username
|
30
|
+
get :index, params: { user_id: users(:user1).username }
|
31
31
|
response.should be_success
|
32
32
|
assigns(:purchase_requests).total_entries.should eq users(:user1).purchase_requests.count
|
33
33
|
assigns(:purchase_requests).should_not be_empty
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should get other user's index with order_list_id" do
|
37
|
-
get :index, order_list_id: 1
|
37
|
+
get :index, params: { order_list_id: 1 }
|
38
38
|
response.should be_success
|
39
39
|
assigns(:purchase_requests).total_entries.should eq order_lists(:order_list_00001).purchase_requests.count
|
40
40
|
assigns(:purchase_requests).should_not be_empty
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
44
|
+
describe 'When logged in as User' do
|
45
45
|
login_fixture_user
|
46
46
|
|
47
|
-
it
|
47
|
+
it 'assigns my purchase_requests as @purchase_requests' do
|
48
48
|
get :index
|
49
49
|
assigns(:purchase_requests).should_not be_empty
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
52
|
+
it 'should be get my index without user_id' do
|
53
53
|
get :index
|
54
54
|
assigns(:purchase_requests).should eq users(:user1).purchase_requests
|
55
55
|
assigns(:purchase_requests).total_entries.should eq users(:user1).purchase_requests.count
|
56
56
|
response.should be_success
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
get :index, user_id: users(:user1).username
|
59
|
+
it 'should get my index' do
|
60
|
+
get :index, params: { user_id: users(:user1).username }
|
61
61
|
response.should redirect_to purchase_requests_url
|
62
62
|
assigns(:purchase_requests).should be_nil
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
get :index, order_list_id: 1
|
65
|
+
it 'should not get index with order_list_id' do
|
66
|
+
get :index, params: { order_list_id: 1 }
|
67
67
|
response.should be_forbidden
|
68
68
|
assigns(:purchase_requests).should be_nil
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
get :index, user_id: users(:user1).username, :
|
73
|
-
response.should redirect_to purchase_requests_url(:
|
71
|
+
it 'should get my index in csv format' do
|
72
|
+
get :index, params: { user_id: users(:user1).username, format: 'csv' }
|
73
|
+
response.should redirect_to purchase_requests_url(format: :csv)
|
74
74
|
assigns(:purchase_requests).should be_nil
|
75
75
|
end
|
76
76
|
|
77
|
-
it
|
78
|
-
get :index, user_id: users(:user1).username, :
|
79
|
-
response.should redirect_to purchase_requests_url(:
|
77
|
+
it 'should get my index in rss format' do
|
78
|
+
get :index, params: { user_id: users(:user1).username, format: 'rss' }
|
79
|
+
response.should redirect_to purchase_requests_url(format: :rss)
|
80
80
|
assigns(:purchase_requests).should be_nil
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should not get other user's index" do
|
84
|
-
get :index, user_id: users(:librarian1).username
|
84
|
+
get :index, params: { user_id: users(:librarian1).username }
|
85
85
|
response.should be_forbidden
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
describe
|
90
|
-
it
|
89
|
+
describe 'When not logged in' do
|
90
|
+
it 'assigns empty as @purchase_requests' do
|
91
91
|
get :index
|
92
92
|
assigns(:purchase_requests).should be_nil
|
93
93
|
response.should redirect_to(new_user_session_url)
|
@@ -95,103 +95,103 @@ describe PurchaseRequestsController do
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
describe
|
98
|
+
describe 'GET show' do
|
99
99
|
before(:each) do
|
100
100
|
@purchase_request = purchase_requests(:purchase_request_00003)
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
103
|
+
describe 'When logged in as Administrator' do
|
104
104
|
login_admin
|
105
105
|
|
106
|
-
it
|
107
|
-
get :show, :id
|
106
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
107
|
+
get :show, params: { id: @purchase_request.id }
|
108
108
|
assigns(:purchase_request).should eq(@purchase_request)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
describe
|
112
|
+
describe 'When logged in as Librarian' do
|
113
113
|
login_fixture_librarian
|
114
114
|
|
115
|
-
it
|
116
|
-
get :show, :id
|
115
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
116
|
+
get :show, params: { id: @purchase_request.id }
|
117
117
|
assigns(:purchase_request).should eq(@purchase_request)
|
118
118
|
end
|
119
119
|
|
120
|
-
it
|
121
|
-
get :show, :id
|
120
|
+
it 'should show purchase_request without user_id' do
|
121
|
+
get :show, params: { id: purchase_requests(:purchase_request_00002).id }
|
122
122
|
response.should be_success
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
126
|
+
describe 'When logged in as User' do
|
127
127
|
login_fixture_user
|
128
128
|
|
129
|
-
it
|
130
|
-
get :show, :id
|
129
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
130
|
+
get :show, params: { id: @purchase_request.id }
|
131
131
|
assigns(:purchase_request).should eq(@purchase_request)
|
132
132
|
end
|
133
133
|
|
134
|
-
it
|
135
|
-
get :show, :id
|
134
|
+
it 'should show my purchase request' do
|
135
|
+
get :show, params: { id: @purchase_request.id }
|
136
136
|
response.should be_success
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should not show other user's purchase request" do
|
140
|
-
get :show, :id
|
140
|
+
get :show, params: { id: purchase_requests(:purchase_request_00001).id }
|
141
141
|
response.should be_forbidden
|
142
142
|
end
|
143
143
|
|
144
144
|
render_views
|
145
|
-
it
|
146
|
-
get :show, :id
|
145
|
+
it 'should not show add or delete order link' do
|
146
|
+
get :show, params: { id: @purchase_request.id }
|
147
147
|
response.should be_success
|
148
148
|
response.body.should_not match /\/order\/new/
|
149
149
|
response.body.should_not match /delete.*\/order/
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
describe
|
154
|
-
it
|
155
|
-
get :show, :id
|
153
|
+
describe 'When not logged in' do
|
154
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
155
|
+
get :show, params: { id: @purchase_request.id }
|
156
156
|
assigns(:purchase_request).should eq(@purchase_request)
|
157
157
|
response.should redirect_to new_user_session_url
|
158
158
|
end
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
-
describe
|
163
|
-
describe
|
162
|
+
describe 'GET new' do
|
163
|
+
describe 'When logged in as Administrator' do
|
164
164
|
login_admin
|
165
165
|
|
166
|
-
it
|
166
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
167
167
|
get :new
|
168
168
|
assigns(:purchase_request).should_not be_valid
|
169
169
|
response.should be_success
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
describe
|
173
|
+
describe 'When logged in as Librarian' do
|
174
174
|
login_fixture_librarian
|
175
175
|
|
176
|
-
it
|
176
|
+
it 'should not assign the requested purchase_request as @purchase_request' do
|
177
177
|
get :new
|
178
178
|
assigns(:purchase_request).should_not be_valid
|
179
179
|
response.should be_success
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
-
describe
|
183
|
+
describe 'When logged in as User' do
|
184
184
|
login_fixture_user
|
185
185
|
|
186
|
-
it
|
186
|
+
it 'should not assign the requested purchase_request as @purchase_request' do
|
187
187
|
get :new
|
188
188
|
assigns(:purchase_request).should_not be_valid
|
189
189
|
response.should be_success
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
describe
|
194
|
-
it
|
193
|
+
describe 'When not logged in' do
|
194
|
+
it 'should not assign the requested purchase_request as @purchase_request' do
|
195
195
|
get :new
|
196
196
|
assigns(:purchase_request).should be_nil
|
197
197
|
response.should redirect_to(new_user_session_url)
|
@@ -199,365 +199,365 @@ describe PurchaseRequestsController do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
describe
|
203
|
-
describe
|
202
|
+
describe 'GET edit' do
|
203
|
+
describe 'When logged in as Administrator' do
|
204
204
|
login_fixture_admin
|
205
205
|
|
206
|
-
it
|
207
|
-
get :edit, :id
|
206
|
+
it 'should assign the requested purchase_request as @purchase_request' do
|
207
|
+
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
|
208
208
|
assigns(:purchase_request).should eq(purchase_requests(:purchase_request_00001))
|
209
209
|
response.should be_success
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
-
describe
|
213
|
+
describe 'When logged in as Librarian' do
|
214
214
|
login_fixture_librarian
|
215
215
|
|
216
|
-
it
|
217
|
-
get :edit, :id
|
216
|
+
it 'should assign the requested purchase_request as @purchase_request' do
|
217
|
+
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
|
218
218
|
assigns(:purchase_request).should eq(purchase_requests(:purchase_request_00001))
|
219
219
|
response.should be_success
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
describe
|
223
|
+
describe 'When logged in as User' do
|
224
224
|
login_fixture_user
|
225
225
|
|
226
|
-
it
|
227
|
-
get :edit, :id
|
226
|
+
it 'should edit my purchase_request' do
|
227
|
+
get :edit, params: { id: purchase_requests(:purchase_request_00003).id }
|
228
228
|
response.should be_success
|
229
229
|
end
|
230
230
|
|
231
231
|
it "should not edit other user's purchase_request" do
|
232
|
-
get :edit, :id
|
232
|
+
get :edit, params: { id: purchase_requests(:purchase_request_00002).id }
|
233
233
|
response.should be_forbidden
|
234
234
|
end
|
235
235
|
end
|
236
236
|
|
237
|
-
describe
|
238
|
-
it
|
239
|
-
get :edit, :id
|
237
|
+
describe 'When not logged in' do
|
238
|
+
it 'should not assign the requested purchase_request as @purchase_request' do
|
239
|
+
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
|
240
240
|
response.should redirect_to new_user_session_url
|
241
241
|
end
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
-
describe
|
245
|
+
describe 'POST create' do
|
246
246
|
before(:each) do
|
247
247
|
@attrs = FactoryBot.attributes_for(:purchase_request)
|
248
|
-
@invalid_attrs = {:
|
248
|
+
@invalid_attrs = { title: '' }
|
249
249
|
end
|
250
250
|
|
251
|
-
describe
|
251
|
+
describe 'When logged in as Administrator' do
|
252
252
|
login_fixture_admin
|
253
253
|
|
254
|
-
describe
|
255
|
-
it
|
256
|
-
post :create, :purchase_request
|
254
|
+
describe 'with valid params' do
|
255
|
+
it 'assigns a newly created purchase_request as @purchase_request' do
|
256
|
+
post :create, params: { purchase_request: @attrs }
|
257
257
|
assigns(:purchase_request).should be_valid
|
258
258
|
end
|
259
259
|
|
260
|
-
it
|
261
|
-
post :create, :purchase_request
|
260
|
+
it 'redirects to the created purchase_request' do
|
261
|
+
post :create, params: { purchase_request: @attrs }
|
262
262
|
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
describe
|
267
|
-
it
|
268
|
-
post :create, :purchase_request
|
266
|
+
describe 'with invalid params' do
|
267
|
+
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
|
268
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
269
269
|
assigns(:purchase_request).should_not be_valid
|
270
270
|
end
|
271
271
|
|
272
272
|
it "re-renders the 'new' template" do
|
273
|
-
post :create, :purchase_request
|
274
|
-
response.should render_template(
|
273
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
274
|
+
response.should render_template('new')
|
275
275
|
end
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
|
-
describe
|
279
|
+
describe 'When logged in as Librarian' do
|
280
280
|
login_fixture_librarian
|
281
281
|
|
282
|
-
describe
|
283
|
-
it
|
284
|
-
post :create, :purchase_request
|
282
|
+
describe 'with valid params' do
|
283
|
+
it 'assigns a newly created purchase_request as @purchase_request' do
|
284
|
+
post :create, params: { purchase_request: @attrs }
|
285
285
|
assigns(:purchase_request).should be_valid
|
286
286
|
end
|
287
287
|
|
288
|
-
it
|
289
|
-
post :create, :purchase_request
|
288
|
+
it 'redirects to the created purchase_request' do
|
289
|
+
post :create, params: { purchase_request: @attrs }
|
290
290
|
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
describe
|
295
|
-
it
|
296
|
-
post :create, :purchase_request
|
294
|
+
describe 'with invalid params' do
|
295
|
+
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
|
296
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
297
297
|
assigns(:purchase_request).should_not be_valid
|
298
298
|
end
|
299
299
|
|
300
300
|
it "re-renders the 'new' template" do
|
301
|
-
post :create, :purchase_request
|
302
|
-
response.should render_template(
|
301
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
302
|
+
response.should render_template('new')
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
306
|
it "should create purchase_request with other user's user_id" do
|
307
|
-
post :create, :purchase_request
|
307
|
+
post :create, params: { purchase_request: { title: 'test', user_id: users(:user1).id } }
|
308
308
|
response.should redirect_to purchase_request_url(assigns(:purchase_request))
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
-
describe
|
312
|
+
describe 'When logged in as User' do
|
313
313
|
login_fixture_user
|
314
314
|
|
315
|
-
describe
|
316
|
-
it
|
317
|
-
post :create, :purchase_request
|
315
|
+
describe 'with valid params' do
|
316
|
+
it 'assigns a newly created purchase_request as @purchase_request' do
|
317
|
+
post :create, params: { purchase_request: @attrs }
|
318
318
|
assigns(:purchase_request).should be_valid
|
319
319
|
end
|
320
320
|
|
321
|
-
it
|
322
|
-
post :create, :purchase_request
|
321
|
+
it 'redirects to the created purchase_request' do
|
322
|
+
post :create, params: { purchase_request: @attrs }
|
323
323
|
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
|
324
324
|
end
|
325
325
|
end
|
326
326
|
|
327
|
-
describe
|
328
|
-
it
|
329
|
-
post :create, :purchase_request
|
327
|
+
describe 'with invalid params' do
|
328
|
+
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
|
329
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
330
330
|
assigns(:purchase_request).should_not be_valid
|
331
331
|
end
|
332
332
|
|
333
333
|
it "re-renders the 'new' template" do
|
334
|
-
post :create, :purchase_request
|
335
|
-
response.should render_template(
|
334
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
335
|
+
response.should render_template('new')
|
336
336
|
end
|
337
337
|
end
|
338
338
|
|
339
|
-
it
|
340
|
-
post :create, :purchase_request
|
339
|
+
it 'should create purchase_request without user_id' do
|
340
|
+
post :create, params: { purchase_request: { title: 'test', user_id: users(:user1).id, pub_date: 2010 } }
|
341
341
|
assigns(:purchase_request).date_of_publication.should eq Time.zone.parse('2010-01-01')
|
342
342
|
response.should redirect_to purchase_request_url(assigns(:purchase_request))
|
343
343
|
end
|
344
344
|
end
|
345
345
|
|
346
|
-
describe
|
347
|
-
describe
|
348
|
-
it
|
349
|
-
post :create, :purchase_request
|
346
|
+
describe 'When not logged in' do
|
347
|
+
describe 'with valid params' do
|
348
|
+
it 'assigns a newly created purchase_request as @purchase_request' do
|
349
|
+
post :create, params: { purchase_request: @attrs }
|
350
350
|
assigns(:purchase_request).should be_nil
|
351
351
|
end
|
352
352
|
|
353
|
-
it
|
354
|
-
post :create, :purchase_request
|
353
|
+
it 'should redirect to new_user_session_url' do
|
354
|
+
post :create, params: { purchase_request: @attrs }
|
355
355
|
response.should redirect_to(new_user_session_url)
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
-
describe
|
360
|
-
it
|
361
|
-
post :create, :purchase_request
|
359
|
+
describe 'with invalid params' do
|
360
|
+
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
|
361
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
362
362
|
assigns(:purchase_request).should be_nil
|
363
363
|
end
|
364
364
|
|
365
|
-
it
|
366
|
-
post :create, :purchase_request
|
365
|
+
it 'should redirect to new_user_session_url' do
|
366
|
+
post :create, params: { purchase_request: @invalid_attrs }
|
367
367
|
response.should redirect_to(new_user_session_url)
|
368
368
|
end
|
369
369
|
end
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
373
|
-
describe
|
373
|
+
describe 'PUT update' do
|
374
374
|
before(:each) do
|
375
375
|
@purchase_request = purchase_requests(:purchase_request_00001)
|
376
376
|
@attrs = FactoryBot.attributes_for(:purchase_request)
|
377
|
-
@invalid_attrs = {:
|
377
|
+
@invalid_attrs = { title: '' }
|
378
378
|
end
|
379
379
|
|
380
|
-
describe
|
380
|
+
describe 'When logged in as Administrator' do
|
381
381
|
before(:each) do
|
382
382
|
@user = FactoryBot.create(:admin)
|
383
383
|
sign_in @user
|
384
384
|
end
|
385
385
|
|
386
|
-
describe
|
387
|
-
it
|
388
|
-
put :update, :id
|
386
|
+
describe 'with valid params' do
|
387
|
+
it 'updates the requested purchase_request' do
|
388
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
389
389
|
end
|
390
390
|
|
391
|
-
it
|
392
|
-
put :update, :id
|
391
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
392
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
393
393
|
assigns(:purchase_request).should eq(@purchase_request)
|
394
394
|
response.should redirect_to purchase_request_url(assigns(:purchase_request))
|
395
395
|
end
|
396
396
|
end
|
397
397
|
|
398
|
-
describe
|
399
|
-
it
|
400
|
-
put :update, :id
|
398
|
+
describe 'with invalid params' do
|
399
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
400
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
401
401
|
end
|
402
402
|
|
403
403
|
it "re-renders the 'edit' template" do
|
404
|
-
put :update, :id
|
405
|
-
response.should render_template(
|
404
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
405
|
+
response.should render_template('edit')
|
406
406
|
end
|
407
407
|
end
|
408
408
|
end
|
409
409
|
|
410
|
-
describe
|
410
|
+
describe 'When logged in as Librarian' do
|
411
411
|
before(:each) do
|
412
412
|
@user = FactoryBot.create(:librarian)
|
413
413
|
sign_in @user
|
414
414
|
end
|
415
415
|
|
416
|
-
describe
|
417
|
-
it
|
418
|
-
put :update, :id
|
416
|
+
describe 'with valid params' do
|
417
|
+
it 'updates the requested purchase_request' do
|
418
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
419
419
|
end
|
420
420
|
|
421
|
-
it
|
422
|
-
put :update, :id
|
421
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
422
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
423
423
|
assigns(:purchase_request).should eq(@purchase_request)
|
424
424
|
response.should redirect_to purchase_request_url(assigns(:purchase_request))
|
425
425
|
end
|
426
426
|
end
|
427
427
|
|
428
|
-
describe
|
429
|
-
it
|
430
|
-
put :update, :id
|
428
|
+
describe 'with invalid params' do
|
429
|
+
it 'assigns the purchase_request as @purchase_request' do
|
430
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
431
431
|
assigns(:purchase_request).should_not be_valid
|
432
432
|
end
|
433
433
|
|
434
434
|
it "re-renders the 'edit' template" do
|
435
|
-
put :update, :id
|
436
|
-
response.should render_template(
|
435
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
436
|
+
response.should render_template('edit')
|
437
437
|
end
|
438
438
|
end
|
439
439
|
end
|
440
440
|
|
441
|
-
describe
|
441
|
+
describe 'When logged in as User' do
|
442
442
|
login_fixture_user
|
443
443
|
|
444
|
-
describe
|
445
|
-
it
|
446
|
-
put :update, :id
|
444
|
+
describe 'with valid params' do
|
445
|
+
it 'updates the requested purchase_request' do
|
446
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
447
447
|
end
|
448
448
|
|
449
|
-
it
|
450
|
-
put :update, :id
|
449
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
450
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
451
451
|
assigns(:purchase_request).should eq(@purchase_request)
|
452
452
|
response.should be_forbidden
|
453
453
|
end
|
454
454
|
end
|
455
455
|
|
456
|
-
describe
|
457
|
-
it
|
458
|
-
put :update, :id
|
456
|
+
describe 'with invalid params' do
|
457
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
458
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
459
459
|
response.should be_forbidden
|
460
460
|
end
|
461
461
|
end
|
462
462
|
|
463
|
-
it
|
464
|
-
put :update, :id
|
463
|
+
it 'should update my purchase_request' do
|
464
|
+
put :update, params: { id: purchase_requests(:purchase_request_00003).id, purchase_request: { note: 'test' } }
|
465
465
|
response.should redirect_to purchase_request_url(assigns(:purchase_request))
|
466
466
|
end
|
467
467
|
|
468
468
|
it "should not update other user's purchase_request" do
|
469
|
-
put :update, :id
|
469
|
+
put :update, params: { id: purchase_requests(:purchase_request_00002).id, purchase_request: { note: 'test' } }
|
470
470
|
response.should be_forbidden
|
471
471
|
end
|
472
472
|
end
|
473
473
|
|
474
|
-
describe
|
475
|
-
describe
|
476
|
-
it
|
477
|
-
put :update, :id
|
474
|
+
describe 'When not logged in' do
|
475
|
+
describe 'with valid params' do
|
476
|
+
it 'updates the requested purchase_request' do
|
477
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
478
478
|
end
|
479
479
|
|
480
|
-
it
|
481
|
-
put :update, :id
|
480
|
+
it 'should be forbidden' do
|
481
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
|
482
482
|
response.should redirect_to(new_user_session_url)
|
483
483
|
end
|
484
484
|
end
|
485
485
|
|
486
|
-
describe
|
487
|
-
it
|
488
|
-
put :update, :id
|
486
|
+
describe 'with invalid params' do
|
487
|
+
it 'assigns the requested purchase_request as @purchase_request' do
|
488
|
+
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
|
489
489
|
response.should redirect_to(new_user_session_url)
|
490
490
|
end
|
491
491
|
end
|
492
492
|
end
|
493
493
|
end
|
494
494
|
|
495
|
-
describe
|
495
|
+
describe 'DELETE destroy' do
|
496
496
|
before(:each) do
|
497
497
|
@purchase_request = purchase_requests(:purchase_request_00001)
|
498
498
|
end
|
499
499
|
|
500
|
-
describe
|
500
|
+
describe 'When logged in as Administrator' do
|
501
501
|
login_admin
|
502
502
|
|
503
|
-
it
|
504
|
-
delete :destroy, :id
|
503
|
+
it 'destroys the requested purchase_request' do
|
504
|
+
delete :destroy, params: { id: @purchase_request.id }
|
505
505
|
end
|
506
506
|
|
507
|
-
it
|
508
|
-
delete :destroy, :id
|
507
|
+
it 'redirects to the purchase_requests list' do
|
508
|
+
delete :destroy, params: { id: @purchase_request.id }
|
509
509
|
response.should redirect_to purchase_requests_url
|
510
510
|
end
|
511
511
|
end
|
512
512
|
|
513
|
-
describe
|
513
|
+
describe 'When logged in as Librarian' do
|
514
514
|
login_fixture_librarian
|
515
515
|
|
516
|
-
it
|
517
|
-
delete :destroy, :id
|
516
|
+
it 'destroys the requested purchase_request' do
|
517
|
+
delete :destroy, params: { id: @purchase_request.id }
|
518
518
|
end
|
519
519
|
|
520
|
-
it
|
521
|
-
delete :destroy, :id
|
520
|
+
it 'redirects to the purchase_requests list' do
|
521
|
+
delete :destroy, params: { id: @purchase_request.id }
|
522
522
|
response.should redirect_to purchase_requests_url
|
523
523
|
end
|
524
524
|
|
525
525
|
it "should destroy other user's purchase request" do
|
526
|
-
delete :destroy, :id
|
526
|
+
delete :destroy, params: { id: purchase_requests(:purchase_request_00003).id }
|
527
527
|
response.should redirect_to purchase_requests_url
|
528
528
|
end
|
529
529
|
end
|
530
530
|
|
531
|
-
describe
|
531
|
+
describe 'When logged in as User' do
|
532
532
|
login_fixture_user
|
533
533
|
|
534
|
-
it
|
535
|
-
delete :destroy, :id
|
534
|
+
it 'destroys the requested purchase_request' do
|
535
|
+
delete :destroy, params: { id: @purchase_request.id }
|
536
536
|
end
|
537
537
|
|
538
|
-
it
|
539
|
-
delete :destroy, :id
|
538
|
+
it 'should be forbidden' do
|
539
|
+
delete :destroy, params: { id: @purchase_request.id }
|
540
540
|
response.should be_forbidden
|
541
541
|
end
|
542
542
|
|
543
|
-
it
|
544
|
-
delete :destroy, :id
|
543
|
+
it 'should destroy my purchase_request' do
|
544
|
+
delete :destroy, params: { id: purchase_requests(:purchase_request_00003).id }
|
545
545
|
response.should redirect_to purchase_requests_url
|
546
546
|
end
|
547
547
|
|
548
548
|
it "should not destroy other user's purchase_request" do
|
549
|
-
delete :destroy, :id
|
549
|
+
delete :destroy, params: { id: purchase_requests(:purchase_request_00002).id }
|
550
550
|
response.should be_forbidden
|
551
551
|
end
|
552
552
|
end
|
553
553
|
|
554
|
-
describe
|
555
|
-
it
|
556
|
-
delete :destroy, :id
|
554
|
+
describe 'When not logged in' do
|
555
|
+
it 'destroys the requested purchase_request' do
|
556
|
+
delete :destroy, params: { id: @purchase_request.id }
|
557
557
|
end
|
558
558
|
|
559
|
-
it
|
560
|
-
delete :destroy, :id
|
559
|
+
it 'should be forbidden' do
|
560
|
+
delete :destroy, params: { id: @purchase_request.id }
|
561
561
|
response.should redirect_to(new_user_session_url)
|
562
562
|
end
|
563
563
|
end
|