enju_leaf 1.1.0.rc7 → 1.1.0.rc8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +7 -4
- data/app/assets/javascripts/jquery.mobile-1.4.2.js +15056 -0
- data/app/assets/javascripts/mobile.js +1 -1
- data/app/assets/javascripts/profiles.js +2 -0
- data/app/assets/stylesheets/enju.css +1 -1
- data/app/assets/stylesheets/jquery.mobile-1.4.2.css +4698 -0
- data/app/assets/stylesheets/mobile.css +1 -1
- data/app/assets/stylesheets/normalize.css +406 -0
- data/app/assets/stylesheets/profiles.css +4 -0
- data/app/controllers/user_import_files_controller.rb +93 -0
- data/app/controllers/user_import_results_controller.rb +15 -0
- data/app/controllers/users_controller.rb +2 -2
- data/app/helpers/profiles_helper.rb +2 -0
- data/app/models/enju_leaf/ability.rb +12 -2
- data/app/models/profile.rb +15 -0
- data/app/models/user_import_file.rb +171 -0
- data/app/models/user_import_result.rb +9 -0
- data/app/views/kaminari/{_first_page.mobile.erb → enju_leaf_mobile/_first_page.html.erb} +0 -0
- data/app/views/kaminari/{_gap.mobile.erb → enju_leaf_mobile/_gap.html.erb} +0 -0
- data/app/views/kaminari/{_last_page.mobile.erb → enju_leaf_mobile/_last_page.html.erb} +0 -0
- data/app/views/kaminari/{_next_page.mobile.erb → enju_leaf_mobile/_next_page.html.erb} +0 -0
- data/app/views/kaminari/{_page.mobile.erb → enju_leaf_mobile/_page.html.erb} +0 -0
- data/app/views/kaminari/{_paginator.mobile.erb → enju_leaf_mobile/_paginator.html.erb} +0 -0
- data/app/views/kaminari/{_prev_page.mobile.erb → enju_leaf_mobile/_prev_page.html.erb} +0 -0
- data/app/views/page/_footer.html.erb +3 -3
- data/app/views/page/_menu.html.erb +1 -1
- data/app/views/page/about.en.html.erb +2 -2
- data/app/views/page/about.ja.html.erb +2 -2
- data/app/views/page/configuration.html.erb +12 -0
- data/app/views/page/import.html.erb +6 -5
- data/app/views/profiles/_form.html.erb +53 -0
- data/app/views/profiles/edit.html.erb +6 -0
- data/app/views/profiles/index.html.erb +43 -0
- data/app/views/profiles/new.html.erb +14 -0
- data/app/views/profiles/show.html.erb +54 -0
- data/app/views/user_groups/_form.html.erb +1 -1
- data/app/views/user_import_files/_form.html.erb +61 -0
- data/app/views/user_import_files/edit.html.erb +6 -0
- data/app/views/user_import_files/index.html.erb +43 -0
- data/app/views/user_import_files/new.html.erb +35 -0
- data/app/views/user_import_files/show.html.erb +59 -0
- data/app/views/user_import_results/_form.html.erb +29 -0
- data/app/views/user_import_results/index.html.erb +31 -0
- data/app/views/user_import_results/show.html.erb +19 -0
- data/app/views/users/new.html.erb +4 -4
- data/config/locales/translation_en.yml +17 -6
- data/config/locales/translation_ja.yml +17 -1
- data/config/routes.rb +8 -0
- data/db/migrate/20140110122216_create_user_import_files.rb +19 -0
- data/db/migrate/20140110131010_create_user_import_results.rb +11 -0
- data/db/migrate/20140122054321_create_profiles.rb +21 -0
- data/lib/enju_leaf/engine.rb +1 -0
- data/lib/enju_leaf/user.rb +6 -3
- data/lib/enju_leaf/version.rb +1 -1
- data/lib/generators/enju_leaf/setup/setup_generator.rb +3 -1
- data/lib/generators/enju_leaf/setup/templates/Procfile +3 -0
- data/lib/generators/enju_leaf/setup/templates/config/application.yml +1 -1
- data/lib/generators/enju_leaf/setup/templates/config/schedule.rb +1 -2
- data/spec/controllers/user_import_files_controller_spec.rb +294 -0
- data/spec/controllers/user_import_results_controller_spec.rb +137 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +25 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_delete_file.tsv +4 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_import_file_sample.tsv +5 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/963/original/user_update_file.tsv +4 -0
- data/spec/dummy/private/system/user_import_files/user_imports/980/190/964/original/user_delete_file.tsv +4 -0
- data/spec/dummy/solr/default/data/index/segments.gen +0 -0
- data/spec/dummy/solr/default/data/index/segments_1la +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000063 → tlog.0000000000000002051} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002052 +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000065 → tlog.0000000000000002053} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002054 +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000067 → tlog.0000000000000002055} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002056 +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000069 → tlog.0000000000000002057} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002058 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002059 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002060 +0 -0
- data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
- data/spec/dummy/tmp/cache/ACB/B20/manifestation_search_total +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/154f7b83f2da0e86effbe25f32135177 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/1b984bdbd3204a51a82d0e01a1569e2d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3054c50144654f9c7e57bb0639a276e9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/3bd7a263237ba366f64d938fe5303757 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/62899096da1a3e67660f3b88068be8c9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/65b2e4f67eab21b30217e29075f433b2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87d24a3f43f175d4d17babe9203c79a7 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d38d8658b30de1d068603968227680d4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/fixtures/user_import_files.yml +27 -0
- data/spec/fixtures/user_import_results.yml +13 -0
- data/spec/models/user_import_file_spec.rb +64 -0
- data/spec/models/user_import_result_spec.rb +7 -0
- data/vendor/assets/javascripts/jquery.colorbox.js +220 -213
- data/vendor/assets/stylesheets/colorbox.css +1 -1
- metadata +224 -150
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +0 -620
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +0 -620
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +0 -620
- data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +0 -620
- data/spec/cassette_library/Manifestation/should_import_isbn.yml +0 -537
- data/spec/cassette_library/Question/test_should_get_crd_search.yml +0 -437
- data/spec/dummy/solr/default/data/index/_z.fdt +0 -0
- data/spec/dummy/solr/default/data/index/_z.fdx +0 -0
- data/spec/dummy/solr/default/data/index/_z.fnm +0 -0
- data/spec/dummy/solr/default/data/index/_z.nvd +0 -0
- data/spec/dummy/solr/default/data/index/_z.nvm +0 -0
- data/spec/dummy/solr/default/data/index/_z.si +0 -0
- data/spec/dummy/solr/default/data/index/_z_Lucene41_0.doc +0 -0
- data/spec/dummy/solr/default/data/index/_z_Lucene41_0.pos +0 -0
- data/spec/dummy/solr/default/data/index/_z_Lucene41_0.tim +0 -0
- data/spec/dummy/solr/default/data/index/_z_Lucene41_0.tip +0 -0
- data/spec/dummy/solr/default/data/index/segments_21 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000062 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000064 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000066 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000068 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000070 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000071 +0 -0
@@ -4,11 +4,9 @@ en:
|
|
4
4
|
user: User
|
5
5
|
role: Role
|
6
6
|
user_group: User group
|
7
|
-
attachment_file: Attachment file
|
8
7
|
user_has_role: User and roles
|
9
|
-
|
10
|
-
|
11
|
-
expression: Expression
|
8
|
+
user_import_file: User import file
|
9
|
+
user_import_result: User import result
|
12
10
|
|
13
11
|
attributes:
|
14
12
|
user:
|
@@ -61,6 +59,19 @@ en:
|
|
61
59
|
number_of_day_to_notify_due_date: Number of day to notify due date
|
62
60
|
number_of_day_to_notify_overdue: Number of day to notify overdue
|
63
61
|
number_of_time_to_notify_overdue: Number of time to notify overdue
|
62
|
+
user_import_file:
|
63
|
+
user_import_file_name: Filename
|
64
|
+
user_import_content_type: Content type
|
65
|
+
user_import_file_size: Size
|
66
|
+
user_import_fingerprint: File hash
|
67
|
+
note: Note
|
68
|
+
executed_at: Executed at
|
69
|
+
user_import_updated_at: Updated at
|
70
|
+
state: State
|
71
|
+
edit_mode: Edit mode
|
72
|
+
error_message: Error message
|
73
|
+
user_import_result:
|
74
|
+
body: Body
|
64
75
|
|
65
76
|
page:
|
66
77
|
user_title: "Welcome %{login_name}"
|
@@ -160,7 +171,7 @@ en:
|
|
160
171
|
new_resource: "New resources"
|
161
172
|
checkout_history: "Checkout history"
|
162
173
|
recommendation: "Recommendation"
|
163
|
-
|
174
|
+
add_resource_manually: "Add a resource manually"
|
164
175
|
import: "Import"
|
165
176
|
import_from_file: "Import from TSV file"
|
166
177
|
import_from_network: "Import from networks"
|
@@ -249,7 +260,7 @@ en:
|
|
249
260
|
not_logged_in: "Not logged in"
|
250
261
|
add_child: "Add a child"
|
251
262
|
electronic_resource_management: "Electronic resource management"
|
252
|
-
|
263
|
+
system: System
|
253
264
|
title:
|
254
265
|
index: "index"
|
255
266
|
show: "show"
|
@@ -5,6 +5,8 @@ ja:
|
|
5
5
|
role: 権限
|
6
6
|
user_group: 利用者グループ
|
7
7
|
user_has_role: 利用者と権限
|
8
|
+
user_import_file: 利用者のインポート用ファイル
|
9
|
+
user_import_result: 利用者インポートの結果
|
8
10
|
|
9
11
|
attributes:
|
10
12
|
user:
|
@@ -57,6 +59,19 @@ ja:
|
|
57
59
|
number_of_day_to_notify_due_date: 貸出期限の何日前に督促を送るか
|
58
60
|
number_of_day_to_notify_overdue: 貸出期限の何日後に督促を送るか
|
59
61
|
number_of_time_to_notify_overdue: 貸出期限が切れた後に何回督促を送るか
|
62
|
+
user_import_file:
|
63
|
+
user_import_file_name: ファイル名
|
64
|
+
user_import_content_type: Content-Type
|
65
|
+
user_import_file_size: ファイルサイズ
|
66
|
+
user_import_fingerprint: ファイルのハッシュ
|
67
|
+
note: 注記
|
68
|
+
executed_at: 実行時刻
|
69
|
+
user_import_updated_at: 更新時刻
|
70
|
+
state: 状態
|
71
|
+
edit_mode: 編集モード
|
72
|
+
error_message: エラーメッセージ
|
73
|
+
user_import_result:
|
74
|
+
body: 本文
|
60
75
|
|
61
76
|
page:
|
62
77
|
user_title: "ようこそ %{login_name} さん"
|
@@ -145,7 +160,7 @@ ja:
|
|
145
160
|
new_resource: "新着資料"
|
146
161
|
checkout_history: "貸出履歴"
|
147
162
|
recommendation: "おすすめの資料"
|
148
|
-
|
163
|
+
add_resource_manually: "手動で資料を登録する"
|
149
164
|
import_from_file: "TSVファイルからのインポート"
|
150
165
|
import_from_network: "ネットワークからインポート"
|
151
166
|
no_record_found: "資料が見つかりませんでした。"
|
@@ -229,6 +244,7 @@ ja:
|
|
229
244
|
not_logged_in: "ログインしていません"
|
230
245
|
add_child: "子を追加"
|
231
246
|
electronic_resource_management: 電子リソース管理
|
247
|
+
system: システム
|
232
248
|
title:
|
233
249
|
index: "一覧"
|
234
250
|
show: "表示"
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
+
authenticate :user, lambda {|u| u.role.try(:name) == 'Administrator' } do
|
3
|
+
mount Resque::Server.new, :at => "/resque", :as => :resque
|
4
|
+
end
|
5
|
+
|
6
|
+
resources :user_import_results
|
7
|
+
|
8
|
+
resources :user_import_files
|
9
|
+
|
2
10
|
resource :my_account
|
3
11
|
|
4
12
|
#resources :users do
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateUserImportFiles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :user_import_files do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.text :note
|
6
|
+
t.datetime :executed_at
|
7
|
+
t.string :state
|
8
|
+
t.string :user_import_file_name
|
9
|
+
t.string :user_import_content_type
|
10
|
+
t.string :user_import_file_size
|
11
|
+
t.datetime :user_import_updated_at
|
12
|
+
t.string :user_import_fingerprint
|
13
|
+
t.string :edit_mode
|
14
|
+
t.text :error_message
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateProfiles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :profiles do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.integer :user_group_id
|
6
|
+
t.integer :library_id
|
7
|
+
t.string :locale
|
8
|
+
t.string :user_number
|
9
|
+
t.text :full_name
|
10
|
+
t.text :note
|
11
|
+
t.text :keyword_list
|
12
|
+
t.integer :required_role_id
|
13
|
+
t.string :state
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
|
18
|
+
add_index :profiles, :user_id
|
19
|
+
add_index :profiles, :user_number
|
20
|
+
end
|
21
|
+
end
|
data/lib/enju_leaf/engine.rb
CHANGED
data/lib/enju_leaf/user.rb
CHANGED
@@ -65,7 +65,8 @@ module EnjuLeaf
|
|
65
65
|
extend FriendlyId
|
66
66
|
friendly_id :username
|
67
67
|
#has_paper_trail
|
68
|
-
normalize_attributes :username, :user_number
|
68
|
+
normalize_attributes :username, :user_number
|
69
|
+
normalize_attributes :email, :with => :strip
|
69
70
|
|
70
71
|
searchable do
|
71
72
|
text :username, :email, :note, :user_number
|
@@ -188,8 +189,10 @@ module EnjuLeaf
|
|
188
189
|
end
|
189
190
|
|
190
191
|
def set_expired_at
|
191
|
-
if
|
192
|
-
|
192
|
+
if expired_at.blank?
|
193
|
+
if user_group.valid_period_for_new_user > 0
|
194
|
+
self.expired_at = user_group.valid_period_for_new_user.days.from_now.end_of_day
|
195
|
+
end
|
193
196
|
end
|
194
197
|
end
|
195
198
|
|
data/lib/enju_leaf/version.rb
CHANGED
@@ -4,6 +4,7 @@ class EnjuLeaf::SetupGenerator < Rails::Generators::Base
|
|
4
4
|
|
5
5
|
def copy_setup_files
|
6
6
|
directory("db/fixtures", "db/fixtures/enju_leaf")
|
7
|
+
copy_file("Procfile", "Procfile")
|
7
8
|
copy_file("config/application.yml", "config/application.yml")
|
8
9
|
copy_file("config/resque.yml", "config/resque.yml")
|
9
10
|
copy_file("config/schedule.rb", "config/schedule.rb")
|
@@ -12,7 +13,8 @@ class EnjuLeaf::SetupGenerator < Rails::Generators::Base
|
|
12
13
|
gsub_file 'config/application.rb', /# config.time_zone = 'Central Time \(US & Canada\)'$/,
|
13
14
|
"config.time_zone = 'Tokyo'"
|
14
15
|
gsub_file 'config/schedule.rb', /\/path\/to\/enju_leaf/, Rails.root.to_s
|
15
|
-
append_to_file("Rakefile", "require 'resque/tasks'")
|
16
|
+
append_to_file("Rakefile", "require 'resque/tasks'\n")
|
17
|
+
append_to_file("Rakefile", "require 'resque_scheduler/tasks'")
|
16
18
|
append_to_file("db/seeds.rb", File.open(File.expand_path('../templates', __FILE__) + '/db/seeds.rb').read)
|
17
19
|
append_to_file 'config/initializers/inflections.rb', <<EOS
|
18
20
|
ActiveSupport::Inflector.inflections do |inflect|
|
@@ -14,7 +14,7 @@ defaults: &defaults
|
|
14
14
|
amazon:
|
15
15
|
aws_hostname: ecs.amazonaws.jp
|
16
16
|
hostname: www.amazon.co.jp
|
17
|
-
|
17
|
+
access_key_id: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
|
18
18
|
secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
|
19
19
|
|
20
20
|
# :google, :amazon
|
@@ -0,0 +1,294 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserImportFilesController do
|
4
|
+
fixtures :all
|
5
|
+
|
6
|
+
describe "GET index" do
|
7
|
+
describe "When logged in as Administrator" do
|
8
|
+
login_admin
|
9
|
+
|
10
|
+
it "assigns all user_import_files as @user_import_files" do
|
11
|
+
get :index
|
12
|
+
assigns(:user_import_files).should eq(UserImportFile.page(1))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "When logged in as Librarian" do
|
17
|
+
login_librarian
|
18
|
+
|
19
|
+
it "assigns all user_import_files as @user_import_files" do
|
20
|
+
get :index
|
21
|
+
assigns(:user_import_files).should eq(UserImportFile.page(1))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "When logged in as User" do
|
26
|
+
login_user
|
27
|
+
|
28
|
+
it "assigns empty as @user_import_files" do
|
29
|
+
get :index
|
30
|
+
assigns(:user_import_files).should be_empty
|
31
|
+
response.should be_forbidden
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "When not logged in" do
|
36
|
+
it "assigns empty as @user_import_files" do
|
37
|
+
get :index
|
38
|
+
assigns(:user_import_files).should be_empty
|
39
|
+
response.should redirect_to(new_user_session_url)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "GET show" do
|
45
|
+
describe "When logged in as Administrator" do
|
46
|
+
login_admin
|
47
|
+
|
48
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
49
|
+
get :show, :id => user_import_files(:two).id
|
50
|
+
assigns(:user_import_file).should eq(user_import_files(:two))
|
51
|
+
response.should be_success
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "When logged in as Librarian" do
|
56
|
+
login_librarian
|
57
|
+
|
58
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
59
|
+
get :show, :id => user_import_files(:two).id
|
60
|
+
assigns(:user_import_file).should eq(user_import_files(:two))
|
61
|
+
response.should be_success
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "When logged in as User" do
|
66
|
+
login_user
|
67
|
+
|
68
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
69
|
+
get :show, :id => user_import_files(:two).id
|
70
|
+
assigns(:user_import_file).should eq(user_import_files(:two))
|
71
|
+
response.should be_forbidden
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "When not logged in" do
|
76
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
77
|
+
get :show, :id => user_import_files(:two).id
|
78
|
+
assigns(:user_import_file).should eq(user_import_files(:two))
|
79
|
+
response.should redirect_to(new_user_session_url)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "GET new" do
|
85
|
+
describe "When logged in as Administrator" do
|
86
|
+
login_admin
|
87
|
+
|
88
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
89
|
+
get :new
|
90
|
+
assigns(:user_import_file).should_not be_valid
|
91
|
+
response.should be_success
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "When logged in as Librarian" do
|
96
|
+
login_librarian
|
97
|
+
|
98
|
+
it "should not assign the requested user_import_file as @user_import_file" do
|
99
|
+
get :new
|
100
|
+
assigns(:user_import_file).should_not be_valid
|
101
|
+
response.should be_success
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "When logged in as User" do
|
106
|
+
login_user
|
107
|
+
|
108
|
+
it "should not assign the requested user_import_file as @user_import_file" do
|
109
|
+
get :new
|
110
|
+
assigns(:user_import_file).should_not be_valid
|
111
|
+
response.should be_forbidden
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "When not logged in" do
|
116
|
+
it "should not assign the requested user_import_file as @user_import_file" do
|
117
|
+
get :new
|
118
|
+
assigns(:user_import_file).should_not be_valid
|
119
|
+
response.should redirect_to(new_user_session_url)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "POST create" do
|
125
|
+
describe "When logged in as Librarian" do
|
126
|
+
before(:each) do
|
127
|
+
@user = FactoryGirl.create(:librarian)
|
128
|
+
sign_in @user
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should create agent_import_file" do
|
132
|
+
post :create, :user_import_file => {:user_import => fixture_file_upload("/../../examples/user_import_file_sample.tsv", 'text/csv') }
|
133
|
+
assigns(:user_import_file).should be_valid
|
134
|
+
assigns(:user_import_file).user.username.should eq @user.username
|
135
|
+
response.should redirect_to user_import_file_url(assigns(:user_import_file))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "When logged in as User" do
|
140
|
+
before(:each) do
|
141
|
+
@user = FactoryGirl.create(:user)
|
142
|
+
sign_in @user
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should be forbidden" do
|
146
|
+
post :create, :user_import_file => {:user_import => fixture_file_upload("/../../examples/user_import_file_sample.tsv", 'text/csv') }
|
147
|
+
assigns(:user_import_file).user.should be_nil
|
148
|
+
response.should be_forbidden
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "When not logged in" do
|
153
|
+
it "should be redirected to new session url" do
|
154
|
+
post :create, :user_import_file => {:user_import => fixture_file_upload("/../../examples/user_import_file_sample.tsv", 'text/csv') }
|
155
|
+
assigns(:user_import_file).user.should be_nil
|
156
|
+
response.should redirect_to new_user_session_url
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "GET edit" do
|
162
|
+
describe "When logged in as Administrator" do
|
163
|
+
login_admin
|
164
|
+
|
165
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
166
|
+
user_import_file = user_import_files(:one)
|
167
|
+
get :edit, :id => user_import_file.id
|
168
|
+
assigns(:user_import_file).should eq(user_import_file)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "When logged in as Librarian" do
|
173
|
+
login_librarian
|
174
|
+
|
175
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
176
|
+
user_import_file = user_import_files(:one)
|
177
|
+
get :edit, :id => user_import_file.id
|
178
|
+
assigns(:user_import_file).should eq(user_import_file)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "When logged in as User" do
|
183
|
+
login_user
|
184
|
+
|
185
|
+
it "assigns the requested user_import_file as @user_import_file" do
|
186
|
+
user_import_file = user_import_files(:one)
|
187
|
+
get :edit, :id => user_import_file.id
|
188
|
+
response.should be_forbidden
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "When not logged in" do
|
193
|
+
it "should not assign the requested user_import_file as @user_import_file" do
|
194
|
+
user_import_file = user_import_files(:one)
|
195
|
+
get :edit, :id => user_import_file.id
|
196
|
+
response.should redirect_to(new_user_session_url)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
describe "PUT update" do
|
202
|
+
describe "When logged in as Administrator" do
|
203
|
+
login_admin
|
204
|
+
|
205
|
+
it "should update user_import_file" do
|
206
|
+
post :create, :user_import_file => {:user_import => fixture_file_upload("/../../examples/user_import_file_sample.tsv", 'text/csv') }
|
207
|
+
put :update, :id => assigns(:user_import_file).id, :user_import_file => { :note => 'test' }
|
208
|
+
response.should redirect_to user_import_file_url(assigns(:user_import_file))
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "When logged in as Librarian" do
|
213
|
+
login_librarian
|
214
|
+
|
215
|
+
it "should update user_import_file" do
|
216
|
+
post :create, :user_import_file => {:user_import => fixture_file_upload("/../../examples/user_import_file_sample.tsv", 'text/csv') }
|
217
|
+
put :update, :id => assigns(:user_import_file).id, :user_import_file => { :note => 'test' }
|
218
|
+
response.should redirect_to user_import_file_url(assigns(:user_import_file))
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe "When logged in as User" do
|
223
|
+
login_user
|
224
|
+
|
225
|
+
it "should not update user_import_file" do
|
226
|
+
put :update, :id => user_import_files(:two).id, :user_import_file => { }
|
227
|
+
response.should be_forbidden
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe "When not logged in" do
|
232
|
+
it "should not update user_import_file" do
|
233
|
+
put :update, :id => user_import_files(:two).id, :user_import_file => { }
|
234
|
+
response.should redirect_to new_user_session_url
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe "DELETE destroy" do
|
240
|
+
before(:each) do
|
241
|
+
@user_import_file = user_import_files(:one)
|
242
|
+
end
|
243
|
+
|
244
|
+
describe "When logged in as Administrator" do
|
245
|
+
login_admin
|
246
|
+
|
247
|
+
it "destroys the requested user_import_file" do
|
248
|
+
delete :destroy, :id => @user_import_file.id
|
249
|
+
end
|
250
|
+
|
251
|
+
it "redirects to the user_import_files list" do
|
252
|
+
delete :destroy, :id => @user_import_file.id
|
253
|
+
response.should redirect_to(user_import_files_url)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe "When logged in as Librarian" do
|
258
|
+
login_librarian
|
259
|
+
|
260
|
+
it "destroys the requested user_import_file" do
|
261
|
+
delete :destroy, :id => @user_import_file.id
|
262
|
+
end
|
263
|
+
|
264
|
+
it "redirects to the user_import_files list" do
|
265
|
+
delete :destroy, :id => @user_import_file.id
|
266
|
+
response.should redirect_to(user_import_files_url)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
describe "When logged in as User" do
|
271
|
+
login_user
|
272
|
+
|
273
|
+
it "destroys the requested user_import_file" do
|
274
|
+
delete :destroy, :id => @user_import_file.id
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should be forbidden" do
|
278
|
+
delete :destroy, :id => @user_import_file.id
|
279
|
+
response.should be_forbidden
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe "When not logged in" do
|
284
|
+
it "destroys the requested user_import_file" do
|
285
|
+
delete :destroy, :id => @user_import_file.id
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should be forbidden" do
|
289
|
+
delete :destroy, :id => @user_import_file.id
|
290
|
+
response.should redirect_to(new_user_session_url)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|