enju_leaf 1.2.0.beta.1 → 1.2.0.beta.2

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.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/lib/enju_leaf/engine.rb +1 -15
  3. data/lib/enju_leaf/version.rb +1 -1
  4. data/lib/generators/enju_leaf/quick_install/quick_install_generator.rb +3 -3
  5. data/lib/generators/enju_leaf/setup/setup_generator.rb +0 -1
  6. data/spec/controllers/page_controller_spec.rb +1 -1
  7. data/spec/dummy/app/controllers/application_controller.rb +0 -1
  8. data/spec/dummy/app/helpers/application_helper.rb +2 -1
  9. data/spec/dummy/app/models/user.rb +0 -1
  10. data/spec/dummy/config/application.rb +1 -2
  11. data/{db → spec/dummy/db}/migrate/041_create_roles.rb +0 -0
  12. data/spec/dummy/db/migrate/059_create_libraries.rb +1 -5
  13. data/spec/dummy/db/migrate/069_create_shelves.rb +1 -5
  14. data/{db → spec/dummy/db}/migrate/077_create_user_groups.rb +0 -0
  15. data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -5
  16. data/spec/dummy/db/migrate/131_create_request_types.rb +1 -5
  17. data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
  18. data/{db → spec/dummy/db}/migrate/20100606065209_create_user_has_roles.rb +0 -0
  19. data/{db → spec/dummy/db}/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +0 -0
  20. data/spec/dummy/db/migrate/20111129044509_add_pickup_location_to_reserve.rb +6 -0
  21. data/{db → spec/dummy/db}/migrate/20130221154434_add_additional_attributes_to_user.rb +0 -0
  22. data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
  23. data/{db → spec/dummy/db}/migrate/20140110122216_create_user_import_files.rb +0 -0
  24. data/{db → spec/dummy/db}/migrate/20140110131010_create_user_import_results.rb +0 -0
  25. data/{db → spec/dummy/db}/migrate/20140122054321_create_profiles.rb +0 -0
  26. data/{db → spec/dummy/db}/migrate/20140524074813_create_user_import_file_transitions.rb +0 -0
  27. data/{db → spec/dummy/db}/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +0 -0
  28. data/{db → spec/dummy/db}/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +0 -0
  29. data/{db → spec/dummy/db}/migrate/20140709113413_create_user_export_files.rb +0 -0
  30. data/{db → spec/dummy/db}/migrate/20140709113905_create_user_export_file_transitions.rb +0 -0
  31. data/{db → spec/dummy/db}/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +0 -0
  32. data/{db → spec/dummy/db}/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +0 -0
  33. data/{db → spec/dummy/db}/migrate/20140811031145_add_expired_at_to_profile.rb +0 -0
  34. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
  35. data/{db → spec/dummy/db}/migrate/20141003181336_add_full_name_transcription_to_profile.rb +0 -0
  36. data/{db → spec/dummy/db}/migrate/20141003182825_add_date_of_birth_to_profile.rb +0 -0
  37. data/spec/dummy/db/migrate/20141020120523_add_library_id_to_checkout.rb +6 -0
  38. data/spec/dummy/db/migrate/20150106001709_create_demands.rb +14 -0
  39. data/{db → spec/dummy/db}/migrate/20150421023923_create_identities.rb +0 -0
  40. data/{db → spec/dummy/db}/migrate/20150506105356_add_error_message_to_user_import_result.rb +0 -0
  41. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  42. data/{db → spec/dummy/db}/migrate/20151126005552_add_provider_to_identity.rb +0 -0
  43. data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +5 -0
  44. data/{db → spec/dummy/db}/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +0 -0
  45. data/{db → spec/dummy/db}/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +0 -0
  46. data/spec/dummy/db/migrate/20160703184619_add_most_recent_to_reserve_transitions.rb +9 -0
  47. data/spec/dummy/db/migrate/20160703184650_add_most_recent_to_manifestation_checkout_stat_transitions.rb +9 -0
  48. data/spec/dummy/db/migrate/20160703184723_add_most_recent_to_manifestation_reserve_stat_transitions.rb +9 -0
  49. data/spec/dummy/db/migrate/20160703184747_add_most_recent_to_user_checkout_stat_transitions.rb +9 -0
  50. data/spec/dummy/db/migrate/20160703184805_add_most_recent_to_user_reserve_stat_transitions.rb +9 -0
  51. data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
  52. data/spec/dummy/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +5 -0
  53. data/spec/dummy/db/schema.rb +47 -12
  54. data/spec/fixtures/library_groups.yml +1 -4
  55. data/spec/models/user_spec.rb +0 -22
  56. data/spec/rails_helper.rb +1 -1
  57. data/spec/views/page/index.html.erb_spec.rb +0 -2
  58. metadata +96 -337
  59. data/app/controllers/concerns/enju_leaf/controller.rb +0 -225
  60. data/app/controllers/my_accounts_controller.rb +0 -93
  61. data/app/controllers/names_controller.rb +0 -60
  62. data/app/controllers/profiles_controller.rb +0 -219
  63. data/app/controllers/roles_controller.rb +0 -61
  64. data/app/controllers/user_export_files_controller.rb +0 -116
  65. data/app/controllers/user_groups_controller.rb +0 -118
  66. data/app/controllers/user_import_files_controller.rb +0 -129
  67. data/app/controllers/user_import_results_controller.rb +0 -57
  68. data/app/mailers/notifier.rb +0 -30
  69. data/app/models/identity.rb +0 -9
  70. data/app/models/profile.rb +0 -101
  71. data/app/models/role.rb +0 -50
  72. data/app/models/user_export_file.rb +0 -67
  73. data/app/models/user_export_file_state_machine.rb +0 -15
  74. data/app/models/user_export_file_transition.rb +0 -20
  75. data/app/models/user_group.rb +0 -29
  76. data/app/models/user_has_role.rb +0 -19
  77. data/app/models/user_import_file.rb +0 -352
  78. data/app/models/user_import_file_state_machine.rb +0 -19
  79. data/app/models/user_import_file_transition.rb +0 -20
  80. data/app/models/user_import_result.rb +0 -20
  81. data/app/policies/application_policy.rb +0 -53
  82. data/app/policies/name_policy.rb +0 -21
  83. data/app/policies/profile_policy.rb +0 -55
  84. data/app/policies/role_policy.rb +0 -21
  85. data/app/policies/user_export_file_policy.rb +0 -21
  86. data/app/policies/user_group_policy.rb +0 -22
  87. data/app/policies/user_import_file_policy.rb +0 -21
  88. data/app/policies/user_import_result_policy.rb +0 -21
  89. data/app/views/my_accounts/_edit_credential.html.erb +0 -99
  90. data/app/views/my_accounts/_form.html.erb +0 -24
  91. data/app/views/my_accounts/_show.html.erb +0 -1
  92. data/app/views/my_accounts/edit.html.erb +0 -32
  93. data/app/views/my_accounts/show.html+phone.erb +0 -1
  94. data/app/views/my_accounts/show.html.erb +0 -49
  95. data/app/views/names/_form.html.erb +0 -41
  96. data/app/views/names/edit.html.erb +0 -6
  97. data/app/views/names/index.html.erb +0 -37
  98. data/app/views/names/new.html.erb +0 -5
  99. data/app/views/names/show.html.erb +0 -34
  100. data/app/views/profiles/_edit_credential.html.erb +0 -88
  101. data/app/views/profiles/_edit_profile.html.erb +0 -42
  102. data/app/views/profiles/_form.html.erb +0 -15
  103. data/app/views/profiles/_show.html.erb +0 -1
  104. data/app/views/profiles/edit.html.erb +0 -33
  105. data/app/views/profiles/index.html.erb +0 -70
  106. data/app/views/profiles/new.html.erb +0 -88
  107. data/app/views/profiles/show.html+phone.erb +0 -1
  108. data/app/views/profiles/show.html.erb +0 -71
  109. data/app/views/roles/_form.html.erb +0 -19
  110. data/app/views/roles/edit.html.erb +0 -13
  111. data/app/views/roles/index.html.erb +0 -32
  112. data/app/views/roles/new.html.erb +0 -12
  113. data/app/views/roles/show.html.erb +0 -46
  114. data/app/views/user_export_files/_form.html.erb +0 -12
  115. data/app/views/user_export_files/edit.html.erb +0 -6
  116. data/app/views/user_export_files/index.html.erb +0 -44
  117. data/app/views/user_export_files/new.html.erb +0 -16
  118. data/app/views/user_export_files/show.html.erb +0 -36
  119. data/app/views/user_groups/_form.html.erb +0 -40
  120. data/app/views/user_groups/edit.html.erb +0 -13
  121. data/app/views/user_groups/index.html.erb +0 -51
  122. data/app/views/user_groups/new.html.erb +0 -12
  123. data/app/views/user_groups/show.html.erb +0 -68
  124. data/app/views/user_import_files/_form.html.erb +0 -61
  125. data/app/views/user_import_files/_results.html.erb +0 -22
  126. data/app/views/user_import_files/edit.html.erb +0 -6
  127. data/app/views/user_import_files/index.html.erb +0 -45
  128. data/app/views/user_import_files/new.html.erb +0 -60
  129. data/app/views/user_import_files/show.html.erb +0 -85
  130. data/app/views/user_import_results/_form.html.erb +0 -29
  131. data/app/views/user_import_results/_list.html.erb +0 -22
  132. data/app/views/user_import_results/_list_lines.html.erb +0 -24
  133. data/app/views/user_import_results/index.html.erb +0 -25
  134. data/app/views/user_import_results/index.txt.erb +0 -3
  135. data/app/views/user_import_results/show.html.erb +0 -33
  136. data/db/migrate/20091202124834_create_versions.rb +0 -18
  137. data/spec/controllers/my_accounts_controller_spec.rb +0 -229
  138. data/spec/controllers/profiles_controller_spec.rb +0 -594
  139. data/spec/controllers/roles_controller_spec.rb +0 -136
  140. data/spec/controllers/user_export_files_controller_spec.rb +0 -296
  141. data/spec/controllers/user_groups_controller_spec.rb +0 -443
  142. data/spec/controllers/user_import_files_controller_spec.rb +0 -305
  143. data/spec/controllers/user_import_results_controller_spec.rb +0 -157
  144. data/spec/fixtures/user_export_files.yml +0 -25
  145. data/spec/fixtures/user_import_files.yml +0 -51
  146. data/spec/fixtures/user_import_results.yml +0 -26
  147. data/spec/fixtures/user_reserve_stats.yml +0 -27
  148. data/spec/models/basket_spec.rb +0 -23
  149. data/spec/models/profile_spec.rb +0 -98
  150. data/spec/models/role_spec.rb +0 -40
  151. data/spec/models/user_export_file_spec.rb +0 -30
  152. data/spec/models/user_group_spec.rb +0 -37
  153. data/spec/models/user_has_role_spec.rb +0 -18
  154. data/spec/models/user_import_file_spec.rb +0 -220
  155. data/spec/models/user_import_result_spec.rb +0 -20
  156. data/spec/requests/profiles_spec.rb +0 -9
  157. data/spec/routing/profiles_routing_spec.rb +0 -35
  158. data/spec/routing/resource_import_files_routing_spec.rb +0 -35
  159. data/spec/routing/roles_routing_spec.rb +0 -35
  160. data/spec/routing/users_spec.rb +0 -14
  161. data/spec/views/my_accounts/show.html.erb_spec.rb +0 -43
  162. data/spec/views/profiles/edit.html.erb_spec.rb +0 -42
  163. data/spec/views/profiles/index.html.erb_spec.rb +0 -19
  164. data/spec/views/profiles/new.html.erb_spec.rb +0 -25
  165. data/spec/views/profiles/show.html.erb_spec.rb +0 -31
  166. data/spec/views/user_export_files/new.html.erb_spec.rb +0 -19
  167. data/spec/views/user_import_results/index.html.erb_spec.rb +0 -29
