enju_biblio 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/icons/book.png +0 -0
  3. data/app/assets/images/icons/cd.png +0 -0
  4. data/app/assets/images/icons/dvd.png +0 -0
  5. data/app/assets/images/icons/monitor.png +0 -0
  6. data/app/controllers/carrier_types_controller.rb +8 -3
  7. data/app/controllers/manifestations_controller.rb +17 -4
  8. data/app/controllers/picture_files_controller.rb +1 -1
  9. data/app/controllers/series_statements_controller.rb +6 -0
  10. data/app/helpers/manifestations_helper.rb +1 -1
  11. data/app/models/agent_import_file_transition.rb +1 -0
  12. data/app/models/carrier_type.rb +11 -7
  13. data/app/models/import_request_transition.rb +1 -0
  14. data/app/models/manifestation.rb +5 -0
  15. data/app/models/resource_export_file_transition.rb +1 -0
  16. data/app/models/resource_import_file_transition.rb +1 -0
  17. data/app/views/carrier_types/index.html.erb +4 -1
  18. data/app/views/manifestations/_show_detail_librarian.html.erb +4 -0
  19. data/app/views/manifestations/index.html.erb +3 -0
  20. data/config/locales/translation_en.yml +2 -0
  21. data/config/locales/translation_ja.yml +2 -0
  22. data/lib/enju_biblio/biblio_helper.rb +1 -12
  23. data/lib/enju_biblio/version.rb +1 -1
  24. data/lib/generators/enju_biblio/setup/templates/config/schedule.rb +3 -3
  25. data/lib/tasks/carrier_type.rb +30 -18
  26. data/lib/tasks/enju_biblio_tasks.rake +2 -0
  27. data/spec/controllers/agent_import_files_controller_spec.rb +87 -87
  28. data/spec/controllers/agent_import_results_controller_spec.rb +22 -22
  29. data/spec/controllers/agent_merge_lists_controller_spec.rb +157 -157
  30. data/spec/controllers/agent_merges_controller_spec.rb +151 -151
  31. data/spec/controllers/agent_relationship_types_controller_spec.rb +152 -152
  32. data/spec/controllers/agent_relationships_controller_spec.rb +153 -153
  33. data/spec/controllers/agent_types_controller_spec.rb +49 -50
  34. data/spec/controllers/agents_controller_spec.rb +234 -234
  35. data/spec/controllers/carrier_types_controller_spec.rb +123 -103
  36. data/spec/controllers/content_types_controller_spec.rb +51 -52
  37. data/spec/controllers/countries_controller_spec.rb +156 -156
  38. data/spec/controllers/create_types_controller_spec.rb +48 -49
  39. data/spec/controllers/creates_controller_spec.rb +154 -154
  40. data/spec/controllers/donates_controller_spec.rb +153 -153
  41. data/spec/controllers/form_of_works_controller_spec.rb +48 -49
  42. data/spec/controllers/frequencies_controller_spec.rb +51 -52
  43. data/spec/controllers/identifier_types_controller_spec.rb +48 -49
  44. data/spec/controllers/import_requests_controller_spec.rb +165 -164
  45. data/spec/controllers/items_controller_spec.rb +214 -216
  46. data/spec/controllers/languages_controller_spec.rb +109 -109
  47. data/spec/controllers/licenses_controller_spec.rb +48 -49
  48. data/spec/controllers/manifestation_relationship_types_controller_spec.rb +152 -152
  49. data/spec/controllers/manifestation_relationships_controller_spec.rb +153 -153
  50. data/spec/controllers/manifestations_controller_spec.rb +319 -289
  51. data/spec/controllers/medium_of_performances_controller_spec.rb +48 -49
  52. data/spec/controllers/owns_controller_spec.rb +153 -153
  53. data/spec/controllers/picture_files_controller_spec.rb +156 -156
  54. data/spec/controllers/produce_types_controller_spec.rb +48 -49
  55. data/spec/controllers/produces_controller_spec.rb +154 -154
  56. data/spec/controllers/realize_types_controller_spec.rb +48 -49
  57. data/spec/controllers/realizes_controller_spec.rb +155 -155
  58. data/spec/controllers/resource_export_files_controller_spec.rb +72 -72
  59. data/spec/controllers/resource_import_files_controller_spec.rb +90 -90
  60. data/spec/controllers/resource_import_results_controller_spec.rb +43 -43
  61. data/spec/controllers/series_statement_merge_lists_controller_spec.rb +153 -153
  62. data/spec/controllers/series_statement_merges_controller_spec.rb +151 -151
  63. data/spec/controllers/series_statements_controller_spec.rb +154 -154
  64. data/spec/factories/checkout.rb +9 -0
  65. data/spec/factories/library.rb +13 -0
  66. data/spec/factories/shelf.rb +6 -0
  67. data/spec/fixtures/carrier_types.yml +11 -7
  68. data/spec/models/carrier_type_spec.rb +11 -7
  69. data/spec/models/resource_export_file_spec.rb +58 -16
  70. data/spec/support/resque.rb +0 -1
  71. data/spec/views/manifestations/show.html.erb_spec.rb +5 -0
  72. data/spec/views/resource_import_files/index.html.erb_spec.rb +1 -1
  73. data/spec/views/resource_import_files/show.html.erb_spec.rb +1 -1
  74. data/spec/views/resource_import_results/index.html.erb_spec.rb +1 -1
  75. data/spec/views/resource_import_results/show.html.erb_spec.rb +1 -1
  76. metadata +49 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c37cbe83dd1627b914c2c413b1e182782d1838c0
