enju_trunk_subject 1.0.4
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 +15 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/controllers/classification_types_controller.rb +13 -0
- data/app/controllers/classifications_controller.rb +114 -0
- data/app/controllers/subject_has_classifications_controller.rb +97 -0
- data/app/controllers/subject_heading_type_has_subjects_controller.rb +80 -0
- data/app/controllers/subject_heading_types_controller.rb +13 -0
- data/app/controllers/subject_types_controller.rb +13 -0
- data/app/controllers/subjects_controller.rb +216 -0
- data/app/controllers/work_has_subjects_controller.rb +107 -0
- data/app/models/classification.rb +89 -0
- data/app/models/classification_type.rb +20 -0
- data/app/models/enju_subject/ability.rb +55 -0
- data/app/models/subject.rb +100 -0
- data/app/models/subject_has_classification.rb +37 -0
- data/app/models/subject_heading_type.rb +21 -0
- data/app/models/subject_heading_type_has_subject.rb +22 -0
- data/app/models/subject_type.rb +20 -0
- data/app/models/work_has_subject.rb +35 -0
- data/app/views/classification_types/_form.html.erb +19 -0
- data/app/views/classification_types/edit.html.erb +13 -0
- data/app/views/classification_types/index.html.erb +45 -0
- data/app/views/classification_types/new.html.erb +12 -0
- data/app/views/classification_types/show.html.erb +30 -0
- data/app/views/classifications/_form.html.erb +27 -0
- data/app/views/classifications/edit.html.erb +13 -0
- data/app/views/classifications/index.html.erb +54 -0
- data/app/views/classifications/new.html.erb +12 -0
- data/app/views/classifications/show.html.erb +34 -0
- data/app/views/manifestations/_classification_detail.html.erb +14 -0
- data/app/views/manifestations/_subject_detail.html.erb +14 -0
- data/app/views/manifestations/_subject_facet.html.erb +18 -0
- data/app/views/manifestations/_subject_form.html.erb +21 -0
- data/app/views/subject_has_classifications/edit.html.erb +30 -0
- data/app/views/subject_has_classifications/index.html.erb +38 -0
- data/app/views/subject_has_classifications/new.html.erb +32 -0
- data/app/views/subject_has_classifications/show.html.erb +22 -0
- data/app/views/subject_heading_type_has_subjects/edit.html.erb +28 -0
- data/app/views/subject_heading_type_has_subjects/index.html.erb +30 -0
- data/app/views/subject_heading_type_has_subjects/new.html.erb +27 -0
- data/app/views/subject_heading_type_has_subjects/show.html.erb +23 -0
- data/app/views/subject_heading_types/_form.html.erb +19 -0
- data/app/views/subject_heading_types/edit.html.erb +13 -0
- data/app/views/subject_heading_types/index.html.erb +43 -0
- data/app/views/subject_heading_types/new.html.erb +12 -0
- data/app/views/subject_heading_types/show.html.erb +27 -0
- data/app/views/subject_types/_form.html.erb +19 -0
- data/app/views/subject_types/edit.html.erb +13 -0
- data/app/views/subject_types/index.html.erb +43 -0
- data/app/views/subject_types/new.html.erb +12 -0
- data/app/views/subject_types/show.html.erb +29 -0
- data/app/views/subjects/_form.html.erb +42 -0
- data/app/views/subjects/_index.html.erb +48 -0
- data/app/views/subjects/_index_classification.html.erb +57 -0
- data/app/views/subjects/_index_work.html.erb +60 -0
- data/app/views/subjects/_show_work_list.html.erb +15 -0
- data/app/views/subjects/edit.html.erb +13 -0
- data/app/views/subjects/index.atom.builder +10 -0
- data/app/views/subjects/index.html.erb +7 -0
- data/app/views/subjects/index.rss.builder +29 -0
- data/app/views/subjects/new.html.erb +12 -0
- data/app/views/subjects/show.html.erb +69 -0
- data/app/views/subjects/show.js.erb +1 -0
- data/app/views/work_has_subjects/_form.html.erb +24 -0
- data/app/views/work_has_subjects/edit.html.erb +29 -0
- data/app/views/work_has_subjects/index.html.erb +31 -0
- data/app/views/work_has_subjects/new.html.erb +42 -0
- data/app/views/work_has_subjects/show.html.erb +25 -0
- data/config/locales/translation_en.yml +35 -0
- data/config/locales/translation_ja.yml +39 -0
- data/config/routes.rb +7 -0
- data/db/fixtures/classification_types.yml +7 -0
- data/db/fixtures/subject_types.yml +28 -0
- data/db/migrate/029_create_subjects.rb +28 -0
- data/db/migrate/142_create_classifications.rb +19 -0
- data/db/migrate/144_create_classification_types.rb +16 -0
- data/db/migrate/145_create_subject_heading_types.rb +16 -0
- data/db/migrate/146_create_subject_types.rb +16 -0
- data/db/migrate/20110913120629_add_lft_and_rgt_to_classification.rb +11 -0
- data/db/migrate/20140427142354_add_classifiation_identifier_to_classification.rb +6 -0
- data/lib/enju_subject.rb +33 -0
- data/lib/enju_subject/engine.rb +8 -0
- data/lib/enju_subject/manifestation.rb +31 -0
- data/lib/enju_subject/master_model.rb +41 -0
- data/lib/enju_subject/version.rb +3 -0
- data/lib/generators/enju_subject/setup/USAGE +8 -0
- data/lib/generators/enju_subject/setup/setup_generator.rb +10 -0
- data/lib/generators/enju_subject/setup/templates/db/fixtures/classification_types.yml +13 -0
- data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_heading_types.yml +39 -0
- data/lib/generators/enju_subject/setup/templates/db/fixtures/subject_types.yml +28 -0
- data/lib/tasks/enju_subject_tasks.rake +19 -0
- data/spec/controllers/classification_types_controller_spec.rb +445 -0
- data/spec/controllers/classifications_controller_spec.rb +441 -0
- data/spec/controllers/subject_heading_types_controller_spec.rb +445 -0
- data/spec/controllers/subject_types_controller_spec.rb +447 -0
- data/spec/controllers/subjects_controller_spec.rb +437 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +47 -0
- data/spec/dummy/app/helpers/application_helper.rb +21 -0
- data/spec/dummy/app/models/ability.rb +59 -0
- data/spec/dummy/app/models/setting.rb +4 -0
- data/spec/dummy/app/models/user.rb +43 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +46 -0
- data/spec/dummy/config/application.yml +38 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +207 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +57 -0
- data/spec/dummy/config/locales/en.yml +18 -0
- data/spec/dummy/config/locales/ja.yml +18 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/fixtures/roles.yml +25 -0
- data/spec/dummy/db/migrate/001_create_agents.rb +53 -0
- data/spec/dummy/db/migrate/005_create_manifestations.rb +56 -0
- data/spec/dummy/db/migrate/006_create_items.rb +24 -0
- data/spec/dummy/db/migrate/012_create_owns.rb +12 -0
- data/spec/dummy/db/migrate/015_create_creates.rb +12 -0
- data/spec/dummy/db/migrate/047_create_produces.rb +12 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +11 -0
- data/spec/dummy/db/migrate/077_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +18 -0
- data/spec/dummy/db/migrate/112_create_frequencies.rb +12 -0
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +12 -0
- data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/125_create_donates.rb +12 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
- data/spec/dummy/db/migrate/131_create_request_types.rb +12 -0
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +13 -0
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +13 -0
- data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +12 -0
- 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/20081025083323_create_countries.rb +28 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +23 -0
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +15 -0
- data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +22 -0
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +22 -0
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +15 -0
- data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +15 -0
- data/spec/dummy/db/migrate/20090719201843_create_extents.rb +12 -0
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +12 -0
- data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +12 -0
- data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +27 -0
- data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +12 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +13 -0
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +15 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +13 -0
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100606073747_create_agent_relationships.rb +13 -0
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +12 -0
- data/spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb +11 -0
- data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +15 -0
- data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +12 -0
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb +11 -0
- data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +9 -0
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +11 -0
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +9 -0
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +12 -0
- data/spec/dummy/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +13 -0
- data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +13 -0
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +13 -0
- data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +13 -0
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +10 -0
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +9 -0
- data/spec/dummy/db/migrate/20111009183423_add_ndc_to_manifestation.rb +9 -0
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +12 -0
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +7 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +8 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +49 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +6 -0
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +6 -0
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +6 -0
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120413170720_add_error_message_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +9 -0
- data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb +6 -0
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +26 -0
- data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
- data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
- data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +12 -0
- data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +15 -0
- data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +5 -0
- data/spec/dummy/db/schema.rb +901 -0
- data/spec/dummy/db/seeds.rb +32 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/fixtures/subjects.yml +72 -0
- data/spec/dummy/test/fixtures/user_groups.yml +13 -0
- data/spec/dummy/test/fixtures/user_has_roles.yml +9 -0
- data/spec/dummy/test/fixtures/users.yml +11 -0
- data/spec/dummy/test/unit/user_group_test.rb +7 -0
- data/spec/dummy/test/unit/user_has_role_test.rb +7 -0
- data/spec/dummy/test/unit/user_test.rb +7 -0
- data/spec/factories/classification.rb +6 -0
- data/spec/factories/classification_type.rb +5 -0
- data/spec/factories/manifestation.rb +6 -0
- data/spec/factories/subject.rb +7 -0
- data/spec/factories/subject_heading_type.rb +5 -0
- data/spec/factories/subject_heading_type_has_subject.rb +6 -0
- data/spec/factories/subject_type.rb +5 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/agent_types.yml +35 -0
- data/spec/fixtures/agents.yml +143 -0
- data/spec/fixtures/carrier_types.yml +51 -0
- data/spec/fixtures/classification_types.yml +188 -0
- data/spec/fixtures/classifications.yml +118 -0
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/library_groups.yml +33 -0
- data/spec/fixtures/manifestations.yml +22 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/shtsv.tsv +3 -0
- data/spec/fixtures/subject_heading_types.yml +39 -0
- data/spec/fixtures/subject_types.yml +42 -0
- data/spec/fixtures/subjects.yml +80 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/classification_spec.rb +46 -0
- data/spec/models/classification_type_spec.rb +21 -0
- data/spec/models/subject_heading_type_spec.rb +21 -0
- data/spec/models/subject_spec.rb +33 -0
- data/spec/models/subject_type_spec.rb +21 -0
- data/spec/requests/subjects_spec.rb +9 -0
- data/spec/routing/subject_heading_types_routing_spec.rb +35 -0
- data/spec/routing/subject_types_routing_spec.rb +35 -0
- data/spec/routing/subjects_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +3 -0
- metadata +675 -0
@@ -0,0 +1,447 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sunspot/rails/spec_helper'
|
3
|
+
|
4
|
+
describe SubjectTypesController do
|
5
|
+
fixtures :all
|
6
|
+
disconnect_sunspot
|
7
|
+
|
8
|
+
def valid_attributes
|
9
|
+
FactoryGirl.attributes_for(:subject_type)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "GET index" do
|
13
|
+
before(:each) do
|
14
|
+
FactoryGirl.create(:subject_type)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "When logged in as Administrator" do
|
18
|
+
login_admin
|
19
|
+
|
20
|
+
it "assigns all subject_types as @subject_types" do
|
21
|
+
get :index
|
22
|
+
assigns(:subject_types).should eq(SubjectType.all)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "When logged in as Librarian" do
|
27
|
+
login_librarian
|
28
|
+
|
29
|
+
it "assigns all subject_types as @subject_types" do
|
30
|
+
get :index
|
31
|
+
assigns(:subject_types).should eq(SubjectType.all)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "When logged in as User" do
|
36
|
+
login_user
|
37
|
+
|
38
|
+
it "assigns all subject_types as @subject_types" do
|
39
|
+
get :index
|
40
|
+
assigns(:subject_types).should be_empty
|
41
|
+
response.should be_forbidden
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "When not logged in" do
|
46
|
+
it "assigns all subject_types as @subject_types" do
|
47
|
+
get :index
|
48
|
+
assigns(:subject_types).should be_empty
|
49
|
+
response.should redirect_to(new_user_session_url)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "GET show" do
|
55
|
+
describe "When logged in as Administrator" do
|
56
|
+
login_admin
|
57
|
+
|
58
|
+
it "assigns the requested subject_type as @subject_type" do
|
59
|
+
subject_type = FactoryGirl.create(:subject_type)
|
60
|
+
get :show, :id => subject_type.id
|
61
|
+
assigns(:subject_type).should eq(subject_type)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "When logged in as Librarian" do
|
66
|
+
login_librarian
|
67
|
+
|
68
|
+
it "assigns the requested subject_type as @subject_type" do
|
69
|
+
subject_type = FactoryGirl.create(:subject_type)
|
70
|
+
get :show, :id => subject_type.id
|
71
|
+
assigns(:subject_type).should eq(subject_type)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "When logged in as User" do
|
76
|
+
login_user
|
77
|
+
|
78
|
+
it "assigns the requested subject_type as @subject_type" do
|
79
|
+
subject_type = FactoryGirl.create(:subject_type)
|
80
|
+
get :show, :id => subject_type.id
|
81
|
+
assigns(:subject_type).should eq(subject_type)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "When not logged in" do
|
86
|
+
it "assigns the requested subject_type as @subject_type" do
|
87
|
+
subject_type = FactoryGirl.create(:subject_type)
|
88
|
+
get :show, :id => subject_type.id
|
89
|
+
assigns(:subject_type).should eq(subject_type)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "GET new" do
|
95
|
+
describe "When logged in as Administrator" do
|
96
|
+
login_admin
|
97
|
+
|
98
|
+
it "assigns the requested subject_type as @subject_type" do
|
99
|
+
get :new
|
100
|
+
assigns(:subject_type).should_not be_valid
|
101
|
+
response.should be_success
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "When logged in as Librarian" do
|
106
|
+
login_librarian
|
107
|
+
|
108
|
+
it "should not assign the requested subject_type as @subject_type" do
|
109
|
+
get :new
|
110
|
+
assigns(:subject_type).should_not be_valid
|
111
|
+
response.should be_forbidden
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "When logged in as User" do
|
116
|
+
login_user
|
117
|
+
|
118
|
+
it "should not assign the requested subject_type as @subject_type" do
|
119
|
+
get :new
|
120
|
+
assigns(:subject_type).should_not be_valid
|
121
|
+
response.should be_forbidden
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "When not logged in" do
|
126
|
+
it "should not assign the requested subject_type as @subject_type" do
|
127
|
+
get :new
|
128
|
+
assigns(:subject_type).should_not be_valid
|
129
|
+
response.should redirect_to(new_user_session_url)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "GET edit" do
|
135
|
+
describe "When logged in as Administrator" do
|
136
|
+
login_admin
|
137
|
+
|
138
|
+
it "assigns the requested subject_type as @subject_type" do
|
139
|
+
subject_type = FactoryGirl.create(:subject_type)
|
140
|
+
get :edit, :id => subject_type.id
|
141
|
+
assigns(:subject_type).should eq(subject_type)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "When logged in as Librarian" do
|
146
|
+
login_librarian
|
147
|
+
|
148
|
+
it "assigns the requested subject_type as @subject_type" do
|
149
|
+
subject_type = FactoryGirl.create(:subject_type)
|
150
|
+
get :edit, :id => subject_type.id
|
151
|
+
response.should be_forbidden
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "When logged in as User" do
|
156
|
+
login_user
|
157
|
+
|
158
|
+
it "assigns the requested subject_type as @subject_type" do
|
159
|
+
subject_type = FactoryGirl.create(:subject_type)
|
160
|
+
get :edit, :id => subject_type.id
|
161
|
+
response.should be_forbidden
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "When not logged in" do
|
166
|
+
it "should not assign the requested subject_type as @subject_type" do
|
167
|
+
subject_type = FactoryGirl.create(:subject_type)
|
168
|
+
get :edit, :id => subject_type.id
|
169
|
+
response.should redirect_to(new_user_session_url)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "POST create" do
|
175
|
+
before(:each) do
|
176
|
+
@attrs = valid_attributes
|
177
|
+
@invalid_attrs = {:name => ''}
|
178
|
+
end
|
179
|
+
|
180
|
+
describe "When logged in as Administrator" do
|
181
|
+
login_admin
|
182
|
+
|
183
|
+
describe "with valid params" do
|
184
|
+
it "assigns a newly created subject_type as @subject_type" do
|
185
|
+
post :create, :subject_type => @attrs
|
186
|
+
assigns(:subject_type).should be_valid
|
187
|
+
end
|
188
|
+
|
189
|
+
it "redirects to the created agent" do
|
190
|
+
post :create, :subject_type => @attrs
|
191
|
+
response.should redirect_to(assigns(:subject_type))
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "with invalid params" do
|
196
|
+
it "assigns a newly created but unsaved subject_type as @subject_type" do
|
197
|
+
post :create, :subject_type => @invalid_attrs
|
198
|
+
assigns(:subject_type).should_not be_valid
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should be successful" do
|
202
|
+
post :create, :subject_type => @invalid_attrs
|
203
|
+
response.should be_success
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe "When logged in as Librarian" do
|
209
|
+
login_librarian
|
210
|
+
|
211
|
+
describe "with valid params" do
|
212
|
+
it "assigns a newly created subject_type as @subject_type" do
|
213
|
+
post :create, :subject_type => @attrs
|
214
|
+
assigns(:subject_type).should be_valid
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should be forbidden" do
|
218
|
+
post :create, :subject_type => @attrs
|
219
|
+
response.should be_forbidden
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "with invalid params" do
|
224
|
+
it "assigns a newly created but unsaved subject_type as @subject_type" do
|
225
|
+
post :create, :subject_type => @invalid_attrs
|
226
|
+
assigns(:subject_type).should_not be_valid
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should be forbidden" do
|
230
|
+
post :create, :subject_type => @invalid_attrs
|
231
|
+
response.should be_forbidden
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "When logged in as User" do
|
237
|
+
login_user
|
238
|
+
|
239
|
+
describe "with valid params" do
|
240
|
+
it "assigns a newly created subject_type as @subject_type" do
|
241
|
+
post :create, :subject_type => @attrs
|
242
|
+
assigns(:subject_type).should be_valid
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should be forbidden" do
|
246
|
+
post :create, :subject_type => @attrs
|
247
|
+
response.should be_forbidden
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe "with invalid params" do
|
252
|
+
it "assigns a newly created but unsaved subject_type as @subject_type" do
|
253
|
+
post :create, :subject_type => @invalid_attrs
|
254
|
+
assigns(:subject_type).should_not be_valid
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should be forbidden" do
|
258
|
+
post :create, :subject_type => @invalid_attrs
|
259
|
+
response.should be_forbidden
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe "When not logged in" do
|
265
|
+
describe "with valid params" do
|
266
|
+
it "assigns a newly created subject_type as @subject_type" do
|
267
|
+
post :create, :subject_type => @attrs
|
268
|
+
assigns(:subject_type).should be_valid
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should be forbidden" do
|
272
|
+
post :create, :subject_type => @attrs
|
273
|
+
response.should redirect_to(new_user_session_url)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "with invalid params" do
|
278
|
+
it "assigns a newly created but unsaved subject_type as @subject_type" do
|
279
|
+
post :create, :subject_type => @invalid_attrs
|
280
|
+
assigns(:subject_type).should_not be_valid
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should be forbidden" do
|
284
|
+
post :create, :subject_type => @invalid_attrs
|
285
|
+
response.should redirect_to(new_user_session_url)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
describe "PUT update" do
|
292
|
+
before(:each) do
|
293
|
+
@subject_type = FactoryGirl.create(:subject_type)
|
294
|
+
@attrs = valid_attributes
|
295
|
+
@invalid_attrs = {:name => ''}
|
296
|
+
end
|
297
|
+
|
298
|
+
describe "When logged in as Administrator" do
|
299
|
+
login_admin
|
300
|
+
|
301
|
+
describe "with valid params" do
|
302
|
+
it "updates the requested subject_type" do
|
303
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
304
|
+
end
|
305
|
+
|
306
|
+
it "assigns the requested subject_type as @subject_type" do
|
307
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
308
|
+
assigns(:subject_type).should eq(@subject_type)
|
309
|
+
end
|
310
|
+
|
311
|
+
it "moves its position when specified" do
|
312
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs, :move => 'lower'
|
313
|
+
response.should redirect_to(subject_types_url)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
describe "with invalid params" do
|
318
|
+
it "assigns the requested subject_type as @subject_type" do
|
319
|
+
put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
|
320
|
+
response.should render_template("edit")
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe "When logged in as Librarian" do
|
326
|
+
login_librarian
|
327
|
+
|
328
|
+
describe "with valid params" do
|
329
|
+
it "updates the requested subject_type" do
|
330
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
331
|
+
end
|
332
|
+
|
333
|
+
it "assigns the requested subject_type as @subject_type" do
|
334
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
335
|
+
assigns(:subject_type).should eq(@subject_type)
|
336
|
+
response.should be_forbidden
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
describe "with invalid params" do
|
341
|
+
it "assigns the requested subject_type as @subject_type" do
|
342
|
+
put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
|
343
|
+
response.should be_forbidden
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
describe "When logged in as User" do
|
349
|
+
login_user
|
350
|
+
|
351
|
+
describe "with valid params" do
|
352
|
+
it "updates the requested subject_type" do
|
353
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
354
|
+
end
|
355
|
+
|
356
|
+
it "assigns the requested subject_type as @subject_type" do
|
357
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
358
|
+
assigns(:subject_type).should eq(@subject_type)
|
359
|
+
response.should be_forbidden
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
describe "with invalid params" do
|
364
|
+
it "assigns the requested subject_type as @subject_type" do
|
365
|
+
put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
|
366
|
+
response.should be_forbidden
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
describe "When not logged in" do
|
372
|
+
describe "with valid params" do
|
373
|
+
it "updates the requested subject_type" do
|
374
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should be forbidden" do
|
378
|
+
put :update, :id => @subject_type.id, :subject_type => @attrs
|
379
|
+
response.should redirect_to(new_user_session_url)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
383
|
+
describe "with invalid params" do
|
384
|
+
it "assigns the requested subject_type as @subject_type" do
|
385
|
+
put :update, :id => @subject_type.id, :subject_type => @invalid_attrs
|
386
|
+
response.should redirect_to(new_user_session_url)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
describe "DELETE destroy" do
|
393
|
+
before(:each) do
|
394
|
+
@subject_type = FactoryGirl.create(:subject_type)
|
395
|
+
end
|
396
|
+
|
397
|
+
describe "When logged in as Administrator" do
|
398
|
+
login_admin
|
399
|
+
|
400
|
+
it "destroys the requested subject_type" do
|
401
|
+
delete :destroy, :id => @subject_type.id
|
402
|
+
end
|
403
|
+
|
404
|
+
it "redirects to the subject_types list" do
|
405
|
+
delete :destroy, :id => @subject_type.id
|
406
|
+
response.should redirect_to(subject_types_url)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
describe "When logged in as Librarian" do
|
411
|
+
login_librarian
|
412
|
+
|
413
|
+
it "destroys the requested subject_type" do
|
414
|
+
delete :destroy, :id => @subject_type.id
|
415
|
+
end
|
416
|
+
|
417
|
+
it "should be forbidden" do
|
418
|
+
delete :destroy, :id => @subject_type.id
|
419
|
+
response.should be_forbidden
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
describe "When logged in as User" do
|
424
|
+
login_user
|
425
|
+
|
426
|
+
it "destroys the requested subject_type" do
|
427
|
+
delete :destroy, :id => @subject_type.id
|
428
|
+
end
|
429
|
+
|
430
|
+
it "should be forbidden" do
|
431
|
+
delete :destroy, :id => @subject_type.id
|
432
|
+
response.should be_forbidden
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
describe "When not logged in" do
|
437
|
+
it "destroys the requested subject_type" do
|
438
|
+
delete :destroy, :id => @subject_type.id
|
439
|
+
end
|
440
|
+
|
441
|
+
it "should be forbidden" do
|
442
|
+
delete :destroy, :id => @subject_type.id
|
443
|
+
response.should redirect_to(new_user_session_url)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
@@ -0,0 +1,437 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SubjectsController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
def valid_attributes
|
7
|
+
FactoryGirl.attributes_for(:subject)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "GET index", :solr => true do
|
11
|
+
before do
|
12
|
+
Subject.reindex
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "When logged in as Administrator" do
|
16
|
+
login_admin
|
17
|
+
|
18
|
+
it "assigns all subjects as @subjects" do
|
19
|
+
get :index
|
20
|
+
assigns(:subjects).should_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "When logged in as Librarian" do
|
25
|
+
login_librarian
|
26
|
+
|
27
|
+
it "assigns all subjects as @subjects" do
|
28
|
+
get :index
|
29
|
+
assigns(:subjects).should_not be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "When logged in as User" do
|
34
|
+
login_user
|
35
|
+
|
36
|
+
it "assigns all subjects as @subjects" do
|
37
|
+
get :index
|
38
|
+
assigns(:subjects).should_not be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "When not logged in" do
|
43
|
+
it "assigns all subjects as @subjects" do
|
44
|
+
get :index
|
45
|
+
response.should be_success
|
46
|
+
assigns(:subjects).should_not be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "GET show", :solr => true do
|
52
|
+
describe "When logged in as Administrator" do
|
53
|
+
login_admin
|
54
|
+
|
55
|
+
it "assigns the requested subject as @subject" do
|
56
|
+
subject = FactoryGirl.create(:subject)
|
57
|
+
get :show, :id => subject.id
|
58
|
+
assigns(:subject).should eq(subject)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "When logged in as Librarian" do
|
63
|
+
login_librarian
|
64
|
+
|
65
|
+
it "assigns the requested subject as @subject" do
|
66
|
+
subject = FactoryGirl.create(:subject)
|
67
|
+
get :show, :id => subject.id
|
68
|
+
assigns(:subject).should eq(subject)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "When logged in as User" do
|
73
|
+
login_user
|
74
|
+
|
75
|
+
it "assigns the requested subject as @subject" do
|
76
|
+
subject = FactoryGirl.create(:subject)
|
77
|
+
get :show, :id => subject.id
|
78
|
+
assigns(:subject).should eq(subject)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "When not logged in" do
|
83
|
+
it "assigns the requested subject as @subject" do
|
84
|
+
subject = FactoryGirl.create(:subject)
|
85
|
+
get :show, :id => subject.id
|
86
|
+
assigns(:subject).should eq(subject)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "GET new" do
|
92
|
+
describe "When logged in as Administrator" do
|
93
|
+
login_admin
|
94
|
+
|
95
|
+
it "assigns the requested subject as @subject" do
|
96
|
+
get :new
|
97
|
+
assigns(:subject).should_not be_valid
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "When logged in as Librarian" do
|
102
|
+
login_librarian
|
103
|
+
|
104
|
+
it "assigns the requested subject as @subject" do
|
105
|
+
get :new
|
106
|
+
assigns(:subject).should_not be_valid
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "When logged in as User" do
|
111
|
+
login_user
|
112
|
+
|
113
|
+
it "should not assign the requested subject as @subject" do
|
114
|
+
get :new
|
115
|
+
assigns(:subject).should_not be_valid
|
116
|
+
response.should be_forbidden
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe "When not logged in" do
|
121
|
+
it "should not assign the requested subject as @subject" do
|
122
|
+
get :new
|
123
|
+
assigns(:subject).should_not be_valid
|
124
|
+
response.should redirect_to(new_user_session_url)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "GET edit" do
|
130
|
+
describe "When logged in as Administrator" do
|
131
|
+
login_admin
|
132
|
+
|
133
|
+
it "assigns the requested subject as @subject" do
|
134
|
+
subject = FactoryGirl.create(:subject)
|
135
|
+
get :edit, :id => subject.id
|
136
|
+
assigns(:subject).should eq(subject)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "When logged in as Librarian" do
|
141
|
+
login_librarian
|
142
|
+
|
143
|
+
it "assigns the requested subject as @subject" do
|
144
|
+
subject = FactoryGirl.create(:subject)
|
145
|
+
get :edit, :id => subject.id
|
146
|
+
assigns(:subject).should eq(subject)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "When logged in as User" do
|
151
|
+
login_user
|
152
|
+
|
153
|
+
it "assigns the requested subject as @subject" do
|
154
|
+
subject = FactoryGirl.create(:subject)
|
155
|
+
get :edit, :id => subject.id
|
156
|
+
response.should be_forbidden
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "When not logged in" do
|
161
|
+
it "should not assign the requested subject as @subject" do
|
162
|
+
subject = FactoryGirl.create(:subject)
|
163
|
+
get :edit, :id => subject.id
|
164
|
+
response.should redirect_to(new_user_session_url)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "POST create" do
|
170
|
+
before(:each) do
|
171
|
+
@attrs = valid_attributes
|
172
|
+
@invalid_attrs = {:term => ''}
|
173
|
+
end
|
174
|
+
|
175
|
+
describe "When logged in as Administrator" do
|
176
|
+
login_admin
|
177
|
+
|
178
|
+
describe "with valid params" do
|
179
|
+
it "assigns a newly created subject as @subject" do
|
180
|
+
post :create, :subject => @attrs
|
181
|
+
assigns(:subject).should be_valid
|
182
|
+
end
|
183
|
+
|
184
|
+
it "redirects to the created subject" do
|
185
|
+
post :create, :subject => @attrs
|
186
|
+
response.should redirect_to(subject_url(assigns(:subject)))
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "with invalid params" do
|
191
|
+
it "assigns a newly created but unsaved subject as @subject" do
|
192
|
+
post :create, :subject => @invalid_attrs
|
193
|
+
assigns(:subject).should_not be_valid
|
194
|
+
end
|
195
|
+
|
196
|
+
it "re-renders the 'new' template" do
|
197
|
+
post :create, :subject => @invalid_attrs
|
198
|
+
response.should render_template("new")
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "When logged in as Librarian" do
|
204
|
+
login_librarian
|
205
|
+
|
206
|
+
describe "with valid params" do
|
207
|
+
it "assigns a newly created subject as @subject" do
|
208
|
+
post :create, :subject => @attrs
|
209
|
+
assigns(:subject).should be_valid
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should be forbidden" do
|
213
|
+
post :create, :subject => @attrs
|
214
|
+
response.should be_forbidden
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
describe "with invalid params" do
|
219
|
+
it "assigns a newly created but unsaved subject as @subject" do
|
220
|
+
post :create, :subject => @invalid_attrs
|
221
|
+
assigns(:subject).should_not be_valid
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should be forbidden" do
|
225
|
+
post :create, :subject => @invalid_attrs
|
226
|
+
response.should be_forbidden
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "When logged in as User" do
|
232
|
+
login_user
|
233
|
+
|
234
|
+
describe "with valid params" do
|
235
|
+
it "assigns a newly created subject as @subject" do
|
236
|
+
post :create, :subject => @attrs
|
237
|
+
assigns(:subject).should be_valid
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should be forbidden" do
|
241
|
+
post :create, :subject => @attrs
|
242
|
+
response.should be_forbidden
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe "with invalid params" do
|
247
|
+
it "assigns a newly created but unsaved subject as @subject" do
|
248
|
+
post :create, :subject => @invalid_attrs
|
249
|
+
assigns(:subject).should_not be_valid
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should be forbidden" do
|
253
|
+
post :create, :subject => @invalid_attrs
|
254
|
+
response.should be_forbidden
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "When not logged in" do
|
260
|
+
describe "with valid params" do
|
261
|
+
it "assigns a newly created subject as @subject" do
|
262
|
+
post :create, :subject => @attrs
|
263
|
+
assigns(:subject).should be_valid
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should be forbidden" do
|
267
|
+
post :create, :subject => @attrs
|
268
|
+
response.should redirect_to(new_user_session_url)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "with invalid params" do
|
273
|
+
it "assigns a newly created but unsaved subject as @subject" do
|
274
|
+
post :create, :subject => @invalid_attrs
|
275
|
+
assigns(:subject).should_not be_valid
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should be forbidden" do
|
279
|
+
post :create, :subject => @invalid_attrs
|
280
|
+
response.should redirect_to(new_user_session_url)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
describe "PUT update" do
|
287
|
+
before(:each) do
|
288
|
+
@subject = FactoryGirl.create(:subject)
|
289
|
+
@attrs = valid_attributes
|
290
|
+
@invalid_attrs = {:term => ''}
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "When logged in as Administrator" do
|
294
|
+
login_admin
|
295
|
+
|
296
|
+
describe "with valid params" do
|
297
|
+
it "updates the requested subject" do
|
298
|
+
put :update, :id => @subject.id, :subject => @attrs
|
299
|
+
end
|
300
|
+
|
301
|
+
it "assigns the requested subject as @subject" do
|
302
|
+
put :update, :id => @subject.id, :subject => @attrs
|
303
|
+
assigns(:subject).should eq(@subject)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
describe "with invalid params" do
|
308
|
+
it "assigns the requested subject as @subject" do
|
309
|
+
put :update, :id => @subject.id, :subject => @invalid_attrs
|
310
|
+
response.should render_template("edit")
|
311
|
+
end
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
describe "When logged in as Librarian" do
|
316
|
+
login_librarian
|
317
|
+
|
318
|
+
describe "with valid params" do
|
319
|
+
it "updates the requested subject" do
|
320
|
+
put :update, :id => @subject.id, :subject => @attrs
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should be forbidden" do
|
324
|
+
put :update, :id => @subject.id, :subject => @attrs
|
325
|
+
assigns(:subject).should eq(@subject)
|
326
|
+
response.should be_forbidden
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
describe "with invalid params" do
|
331
|
+
it "should be forbidden" do
|
332
|
+
put :update, :id => @subject, :subject => @invalid_attrs
|
333
|
+
response.should be_forbidden
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
describe "When logged in as User" do
|
339
|
+
login_user
|
340
|
+
|
341
|
+
describe "with valid params" do
|
342
|
+
it "updates the requested subject" do
|
343
|
+
put :update, :id => @subject.id, :subject => @attrs
|
344
|
+
end
|
345
|
+
|
346
|
+
it "assigns the requested subject as @subject" do
|
347
|
+
put :update, :id => @subject.id, :subject => @attrs
|
348
|
+
assigns(:subject).should eq(@subject)
|
349
|
+
response.should be_forbidden
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
describe "with invalid params" do
|
354
|
+
it "assigns the requested subject as @subject" do
|
355
|
+
put :update, :id => @subject.id, :subject => @invalid_attrs
|
356
|
+
response.should be_forbidden
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
describe "When not logged in" do
|
362
|
+
describe "with valid params" do
|
363
|
+
it "updates the requested subject" do
|
364
|
+
put :update, :id => @subject.id, :subject => @attrs
|
365
|
+
end
|
366
|
+
|
367
|
+
it "should be forbidden" do
|
368
|
+
put :update, :id => @subject.id, :subject => @attrs
|
369
|
+
response.should redirect_to(new_user_session_url)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
|
373
|
+
describe "with invalid params" do
|
374
|
+
it "assigns the requested subject as @subject" do
|
375
|
+
put :update, :id => @subject.id, :subject => @invalid_attrs
|
376
|
+
response.should redirect_to(new_user_session_url)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe "DELETE destroy" do
|
383
|
+
before(:each) do
|
384
|
+
@subject = FactoryGirl.create(:subject)
|
385
|
+
end
|
386
|
+
|
387
|
+
describe "When logged in as Administrator" do
|
388
|
+
login_admin
|
389
|
+
|
390
|
+
it "destroys the requested subject" do
|
391
|
+
delete :destroy, :id => @subject.id
|
392
|
+
end
|
393
|
+
|
394
|
+
it "redirects to the subjects list" do
|
395
|
+
delete :destroy, :id => @subject.id
|
396
|
+
response.should redirect_to(subjects_url)
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe "When logged in as Librarian" do
|
401
|
+
login_librarian
|
402
|
+
|
403
|
+
it "destroys the requested subject" do
|
404
|
+
delete :destroy, :id => @subject.id
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should be forbidden" do
|
408
|
+
delete :destroy, :id => @subject.id
|
409
|
+
response.should be_forbidden
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
describe "When logged in as User" do
|
414
|
+
login_user
|
415
|
+
|
416
|
+
it "destroys the requested subject" do
|
417
|
+
delete :destroy, :id => @subject.id
|
418
|
+
end
|
419
|
+
|
420
|
+
it "should be forbidden" do
|
421
|
+
delete :destroy, :id => @subject.id
|
422
|
+
response.should be_forbidden
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
describe "When not logged in" do
|
427
|
+
it "destroys the requested subject" do
|
428
|
+
delete :destroy, :id => @subject.id
|
429
|
+
end
|
430
|
+
|
431
|
+
it "should be forbidden" do
|
432
|
+
delete :destroy, :id => @subject.id
|
433
|
+
response.should redirect_to(new_user_session_url)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|