@@ -1,25 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- user_export_file_00001:
4
- id: 1
5
- user_id: 1
6
- user_export_file_00002:
7
- id: 2
8
- user_id: 1
9
- user_export_file_00003:
10
- id: 3
11
- user_id: 1
12
-
13
- # == Schema Information
14
- #
15
- # Table name: user_export_files
16
- #
17
- # id :integer not null, primary key
18
- # user_id :integer
19
- # executed_at :datetime
20
- # created_at :datetime
21
- # updated_at :datetime
22
- # user_export_id :string
23
- # user_export_size :integer
24
- # user_import_filename :string
25
- #
@@ -1,51 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
-
3
- one:
4
- id: 1
5
- user_id: 1
6
- note: MyText
7
- executed_at: 2014-01-10 21:22:16
8
- user_import_file_name: MyString
9
- user_import_content_type: text/csv
10
- user_import_file_size: 1
11
- user_import_updated_at: 2014-01-10 21:22:16
12
- user_import_fingerprint: MyString
13
- edit_mode: MyString
14
- error_message: MyText
15
-
16
- two:
17
- id: 2
18
- user_id: 1
19
- note: MyText
20
- executed_at: 2014-01-10 21:22:16
21
- user_import_file_name: MyString
22
- user_import_content_type: text/csv
23
- user_import_file_size: 1
24
- user_import_updated_at: 2014-01-10 21:22:16
25
- user_import_fingerprint: MyString
26
- edit_mode: MyString
27
- error_message: MyText
28
-
29
- # == Schema Information
30
- #
31
- # Table name: user_import_files
32
- #
33
- # id :integer not null, primary key
34
- # user_id :integer
35
- # note :text
36
- # executed_at :datetime
37
- # user_import_file_name :string
38
- # user_import_content_type :string
39
- # user_import_file_size :integer
40
- # user_import_updated_at :datetime
41
- # user_import_fingerprint :string
42
- # edit_mode :string
43
- # error_message :text
44
- # created_at :datetime
45
- # updated_at :datetime
46
- # user_encoding :string
47
- # default_library_id :integer
48
- # default_user_group_id :integer
49
- # user_import_id :string
50
- # user_import_size :integer
51
- #
@@ -1,26 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
-
3
- one:
4
- id: 1
5
- user_import_file_id: 1
6
- user_id: 1
7
- body: MyText
8
-
9
- two:
10
- id: 2
11
- user_import_file_id: 1
12
- user_id: 2
13
- body: MyText
14
-
15
- # == Schema Information
16
- #
17
- # Table name: user_import_results
18
- #
19
- # id :integer not null, primary key
20
- # user_import_file_id :integer
21
- # user_id :integer
22
- # body :text
23
- # created_at :datetime
24
- # updated_at :datetime
25
- # error_message :text
26
- #
@@ -1,27 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- one:
4
- id: 1
5
- start_date: 2008-12-20 11:36:28
6
- end_date: 2008-12-21 11:36:28
7
- note: MyText
8
-
9
- two:
10
- id: 2
11
- start_date: 2008-12-20 11:36:28
12
- end_date: 2008-12-21 11:36:28
13
- note: MyText
14
-
15
- # == Schema Information
16
- #
17
- # Table name: user_reserve_stats
18
- #
19
- # id :integer not null, primary key
20
- # start_date :datetime
21
- # end_date :datetime
22
- # note :text
23
- # created_at :datetime
24
- # updated_at :datetime
25
- # started_at :datetime
26
- # completed_at :datetime
27
- #
@@ -1,23 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Basket do
5
- fixtures :all
6
-
7
- it "should not create basket when user is not active" do
8
- Basket.create(:user => users(:user4)).id.should be_nil
9
- end
10
- end
11
-
12
- # == Schema Information
13
- #
14
- # Table name: baskets
15
- #
16
- # id :integer not null, primary key
17
- # user_id :integer
18
- # note :text
19
- # lock_version :integer default(0), not null
20
- # created_at :datetime not null
21
- # updated_at :datetime not null
22
- #
23
-
@@ -1,98 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Profile do
5
- #pending "add some examples to (or delete) #{__FILE__}"
6
- fixtures :all
7
-
8
- it 'should create a profile' do
9
- FactoryGirl.create(:profile)
10
- end
11
-
12
- it 'should destroy a profile' do
13
- profile = FactoryGirl.create(:profile)
14
- profile.destroy.should be_truthy
15
- end
16
-
17
- it 'should not set expired_at if its user group does not have valid period' do
18
- profile = FactoryGirl.create(:profile)
19
- profile.expired_at.should be_nil
20
- end
21
-
22
- it 'should set expired_at if its user group has valid period' do
23
- profile = FactoryGirl.build(:profile)
24
- user_group = FactoryGirl.create(:user_group, :valid_period_for_new_user => 10)
25
- user_group.profiles << profile
26
- profile.user_group.valid_period_for_new_user.should eq 10
27
- profile.expired_at.should eq 10.days.from_now.end_of_day
28
- end
29
-
30
- it "should create profile" do
31
- profile = FactoryGirl.create(:profile)
32
- assert !profile.new_record?, "#{profile.errors.full_messages.to_sentence}"
33
- end
34
-
35
- it "should create profile with empty user_number" do
36
- profile1 = FactoryGirl.create(:profile, user_number: "")
37
- profile2 = FactoryGirl.create(:profile, user_number: "")
38
- profile1.should be_valid
39
- profile2.should be_valid
40
- end
41
-
42
- if defined?(EnjuQuestion)
43
- it "should reset answer_feed_token" do
44
- profiles(:user1).reset_answer_feed_token
45
- profiles(:user1).answer_feed_token.should be_truthy
46
- end
47
-
48
- it "should delete answer_feed_token" do
49
- profiles(:user1).delete_answer_feed_token
50
- profiles(:user1).answer_feed_token.should be_nil
51
- end
52
- end
53
-
54
- if defined?(EnjuCirculation)
55
- it "should reset checkout_icalendar_token" do
56
- profiles(:user1).reset_checkout_icalendar_token
57
- profiles(:user1).checkout_icalendar_token.should be_truthy
58
- end
59
-
60
- it "should delete checkout_icalendar_token" do
61
- profiles(:user1).delete_checkout_icalendar_token
62
- profiles(:user1).checkout_icalendar_token.should be_nil
63
- end
64
- end
65
-
66
- if defined?(EnjuCirculation)
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))
69
- profiles(:librarian1).reload
70
- profiles(:librarian1).user.reserves.not_sent_expiration_notice_to_patron.should be_empty
71
- end
72
- end
73
- end
74
-
75
- # == Schema Information
76
- #
77
- # Table name: profiles
78
- #
79
- # id :integer not null, primary key
80
- # user_id :integer
81
- # user_group_id :integer
82
- # library_id :integer
83
- # locale :string
84
- # user_number :string
85
- # full_name :text
86
- # note :text
87
- # keyword_list :text
88
- # required_role_id :integer
89
- # created_at :datetime
90
- # updated_at :datetime
91
- # checkout_icalendar_token :string
92
- # save_checkout_history :boolean default(FALSE), not null
93
- # expired_at :datetime
94
- # save_search_history :boolean
95
- # share_bookmarks :boolean
96
- # full_name_transcription :text
97
- # date_of_birth :datetime
98
- #
@@ -1,40 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Role do
5
- #pending "add some examples to (or delete) #{__FILE__}"
6
- fixtures :roles
7
-
8
- it "should not be saved if name is blank" do
9
- role = Role.first
10
- role.name = ''
11
- lambda{role.save!}.should raise_error(ActiveRecord::RecordInvalid)
12
- end
13
-
14
- it "should not be saved if name is not unique" do
15
- role = Role.first
16
- lambda{Role.create!(:name => role.name)}.should raise_error(ActiveRecord::RecordInvalid)
17
- end
18
-
19
- it "should respond to localized_name" do
20
- roles(:role_00001).localized_name.should eq 'Guest'
21
- end
22
-
23
- it "should respond to default_role" do
24
- Role.default_role.should eq roles(:role_00001)
25
- end
26
- end
27
-
28
- # == Schema Information
29
- #
30
- # Table name: roles
31
- #
32
- # id :integer not null, primary key
33
- # name :string not null
34
- # display_name :string
35
- # note :text
36
- # created_at :datetime
37
- # updated_at :datetime
38
- # score :integer default(0), not null
39
- # position :integer
40
- #
@@ -1,30 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe UserExportFile do
5
- fixtures :all
6
-
7
- it "should export in background" do
8
- message_count = Message.count
9
- file = UserExportFile.new
10
- file.user = users(:admin)
11
- file.save
12
- UserExportFileJob.perform_later(file).should be_truthy
13
- Message.count.should eq message_count + 1
14
- Message.order(:id).last.subject.should eq 'エクスポートが完了しました'
15
- end
16
- end
17
-
18
- # == Schema Information
19
- #
20
- # Table name: user_export_files
21
- #
22
- # id :integer not null, primary key
23
- # user_id :integer
24
- # executed_at :datetime
25
- # created_at :datetime
26
- # updated_at :datetime
27
- # user_export_id :string
28
- # user_export_size :integer
29
- # user_import_filename :string
30
- #
@@ -1,37 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe UserGroup do
5
- fixtures :user_groups
6
-
7
- it "should contain string in its display_name" do
8
- user_group = user_groups(:user_group_00001)
9
- user_group.display_name = "en:test"
10
- user_group.valid?.should be_truthy
11
- end
12
-
13
- it "should not contain invalid yaml in its display_name" do
14
- user_group = user_groups(:user_group_00001)
15
- user_group.display_name = "en:test\r\nja: テスト"
16
- user_group.valid?.should be_falsy
17
- end
18
- end
19
-
20
- # == Schema Information
21
- #
22
- # Table name: user_groups
23
- #
24
- # id :integer not null, primary key
25
- # name :string
26
- # display_name :text
27
- # note :text
28
- # position :integer
29
- # created_at :datetime
30
- # updated_at :datetime
31
- # deleted_at :datetime
32
- # valid_period_for_new_user :integer default(0), not null
33
- # expired_at :datetime
34
- # number_of_day_to_notify_overdue :integer default(1), not null
35
- # number_of_day_to_notify_due_date :integer default(7), not null
36
- # number_of_time_to_notify_overdue :integer default(3), not null
37
- #
@@ -1,18 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe UserHasRole do
5
- #pending "add some examples to (or delete) #{__FILE__}"
6
-
7
- end
8
-
9
- # == Schema Information
10
- #
11
- # Table name: user_has_roles
12
- #
13
- # id :integer not null, primary key
14
- # user_id :integer
15
- # role_id :integer
16
- # created_at :datetime
17
- # updated_at :datetime
18
- #
@@ -1,220 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'rails_helper'
3
-
4
- describe UserImportFile do
5
- fixtures :all
6
-
7
- describe "when its mode is 'create'" do
8
- before(:each) do
9
- @file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv")
10
- @file.default_user_group = UserGroup.find(2)
11
- @file.default_library = Library.find(3)
12
- @file.user = users(:admin)
13
- @file.save
14
- end
15
-
16
- it "should be imported" do
17
- old_users_count = User.count
18
- old_import_results_count = UserImportResult.count
19
- @file.current_state.should eq 'pending'
20
- @file.import_start.should eq({:user_imported => 5, :user_found => 0, :failed => 0, error: 3})
21
- User.order('id DESC')[1].username.should eq 'user005'
22
- User.order('id DESC')[2].username.should eq 'user003'
23
- User.count.should eq old_users_count + 5
24
-
25
- user001 = User.where(username: 'user001').first
26
- user001.profile.keyword_list.should eq "日本史\n地理"
27
- user001.profile.full_name.should eq '田辺 浩介'
28
- user001.profile.full_name_transcription.should eq 'たなべ こうすけ'
29
- user001.profile.required_role.name.should eq 'User'
30
- user001.locked_at.should be_truthy
31
-
32
- user002 = User.where(username: 'user002').first
33
- user002.profile.user_group.name.should eq 'faculty'
34
- user002.profile.expired_at.to_i.should eq Time.zone.parse('2013-12-01').end_of_day.to_i
35
- user002.valid_password?('4NsxXPLy')
36
- user002.profile.user_number.should eq '001002'
37
- user002.profile.library.name.should eq 'hachioji'
38
- user002.profile.locale.should eq 'en'
39
- user002.profile.required_role.name.should eq 'Librarian'
40
- user002.locked_at.should be_nil
41
-
42
- user003 = User.where(username: 'user003').first
43
- user003.profile.note.should eq 'テストユーザ'
44
- user003.role.name.should eq 'Librarian'
45
- user003.profile.user_number.should eq '001003'
46
- user003.profile.library.name.should eq 'kamata'
47
- user003.profile.locale.should eq 'ja'
48
- user003.profile.checkout_icalendar_token.should eq 'secrettoken'
49
- user003.profile.save_checkout_history.should be_truthy
50
- user003.profile.save_search_history.should be_falsy
51
- user003.profile.share_bookmarks.should be_falsy
52
- User.where(username: 'user000').first.should be_nil
53
- UserImportResult.count.should eq old_import_results_count + 10
54
- UserImportResult.order('id DESC')[0].error_message.should eq 'line 10: User number has already been taken'
55
- UserImportResult.order('id DESC')[1].error_message.should eq 'line 9: User number is invalid'
56
- UserImportResult.order('id DESC')[2].error_message.should eq 'line 8: Password is too short (minimum is 6 characters)'
57
-
58
- user005 = User.where(username: 'user005').first
59
- user005.role.name.should eq 'User'
60
- user005.profile.library.name.should eq 'hachioji'
61
- user005.profile.locale.should eq 'en'
62
- user005.profile.user_number.should eq '001005'
63
- user005.profile.user_group.name.should eq 'faculty'
64
-
65
- user006 = User.where(username: 'user006').first
66
- user006.role.name.should eq 'User'
67
- user006.profile.library.name.should eq 'hachioji'
68
- user006.profile.locale.should eq 'en'
69
- user006.profile.user_number.should be_nil
70
- user006.profile.user_group.name.should eq UserGroup.find(2).name
71
-
72
- @file.user_import_fingerprint.should be_truthy
73
- @file.executed_at.should be_truthy
74
-
75
- @file.reload
76
- @file.error_message.should eq "The following column(s) were ignored: invalid\nline 8: Password is too short (minimum is 6 characters)\nline 9: User number is invalid\nline 10: User number has already been taken"
77
- @file.current_state.should eq 'failed'
78
- end
79
-
80
- it "should send message when import is completed" do
81
- old_message_count = Message.count
82
- @file.user = User.where(username: 'librarian1').first
83
- @file.import_start
84
- Message.count.should eq old_message_count + 1
85
- Message.order(:id).last.subject.should eq 'インポートが完了しました'
86
- end
87
-
88
- it "should not import users that have higher roles than current user's role" do
89
- old_users_count = User.count
90
- old_import_results_count = UserImportResult.count
91
- @file.user = User.where(username: 'librarian1').first
92
- @file.import_start.should eq({:user_imported => 4, :user_found => 0, :failed => 1, error: 3})
93
- User.order('id DESC')[1].username.should eq 'user005'
94
- User.count.should eq old_users_count + 4
95
- UserImportResult.count.should eq old_import_results_count + 10
96
- end
97
- end
98
-
99
- describe "when its mode is 'update'" do
100
- before(:each) do
101
- FactoryGirl.create(:user,
102
- username: 'user001',
103
- profile: FactoryGirl.create(:profile)
104
- )
105
- end
106
- it "should update users" do
107
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file.tsv"), user: users(:admin)
108
- old_message_count = Message.count
109
- result = @file.modify
110
- result.should have_key(:user_updated)
111
- user001 = User.where(username: 'user001').first
112
- user001.email.should eq 'user001@example.jp'
113
- user001.profile.full_name.should eq '田辺 浩介'
114
- user001.profile.full_name_transcription.should eq 'たなべこうすけ'
115
- user001.profile.user_number.should eq 'user_number_1'
116
- user001.profile.note.should eq 'test'
117
- user001.profile.keyword_list.should eq 'keyword1 keyword2'
118
- Message.count.should eq old_message_count + 1
119
- end
120
-
121
- it "should not overwrite with null value" do
122
- user = User.where(username: 'user001').first
123
- user.profile = FactoryGirl.create(:profile,
124
- user_number: '001',
125
- full_name: 'User 001',
126
- full_name_transcription: 'User 001',
127
- locale: 'ja',
128
- note: 'Note',
129
- keyword_list: 'keyword1 keyword2',
130
- date_of_birth: 10.years.ago)
131
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file2.tsv"), user: users(:admin)
132
- result = @file.modify
133
- result.should have_key(:user_updated)
134
- user001 = User.find('user001')
135
- user001.email.should eq 'user001@example.jp'
136
- user001.profile.user_number.should eq '001'
137
- user001.profile.full_name.should eq 'User 001'
138
- user001.profile.full_name_transcription.should eq 'User 001'
139
- user001.profile.keyword_list.should eq 'keyword1 keyword2'
140
- end
141
- it "should update user_number" do
142
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file3.tsv"), user: users(:admin)
143
- result = @file.modify
144
- result.should have_key(:user_updated)
145
- user001 = User.where(username: 'user001').first
146
- user001.profile.user_number.should eq '0001'
147
- end
148
- it "should update user's lock status" do
149
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_update_file4.tsv"), user: users(:admin)
150
- result = @file.modify
151
- result.should have_key(:user_updated)
152
- user001 = User.where(username: 'user001').first
153
- user001.access_locked?.should be_truthy
154
- end
155
- end
156
-
157
- describe "when its mode is 'destroy'" do
158
- before(:each) do
159
- @file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv"), user: users(:admin)
160
- @file.user = users(:admin)
161
- @file.default_user_group = UserGroup.find(2)
162
- @file.default_library = Library.find(3)
163
- @file.save
164
- @file.import_start
165
- end
166
-
167
- it "should remove users" do
168
- old_count = User.count
169
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_delete_file.tsv"), user: users(:admin)
170
- @file.user = users(:admin)
171
- old_message_count = Message.count
172
- @file.remove
173
- User.count.should eq old_count - 2
174
- Message.count.should eq old_message_count + 1
175
- end
176
-
177
- it "should not remove users if there are checkouts" do
178
- user001 = User.where(username: 'user001').first
179
- FactoryGirl.create(:checkout, user: user001, item: FactoryGirl.create(:item))
180
- old_count = User.count
181
- @file = UserImportFile.create user_import: File.new("#{Rails.root}/../../examples/user_delete_file.tsv"), user: users(:admin)
182
- @file.remove
183
- User.where(username: 'user001').should_not be_blank
184
- User.count.should eq old_count - 2
185
- end
186
- end
187
-
188
- it "should import in background" do
189
- file = UserImportFile.new user_import: File.new("#{Rails.root}/../../examples/user_import_file_sample.tsv"), user: users(:admin)
190
- file.user = users(:admin)
191
- file.default_user_group = UserGroup.find(2)
192
- file.default_library = Library.find(3)
193
- file.save
194
- UserImportFileJob.perform_later(file).should be_truthy
195
- end
196
- end
197
-
198
- # == Schema Information
199
- #
200
- # Table name: user_import_files
201
- #
202
- # id :integer not null, primary key
203
- # user_id :integer
204
- # note :text
205
- # executed_at :datetime
206
- # user_import_file_name :string
207
- # user_import_content_type :string
208
- # user_import_file_size :integer
209
- # user_import_updated_at :datetime
210
- # user_import_fingerprint :string
211
- # edit_mode :string
212
- # error_message :text
213
- # created_at :datetime
214
- # updated_at :datetime
215
- # user_encoding :string
216
- # default_library_id :integer
217
- # default_user_group_id :integer
218
- # user_import_id :string
219
- # user_import_size :integer
220
- #