4
- data.tar.gz: 7a588c5262d34e03cb616c4ef3ef37a4f7c90156
3
+ metadata.gz: a1eb140bfb7d033553767e30d96b21f1e5676b96
4
+ data.tar.gz: 64e7b0582b80a5f10a62f60cb02ac85b0cf1f421
5
5
  SHA512:
6
- metadata.gz: 2ac36b3277b5baec8c67c8f40acff89c03638a1db11d0da40cb5e51949b33e9be9b43d580267ab158991ce07dc46e43edb30e438cf0a84156697c375a5b50fd6
7
- data.tar.gz: c846feccbf62baf34c91bb1a82d96a14cf5790101d6be1d2b37ed05255f8cbacafd5c51ec7d620c8b6c2eaddde61c2f80ba67f8a40f9d2007905fbb7b01dd91d
6
+ metadata.gz: 1ab614207670a2737639e68137b6759a5338b6679352f948b2dd0885e199dca4daea3d8eb99c4e1540cd0554fcf2e96f973a2930f2963178da725d7adbd9a9fa
7
+ data.tar.gz: 9153e48531157e6d7e6f787829fc74d127a5dda1d9edb6bbb6dd6dc8b0c452cc6038ea0d4f063541a8a7cc1778893c404a51335c9bc1638f78b08ace98b5b15c
Binary file
Binary file
Binary file
Binary file
@@ -1,7 +1,8 @@
1
1
  class CarrierTypesController < ApplicationController
2
- before_action :set_carrier_type, only: [:show, :edit, :update, :destroy]
2
+ before_action :set_carrier_type, only: [:edit, :update, :destroy]
3
3
  before_action :check_policy, only: [:index, :new, :create]
4
4
  before_action :prepare_options, only: [:new, :edit]
5
+ skip_after_action :verify_authorized
5
6
 
6
7
  # GET /carrier_types
7
8
  # GET /carrier_types.json
@@ -17,11 +18,15 @@ class CarrierTypesController < ApplicationController
17
18
  # GET /carrier_types/1
18
19
  # GET /carrier_types/1.json
19
20
  def show
21
+ @carrier_type = CarrierType.find(params[:id])
22
+ unless params[:format] == 'download'
23
+ authorize @carrier_type
24
+ end
20
25
  if @carrier_type.attachment.path
21
26
  if ENV['ENJU_STORAGE'] == 's3'
22
27
  file = Faraday.get(@carrier_type.attachment.expiring_url).body.force_encoding('UTF-8')
23
28
  else
24
- file = @carrier_type.attachment.path(size)
29
+ file = @carrier_type.attachment.path
25
30
  end
26
31
  end
27
32
 
@@ -127,7 +132,7 @@ class CarrierTypesController < ApplicationController
127
132
  end
128
133
 
129
134
  def render_image(file)
130
- if @carrier_type.picture.path
135
+ if @carrier_type.attachment.path
131
136
  if ENV['ENJU_STORAGE'] == 's3'
132
137
  send_data file, filename: File.basename(@carrier_type.attachment_file_name), type: @carrier_type.attachment_content_type, disposition: 'inline'
133
138
  else
@@ -571,14 +571,27 @@ class ManifestationsController < ApplicationController
571
571
  library_list = options[:library_adv].split.uniq.join(' OR ')
572
572
  query = "#{query} library_sm:(#{library_list})"
573
573
  end
574
+ shelf_list = []
575
+ options.keys.grep(/_shelf\Z/).each do |library_shelf|
576
+ library_name = library_shelf.sub(/_shelf\Z/, "")
577
+ options[library_shelf].each do |shelf|
578
+ shelf_list << "#{library_name}_#{shelf}"
579
+ end
580
+ end
581
+ unless shelf_list.blank?
582
+ query += " shelf_sm:(#{shelf_list.join(" OR ")})"
583
+ end
574
584
 
575
585
  #unless options[:language].blank?
576
586
  # query = "#{query} language_sm:#{options[:language]}"
577
587
  #end
578
588
 
