enju_seed 0.1.1.pre12 → 0.2.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/MIT-LICENSE +1 -1
- data/app/controllers/my_accounts_controller.rb +93 -0
- data/app/controllers/profiles_controller.rb +219 -0
- data/app/controllers/roles_controller.rb +61 -0
- data/app/models/concerns/master_model.rb +38 -0
- data/app/models/identity.rb +9 -0
- data/app/models/profile.rb +101 -0
- data/app/models/role.rb +50 -0
- data/app/models/user_has_role.rb +19 -0
- data/app/policies/application_policy.rb +53 -0
- data/app/policies/profile_policy.rb +55 -0
- data/app/policies/role_policy.rb +21 -0
- data/app/views/my_accounts/_edit_credential.html.erb +99 -0
- data/app/views/my_accounts/_form.html.erb +24 -0
- data/app/views/my_accounts/_show.html.erb +1 -0
- data/app/views/my_accounts/edit.html.erb +32 -0
- data/app/views/my_accounts/show.html+phone.erb +1 -0
- data/app/views/my_accounts/show.html.erb +49 -0
- data/app/views/profiles/_edit_credential.html.erb +88 -0
- data/app/views/profiles/_edit_profile.html.erb +42 -0
- data/app/views/profiles/_form.html.erb +15 -0
- data/app/views/profiles/_show.html.erb +1 -0
- data/app/views/profiles/edit.html.erb +33 -0
- data/app/views/profiles/index.html.erb +70 -0
- data/app/views/profiles/new.html.erb +88 -0
- data/app/views/profiles/show.html+phone.erb +1 -0
- data/app/views/profiles/show.html.erb +71 -0
- data/app/views/roles/_form.html.erb +19 -0
- data/app/views/roles/edit.html.erb +13 -0
- data/app/views/roles/index.html.erb +32 -0
- data/app/views/roles/new.html.erb +12 -0
- data/app/views/roles/show.html.erb +46 -0
- data/config/routes.rb +5 -0
- data/db/migrate/041_create_roles.rb +13 -0
- data/db/migrate/20100606065209_create_user_has_roles.rb +12 -0
- data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +16 -0
- data/db/migrate/20140122054321_create_profiles.rb +20 -0
- data/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +11 -0
- data/db/migrate/20140811031145_add_expired_at_to_profile.rb +5 -0
- data/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
- data/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
- data/db/migrate/20150421023923_create_identities.rb +15 -0
- data/db/migrate/20151126005552_add_provider_to_identity.rb +5 -0
- data/lib/enju_seed/engine.rb +8 -5
- data/lib/enju_seed/version.rb +1 -1
- data/spec/controllers/my_accounts_controller_spec.rb +229 -0
- data/spec/controllers/profiles_controller_spec.rb +594 -0
- data/spec/controllers/roles_controller_spec.rb +136 -0
- data/spec/dummy/README.rdoc +15 -248
- data/spec/dummy/Rakefile +1 -2
- data/spec/dummy/app/assets/javascripts/application.js +4 -6
- data/spec/dummy/app/assets/stylesheets/application.css +6 -4
- data/spec/dummy/app/controllers/application_controller.rb +9 -1
- data/spec/dummy/app/models/user.rb +9 -0
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +2 -2
- data/spec/dummy/config/application.rb +4 -35
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/database.yml +8 -8
- data/spec/dummy/config/environment.rb +3 -3
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +19 -14
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/devise.rb +274 -0
- data/spec/dummy/config/initializers/enju_leaf.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/routes.rb +24 -25
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/migrate/001_create_agents.rb +50 -0
- data/spec/dummy/db/migrate/002_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/005_create_manifestations.rb +43 -0
- data/spec/dummy/db/migrate/006_create_items.rb +21 -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/032_create_checkins.rb +17 -0
- data/spec/dummy/db/migrate/033_create_checkouts.rb +25 -0
- data/spec/dummy/db/migrate/035_create_reserves.rb +26 -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 +17 -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/121_create_checked_items.rb +17 -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/127_create_use_restrictions.rb +16 -0
- data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +16 -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/132_create_circulation_statuses.rb +16 -0
- data/spec/dummy/db/migrate/133_create_agent_merges.rb +15 -0
- data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +13 -0
- data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
- data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
- data/spec/dummy/db/migrate/20080830154109_create_realizes.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 +20 -0
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +20 -0
- data/spec/dummy/db/migrate/20081030023412_create_checkout_types.rb +17 -0
- data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +25 -0
- data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +18 -0
- data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +17 -0
- data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +15 -0
- data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +15 -0
- data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +17 -0
- data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +17 -0
- data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +15 -0
- data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +15 -0
- data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +17 -0
- data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +23 -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/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/20090831220301_create_lending_policies.rb +21 -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/20091214131723_create_series_statements.rb +13 -0
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +14 -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/20100314190054_add_opening_hour_to_library.rb +9 -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 +11 -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/20110301134521_add_expire_date_to_reserve.rb +9 -0
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +11 -0
- data/spec/dummy/db/migrate/20110328130826_add_current_checkout_count_to_user_group_has_checkout_type.rb +9 -0
- data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.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/20110621093332_remove_expire_date_from_reserve.rb +9 -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/20110913115320_add_lft_and_rgt_to_message.rb +11 -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/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/20111129044509_add_pickup_location_to_reserve.rb +6 -0
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -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/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/20120424103932_add_librarian_id_to_checked_item.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/20121116031206_add_fulltext_content_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20130303124821_add_retained_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +8 -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/20130429020822_add_root_manifestation_id_to_series_statement.rb +6 -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/migrate/20130519065638_add_lock_version_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +5 -0
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +18 -0
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +11 -0
- data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140720140916_add_binding_item_identifier_to_item.rb +8 -0
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140721151416_add_default_shelf_id_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140802082007_add_manifestation_id_to_item.rb +6 -0
- data/spec/dummy/db/migrate/20140810061942_add_user_id_to_user_checkout_stat.rb +12 -0
- data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +6 -0
- data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
- data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +5 -0
- data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +9 -0
- data/spec/dummy/db/migrate/20141014065831_add_shelf_id_to_checkout.rb +6 -0
- data/spec/dummy/db/migrate/20141020120523_add_library_id_to_checkout.rb +6 -0
- data/spec/dummy/db/migrate/20150106001709_create_demands.rb +14 -0
- data/spec/dummy/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +5 -0
- data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +5 -0
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
- data/spec/dummy/db/migrate/20151125004028_add_profile_id_to_agent.rb +6 -0
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184619_add_most_recent_to_reserve_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184650_add_most_recent_to_manifestation_checkout_stat_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184723_add_most_recent_to_manifestation_reserve_stat_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184747_add_most_recent_to_user_checkout_stat_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703184805_add_most_recent_to_user_reserve_stat_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +5 -0
- data/spec/dummy/db/schema.rb +1392 -0
- data/spec/dummy/public/404.html +54 -13
- data/spec/dummy/public/422.html +54 -13
- data/spec/dummy/public/500.html +53 -12
- data/spec/factories/profile.rb +17 -0
- data/spec/factories/user.rb +43 -0
- data/spec/factories/user_group.rb +5 -0
- data/spec/fixtures/libraries.yml +101 -0
- data/spec/fixtures/library_groups.yml +39 -0
- data/spec/fixtures/message_requests.yml +26 -0
- data/spec/fixtures/message_templates.yml +98 -0
- data/spec/fixtures/messages.yml +56 -0
- data/spec/fixtures/profiles.yml +103 -0
- data/spec/fixtures/roles.yml +39 -0
- data/spec/fixtures/user_groups.yml +40 -0
- data/spec/fixtures/user_has_roles.yml +40 -0
- data/spec/fixtures/users.yml +51 -0
- data/spec/models/profile_spec.rb +98 -0
- data/spec/models/role_spec.rb +40 -0
- data/spec/rails_helper.rb +71 -0
- data/spec/requests/profiles_spec.rb +9 -0
- data/spec/routing/profiles_routing_spec.rb +35 -0
- data/spec/routing/users_spec.rb +14 -0
- data/spec/spec_helper.rb +96 -29
- data/spec/support/controller_macros.rb +46 -0
- data/spec/support/devise.rb +4 -0
- metadata +673 -46
- data/spec/dummy/script/rails +0 -6
data/config/routes.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateRoles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table "roles" do |t|
|
4
|
+
t.column :name, :string, :null => false
|
5
|
+
t.column :display_name, :string
|
6
|
+
t.column :note, :text
|
7
|
+
t.column :created_at, :datetime
|
8
|
+
t.column :updated_at, :datetime
|
9
|
+
t.integer :score, :default => 0, :null => false
|
10
|
+
t.integer :position
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateUserHasRoles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :user_has_roles do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.integer :role_id
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :user_has_roles, :user_id
|
10
|
+
add_index :user_has_roles, :role_id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AddAdditionalAttributesToUser < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :users, :username, :string
|
4
|
+
add_column :users, :deleted_at, :datetime
|
5
|
+
add_column :users, :expired_at, :datetime
|
6
|
+
|
7
|
+
add_column :users, :failed_attempts, :integer, :default => 0
|
8
|
+
add_column :users, :unlock_token, :string
|
9
|
+
add_column :users, :locked_at, :datetime
|
10
|
+
|
11
|
+
add_column :users, :confirmed_at, :datetime
|
12
|
+
|
13
|
+
add_index :users, :username, :unique => true
|
14
|
+
add_index :users, :unlock_token, :unique => true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateProfiles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :profiles do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.integer :user_group_id
|
6
|
+
t.integer :library_id
|
7
|
+
t.string :locale
|
8
|
+
t.string :user_number
|
9
|
+
t.text :full_name
|
10
|
+
t.text :note
|
11
|
+
t.text :keyword_list
|
12
|
+
t.integer :required_role_id
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
add_index :profiles, :user_id
|
18
|
+
add_index :profiles, :user_number, :unique => true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateIdentities < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :identities do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
t.string :password_digest
|
7
|
+
t.integer :profile_id
|
8
|
+
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
add_index :identities, :name
|
12
|
+
add_index :identities, :email
|
13
|
+
add_index :identities, :profile_id
|
14
|
+
end
|
15
|
+
end
|
data/lib/enju_seed/engine.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
require 'kaminari'
|
2
2
|
require 'devise'
|
3
|
-
require '
|
3
|
+
require 'pundit'
|
4
4
|
require 'acts_as_list'
|
5
|
-
require '
|
5
|
+
require 'strip_attributes'
|
6
6
|
require 'friendly_id'
|
7
7
|
require 'addressable/uri'
|
8
8
|
require 'sunspot_rails'
|
9
|
-
require '
|
10
|
-
require '
|
11
|
-
require '
|
9
|
+
require 'cocoon'
|
10
|
+
require 'kramdown'
|
11
|
+
require 'rails_autolink'
|
12
|
+
require 'sitemap_generator'
|
13
|
+
require 'statesman'
|
14
|
+
require 'browser'
|
12
15
|
|
13
16
|
module EnjuSeed
|
14
17
|
class Engine < ::Rails::Engine
|
data/lib/enju_seed/version.rb
CHANGED
@@ -0,0 +1,229 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rails_helper'
|
3
|
+
|
4
|
+
describe MyAccountsController do
|
5
|
+
fixtures :all
|
6
|
+
|
7
|
+
describe "GET show" do
|
8
|
+
describe "When logged in as Administrator" do
|
9
|
+
before(:each) do
|
10
|
+
sign_in User.where(username: 'enjuadmin').first
|
11
|
+
end
|
12
|
+
|
13
|
+
it "assigns the requested user as @user" do
|
14
|
+
get :show, id: 'admin'
|
15
|
+
expect(response).to be_success
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "When not logged in" do
|
20
|
+
it "assigns the requested user as @user" do
|
21
|
+
get :show, id: 'admin'
|
22
|
+
expect(assigns(:user)).to be_nil
|
23
|
+
expect(response).to redirect_to(new_user_session_url)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "GET edit" do
|
29
|
+
describe "When logged in as Administrator" do
|
30
|
+
before(:each) do
|
31
|
+
profile = FactoryGirl.create(:profile)
|
32
|
+
@user = FactoryGirl.create(:admin)
|
33
|
+
@user.profile = profile
|
34
|
+
sign_in @user
|
35
|
+
end
|
36
|
+
|
37
|
+
it "assigns the requested user as @user" do
|
38
|
+
get :edit
|
39
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "When logged in as Librarian" do
|
44
|
+
before(:each) do
|
45
|
+
profile = FactoryGirl.create(:profile)
|
46
|
+
@user = FactoryGirl.create(:librarian)
|
47
|
+
@user.profile = profile
|
48
|
+
sign_in @user
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should assign the requested user as @user" do
|
52
|
+
get :edit
|
53
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "When logged in as User" do
|
58
|
+
before(:each) do
|
59
|
+
profile = FactoryGirl.create(:profile)
|
60
|
+
@user = FactoryGirl.create(:user)
|
61
|
+
@user.profile = profile
|
62
|
+
sign_in @user
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should assign the requested user as @user" do
|
66
|
+
get :edit
|
67
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
68
|
+
expect(response).to be_success
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "When not logged in" do
|
73
|
+
it "should not assign the requested user as @user" do
|
74
|
+
get :edit
|
75
|
+
expect(assigns(:user)).to be_nil
|
76
|
+
expect(response).to redirect_to(new_user_session_url)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "PUT update" do
|
82
|
+
before(:each) do
|
83
|
+
@attrs = {:user_attributes => {email: 'newaddress@example.jp', :current_password => 'password'}, :locale => 'en'}
|
84
|
+
@invalid_attrs = {:user_attributes => {username: ''}, user_number: '日本語'}
|
85
|
+
@invalid_passwd_attrs = {:user_attributes => {:current_password=> ''}}
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "When logged in as Administrator" do
|
89
|
+
before(:each) do
|
90
|
+
profile = FactoryGirl.create(:profile)
|
91
|
+
@user = FactoryGirl.create(:admin, :password => 'password', :password_confirmation => 'password')
|
92
|
+
@user.profile = profile
|
93
|
+
sign_in @user
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "with valid params" do
|
97
|
+
it "updates the requested user" do
|
98
|
+
@attrs[:user_attributes][:id] = @user.id
|
99
|
+
put :update, profile: @attrs
|
100
|
+
end
|
101
|
+
|
102
|
+
it "assigns the requested user as @user" do
|
103
|
+
@attrs[:user_attributes][:id] = @user.id
|
104
|
+
put :update, profile: @attrs
|
105
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "redirects to the user" do
|
109
|
+
@attrs[:user_attributes][:id] = @user.id
|
110
|
+
put :update, profile: @attrs
|
111
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
112
|
+
expect(response).to redirect_to(my_account_url)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "with invalid params" do
|
117
|
+
it "assigns the requested user as @user" do
|
118
|
+
put :update, profile: @invalid_attrs
|
119
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "re-renders the 'edit' template" do
|
123
|
+
put :update, profile: @invalid_attrs
|
124
|
+
expect(response).to render_template("edit")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
#describe "with invalid password params" do
|
129
|
+
# it "assigns the requested user as @user" do
|
130
|
+
# put :update, profile: @invalid_passwd_attrs
|
131
|
+
# expect(assigns(:profile).errors).not_to be_blank
|
132
|
+
# end
|
133
|
+
#end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "When logged in as Librarian" do
|
137
|
+
before(:each) do
|
138
|
+
profile = FactoryGirl.create(:profile)
|
139
|
+
@user = FactoryGirl.create(:librarian, :password => 'password', :password_confirmation => 'password')
|
140
|
+
@user.profile = profile
|
141
|
+
sign_in @user
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "with valid params" do
|
145
|
+
it "updates the requested user" do
|
146
|
+
@attrs[:user_attributes][:id] = @user.id
|
147
|
+
put :update, profile: @attrs
|
148
|
+
end
|
149
|
+
|
150
|
+
it "assigns the requested user as @user" do
|
151
|
+
@attrs[:user_attributes][:id] = @user.id
|
152
|
+
put :update, profile: @attrs
|
153
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "redirects to the user" do
|
157
|
+
@attrs[:user_attributes][:id] = @user.id
|
158
|
+
put :update, profile: @attrs
|
159
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
160
|
+
expect(response).to redirect_to(my_account_url)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "with invalid params" do
|
165
|
+
it "assigns the user as @user" do
|
166
|
+
put :update, profile: @invalid_attrs
|
167
|
+
expect(assigns(:profile)).to_not be_valid
|
168
|
+
expect(response).to be_success
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should ignore username" do
|
172
|
+
put :update, profile: @invalid_attrs
|
173
|
+
expect(response).to render_template("edit")
|
174
|
+
expect(assigns(:profile).changed?).to be_truthy
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "When logged in as User" do
|
180
|
+
before(:each) do
|
181
|
+
profile = FactoryGirl.create(:profile)
|
182
|
+
@user = FactoryGirl.create(:user, :password => 'password', :password_confirmation => 'password')
|
183
|
+
@user.profile = profile
|
184
|
+
sign_in @user
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "with valid params" do
|
188
|
+
it "updates the requested user" do
|
189
|
+
@attrs[:user_attributes][:id] = @user.id
|
190
|
+
put :update, profile: @attrs
|
191
|
+
end
|
192
|
+
|
193
|
+
it "assigns the requested user as @user" do
|
194
|
+
@attrs[:user_attributes][:id] = @user.id
|
195
|
+
put :update, profile: @attrs
|
196
|
+
expect(assigns(:profile)).to eq(@user.profile)
|
197
|
+
expect(response).to redirect_to(my_account_url)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "with invalid params" do
|
202
|
+
it "assigns the requested user as @user" do
|
203
|
+
put :update, profile: @invalid_attrs
|
204
|
+
expect(response).to be_success
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "When not logged in" do
|
210
|
+
describe "with valid params" do
|
211
|
+
it "updates the requested user" do
|
212
|
+
put :update, profile: @attrs
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should be forbidden" do
|
216
|
+
put :update, profile: @attrs
|
217
|
+
expect(response).to redirect_to(new_user_session_url)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "with invalid params" do
|
222
|
+
it "assigns the requested user as @user" do
|
223
|
+
put :update, profile: @invalid_attrs
|
224
|
+
expect(response).to redirect_to(new_user_session_url)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -0,0 +1,594 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe ProfilesController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
describe "GET index" do
|
7
|
+
describe "When logged in as Administrator" do
|
8
|
+
login_fixture_admin
|
9
|
+
|
10
|
+
it "assigns all profiles as @profiles" do
|
11
|
+
get :index
|
12
|
+
Sunspot.session.should be_a_search_for(Profile)
|
13
|
+
Sunspot.session.should have_search_params(:fulltext, '')
|
14
|
+
assigns(:profiles).should_not be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "When logged in as Librarian" do
|
19
|
+
login_fixture_librarian
|
20
|
+
|
21
|
+
it "assigns all profiles as @profiles" do
|
22
|
+
get :index
|
23
|
+
Sunspot.session.should be_a_search_for(Profile)
|
24
|
+
Sunspot.session.should have_search_params(:fulltext, '')
|
25
|
+
assigns(:profiles).should_not be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get index with query" do
|
29
|
+
get :index, :query => 'user1'
|
30
|
+
response.should be_success
|
31
|
+
Sunspot.session.should be_a_search_for(Profile)
|
32
|
+
Sunspot.session.should have_search_params(:fulltext, 'user1')
|
33
|
+
assigns(:profiles).should_not be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should get sorted index" do
|
37
|
+
get :index, :query => 'user1', :sort_by => 'username', :order => 'desc'
|
38
|
+
response.should be_success
|
39
|
+
Sunspot.session.should be_a_search_for(Profile)
|
40
|
+
Sunspot.session.should have_search_params(:fulltext, 'user1')
|
41
|
+
Sunspot.session.should have_search_params(:order_by, :username, :desc)
|
42
|
+
assigns(:profiles).should_not be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "When logged in as User" do
|
47
|
+
login_fixture_user
|
48
|
+
|
49
|
+
it "assigns all profiles as @profiles" do
|
50
|
+
get :index
|
51
|
+
assigns(:profiles).should be_nil
|
52
|
+
response.should be_forbidden
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "When not logged in" do
|
57
|
+
it "assigns all profiles as @profiles" do
|
58
|
+
get :index
|
59
|
+
assigns(:profiles).should be_nil
|
60
|
+
response.should redirect_to(new_user_session_url)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "GET show" do
|
66
|
+
describe "When logged in as Administrator" do
|
67
|
+
login_fixture_admin
|
68
|
+
|
69
|
+
it "assigns the requested user as @profile" do
|
70
|
+
get :show, id: profiles(:admin).id
|
71
|
+
assigns(:profile).should eq(profiles(:admin))
|
72
|
+
end
|
73
|
+
it "assigns the another requested user as @profile" do
|
74
|
+
admin_profile = FactoryGirl.create :admin_profile
|
75
|
+
get :show, id: admin_profile.id
|
76
|
+
expect(response).not_to be_forbidden
|
77
|
+
expect(assigns(:profile)).to eq admin_profile
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "When logged in as Librarian" do
|
82
|
+
login_fixture_librarian
|
83
|
+
|
84
|
+
it "assigns the requested user as @profile" do
|
85
|
+
get :show, id: profiles(:librarian1).id
|
86
|
+
assigns(:profile).should eq(profiles(:librarian1))
|
87
|
+
end
|
88
|
+
it "should not assign the requested user as @admin" do
|
89
|
+
admin = FactoryGirl.create(:admin_profile)
|
90
|
+
get :show, id: admin.id
|
91
|
+
response.should be_forbidden
|
92
|
+
end
|
93
|
+
it "should assign the requested user as @librarian" do
|
94
|
+
librarian = FactoryGirl.create(:librarian_profile)
|
95
|
+
get :show, id: librarian.id
|
96
|
+
response.should_not be_forbidden
|
97
|
+
assigns(:profile).should eq librarian
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "When logged in as User" do
|
102
|
+
login_fixture_user
|
103
|
+
|
104
|
+
it "assigns the requested user as @profile" do
|
105
|
+
get :show, id: profiles(:user1).id
|
106
|
+
assigns(:profile).should eq(profiles(:user1))
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should redirect to my user account" do
|
110
|
+
get :show, id: profiles(:user1).id
|
111
|
+
assert_redirected_to my_account_url
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should show other user's account" do
|
115
|
+
get :show, id: profiles(:admin).id
|
116
|
+
assigns(:profile).should eq(profiles(:admin))
|
117
|
+
response.should be_forbidden
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "When not logged in" do
|
122
|
+
it "assigns the requested user as @profile" do
|
123
|
+
get :show, id: profiles(:admin).id
|
124
|
+
assigns(:profile).should eq(profiles(:admin))
|
125
|
+
response.should redirect_to(new_user_session_url)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "GET new" do
|
131
|
+
describe "When logged in as Administrator" do
|
132
|
+
login_fixture_admin
|
133
|
+
|
134
|
+
it "assigns the requested user as @profile" do
|
135
|
+
get :new
|
136
|
+
assigns(:profile).should_not be_valid
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "When logged in as Librarian" do
|
141
|
+
login_fixture_librarian
|
142
|
+
|
143
|
+
it "should not assign the requested user as @profile" do
|
144
|
+
get :new
|
145
|
+
assigns(:profile).should_not be_valid
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "When logged in as User" do
|
150
|
+
login_fixture_user
|
151
|
+
|
152
|
+
it "should not assign the requested user as @profile" do
|
153
|
+
get :new
|
154
|
+
assigns(:profile).should be_nil
|
155
|
+
response.should be_forbidden
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "When not logged in" do
|
160
|
+
it "should not assign the requested user as @profile" do
|
161
|
+
get :new
|
162
|
+
assigns(:profile).should be_nil
|
163
|
+
response.should redirect_to(new_user_session_url)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "GET edit" do
|
169
|
+
describe "When logged in as Administrator" do
|
170
|
+
login_fixture_admin
|
171
|
+
|
172
|
+
it "assigns the requested user as @profile" do
|
173
|
+
profile = FactoryGirl.create(:profile)
|
174
|
+
get :edit, id: profile.id
|
175
|
+
assigns(:profile).should eq(profile)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "When logged in as Librarian" do
|
180
|
+
login_fixture_librarian
|
181
|
+
|
182
|
+
it "should assign the requested user as @profile" do
|
183
|
+
profile = FactoryGirl.create(:profile)
|
184
|
+
get :edit, id: profile.id
|
185
|
+
assigns(:profile).should eq(profile)
|
186
|
+
end
|
187
|
+
it "should not get edit page for admin required user" do
|
188
|
+
admin = FactoryGirl.create(:admin_profile)
|
189
|
+
get :edit, id: admin.id
|
190
|
+
response.should be_forbidden
|
191
|
+
#assigns(:profile).should_not eq(admin)
|
192
|
+
end
|
193
|
+
it "should get edit page for other librarian user" do
|
194
|
+
librarian = FactoryGirl.create(:librarian_profile)
|
195
|
+
get :edit, id: librarian.id
|
196
|
+
response.should_not be_forbidden
|
197
|
+
assigns(:profile).should eq librarian
|
198
|
+
end
|
199
|
+
it "should get edit page for other librarian user" do
|
200
|
+
admin = FactoryGirl.create(:admin_profile, required_role_id: Role.where(name: 'Librarian').first.id)
|
201
|
+
get :edit, id: admin.id
|
202
|
+
response.should be_forbidden
|
203
|
+
assigns(:profile).should eq admin
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should show icalendar feed" do
|
207
|
+
get :edit, id: profiles(:user1).id, mode: 'feed_token'
|
208
|
+
response.should render_template("profiles/_feed_token")
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "When logged in as User" do
|
213
|
+
login_fixture_user
|
214
|
+
|
215
|
+
it "should not assign the requested user as @profile" do
|
216
|
+
profile = FactoryGirl.create(:profile)
|
217
|
+
get :edit, id: profile.id
|
218
|
+
assigns(:profile).should eq(profile)
|
219
|
+
response.should be_forbidden
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should edit myself" do
|
223
|
+
get :edit, id: profiles(:user1).id
|
224
|
+
response.should redirect_to edit_my_account_url
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "When not logged in" do
|
229
|
+
it "should not assign the requested user as @profile" do
|
230
|
+
profile = FactoryGirl.create(:profile)
|
231
|
+
get :edit, id: profile.id
|
232
|
+
assigns(:profile).should eq(profile)
|
233
|
+
response.should redirect_to(new_user_session_url)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
describe "POST create" do
|
239
|
+
before(:each) do
|
240
|
+
@attrs = FactoryGirl.attributes_for(:profile)
|
241
|
+
@invalid_attrs = {:user_group_id => '', :user_number => '日本語'}
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "When logged in as Administrator" do
|
245
|
+
login_fixture_admin
|
246
|
+
|
247
|
+
describe "with valid params" do
|
248
|
+
it "assigns a newly created user as @profile" do
|
249
|
+
post :create, profile: @attrs
|
250
|
+
assigns(:profile).should be_valid
|
251
|
+
end
|
252
|
+
|
253
|
+
it "redirects to the created user" do
|
254
|
+
post :create, profile: @attrs
|
255
|
+
response.should redirect_to(profile_url(assigns(:profile)))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
describe "with invalid params" do
|
260
|
+
it "assigns a newly created but unsaved user as @profile" do
|
261
|
+
post :create, profile: @invalid_attrs
|
262
|
+
assigns(:profile).should_not be_valid
|
263
|
+
end
|
264
|
+
|
265
|
+
it "re-renders the 'new' template" do
|
266
|
+
post :create, profile: @invalid_attrs
|
267
|
+
response.should render_template("new")
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "When logged in as Librarian" do
|
273
|
+
login_fixture_librarian
|
274
|
+
|
275
|
+
describe "with valid params" do
|
276
|
+
it "assigns a newly created user as @profile" do
|
277
|
+
post :create, profile: @attrs
|
278
|
+
assigns(:profile).should be_valid
|
279
|
+
end
|
280
|
+
|
281
|
+
it "redirects to the created user" do
|
282
|
+
post :create, profile: @attrs
|
283
|
+
response.should redirect_to(profile_url(assigns(:profile)))
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "with invalid params" do
|
288
|
+
it "assigns a newly created but unsaved user as @profile" do
|
289
|
+
post :create, profile: @invalid_attrs
|
290
|
+
assigns(:profile).should_not be_valid
|
291
|
+
end
|
292
|
+
|
293
|
+
it "re-renders the 'new' template" do
|
294
|
+
post :create, profile: @invalid_attrs
|
295
|
+
response.should render_template("new")
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
describe "When logged in as User" do
|
301
|
+
login_fixture_user
|
302
|
+
|
303
|
+
it "should not create user" do
|
304
|
+
post :create, profile: { :username => 'test10' }
|
305
|
+
assigns(:profile).should be_nil
|
306
|
+
response.should be_forbidden
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe "When not logged in" do
|
311
|
+
it "should not create user" do
|
312
|
+
post :create, profile: { :username => 'test10' }
|
313
|
+
response.should redirect_to new_user_session_url
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "PUT update" do
|
319
|
+
before(:each) do
|
320
|
+
@profile = profiles(:user1)
|
321
|
+
@attrs = {:user_group_id => '3', :locale => 'en'}
|
322
|
+
@invalid_attrs = {:user_group_id => '', :user_number => '日本語'}
|
323
|
+
end
|
324
|
+
|
325
|
+
describe "When logged in as Administrator" do
|
326
|
+
login_fixture_admin
|
327
|
+
|
328
|
+
describe "with valid params" do
|
329
|
+
it "updates the requested user" do
|
330
|
+
put :update, id: @profile.id, profile: @attrs
|
331
|
+
end
|
332
|
+
|
333
|
+
it "assigns the requested user as @profile" do
|
334
|
+
put :update, id: @profile.id, profile: @attrs
|
335
|
+
assigns(:profile).should eq(@profile)
|
336
|
+
end
|
337
|
+
|
338
|
+
it "redirects to the user" do
|
339
|
+
put :update, id: @profile.id, profile: @attrs
|
340
|
+
assigns(:profile).should eq(@profile)
|
341
|
+
response.should redirect_to(@profile)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
describe "with invalid params" do
|
346
|
+
it "assigns the requested user as @profile" do
|
347
|
+
put :update, id: @profile.id, profile: @invalid_attrs
|
348
|
+
assigns(:profile).should eq(@profile)
|
349
|
+
end
|
350
|
+
|
351
|
+
it "re-renders the 'edit' template" do
|
352
|
+
put :update, id: @profile, profile: @invalid_attrs
|
353
|
+
response.should render_template("edit")
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
it "should update other user's role" do
|
358
|
+
put :update, id: profiles(:user1).id, profile: {:user_attributes => {:user_has_role_attributes => {:role_id => 4}, :email => profiles(:user1).user.email, :locale => 'en', id: profiles(:user1).user.id}}
|
359
|
+
response.should redirect_to profile_url(assigns(:profile))
|
360
|
+
assigns(:profile).reload
|
361
|
+
assigns(:profile).user.role.should eq Role.where(name: 'Administrator').first
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
describe "When logged in as Librarian" do
|
366
|
+
login_fixture_librarian
|
367
|
+
|
368
|
+
describe "with valid params" do
|
369
|
+
it "updates the requested user" do
|
370
|
+
put :update, id: @profile.id, profile: @attrs
|
371
|
+
end
|
372
|
+
|
373
|
+
it "assigns the requested user as @profile" do
|
374
|
+
put :update, id: @profile.id, profile: @attrs
|
375
|
+
assigns(:profile).should eq(@profile)
|
376
|
+
end
|
377
|
+
|
378
|
+
it "redirects to the user" do
|
379
|
+
put :update, id: @profile.id, profile: @attrs
|
380
|
+
assigns(:profile).should eq(@profile)
|
381
|
+
response.should redirect_to(@profile)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
describe "with invalid params" do
|
386
|
+
it "assigns the user as @profile" do
|
387
|
+
put :update, id: @profile, profile: @invalid_attrs
|
388
|
+
assigns(:profile).should_not be_valid
|
389
|
+
end
|
390
|
+
|
391
|
+
it "re-renders the 'edit' template" do
|
392
|
+
put :update, id: @profile, profile: @invalid_attrs
|
393
|
+
response.should render_template("edit")
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
it "should update other user" do
|
398
|
+
put :update, id: profiles(:user1).id, profile: {:user_number => '00003', :locale => 'en', :user_group_id => 3, :library_id => 3, :note => 'test'}
|
399
|
+
response.should redirect_to profile_url(assigns(:profile))
|
400
|
+
end
|
401
|
+
|
402
|
+
it "should not update other admin" do
|
403
|
+
put :update, id: profiles(:admin).id, profile: {:user_number => '00003', :locale => 'en', :user_group_id => 3, :library_id => 3, :note => 'test'}
|
404
|
+
response.should be_forbidden
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should update other user's user_group" do
|
408
|
+
put :update, id: profiles(:user1).id, profile: {:user_group_id => 3, :library_id => 3, :locale => 'en'}
|
409
|
+
response.should redirect_to profile_url(assigns(:profile))
|
410
|
+
assigns(:profile).user_group_id.should eq 3
|
411
|
+
end
|
412
|
+
|
413
|
+
it "should update other user's note" do
|
414
|
+
put :update, id: profiles(:user1).id, profile: {:user_group_id => 3, :library_id => 3, :note => 'test', :locale => 'en'}
|
415
|
+
response.should redirect_to profile_url(assigns(:profile))
|
416
|
+
assert_equal assigns(:profile).note, 'test'
|
417
|
+
end
|
418
|
+
|
419
|
+
it "should update other user's locked status" do
|
420
|
+
put :update, id: profiles(:user1).id, profile: {:user_attributes => {:id => 3, :locked => '1', :username => 'user1'}}
|
421
|
+
response.should redirect_to profile_url(assigns(:profile))
|
422
|
+
assigns(:profile).user.locked_at.should be_truthy
|
423
|
+
assigns(:profile).user.access_locked?.should be_truthy
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
427
|
+
describe "When logged in as User" do
|
428
|
+
login_fixture_user
|
429
|
+
|
430
|
+
describe "with valid params" do
|
431
|
+
it "updates the requested user" do
|
432
|
+
put :update, id: @profile.id, profile: @attrs
|
433
|
+
end
|
434
|
+
|
435
|
+
it "assigns the requested user as @profile" do
|
436
|
+
put :update, id: @profile.id, profile: @attrs
|
437
|
+
assigns(:profile).should be_valid
|
438
|
+
response.should redirect_to profile_url(assigns(:profile))
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
describe "with invalid params" do
|
443
|
+
it "assigns the requested user as @profile" do
|
444
|
+
put :update, id: @profile.id, profile: @invalid_attrs
|
445
|
+
#assigns(:profile).should_not be_valid
|
446
|
+
#response.should be_success
|
447
|
+
assigns(:profile).should be_valid
|
448
|
+
response.should redirect_to profile_url(assigns(:profile))
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
it "should update myself" do
|
453
|
+
put :update, id: profiles(:user1).id, profile: {keyword_list: 'test'}
|
454
|
+
response.should redirect_to profile_url(assigns(:profile))
|
455
|
+
end
|
456
|
+
|
457
|
+
it "should not update my role" do
|
458
|
+
put :update, id: profiles(:user1).id, profile: {:user_has_role_attributes => {:role_id => 4}}
|
459
|
+
response.should redirect_to profile_url(assigns(:profile))
|
460
|
+
assigns(:profile).user.role.should_not eq Role.where(name: 'Administrator').first
|
461
|
+
end
|
462
|
+
|
463
|
+
it "should not update my user_group" do
|
464
|
+
put :update, id: profiles(:user1).id, profile: {:user_group_id => 3, :library_id => 3}
|
465
|
+
response.should redirect_to profile_url(assigns(:profile))
|
466
|
+
assigns(:profile).user_group_id.should eq 1
|
467
|
+
end
|
468
|
+
|
469
|
+
it "should not update my note" do
|
470
|
+
put :update, id: profiles(:user1).id, profile: {:user_group_id => 3, :library_id => 3, :note => 'test'}
|
471
|
+
response.should redirect_to profile_url(assigns(:profile))
|
472
|
+
assigns(:profile).note.should be_nil
|
473
|
+
end
|
474
|
+
|
475
|
+
it "should update my keyword_list" do
|
476
|
+
put :update, id: profiles(:user1).id, profile: {:keyword_list => 'test'}
|
477
|
+
response.should redirect_to profile_url(assigns(:profile))
|
478
|
+
assigns(:profile).keyword_list.should eq 'test'
|
479
|
+
assigns(:profile).user.role.name.should eq 'User'
|
480
|
+
end
|
481
|
+
|
482
|
+
it "should not update other user" do
|
483
|
+
put :update, id: profiles(:user2).id, profile: { }
|
484
|
+
assigns(:profile).should be_valid
|
485
|
+
response.should be_forbidden
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
describe "When not logged in" do
|
490
|
+
describe "with valid params" do
|
491
|
+
it "updates the requested user" do
|
492
|
+
put :update, id: @profile.id, profile: @attrs
|
493
|
+
end
|
494
|
+
|
495
|
+
it "should be forbidden" do
|
496
|
+
put :update, id: @profile.id, profile: @attrs
|
497
|
+
response.should redirect_to(new_user_session_url)
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
describe "with invalid params" do
|
502
|
+
it "assigns the requested user as @profile" do
|
503
|
+
put :update, id: @profile.id, profile: @invalid_attrs
|
504
|
+
response.should redirect_to(new_user_session_url)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
describe "DELETE destroy" do
|
511
|
+
describe "When logged in as Administrator" do
|
512
|
+
login_fixture_admin
|
513
|
+
|
514
|
+
it "destroys the requested user" do
|
515
|
+
delete :destroy, id: profiles(:user2).id
|
516
|
+
end
|
517
|
+
|
518
|
+
it "redirects to the profiles list" do
|
519
|
+
delete :destroy, id: profiles(:user2).id
|
520
|
+
response.should redirect_to(profiles_url)
|
521
|
+
end
|
522
|
+
|
523
|
+
it "should destroy librarian" do
|
524
|
+
delete :destroy, id: profiles(:librarian2).id
|
525
|
+
response.should redirect_to(profiles_url)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
describe "When logged in as Librarian" do
|
530
|
+
login_fixture_librarian
|
531
|
+
|
532
|
+
it "destroys the requested user" do
|
533
|
+
delete :destroy, id: profiles(:user2).id
|
534
|
+
response.should redirect_to(profiles_url)
|
535
|
+
end
|
536
|
+
|
537
|
+
it "redirects to the profiles list" do
|
538
|
+
delete :destroy, id: profiles(:user2).id
|
539
|
+
response.should redirect_to(profiles_url)
|
540
|
+
end
|
541
|
+
|
542
|
+
it "should not destroy librarian" do
|
543
|
+
delete :destroy, id: profiles(:librarian2).id
|
544
|
+
response.should be_forbidden
|
545
|
+
end
|
546
|
+
|
547
|
+
it "should not destroy admin" do
|
548
|
+
delete :destroy, id: profiles(:admin).id
|
549
|
+
response.should be_forbidden
|
550
|
+
end
|
551
|
+
|
552
|
+
it "should not destroy myself" do
|
553
|
+
delete :destroy, id: profiles(:librarian1).id
|
554
|
+
response.should be_forbidden
|
555
|
+
end
|
556
|
+
|
557
|
+
it "should not be able to delete other librarian user" do
|
558
|
+
librarian = FactoryGirl.create(:librarian_profile)
|
559
|
+
delete :destroy, id: librarian.id
|
560
|
+
response.should be_forbidden
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
describe "When logged in as User" do
|
565
|
+
login_fixture_user
|
566
|
+
|
567
|
+
it "destroys the requested user" do
|
568
|
+
delete :destroy, id: profiles(:user2).id
|
569
|
+
end
|
570
|
+
|
571
|
+
it "should be forbidden" do
|
572
|
+
delete :destroy, id: profiles(:user2).id
|
573
|
+
response.should be_forbidden
|
574
|
+
end
|
575
|
+
|
576
|
+
it "should not destroy myself" do
|
577
|
+
delete :destroy, id: profiles(:user1).id
|
578
|
+
response.should be_forbidden
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
describe "When not logged in" do
|
583
|
+
it "destroys the requested user" do
|
584
|
+
delete :destroy, id: profiles(:user2).id
|
585
|
+
response.should redirect_to(new_user_session_url)
|
586
|
+
end
|
587
|
+
|
588
|
+
it "should be forbidden" do
|
589
|
+
delete :destroy, id: profiles(:user2).id
|
590
|
+
response.should redirect_to(new_user_session_url)
|
591
|
+
end
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|