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

Sign up to get free protection for your applications and to get access to all the features.
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,3 +0,0 @@
1
- <%- @user_import_results.each do |user_import_result| -%>
2
- "<%= user_import_result.user.try(:username) %>" <%= user_import_result.body %><%= "\n" -%>
3
- <%- end -%>
@@ -1,33 +0,0 @@
1
- <div id="content_detail" class="ui-corner-all ui-widget-content">
2
- <h1 class="title"><%= t('page.showing', model: t('activerecord.models.user_import_result')) -%></h1>
3
- <div id="content_list">
4
- <p id="notice"><%= notice %></p>
5
-
6
- <p>
7
- <b><%= t('activerecord.models.user_import_file') %></b>
8
- <%= @user_import_result.user_import_file.user_import_file_name %>
9
- </p>
10
-
11
- <p>
12
- <b><%= t('activerecord.models.user') %></b>
13
- <%= link_to @user_import_result.user.username, @user_import_result.user.profile if @user_import_result.user.try(:profile) %>
14
- </p>
15
-
16
- <p>
17
- <b><%= t('activerecord.attributes.user_import_result.body') %></b>
18
- <%= @user_import_result.body.inspect %>
19
- </p>
20
-
21
- <p>
22
- <b><%= t('page.created_at') %></b>
23
- <%=l @user_import_result.created_at %>
24
- </p>
25
-
26
- </div>
27
- </div>
28
-
29
- <div id="submenu" class="ui-corner-all ui-widget-content">
30
- <ul>
31
- <li><%= back_to_index(flash[:page_info]) -%></li>
32
- </ul>
33
- </div>
@@ -1,18 +0,0 @@
1
- class CreateVersions < ActiveRecord::Migration
2
- def self.up
3
- create_table :versions do |t|
4
- t.string :item_type, :null => false
5
- t.integer :item_id, :null => false
6
- t.string :event, :null => false
7
- t.string :whodunnit
8
- t.text :object
9
- t.datetime :created_at
10
- end
11
- add_index :versions, [:item_type, :item_id]
12
- end
13
-
14
- def self.down
15
- remove_index :versions, [:item_type, :item_id]
16
- drop_table :versions
17
- end
18
- end
@@ -1,229 +0,0 @@
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.find('enjuadmin')
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
@@ -1,594 +0,0 @@
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