579
- #unless options[:subject].blank?
580
- # query = "#{query} subject_sm:#{options[:subject]}"
581
- #end
589
+ unless options[:subject].blank?
590
+ query = "#{query} subject_sm:#{options[:subject]}"
591
+ end
592
+ unless options[:subject_text].blank?
593
+ query = "#{query} subject_text:#{options[:subject_text]}"
594
+ end
582
595
  if options[:classification].present? and options[:classification_type].present?
583
596
  classification_type = ClassificationType.find(options[:classification_type]).name
584
597
  query = "#{query} classification_sm:#{classification_type}_#{options[:classification]}*"
@@ -841,7 +854,7 @@ class ManifestationsController < ApplicationController
841
854
  end
842
855
 
843
856
  def filtered_params
844
- params.permit([:view, :format, :library, :carrier_type, :reservable, :pub_date_from, :pub_date_until, :language, :sort_by, :per_page])
857
+ params.permit([:view, :format, :library, :carrier_type, :reservable, :pub_date_from, :pub_date_until, :language, :sort_by, :per_page, :query])
845
858
  end
846
859
 
847
860
  helper_method :filtered_params
@@ -35,7 +35,7 @@ class PictureFilesController < ApplicationController
35
35
  if ENV['ENJU_STORAGE'] == 's3'
36
36
  file = Faraday.get(@picture_file.picture.expiring_url).body.force_encoding('UTF-8')
37
37
  else
38
- file = @picture_file.picture.path(size)
38
+ file = @picture_file.picture.path(size.to_sym)
39
39
  end
40
40
  end
41
41
 
@@ -133,4 +133,10 @@ class SeriesStatementsController < ApplicationController
133
133
  :series_master
134
134
  )
135
135
  end
136
+
137
+ def filtered_params
138
+ params.permit([:locale, :format, :page, :per_page])
139
+ end
140
+
141
+ helper_method :filtered_params
136
142
  end
@@ -96,7 +96,7 @@ module ManifestationsHelper
96
96
 
97
97
  def carrier_type_facet(facet)
98
98
  string = ''
99
- carrier_type = CarrierType.where(name: facet.value).select([:name, :display_name]).first
99
+ carrier_type = CarrierType.where(name: facet.value).select([:id, :name, :display_name]).first
100
100
  if carrier_type
101
101
  string << form_icon(carrier_type)
102
102
  current = true if params[:carrier_type] == carrier_type.name
@@ -17,4 +17,5 @@ end
17
17
  # agent_import_file_id :integer
18
18
  # created_at :datetime
19
19
  # updated_at :datetime
20
+ # most_recent :boolean
20
21
  #
@@ -35,11 +35,15 @@ end
35
35
  #
36
36
  # Table name: carrier_types
37
37
  #
38
- # id :integer not null, primary key
39
- # name :string not null
40
- # display_name :text
41
- # note :text
42
- # position :integer
43
- # created_at :datetime
44
- # updated_at :datetime
38
+ # id :integer not null, primary key
39
+ # name :string not null
40
+ # display_name :text
41
+ # note :text
42
+ # position :integer
43
+ # created_at :datetime
44
+ # updated_at :datetime
45
+ # attachment_file_name :string
46
+ # attachment_content_type :string
47
+ # attachment_file_size :integer
48
+ # attachment_updated_at :datetime
45
49
  #
@@ -17,4 +17,5 @@ end
17
17
  # import_request_id :integer
18
18
  # created_at :datetime
19
19
  # updated_at :datetime
20
+ # most_recent :boolean
20
21
  #
@@ -541,6 +541,7 @@ class Manifestation < ActiveRecord::Base
541
541
  note
542
542
  extent
543
543
  dimensions
544
+ carrier_type
544
545
  )
545
546
 
546
547
  header += IdentifierType.order(:position).pluck(:name)
@@ -567,6 +568,7 @@ class Manifestation < ActiveRecord::Base
567
568
  header += %w(
568
569
  bookstore
569
570
  budget_type
571
+ total_checkouts
570
572
  )
571
573
  end
