enju_seed 0.2.3 → 0.3.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +17 -8
- data/app/assets/config/enju_seed_manifest.js +0 -0
- data/app/controllers/my_accounts_controller.rb +14 -13
- data/app/controllers/profiles_controller.rb +30 -29
- data/app/controllers/roles_controller.rb +2 -1
- data/app/models/concerns/enju_seed/enju_user.rb +22 -26
- data/app/models/concerns/master_model.rb +5 -6
- data/app/models/identity.rb +1 -1
- data/app/models/profile.rb +3 -3
- data/app/models/role.rb +2 -1
- data/app/models/user_has_role.rb +2 -2
- data/app/views/my_accounts/_edit_credential.html.slim +63 -0
- data/app/views/my_accounts/_form.html.slim +20 -0
- data/app/views/my_accounts/_show.html.slim +1 -0
- data/app/views/my_accounts/edit.html.slim +30 -0
- data/app/views/my_accounts/show.html+phone.slim +1 -0
- data/app/views/my_accounts/show.html.slim +57 -0
- data/app/views/profiles/_edit_credential.html.slim +67 -0
- data/app/views/profiles/_edit_profile.html.slim +40 -0
- data/app/views/profiles/_form.html.slim +12 -0
- data/app/views/profiles/_show.html.slim +1 -0
- data/app/views/profiles/edit.html.slim +30 -0
- data/app/views/profiles/index.html.slim +61 -0
- data/app/views/profiles/new.html.slim +65 -0
- data/app/views/profiles/show.html+phone.slim +1 -0
- data/app/views/profiles/show.html.slim +67 -0
- data/app/views/roles/_form.html.slim +16 -0
- data/app/views/roles/edit.html.slim +15 -0
- data/app/views/roles/index.html.slim +27 -0
- data/app/views/roles/new.html.slim +13 -0
- data/app/views/roles/show.html.slim +46 -0
- data/db/migrate/041_create_roles.rb +3 -3
- data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +3 -3
- data/lib/enju_seed.rb +2 -3
- data/lib/enju_seed/engine.rb +1 -2
- data/lib/enju_seed/localized_name.rb +1 -3
- data/lib/enju_seed/version.rb +1 -1
- data/spec/controllers/my_accounts_controller_spec.rb +79 -79
- data/spec/controllers/profiles_controller_spec.rb +210 -210
- data/spec/controllers/roles_controller_spec.rb +47 -47
- data/spec/dummy/app/helpers/application_helper.rb +1 -1
- data/spec/dummy/app/models/user.rb +2 -2
- data/spec/dummy/bin/setup +8 -8
- data/spec/dummy/config/application.rb +2 -18
- data/spec/dummy/config/database.yml +70 -10
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +24 -11
- data/spec/dummy/config/environments/production.rb +24 -17
- data/spec/dummy/config/environments/test.rb +6 -6
- data/spec/dummy/config/initializers/assets.rb +1 -1
- data/spec/dummy/config/initializers/friendly_id.rb +75 -75
- data/spec/dummy/db/migrate/001_create_agents.rb +6 -6
- data/spec/dummy/db/migrate/002_devise_create_users.rb +5 -6
- data/spec/dummy/db/migrate/005_create_manifestations.rb +12 -12
- data/spec/dummy/db/migrate/006_create_items.rb +5 -5
- data/spec/dummy/db/migrate/012_create_owns.rb +2 -2
- data/spec/dummy/db/migrate/015_create_creates.rb +2 -2
- data/spec/dummy/db/migrate/032_create_checkins.rb +1 -1
- data/spec/dummy/db/migrate/033_create_checkouts.rb +4 -4
- data/spec/dummy/db/migrate/035_create_reserves.rb +5 -5
- data/spec/dummy/db/migrate/047_create_produces.rb +2 -2
- data/spec/dummy/db/migrate/059_create_libraries.rb +6 -4
- data/spec/dummy/db/migrate/069_create_shelves.rb +2 -1
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +1 -1
- data/spec/dummy/db/migrate/077_create_user_groups.rb +1 -1
- data/spec/dummy/db/migrate/080_create_library_groups.rb +2 -1
- data/spec/dummy/db/migrate/112_create_frequencies.rb +1 -1
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +1 -1
- data/spec/dummy/db/migrate/120_create_baskets.rb +2 -1
- data/spec/dummy/db/migrate/121_create_checked_items.rb +3 -3
- data/spec/dummy/db/migrate/124_create_bookstores.rb +1 -1
- data/spec/dummy/db/migrate/125_create_donates.rb +2 -2
- data/spec/dummy/db/migrate/127_create_use_restrictions.rb +1 -1
- data/spec/dummy/db/migrate/129_create_item_has_use_restrictions.rb +2 -2
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -1
- data/spec/dummy/db/migrate/131_create_request_types.rb +1 -1
- data/spec/dummy/db/migrate/132_create_circulation_statuses.rb +1 -1
- data/spec/dummy/db/migrate/133_create_agent_merges.rb +1 -1
- data/spec/dummy/db/migrate/149_create_message_templates.rb +5 -5
- data/spec/dummy/db/migrate/154_create_messages.rb +2 -2
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +2 -2
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +13 -0
- data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +1 -1
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +5 -2
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +2 -1
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +5 -5
- data/spec/dummy/db/migrate/20081025083323_create_countries.rb +8 -9
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +5 -6
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +1 -1
- data/spec/dummy/db/migrate/20081030023412_create_checkout_types.rb +1 -1
- data/spec/dummy/db/migrate/20081030023518_create_user_group_has_checkout_types.rb +8 -8
- data/spec/dummy/db/migrate/20081030023615_create_carrier_type_has_checkout_types.rb +3 -3
- data/spec/dummy/db/migrate/20081212075554_create_checkout_stat_has_manifestations.rb +4 -4
- data/spec/dummy/db/migrate/20081215094955_create_checkout_stat_has_users.rb +3 -3
- data/spec/dummy/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb +3 -3
- data/spec/dummy/db/migrate/20081220034117_create_reserve_stat_has_users.rb +2 -2
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +1 -1
- data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +1 -1
- data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +1 -1
- data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +6 -6
- data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +1 -1
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +1 -1
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +3 -3
- data/spec/dummy/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +3 -3
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +0 -1
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +0 -1
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +0 -1
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +1 -2
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +6 -3
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
- data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +2 -2
- data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +2 -2
- data/spec/dummy/db/migrate/20130519065638_add_lock_version_to_reserve.rb +1 -1
- data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +1 -1
- data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +2 -2
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +2 -2
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +3 -3
- data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +0 -1
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +0 -1
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +4 -4
- data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +1 -1
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +3 -1
- data/spec/dummy/db/migrate/20141029131633_create_periodicals.rb +11 -0
- data/spec/dummy/db/migrate/20150124152756_add_foreign_key_to_shelves_referencing_libraries.rb +6 -0
- data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20150302110310_add_attachment_id_to_manifestation.rb +7 -0
- data/spec/dummy/db/migrate/20150304183215_add_picture_id_to_picture_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305025906_add_resource_import_id_to_resource_import_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305030046_add_resource_export_id_to_resource_export_file.rb +8 -0
- data/spec/dummy/db/migrate/20150305031709_add_agent_import_id_to_agent_import_file.rb +7 -0
- data/spec/dummy/db/migrate/20150305105231_add_attachment_fingerprint_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20150420145354_add_attachment_to_carrier_type.rb +8 -0
- data/spec/dummy/db/migrate/20150420145420_add_attachment_to_content_type.rb +8 -0
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +5 -3
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +2 -4
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +2 -19
- data/spec/dummy/db/migrate/20151216123621_create_doi_records.rb +12 -0
- data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +12 -0
- data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +12 -0
- data/spec/dummy/db/migrate/20160513000929_create_agent_names.rb +18 -0
- data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20161111175127_add_attachment_data_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20161111193255_add_attachment_data_to_carrier_type.rb +5 -0
- data/spec/dummy/db/migrate/20161111193346_add_attachment_data_to_content_type.rb +5 -0
- data/spec/dummy/db/migrate/20161112122706_add_attachment_data_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20161112122750_add_attachment_data_to_resource_export_file.rb +5 -0
- data/spec/dummy/db/migrate/20161112122814_add_attachment_data_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/schema.rb +1418 -1402
- data/spec/factories/profile.rb +10 -10
- data/spec/factories/user.rb +10 -10
- data/spec/factories/user_group.rb +2 -2
- data/spec/fixtures/library_groups.yml +1 -0
- data/spec/models/profile_spec.rb +20 -19
- data/spec/models/role_spec.rb +7 -7
- data/spec/models/user_has_role_spec.rb +1 -2
- data/spec/models/user_spec.rb +25 -26
- data/spec/rails_helper.rb +7 -6
- data/spec/requests/profiles_spec.rb +3 -3
- data/spec/routing/profiles_routing_spec.rb +16 -18
- data/spec/routing/roles_routing_spec.rb +16 -18
- data/spec/routing/users_spec.rb +6 -7
- data/spec/spec_helper.rb +47 -49
- data/spec/support/controller_macros.rb +9 -9
- data/spec/views/my_accounts/show.html.erb_spec.rb +6 -6
- data/spec/views/profiles/edit.html.erb_spec.rb +7 -7
- data/spec/views/profiles/index.html.erb_spec.rb +3 -3
- data/spec/views/profiles/new.html.erb_spec.rb +5 -6
- data/spec/views/profiles/show.html.erb_spec.rb +3 -3
- metadata +323 -323
- data/app/views/my_accounts/_edit_credential.html.erb +0 -99
- data/app/views/my_accounts/_form.html.erb +0 -24
- data/app/views/my_accounts/_show.html.erb +0 -1
- data/app/views/my_accounts/edit.html.erb +0 -32
- data/app/views/my_accounts/show.html.erb +0 -49
- data/app/views/profiles/_edit_profile.html.erb +0 -42
- data/app/views/profiles/_form.html.erb +0 -15
- data/app/views/profiles/_show.html.erb +0 -1
- data/app/views/profiles/edit.html.erb +0 -33
- data/app/views/profiles/index.html.erb +0 -70
- data/app/views/profiles/new.html.erb +0 -88
- data/app/views/profiles/show.html+phone.erb +0 -1
- data/app/views/profiles/show.html.erb +0 -67
- data/app/views/roles/_form.html.erb +0 -19
- data/app/views/roles/edit.html.erb +0 -13
- data/app/views/roles/index.html.erb +0 -32
- data/app/views/roles/new.html.erb +0 -12
- data/app/views/roles/show.html.erb +0 -46
- data/lib/generators/enju_seed/update/update_generator.rb +0 -9
- data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +0 -5
- data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +0 -5
- data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +0 -5
- data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +0 -5
- data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +0 -5
data/spec/factories/profile.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
|
2
|
-
factory :profile, :
|
3
|
-
f.user_group_id {UserGroup.first.id}
|
4
|
-
f.required_role_id {Role.where(name: 'User').first.id}
|
5
|
-
f.sequence(:user_number){|n| "user_number_#{n}"}
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :profile, class: Profile do |f|
|
3
|
+
f.user_group_id { UserGroup.first.id }
|
4
|
+
f.required_role_id { Role.where(name: 'User').first.id }
|
5
|
+
f.sequence(:user_number) { |n| "user_number_#{n}" }
|
6
6
|
f.library_id 2
|
7
|
-
f.locale
|
8
|
-
factory :librarian_profile, :
|
9
|
-
profile.required_role_id {Role.where(name: 'Librarian').first.id}
|
7
|
+
f.locale 'ja'
|
8
|
+
factory :librarian_profile, class: Profile do |profile|
|
9
|
+
profile.required_role_id { Role.where(name: 'Librarian').first.id }
|
10
10
|
profile.association :user, factory: :librarian
|
11
11
|
end
|
12
|
-
factory :admin_profile, :
|
13
|
-
profile.required_role_id {Role.where(name: 'Administrator').first.id}
|
12
|
+
factory :admin_profile, class: Profile do |profile|
|
13
|
+
profile.required_role_id { Role.where(name: 'Administrator').first.id }
|
14
14
|
profile.association :user, factory: :admin
|
15
15
|
end
|
16
16
|
end
|
data/spec/factories/user.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
|
1
|
+
FactoryGirl.define do
|
2
2
|
factory :admin, class: User do |f|
|
3
|
-
f.sequence(:username){|n| "admin_#{n}"}
|
4
|
-
f.sequence(:email){|n| "admin_#{n}@example.jp"}
|
3
|
+
f.sequence(:username) { |n| "admin_#{n}" }
|
4
|
+
f.sequence(:email) { |n| "admin_#{n}@example.jp" }
|
5
5
|
f.password 'adminpassword'
|
6
6
|
f.password_confirmation 'adminpassword'
|
7
7
|
f.after(:create) do |user|
|
8
8
|
user_has_role = UserHasRole.new
|
9
|
-
user_has_role.assign_attributes(
|
9
|
+
user_has_role.assign_attributes(user_id: user.id, role_id: Role.find_by(name: 'Administrator').id)
|
10
10
|
user_has_role.save
|
11
11
|
user.reload
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
factory :librarian, class: User do |f|
|
16
|
-
f.sequence(:username){|n| "librarian_#{n}"}
|
17
|
-
f.sequence(:email){|n| "librarian_#{n}@example.jp"}
|
16
|
+
f.sequence(:username) { |n| "librarian_#{n}" }
|
17
|
+
f.sequence(:email) { |n| "librarian_#{n}@example.jp" }
|
18
18
|
f.password 'librarianpassword'
|
19
19
|
f.password_confirmation 'librarianpassword'
|
20
20
|
f.after(:create) do |user|
|
21
21
|
user_has_role = UserHasRole.new
|
22
|
-
user_has_role.assign_attributes(
|
22
|
+
user_has_role.assign_attributes(user_id: user.id, role_id: Role.find_by(name: 'Librarian').id)
|
23
23
|
user_has_role.save
|
24
24
|
user.reload
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
factory :user, class: User do |f|
|
29
|
-
f.sequence(:username){|n| "user_#{n}"}
|
30
|
-
f.sequence(:email){|n| "user_#{n}@example.jp"}
|
29
|
+
f.sequence(:username) { |n| "user_#{n}" }
|
30
|
+
f.sequence(:email) { |n| "user_#{n}@example.jp" }
|
31
31
|
f.password 'userpassword'
|
32
32
|
f.password_confirmation 'userpassword'
|
33
33
|
f.after(:create) do |user|
|
34
34
|
user_has_role = UserHasRole.new
|
35
|
-
user_has_role.assign_attributes(
|
35
|
+
user_has_role.assign_attributes(user_id: user.id, role_id: Role.find_by(name: 'User').id)
|
36
36
|
user_has_role.save
|
37
37
|
user.reload
|
38
38
|
end
|
data/spec/models/profile_spec.rb
CHANGED
@@ -1,70 +1,71 @@
|
|
1
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Profile do
|
4
|
-
#pending "add some examples to (or delete) #{__FILE__}"
|
5
|
+
# pending "add some examples to (or delete) #{__FILE__}"
|
5
6
|
fixtures :all
|
6
7
|
|
7
8
|
it 'should create a profile' do
|
8
|
-
|
9
|
+
FactoryGirl.create(:profile)
|
9
10
|
end
|
10
11
|
|
11
12
|
it 'should destroy a profile' do
|
12
|
-
profile =
|
13
|
+
profile = FactoryGirl.create(:profile)
|
13
14
|
profile.destroy.should be_truthy
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'should not set expired_at if its user group does not have valid period' do
|
17
|
-
profile =
|
18
|
+
profile = FactoryGirl.create(:profile)
|
18
19
|
profile.expired_at.should be_nil
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'should set expired_at if its user group has valid period' do
|
22
|
-
profile =
|
23
|
-
user_group =
|
23
|
+
profile = FactoryGirl.build(:profile)
|
24
|
+
user_group = FactoryGirl.create(:user_group, valid_period_for_new_user: 10)
|
24
25
|
user_group.profiles << profile
|
25
26
|
profile.user_group.valid_period_for_new_user.should eq 10
|
26
27
|
profile.expired_at.should eq 10.days.from_now.end_of_day
|
27
28
|
end
|
28
29
|
|
29
|
-
it
|
30
|
-
profile =
|
31
|
-
assert !profile.new_record?,
|
30
|
+
it 'should create profile' do
|
31
|
+
profile = FactoryGirl.create(:profile)
|
32
|
+
assert !profile.new_record?, profile.errors.full_messages.to_sentence.to_s
|
32
33
|
end
|
33
34
|
|
34
|
-
it
|
35
|
-
profile1 =
|
36
|
-
profile2 =
|
35
|
+
it 'should create profile with empty user_number' do
|
36
|
+
profile1 = FactoryGirl.create(:profile, user_number: '')
|
37
|
+
profile2 = FactoryGirl.create(:profile, user_number: '')
|
37
38
|
profile1.should be_valid
|
38
39
|
profile2.should be_valid
|
39
40
|
end
|
40
41
|
|
41
42
|
if defined?(EnjuQuestion)
|
42
|
-
it
|
43
|
+
it 'should reset answer_feed_token' do
|
43
44
|
profiles(:user1).reset_answer_feed_token
|
44
45
|
profiles(:user1).answer_feed_token.should be_truthy
|
45
46
|
end
|
46
47
|
|
47
|
-
it
|
48
|
+
it 'should delete answer_feed_token' do
|
48
49
|
profiles(:user1).delete_answer_feed_token
|
49
50
|
profiles(:user1).answer_feed_token.should be_nil
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
if defined?(EnjuCirculation)
|
54
|
-
it
|
55
|
+
it 'should reset checkout_icalendar_token' do
|
55
56
|
profiles(:user1).reset_checkout_icalendar_token
|
56
57
|
profiles(:user1).checkout_icalendar_token.should be_truthy
|
57
58
|
end
|
58
59
|
|
59
|
-
it
|
60
|
+
it 'should delete checkout_icalendar_token' do
|
60
61
|
profiles(:user1).delete_checkout_icalendar_token
|
61
62
|
profiles(:user1).checkout_icalendar_token.should be_nil
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
if defined?(EnjuCirculation)
|
66
|
-
it
|
67
|
-
assert profiles(:librarian1).user.send_message('reservation_expired_for_patron', :
|
67
|
+
it 'should send_message' do
|
68
|
+
assert profiles(:librarian1).user.send_message('reservation_expired_for_patron', manifestations: profiles(:librarian1).user.reserves.not_sent_expiration_notice_to_patron.collect(&:manifestation))
|
68
69
|
profiles(:librarian1).reload
|
69
70
|
profiles(:librarian1).user.reserves.not_sent_expiration_notice_to_patron.should be_empty
|
70
71
|
end
|
data/spec/models/role_spec.rb
CHANGED
@@ -2,25 +2,25 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Role do
|
5
|
-
#pending "add some examples to (or delete) #{__FILE__}"
|
5
|
+
# pending "add some examples to (or delete) #{__FILE__}"
|
6
6
|
fixtures :roles
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should not be saved if name is blank' do
|
9
9
|
role = Role.first
|
10
10
|
role.name = ''
|
11
|
-
|
11
|
+
-> { role.save! }.should raise_error(ActiveRecord::RecordInvalid)
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'should not be saved if name is not unique' do
|
15
15
|
role = Role.first
|
16
|
-
|
16
|
+
-> { Role.create!(name: role.name) }.should raise_error(ActiveRecord::RecordInvalid)
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'should respond to localized_name' do
|
20
20
|
roles(:role_00001).localized_name.should eq 'Guest'
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'should respond to default_role' do
|
24
24
|
Role.default_role.should eq roles(:role_00001)
|
25
25
|
end
|
26
26
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -2,85 +2,85 @@
|
|
2
2
|
require 'rails_helper'
|
3
3
|
|
4
4
|
describe User do
|
5
|
-
#pending "add some examples to (or delete) #{__FILE__}"
|
5
|
+
# pending "add some examples to (or delete) #{__FILE__}"
|
6
6
|
fixtures :all
|
7
7
|
|
8
8
|
it 'should create an user' do
|
9
|
-
|
9
|
+
FactoryGirl.create(:user)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should destroy an user' do
|
13
|
-
user =
|
13
|
+
user = FactoryGirl.create(:user)
|
14
14
|
user.destroy.should be_truthy
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should respond to has_role(Administrator)' do
|
18
|
-
admin =
|
18
|
+
admin = FactoryGirl.create(:admin)
|
19
19
|
admin.has_role?('Administrator').should be_truthy
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should respond to has_role(Librarian)' do
|
23
|
-
librarian =
|
23
|
+
librarian = FactoryGirl.create(:librarian)
|
24
24
|
librarian.has_role?('Administrator').should be_falsy
|
25
25
|
librarian.has_role?('Librarian').should be_truthy
|
26
26
|
librarian.has_role?('User').should be_truthy
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should respond to has_role(User)' do
|
30
|
-
user =
|
30
|
+
user = FactoryGirl.create(:user)
|
31
31
|
user.has_role?('Administrator').should be_falsy
|
32
32
|
user.has_role?('Librarian').should be_falsy
|
33
33
|
user.has_role?('User').should be_truthy
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should lock an user' do
|
37
|
-
user =
|
37
|
+
user = FactoryGirl.create(:user)
|
38
38
|
user.locked = '1'
|
39
39
|
user.save
|
40
40
|
user.active_for_authentication?.should be_falsy
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should unlock an user' do
|
44
|
-
user =
|
44
|
+
user = FactoryGirl.create(:user)
|
45
45
|
user.lock_access!
|
46
46
|
user.locked = '0'
|
47
47
|
user.save
|
48
48
|
user.active_for_authentication?.should be_truthy
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
user =
|
53
|
-
assert !user.new_record?,
|
51
|
+
it 'should create user' do
|
52
|
+
user = FactoryGirl.create(:user)
|
53
|
+
assert !user.new_record?, user.errors.full_messages.to_sentence.to_s
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should require username' do
|
57
57
|
old_count = User.count
|
58
|
-
user =
|
58
|
+
user = FactoryGirl.build(:user, username: nil)
|
59
59
|
user.save
|
60
60
|
user.errors[:username].should be_truthy
|
61
61
|
User.count.should eq old_count
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
65
|
-
user =
|
64
|
+
it 'should require password' do
|
65
|
+
user = FactoryGirl.build(:user, password: nil)
|
66
66
|
user.save
|
67
67
|
user.errors[:password].should be_truthy
|
68
68
|
end
|
69
69
|
|
70
|
-
it
|
71
|
-
user =
|
70
|
+
it 'should not require password_confirmation on create' do
|
71
|
+
user = FactoryGirl.build(:user, password: 'new_password', password_confirmation: nil)
|
72
72
|
user.save
|
73
73
|
user.errors[:email].should be_empty
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it 'should reset password' do
|
77
77
|
users(:user1).password = 'new password'
|
78
78
|
users(:user1).password_confirmation = 'new password'
|
79
79
|
users(:user1).save
|
80
80
|
users(:user1).valid_password?('new password').should be_truthy
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
83
|
+
it 'should set temporary_password' do
|
84
84
|
user = users(:user1)
|
85
85
|
old_password = user.encrypted_password
|
86
86
|
user.set_auto_generated_password
|
@@ -89,16 +89,16 @@ describe User do
|
|
89
89
|
user.valid_password?('user1password').should be_falsy
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
92
|
+
it 'should get highest_role' do
|
93
93
|
users(:admin).role.name.should eq 'Administrator'
|
94
94
|
end
|
95
95
|
|
96
|
-
it
|
96
|
+
it 'should lock all expired users' do
|
97
97
|
User.lock_expired_users
|
98
98
|
users(:user4).active_for_authentication?.should be_falsy
|
99
99
|
end
|
100
100
|
|
101
|
-
it
|
101
|
+
it 'should lock_expired users' do
|
102
102
|
user = users(:user1)
|
103
103
|
users(:user1).active_for_authentication?.should be_truthy
|
104
104
|
user.expired_at = 1.day.ago
|
@@ -107,18 +107,18 @@ describe User do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
if defined?(EnjuQuestion)
|
110
|
-
it
|
110
|
+
it 'should reset answer_feed_token' do
|
111
111
|
users(:user1).reset_answer_feed_token
|
112
112
|
users(:user1).answer_feed_token.should be_truthy
|
113
113
|
end
|
114
114
|
|
115
|
-
it
|
115
|
+
it 'should delete answer_feed_token' do
|
116
116
|
users(:user1).delete_answer_feed_token
|
117
117
|
users(:user1).answer_feed_token.should be_nil
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
describe
|
121
|
+
describe '.export' do
|
122
122
|
it "should export all user's information" do
|
123
123
|
lines = User.export
|
124
124
|
CSV.parse(lines, col_sep: "\t")
|
@@ -172,4 +172,3 @@ end
|
|
172
172
|
# save_search_history :boolean default(FALSE), not null
|
173
173
|
# answer_feed_token :string(255)
|
174
174
|
#
|
175
|
-
|
data/spec/rails_helper.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
3
4
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
4
5
|
ENV['RAILS_ENV'] ||= 'test'
|
5
6
|
require File.expand_path('../../spec/dummy/config/environment', __FILE__)
|
6
7
|
# Prevent database truncation if the environment is production
|
7
|
-
abort(
|
8
|
+
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
8
9
|
require 'spec_helper'
|
9
10
|
require 'rspec/rails'
|
10
|
-
require '
|
11
|
+
require 'factory_girl'
|
11
12
|
require 'rspec/active_model/mocks'
|
12
13
|
require 'sunspot_matchers'
|
13
14
|
require 'pundit/rspec'
|
@@ -69,5 +70,5 @@ RSpec.configure do |config|
|
|
69
70
|
config.include SunspotMatchers
|
70
71
|
end
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
|
74
|
+
FactoryGirl.find_definitions
|
@@ -1,35 +1,33 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ProfilesController do
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
{ get: "/profiles" }.should route_to(controller: "profiles", action: "index")
|
4
|
+
describe 'routing' do
|
5
|
+
it 'recognizes and generates #index' do
|
6
|
+
{ get: '/profiles' }.should route_to(controller: 'profiles', action: 'index')
|
8
7
|
end
|
9
8
|
|
10
|
-
it
|
11
|
-
{ get:
|
9
|
+
it 'recognizes and generates #new' do
|
10
|
+
{ get: '/profiles/new' }.should route_to(controller: 'profiles', action: 'new')
|
12
11
|
end
|
13
12
|
|
14
|
-
it
|
15
|
-
{ get:
|
13
|
+
it 'recognizes and generates #show' do
|
14
|
+
{ get: '/profiles/1' }.should route_to(controller: 'profiles', action: 'show', id: '1')
|
16
15
|
end
|
17
16
|
|
18
|
-
it
|
19
|
-
{ get:
|
17
|
+
it 'recognizes and generates #edit' do
|
18
|
+
{ get: '/profiles/1/edit' }.should route_to(controller: 'profiles', action: 'edit', id: '1')
|
20
19
|
end
|
21
20
|
|
22
|
-
it
|
23
|
-
{ post:
|
21
|
+
it 'recognizes and generates #create' do
|
22
|
+
{ post: '/profiles' }.should route_to(controller: 'profiles', action: 'create')
|
24
23
|
end
|
25
24
|
|
26
|
-
it
|
27
|
-
{ put:
|
25
|
+
it 'recognizes and generates #update' do
|
26
|
+
{ put: '/profiles/1' }.should route_to(controller: 'profiles', action: 'update', id: '1')
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
31
|
-
{ delete:
|
29
|
+
it 'recognizes and generates #destroy' do
|
30
|
+
{ delete: '/profiles/1' }.should route_to(controller: 'profiles', action: 'destroy', id: '1')
|
32
31
|
end
|
33
|
-
|
34
32
|
end
|
35
33
|
end
|