572
574
  header += %w(
@@ -612,6 +614,7 @@ class Manifestation < ActiveRecord::Base
612
614
  item_lines << note
613
615
  item_lines << extent
614
616
  item_lines << dimensions
617
+ item_lines << carrier_type.name
615
618
 
616
619
  IdentifierType.order(:position).pluck(:name).each do |identifier_type|
617
620
  if identifier_contents(identifier_type.to_sym).first
@@ -650,6 +653,7 @@ class Manifestation < ActiveRecord::Base
650
653
  when :Administrator, :Librarian
651
654
  item_lines << i.bookstore.try(:name)
652
655
  item_lines << i.budget_type.try(:name)
656
+ item_lines << Checkout.where(:item_id => i.id).size
653
657
  end
654
658
  item_lines << i.circulation_status.try(:name)
655
659
  item_lines << i.shelf.name
@@ -687,6 +691,7 @@ class Manifestation < ActiveRecord::Base
687
691
  line << note
688
692
  line << extent
689
693
  line << dimensions
694
+ line << carrier_type.name
690
695
 
691
696
  IdentifierType.order(:position).pluck(:name).each do |identifier_type|
692
697
  if identifier_contents(identifier_type.to_sym).first
@@ -17,4 +17,5 @@ end
17
17
  # resource_export_file_id :integer
18
18
  # created_at :datetime
19
19
  # updated_at :datetime
20
+ # most_recent :boolean
20
21
  #
@@ -17,4 +17,5 @@ end
17
17
  # resource_import_file_id :integer
18
18
  # created_at :datetime
19
19
  # updated_at :datetime
20
+ # most_recent :boolean
20
21
  #
@@ -22,7 +22,10 @@
22
22
  <%= move_position(carrier_type) -%>
23
23
  <%- end -%>
24
24
  </td>
25
- <td><%= carrier_type.name -%></td>
25
+ <td>
26
+ <%= image_tag(carrier_type_path(carrier_type, format: :download), size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize) %>
27
+ <%= carrier_type.name -%>
28
+ </td>
26
29
  <td>
27
30
  <%= link_to carrier_type.display_name.localize, carrier_type -%>
28
31
  <br />
@@ -104,6 +104,10 @@
104
104
  </table>
105
105
  <% end %>
106
106
  <%- if manifestation.items.exists? -%>
107
+ <div class="manifestation_total_checkouts">
108
+ <%= t('manifestation.total_checkouts') %>: <%= manifestation.checkouts(manifestation.created_at, Date.today).size %>
109
+ (<%= t('manifestation.this_year_checkouts') %>: <%= manifestation.checkouts(Date.today-1.year, Date.today).size %>)
110
+ </div>
107
111
  <%= render 'manifestations/show_holding', manifestation: manifestation, items: manifestation.items %>
108
112
  <%- end -%>
109
113
  <%- if policy(Item).create? -%>
@@ -61,6 +61,9 @@
61
61
  t('page.sort_criteria.title_desc')].join(" : ") => 'title:desc',
62
62
  }, selected: filtered_params[:sort_by] || 'created_at:desc') -%>
63
63
  <%= hidden_field_tag 'query', @query -%>
64
+ <% [ :reservable, :carrier_type, :library, :language, :pub_year ].each do |p| -%>
65
+ <%= hidden_field_tag p, filtered_params[p] if filtered_params[p] -%>
66
+ <% end -%>
64
67
  <%= submit_tag t('page.show') -%><br />
65
68
  </p>
66
69
  <%- end -%>
@@ -393,6 +393,8 @@ en:
393
393
  attachment_file: "Attachment file"
394
394
  add_derivation: "Add a derivation"
395
395
  new_item: "New item"
396
+ this_year_checkouts: "Checkouts for the past year"
397
+ total_checkouts: "Total checkouts"
396
398
 
397
399
  item:
398
400
  current_checkout: "Current checkout"
@@ -397,6 +397,8 @@ ja:
397
397
  attachment_file: "添付ファイル"
398
398
  add_derivation: "派生資料を追加"
399
399
  new_item: "新規作成"
400
+ this_year_checkouts: "過去一年間の貸出回数"
401
+ total_checkouts: "累計貸出回数"
400
402
 
401
403
  item:
402
404
  current_checkout: "現在の貸出"
@@ -1,18 +1,7 @@
1
1
  module EnjuBiblio
2
2
  module BiblioHelper
3
3
  def form_icon(carrier_type)
4
- case carrier_type.name
5
- when 'volume'
6
- image_tag('icons/book.png', size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
7
- when 'audio_disc'
8
- image_tag('icons/cd.png', size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
9
- when 'videodisc'
10
- image_tag('icons/dvd.png', size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
11
- when 'online_resource'
12
- image_tag('icons/monitor.png', size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
13
- else
14
- image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
15
- end
4
+ image_tag(carrier_type_path(carrier_type, format: :download), size: '16x16', class: 'enju_icon', alt: carrier_type.display_name.localize)
16
5
  rescue NoMethodError
17
6
  image_tag('icons/help.png', size: '16x16', class: 'enju_icon', alt: t('page.unknown'))
18
7
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,4 +1,4 @@
1
1
 
2
- every 1.hour do
3
- rake "enju_biblio:import"
4
- end
2
+ #every 1.hour do
3
+ # rake "enju_biblio:resource_import"
4
+ #end
@@ -1,26 +1,38 @@
1
1
  def update_carrier_type
2
- cd = CarrierType.where(name: 'CD').first
3
- cd.update_column(:name, 'cd') if cd
4
- dvd = CarrierType.where(name: 'DVD').first
5
- dvd.update_column(:name, 'dvd') if cd
6
-
7
- carrier_types = YAML.load(open('db/fixtures/enju_biblio/carrier_types.yml').read)
8
- carrier_types.each do |line|
9
- l = line[1].select!{|k, v| %w(name display_name note).include?(k)}
10
-
11
- case line[1]["name"]
2
+ CarrierType.find_each do |carrier_type|
3
+ case carrier_type.name
12
4
  when "volume"
13
- carrier_type = CarrierType.where(name: 'print').first
14
- carrier_type.update_attributes!(line[1]) if carrier_type
5
+ carrier_type = CarrierType.find_by(name: 'volume')
6
+ if carrier_type
7
+ unless carrier_type.attachment
8
+ carrier_type.attachment = File.open("#{File.dirname(__FILE__)}/../../app/assets/images/icons/book.png")
9
+ carrier_type.save!
10
+ end
11
+ end
15
12
  when "audio_disc"
16
- carrier_type = CarrierType.where(name: 'cd').first
17
- carrier_type.update_attributes!(line[1]) if carrier_type
13
+ carrier_type = CarrierType.find_by(name: 'audio_disc')
14
+ if carrier_type
15
+ unless carrier_type.attachment
16
+ carrier_type.attachment = File.open("#{File.dirname(__FILE__)}/../../app/assets/images/icons/cd.png")
17
+ carrier_type.save!
18
+ end
19
+ end
18
20
  when "videodisc"
19
- carrier_type = CarrierType.where(name: 'dvd').first
20
- carrier_type.update_attributes!(line[1]) if carrier_type
21
+ carrier_type = CarrierType.find_by(name: 'videodisc')
22
+ if carrier_type
23
+ unless carrier_type.attachment
24
+ carrier_type.attachment = File.open("#{File.dirname(__FILE__)}/../../app/assets/images/icons/dvd.png")
25
+ carrier_type.save!
26
+ end
27
+ end
21
28
  when "online_resource"
22
- carrier_type = CarrierType.where(name: 'file').first
23
- carrier_type.update_attributes!(line[1]) if carrier_type
29
+ carrier_type = CarrierType.find_by(name: 'online_resource')
30
+ if carrier_type
31
+ unless carrier_type.attachment
32
+ carrier_type.attachment = File.open("#{File.dirname(__FILE__)}/../../app/assets/images/icons/monitor.png")
33
+ carrier_type.save!
34
+ end
35
+ end
24
36
  end
25
37
  end
26
38
  end
@@ -11,6 +11,7 @@ namespace :enju_biblio do
11
11
  Dir.glob(Rails.root.to_s + '/db/fixtures/enju_biblio/*.yml').each do |file|
12
12
  ActiveRecord::FixtureSet.create_fixtures('db/fixtures/enju_biblio', File.basename(file, '.*'))
13
13
  end
14
+ update_carrier_type
14
15
  end
15
16
 
16
17
  desc "import manifestations and items from a TSV file"
@@ -29,6 +30,7 @@ namespace :enju_biblio do
29
30
  Rake::Task['statesman:backfill_most_recent'].invoke('ImportRequest')
30
31
  Rake::Task['statesman:backfill_most_recent'].invoke('ResourceExportFile')
31
32
  Rake::Task['statesman:backfill_most_recent'].invoke('ResourceImportFile')
33
+ update_carrier_type
32
34
  puts 'enju_biblio: The upgrade completed successfully.'
33
35
  end
34
36
  end
@@ -4,37 +4,37 @@ require 'rails_helper'
4
4
  describe AgentImportFilesController do
5
5
  fixtures :all
6
6
 
7
- describe "GET index" do
8
- describe "When logged in as Administrator" do
7
+ describe 'GET index' do
8
+ describe 'When logged in as Administrator' do
9
9
  login_fixture_admin
10
10
 
11
- it "assigns all agent_import_files as @agent_import_files" do
11
+ it 'assigns all agent_import_files as @agent_import_files' do
12
12
  get :index
13
13
  expect(assigns(:agent_import_files)).to eq(AgentImportFile.page(1))
14
14
  end
15
15
  end
16
16
 
17
- describe "When logged in as Librarian" do
17
+ describe 'When logged in as Librarian' do
18
18
  login_fixture_librarian
19
19
 
20
- it "assigns all agent_import_files as @agent_import_files" do
20
+ it 'assigns all agent_import_files as @agent_import_files' do
21
21
  get :index
22
22
  expect(assigns(:agent_import_files)).to eq(AgentImportFile.page(1))
23
23
  end
24
24
  end
25
25
 
26
- describe "When logged in as User" do
26
+ describe 'When logged in as User' do
27
27
  login_fixture_user
28
28
 
29
- it "assigns empty as @agent_import_files" do
29
+ it 'assigns empty as @agent_import_files' do
30
30
  get :index
31
31
  expect(assigns(:agent_import_files)).to be_nil
32
32
  expect(response).to be_forbidden
33
33
  end
34
34
  end
35
35
 
36
- describe "When not logged in" do
37
- it "assigns empty as @agent_import_files" do
36
+ describe 'When not logged in' do
37
+ it 'assigns empty as @agent_import_files' do
38
38
  get :index
39
39
  expect(assigns(:agent_import_files)).to be_nil
40
40
  expect(response).to redirect_to(new_user_session_url)
@@ -42,76 +42,76 @@ describe AgentImportFilesController do
42
42
  end
43
43
  end
44
44
 
45
- describe "GET show" do
46
- describe "When logged in as Administrator" do
45
+ describe 'GET show' do
46
+ describe 'When logged in as Administrator' do
47
47
  login_fixture_admin
48
48
 
49
- it "assigns the requested agent_import_file as @agent_import_file" do
50
- get :show, :id => 1
49
+ it 'assigns the requested agent_import_file as @agent_import_file' do
50
+ get :show, id: 1
51
51
  expect(assigns(:agent_import_file)).to eq(AgentImportFile.find(1))
52
52
  end
53
53
  end
54
54
 
55
- describe "When logged in as Librarian" do
55
+ describe 'When logged in as Librarian' do
56
56
  login_fixture_librarian
57
57
 
58
- it "assigns the requested agent_import_file as @agent_import_file" do
59
- get :show, :id => 1
58
+ it 'assigns the requested agent_import_file as @agent_import_file' do
59
+ get :show, id: 1
60
60
  expect(assigns(:agent_import_file)).to eq(AgentImportFile.find(1))
61
61
  end
62
62
  end
63
63
 
64
- describe "When logged in as User" do
64
+ describe 'When logged in as User' do
65
65
  login_fixture_user
66
66
 
67
- it "assigns the requested agent_import_file as @agent_import_file" do
68
- get :show, :id => 1
67
+ it 'assigns the requested agent_import_file as @agent_import_file' do
68
+ get :show, id: 1
69
69
  expect(assigns(:agent_import_file)).to eq(AgentImportFile.find(1))
70
70
  end
71
71
  end
72
72
 
73
- describe "When not logged in" do
74
- it "assigns the requested agent_import_file as @agent_import_file" do
75
- get :show, :id => 1
73
+ describe 'When not logged in' do
74
+ it 'assigns the requested agent_import_file as @agent_import_file' do
75
+ get :show, id: 1
76
76
  expect(assigns(:agent_import_file)).to eq(AgentImportFile.find(1))
77
77
  expect(response).to redirect_to(new_user_session_url)
78
78
  end
79
79
  end
80
80
  end
81
81
 
82
- describe "GET new" do
83
- describe "When logged in as Administrator" do
82
+ describe 'GET new' do
83
+ describe 'When logged in as Administrator' do
84
84
  login_fixture_admin
85
85
 
86
- it "assigns the requested agent_import_file as @agent_import_file" do
86
+ it 'assigns the requested agent_import_file as @agent_import_file' do
87
87
  get :new
88
88
  expect(assigns(:agent_import_file)).to_not be_valid
89
89
  expect(response).to be_success
90
90
  end
91
91
  end
92
92
 
93
- describe "When logged in as Librarian" do
93
+ describe 'When logged in as Librarian' do
94
94
  login_fixture_librarian
95
95
 
96
- it "should not assign the requested agent_import_file as @agent_import_file" do
96
+ it 'should not assign the requested agent_import_file as @agent_import_file' do
97
97
  get :new
98
98
  expect(assigns(:agent_import_file)).to_not be_valid
99
99
  expect(response).to be_success
100
100
  end
101
101
  end
102
102
 
103
- describe "When logged in as User" do
103
+ describe 'When logged in as User' do
104
104
  login_fixture_user
105
105
 
106
- it "should not assign the requested agent_import_file as @agent_import_file" do
106
+ it 'should not assign the requested agent_import_file as @agent_import_file' do
107
107
  get :new
108
108
  expect(assigns(:agent_import_file)).to be_nil
109
109
  expect(response).to be_forbidden
110
110
  end
111
111
  end
112
112
 
113
- describe "When not logged in" do
114
- it "should not assign the requested agent_import_file as @agent_import_file" do
113
+ describe 'When not logged in' do
114
+ it 'should not assign the requested agent_import_file as @agent_import_file' do
115
115
  get :new
116
116
  expect(assigns(:agent_import_file)).to be_nil
117
117
  expect(response).to redirect_to(new_user_session_url)
@@ -119,161 +119,161 @@ describe AgentImportFilesController do
119
119
  end
120
120
  end
121
121
 
122
- describe "POST create" do
123
- describe "When logged in as Librarian" do
122
+ describe 'POST create' do
123
+ describe 'When logged in as Librarian' do
124
124
  login_fixture_librarian
125
125
 
126
- it "should create agent_import_file" do
127
- post :create, :agent_import_file => {:agent_import => fixture_file_upload("/../../examples/agent_import_file_sample1.tsv", 'text/csv') }
126
+ it 'should create agent_import_file' do
127
+ post :create, agent_import_file: { agent_import: fixture_file_upload('/../../examples/agent_import_file_sample1.tsv', 'text/csv') }
128
128
  expect(assigns(:agent_import_file)).to be_valid
129
129
  assigns(:agent_import_file).user.username.should eq @user.username
130
130
  expect(response).to redirect_to agent_import_file_url(assigns(:agent_import_file))
131
131
  end
132
132
 
133
- it "should import user" do
133
+ it 'should import user' do
134
134
  old_agents_count = Agent.count
135
- post :create, :agent_import_file => {:agent_import => fixture_file_upload("/../../examples/agent_import_file_sample2.tsv", 'text/csv') }
135
+ post :create, agent_import_file: { agent_import: fixture_file_upload('/../../examples/agent_import_file_sample2.tsv', 'text/csv') }
136
136
  assigns(:agent_import_file).import_start
137
137
  Agent.count.should eq old_agents_count + 3
138
138
  expect(response).to redirect_to agent_import_file_url(assigns(:agent_import_file))
139
139
  end
140
140
  end
141
141
 
142
- describe "When logged in as User" do
142
+ describe 'When logged in as User' do
143
143
  login_fixture_user
144
144
 
145
- it "should be forbidden" do
146
- post :create, :agent_import_file => {:agent_import => fixture_file_upload("/../..//examples/agent_import_file_sample1.tsv", 'text/csv') }
145
+ it 'should be forbidden' do
146
+ post :create, agent_import_file: { agent_import: fixture_file_upload('/../..//examples/agent_import_file_sample1.tsv', 'text/csv') }
147
147
  expect(response).to be_forbidden
148
148
  end
149
149
  end
150
150
 
151
- describe "When not logged in" do
152
- it "should be redirect to new session url" do
153
- post :create, :agent_import_file => {:agent_import => fixture_file_upload("/../../examples/agent_import_file_sample1.tsv", 'text/csv') }
151
+ describe 'When not logged in' do
152
+ it 'should be redirect to new session url' do
153
+ post :create, agent_import_file: { agent_import: fixture_file_upload('/../../examples/agent_import_file_sample1.tsv', 'text/csv') }
154
154
  expect(response).to redirect_to new_user_session_url
155
155
  end
156
156
  end
157
157
  end
158
158
 
159
- describe "GET edit" do
160
- describe "When logged in as Administrator" do
159
+ describe 'GET edit' do
160
+ describe 'When logged in as Administrator' do
161
161
  login_fixture_admin
162
162
 
163
- it "assigns the requested agent_import_file as @agent_import_file" do
163
+ it 'assigns the requested agent_import_file as @agent_import_file' do
164
164
  agent_import_file = agent_import_files(:agent_import_file_00001)
165
- get :edit, :id => agent_import_file.id
165
+ get :edit, id: agent_import_file.id
166
166
  expect(assigns(:agent_import_file)).to eq(agent_import_file)
167
167
  end
168
168
  end
169
169
 
170
- describe "When logged in as Librarian" do
170
+ describe 'When logged in as Librarian' do
171
171
  login_fixture_librarian
172
172
 
173
- it "assigns the requested agent_import_file as @agent_import_file" do
173
+ it 'assigns the requested agent_import_file as @agent_import_file' do
174
174
  agent_import_file = agent_import_files(:agent_import_file_00001)
175
- get :edit, :id => agent_import_file.id
175
+ get :edit, id: agent_import_file.id
176
176
  expect(assigns(:agent_import_file)).to eq(agent_import_file)
177
177
  end
178
178
  end
179
179
 
180
- describe "When logged in as User" do
180
+ describe 'When logged in as User' do
181
181
  login_fixture_user
182
182
 
183
- it "assigns the requested agent_import_file as @agent_import_file" do
183
+ it 'assigns the requested agent_import_file as @agent_import_file' do
184
184
  agent_import_file = agent_import_files(:agent_import_file_00001)
185
- get :edit, :id => agent_import_file.id
185
+ get :edit, id: agent_import_file.id
186
186
  expect(response).to be_forbidden
187
187
  end
188
188
  end
189
189
 
190
- describe "When not logged in" do
191
- it "should not assign the requested agent_import_file as @agent_import_file" do
190
+ describe 'When not logged in' do
191
+ it 'should not assign the requested agent_import_file as @agent_import_file' do
192
192
  agent_import_file = agent_import_files(:agent_import_file_00001)
193
- get :edit, :id => agent_import_file.id
193
+ get :edit, id: agent_import_file.id
194
194
  expect(response).to redirect_to(new_user_session_url)
195
195
  end
196
196
  end
197
197
  end
198
198
 
199
- describe "PUT update" do
200
- describe "When logged in as Librarian" do
199
+ describe 'PUT update' do
200
+ describe 'When logged in as Librarian' do
201
201
  login_fixture_librarian
202
202
 
203
- it "should update agent_import_file" do
204
- put :update, :id => agent_import_files(:agent_import_file_00003).id, :agent_import_file => {mode: "modify"}
203
+ it 'should update agent_import_file' do
204
+ put :update, id: agent_import_files(:agent_import_file_00003).id, agent_import_file: { mode: 'modify' }
205
205
  expect(response).to redirect_to agent_import_file_url(assigns(:agent_import_file))
206
206
  end
207
207
  end
208
208
 
209
- describe "When logged in as User" do
209
+ describe 'When logged in as User' do
210
210
  login_fixture_user
211
211
 
212
- it "should not update agent_import_file" do
213
- put :update, :id => agent_import_files(:agent_import_file_00003).id, :agent_import_file => {mode: "modify"}
212
+ it 'should not update agent_import_file' do
213
+ put :update, id: agent_import_files(:agent_import_file_00003).id, agent_import_file: { mode: 'modify' }
214
214
  expect(response).to be_forbidden
215
215
  end
216
216
  end
217
217
 
218
- describe "When not logged in" do
219
- it "should not update agent_import_file" do
220
- put :update, :id => agent_import_files(:agent_import_file_00003).id, :agent_import_file => {mode: "modify"}
218
+ describe 'When not logged in' do
219
+ it 'should not update agent_import_file' do
220
+ put :update, id: agent_import_files(:agent_import_file_00003).id, agent_import_file: { mode: 'modify' }
221
221
  expect(response).to redirect_to new_user_session_url
222
222
  end
223
223
  end
224
224
  end
225
225
 
226
- describe "DELETE destroy" do
226
+ describe 'DELETE destroy' do
227
227
  before(:each) do
228
228
  @agent_import_file = agent_import_files(:agent_import_file_00001)
229
229
  end
230
230
 
231
- describe "When logged in as Administrator" do
231
+ describe 'When logged in as Administrator' do
232
232
  login_fixture_admin
233
233
 
234
- it "destroys the requested agent_import_file" do
235
- delete :destroy, :id => @agent_import_file.id
234
+ it 'destroys the requested agent_import_file' do
235
+ delete :destroy, id: @agent_import_file.id
236
236
  end
237
237
 
238
- it "redirects to the agent_import_files list" do
239
- delete :destroy, :id => @agent_import_file.id
238
+ it 'redirects to the agent_import_files list' do
239
+ delete :destroy, id: @agent_import_file.id
240
240
  expect(response).to redirect_to(agent_import_files_url)
241
241
  end
242
242
  end
243
243
 
244
- describe "When logged in as Librarian" do
244
+ describe 'When logged in as Librarian' do
245
245
  login_fixture_librarian
246
246
 
247
- it "destroys the requested agent_import_file" do
248
- delete :destroy, :id => @agent_import_file.id
247
+ it 'destroys the requested agent_import_file' do
248
+ delete :destroy, id: @agent_import_file.id
249
249
  end
250
250
 
251
- it "redirects to the agent_import_files list" do
252
- delete :destroy, :id => @agent_import_file.id
251
+ it 'redirects to the agent_import_files list' do
252
+ delete :destroy, id: @agent_import_file.id
253
253
  expect(response).to redirect_to(agent_import_files_url)
254
254
  end
255
255
  end
256
256
 
257
- describe "When logged in as User" do
257
+ describe 'When logged in as User' do
258
258
  login_fixture_user
259
259
 
260
- it "destroys the requested agent_import_file" do
261
- delete :destroy, :id => @agent_import_file.id
260
+ it 'destroys the requested agent_import_file' do
261
+ delete :destroy, id: @agent_import_file.id
262
262
  end
263
263
 
264
- it "should be forbidden" do
265
- delete :destroy, :id => @agent_import_file.id
264
+ it 'should be forbidden' do
265
+ delete :destroy, id: @agent_import_file.id
266
266
  expect(response).to be_forbidden
267
267
  end
268
268
  end
269
269
 
270
- describe "When not logged in" do
271
- it "destroys the requested agent_import_file" do
272
- delete :destroy, :id => @agent_import_file.id
270
+ describe 'When not logged in' do
271
+ it 'destroys the requested agent_import_file' do
272
+ delete :destroy, id: @agent_import_file.id
273
273
  end
274
274
 
275
- it "should be forbidden" do
276
- delete :destroy, :id => @agent_import_file.id
275
+ it 'should be forbidden' do
276
+ delete :destroy, id: @agent_import_file.id
277
277
  expect(response).to redirect_to(new_user_session_url)
278
278
  end
279
279
  end