enju_biblio 0.3.11 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/agent_import_results_controller.rb +1 -1
  3. data/app/controllers/agents_controller.rb +0 -6
  4. data/app/controllers/items_controller.rb +15 -10
  5. data/app/controllers/manifestations_controller.rb +68 -76
  6. data/app/controllers/resource_import_results_controller.rb +2 -2
  7. data/app/controllers/series_statements_controller.rb +0 -6
  8. data/app/helpers/manifestations_helper.rb +8 -8
  9. data/app/models/agent.rb +10 -1
  10. data/app/models/form_of_work.rb +1 -1
  11. data/app/models/frequency.rb +1 -1
  12. data/app/models/identifier.rb +1 -1
  13. data/app/models/import_request.rb +2 -3
  14. data/app/models/item.rb +6 -6
  15. data/app/models/item_custom_value.rb +1 -1
  16. data/app/models/manifestation.rb +10 -18
  17. data/app/models/manifestation_custom_value.rb +1 -1
  18. data/app/models/resource_import_file.rb +8 -4
  19. data/app/views/agent_import_results/{index.txt.ruby → index.text.ruby} +0 -0
  20. data/app/views/agent_relationship_types/index.html.erb +3 -3
  21. data/app/views/agents/index.rss.builder +2 -2
  22. data/app/views/items/_item.json.jbuilder +17 -0
  23. data/app/views/items/index.json.jbuilder +5 -0
  24. data/app/views/items/index.text.ruby +13 -0
  25. data/app/views/items/show.html.erb +125 -125
  26. data/app/views/items/show.json.jbuilder +1 -0
  27. data/app/views/layouts/agents.html.erb +2 -2
  28. data/app/views/layouts/manifestations.html.erb +2 -2
  29. data/app/views/manifestations/_carrier_type_facet.html.erb +1 -1
  30. data/app/views/manifestations/_classification_facet.html.erb +2 -2
  31. data/app/views/manifestations/_export_list.html.erb +4 -4
  32. data/app/views/manifestations/_form.html.erb +3 -3
  33. data/app/views/manifestations/_language_facet.html.erb +1 -1
  34. data/app/views/manifestations/_library_facet.html.erb +1 -1
  35. data/app/views/manifestations/_pub_year_facet.html.erb +1 -1
  36. data/app/views/manifestations/_reservable_facet.html.erb +2 -2
  37. data/app/views/manifestations/_show_detail_librarian.html.erb +12 -8
  38. data/app/views/manifestations/_show_detail_user.html.erb +12 -8
  39. data/app/views/manifestations/_title.html.erb +1 -1
  40. data/app/views/manifestations/index.html.erb +7 -7
  41. data/app/views/manifestations/index.rdf.builder +2 -2
  42. data/app/views/manifestations/index.rss.builder +2 -2
  43. data/app/views/manifestations/index.text.ruby +13 -0
  44. data/app/views/manifestations/{show.txt.ruby → show.text.ruby} +0 -0
  45. data/app/views/resource_import_results/{index.txt.ruby → index.text.ruby} +0 -0
  46. data/lib/enju_biblio/version.rb +1 -1
  47. data/lib/enju_biblio.rb +0 -2
  48. data/spec/controllers/items_controller_spec.rb +41 -0
  49. data/spec/controllers/manifestations_controller_spec.rb +2 -21
  50. data/spec/fixtures/items.yml +1 -0
  51. data/spec/fixtures/manifestations.yml +1 -0
  52. data/spec/models/manifestation_spec.rb +11 -66
  53. data/spec/models/resource_import_file_spec.rb +18 -0
  54. data/spec/system/items_spec.rb +6 -0
  55. data/spec/views/agent_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  56. data/spec/views/items/index.json.jbuilder_spec.rb +15 -0
  57. data/spec/views/items/show.json.jbuilder_spec.rb +15 -0
  58. data/spec/views/manifestations/index.html.erb_spec.rb +1 -1
  59. data/spec/views/manifestations/index.rdf.builder_spec.rb +0 -1
  60. data/spec/views/manifestations/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  61. data/spec/views/manifestations/{show.txt.ruby_spec.rb → show.text.ruby_spec.rb} +1 -1
  62. data/spec/views/resource_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
  63. metadata +37 -34
  64. data/app/views/items/index.txt.erb +0 -4
  65. data/app/views/manifestations/explain.sru +0 -9
  66. data/app/views/manifestations/index.sru.builder +0 -101
  67. data/app/views/manifestations/index.txt.ruby +0 -7
  68. data/lib/enju_biblio/porta_cql.rb +0 -282
  69. data/lib/enju_biblio/sru.rb +0 -85
@@ -5,11 +5,11 @@ xml.rss('version' => "2.0",
5
5
  'xmlns:atom' => "http://www.w3.org/2005/Atom"){
6
6
  xml.channel{
7
7
  xml.title t('manifestation.query_search_result', query: @query, library_group_name: @library_group.display_name.localize)
8
- xml.link "#{request.protocol}#{request.host_with_port}#{url_for(filtered_params.merge(format: nil, only_path: true))}"
8
+ xml.link "#{request.protocol}#{request.host_with_port}#{url_for(request.params.merge(format: nil, only_path: true))}"
9
9
  xml.description "Next-L Enju, an open source integrated library system developed by Project Next-L"
10
10
  xml.language @locale.to_s
11
11
  xml.ttl "60"
12
- xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(filtered_params.merge(format: :rss, only_path: true))}"
12
+ xml.tag! "atom:link", rel: 'self', href: "#{request.protocol}#{request.host_with_port}#{url_for(request.params.merge(format: :rss, only_path: true))}"
13
13
  xml.tag! "atom:link", rel: 'alternate', href: manifestations_url
14
14
  xml.tag! "atom:link", rel: 'search', type: 'application/opensearchdescription+xml', href: page_opensearch_url
15
15
  if params[:query].present?
@@ -0,0 +1,13 @@
1
+ csv = (Manifestation.csv_header(role: current_user_role_name) + Item.csv_header(role: current_user_role_name)).to_csv(col_sep: "\t")
2
+
3
+ @manifestations.map{|manifestation|
4
+ if manifestation.items.empty?
5
+ csv += manifestation.to_hash(role: current_user_role_name).values.to_csv(col_sep: "\t")
6
+ else
7
+ manifestation.items.each do |item|
8
+ csv += (manifestation.to_hash(role: current_user_role_name).values + item.to_hash(role: current_user_role_name).values).to_csv(col_sep: "\t")
9
+ end
10
+ end
11
+ }
12
+
13
+ csv
@@ -1,3 +1,3 @@
1
1
  module EnjuBiblio
2
- VERSION = "0.3.11".freeze
2
+ VERSION = "0.3.14".freeze
3
3
  end
data/lib/enju_biblio.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require "enju_biblio/engine"
2
2
  require "enju_biblio/openurl"
3
- require "enju_biblio/porta_cql"
4
- require "enju_biblio/sru"
5
3
 
6
4
  module EnjuBiblio
7
5
  end
@@ -46,6 +46,23 @@ describe ItemsController do
46
46
  expect(assigns(:items)).to_not be_nil
47
47
  expect(assigns(:items).count).to eq 1
48
48
  end
49
+
50
+ it 'accepts text format' do
51
+ get :index, format: :text
52
+ expect(assigns(:items)).to_not be_nil
53
+ end
54
+
55
+ describe 'in JSON response' do
56
+ render_views
57
+ it 'should not assign unnecessary attributes' do
58
+ get :index, format: :json
59
+ expect(response.body).to match /manifestation_id/
60
+ expect(response.body).not_to match /price/
61
+ expect(response.body).not_to match /memo/
62
+ expect(response.body).not_to match /bookstore_id/
63
+ expect(response.body).not_to match /budget_type_id/
64
+ end
65
+ end
49
66
  end
50
67
 
51
68
  describe 'When logged in as User' do
@@ -55,6 +72,18 @@ describe ItemsController do
55
72
  get :index
56
73
  expect(assigns(:items)).to_not be_nil
57
74
  end
75
+
76
+ describe 'in JSON response' do
77
+ render_views
78
+ it 'should not assign unnecessary attributes' do
79
+ get :index, format: :json
80
+ expect(response.body).to match /manifestation_id/
81
+ expect(response.body).not_to match /price/
82
+ expect(response.body).not_to match /memo/
83
+ expect(response.body).not_to match /bookstore_id/
84
+ expect(response.body).not_to match /budget_type_id/
85
+ end
86
+ end
58
87
  end
59
88
 
60
89
  describe 'When not logged in' do
@@ -83,6 +112,18 @@ describe ItemsController do
83
112
  assigns(:shelf).should eq Shelf.find(1)
84
113
  expect(assigns(:items)).to eq assigns(:shelf).items.order('created_at DESC').page(1)
85
114
  end
115
+
116
+ describe 'in JSON response' do
117
+ render_views
118
+ it 'should not assign unnecessary attributes' do
119
+ get :index, format: :json
120
+ expect(response.body).to match /manifestation_id/
121
+ expect(response.body).not_to match /price/
122
+ expect(response.body).not_to match /memo/
123
+ expect(response.body).not_to match /bookstore_id/
124
+ expect(response.body).not_to match /budget_type_id/
125
+ end
126
+ end
86
127
  end
87
128
  end
88
129
 
@@ -51,32 +51,13 @@ describe ManifestationsController do
51
51
  expect(assigns(:manifestations)).to_not be_nil
52
52
  end
53
53
 
54
- it 'assigns all manifestations as @manifestations in txt format without operation' do
55
- get :index, format: 'txt'
54
+ it 'assigns all manifestations as @manifestations in text format without operation' do
55
+ get :index, format: :text
56
56
  expect(response).to be_successful
57
57
  expect(assigns(:manifestations)).to_not be_nil
58
58
  expect(response).to render_template('manifestations/index')
59
59
  end
60
60
 
61
- it 'assigns all manifestations as @manifestations in sru format without operation' do
62
- get :index, format: 'sru'
63
- assert_response :success
64
- expect(assigns(:manifestations)).to be_nil
65
- expect(response).to render_template('manifestations/explain')
66
- end
67
-
68
- it 'assigns all manifestations as @manifestations in sru format with operation' do
69
- get :index, params: { format: 'sru', operation: 'searchRetrieve', query: 'ruby' }
70
- expect(assigns(:manifestations)).to_not be_nil
71
- expect(response).to render_template('manifestations/index')
72
- end
73
-
74
- it 'assigns all manifestations as @manifestations in sru format with operation and title' do
75
- get :index, params: { format: 'sru', query: 'title=ruby', operation: 'searchRetrieve' }
76
- expect(assigns(:manifestations)).to_not be_nil
77
- expect(response).to render_template('manifestations/index')
78
- end
79
-
80
61
  it 'assigns all manifestations as @manifestations in openurl' do
81
62
  get :index, params: { api: 'openurl', title: 'ruby' }
82
63
  expect(assigns(:manifestations)).to_not be_nil
@@ -10,6 +10,7 @@ item_00001:
10
10
  id: 1
11
11
  include_supplements: false
12
12
  created_at: 2007-08-24 23:46:00.484813 +09:00
13
+ memo: 所蔵確認用のメモ
13
14
  item_00002:
14
15
  updated_at: 2007-08-24 23:46:01.641413 +09:00
15
16
  item_identifier: '00002'
@@ -18,6 +18,7 @@ manifestation_00001:
18
18
  repository_content: true
19
19
  extent: "123p"
20
20
  dimensions: "25cm"
21
+ memo: 確認用の書誌情報
21
22
  manifestation_00002:
22
23
  carrier_type_id: 1
23
24
  language_id: 1
@@ -98,71 +98,6 @@ describe Manifestation, solr: true do
98
98
  lambda{Openurl.new({aufirst: "テスト 名称"})}.should raise_error(OpenurlQuerySyntaxError)
99
99
  end
100
100
 
101
- it "should search in sru" do
102
- sru = Sru.new({query: "title=Ruby"})
103
- sru.search
104
- sru.manifestations.size.should eq 18
105
- sru.manifestations.first.titles.first.should eq 'Ruby'
106
- sru = Sru.new({query: "title=^ruby"})
107
- sru.search
108
- sru.manifestations.size.should eq 9
109
- sru = Sru.new({query: 'title ALL "awk sed"'})
110
- sru.search
111
- sru.manifestations.size.should eq 2
112
- sru.manifestations.collect{|m| m.id}.should eq [184, 116]
113
- sru = Sru.new({query: 'title ANY "ruby awk sed"'})
114
- sru.search
115
- sru.manifestations.size.should eq 22
116
- sru = Sru.new({query: 'isbn=9784756137470'})
117
- sru.search
118
- sru.manifestations.first.id.should eq 114
119
- sru = Sru.new({query: "creator=テスト"})
120
- sru.search
121
- sru.manifestations.size.should eq 1
122
- end
123
-
124
- it "should search date in sru" do
125
- sru = Sru.new({query: "from = 2000-09 AND until = 2000-11-01"})
126
- sru.search
127
- sru.manifestations.size.should eq 1
128
- sru.manifestations.first.id.should eq 120
129
- sru = Sru.new({query: "from = 1993-02-24"})
130
- sru.search
131
- sru.manifestations.size.should eq 5
132
- sru = Sru.new({query: "until = 2006-08-06"})
133
- sru.search
134
- sru.manifestations.size.should eq 4
135
- end
136
-
137
- it "should accept sort_by in sru" do
138
- sru = Sru.new({query: "title=Ruby"})
139
- sru.sort_by.should eq({sort_by: 'created_at', order: 'desc'})
140
- sru = Sru.new({query: 'title=Ruby AND sortBy="title/sort.ascending"', sortKeys: 'creator,0', version: '1.2'})
141
- sru.sort_by.should eq({sort_by: 'sort_title', order: 'asc'})
142
- sru = Sru.new({query: 'title=Ruby AND sortBy="title/sort.ascending"', sortKeys: 'creator,0', version: '1.1'})
143
- sru.sort_by.should eq({sort_by: 'creator', order: 'desc'})
144
- sru = Sru.new({query: 'title=Ruby AND sortBy="title/sort.ascending"', sortKeys: 'creator,1', version: '1.1'})
145
- sru.sort_by.should eq({sort_by: 'creator', order: 'asc'})
146
- sru = Sru.new({query: 'title=Ruby AND sortBy="title'})
147
- sru.sort_by.should eq({sort_by: 'sort_title', order: 'asc'})
148
- # TODO ソート基準が入手しやすさの場合の処理
149
- end
150
-
151
- it "should accept ranges in sru" do
152
- sru = Sru.new({query: "from = 1993-02-24 AND until = 2006-08-06 AND title=プログラミング"})
153
- sru.search
154
- sru.manifestations.size.should eq 2
155
- sru = Sru.new({query: "until = 2000 AND title=プログラミング"})
156
- sru.search
157
- sru.manifestations.size.should eq 1
158
- sru = Sru.new({query: "from = 2006 AND title=プログラミング"})
159
- sru.search
160
- sru.manifestations.size.should eq 1
161
- sru = Sru.new({query: "from = 2007 OR title=awk"})
162
- sru.search
163
- sru.manifestations.size.should eq 6
164
- end
165
-
166
101
  it "should_get_number_of_pages" do
167
102
  manifestations(:manifestation_00001).number_of_pages.should eq 100
168
103
  end
@@ -223,6 +158,8 @@ describe Manifestation, solr: true do
223
158
  csv["classification:ndc9"].compact.inject(0){|count, a| count += 1 if a == '400'; count}.should eq manifestations(:manifestation_00001).items.count
224
159
  csv["extent"].compact.should_not be_empty
225
160
  csv["dimensions"].compact.should_not be_empty
161
+ csv["manifestation_memo"].compact.should be_empty
162
+ csv["item_memo"].compact.should be_empty
226
163
  end
227
164
 
228
165
  it "should export edition fields" do
@@ -277,17 +214,25 @@ describe Manifestation, solr: true do
277
214
  expect(csv["bookstore"].compact).not_to be_empty
278
215
  expect(csv["item_price"].compact).not_to be_empty
279
216
  expect(csv["budget_type"].compact).not_to be_empty
217
+ expect(csv["manifestation_memo"].compact).not_to be_empty
218
+ expect(csv["item_memo"].compact).not_to be_empty
280
219
  end
281
220
 
282
221
  it 'should escape LF/CR to "\n"' do
283
- manifestation = FactoryBot.create(:manifestation, description: "test\ntest", note: "test\ntest")
222
+ manifestation = FactoryBot.create(:manifestation,
223
+ abstract: "test\ntest",
224
+ description: "test\ntest",
225
+ note: "test\ntest"
226
+ )
284
227
  item = FactoryBot.create(:item, manifestation: manifestation, note: "test\ntest")
285
228
  lines = Manifestation.export
286
229
  csv = CSV.parse(lines, headers: true, col_sep: "\t")
230
+ expect(csv["abstract"].compact).not_to be_empty
287
231
  expect(csv["description"].compact).not_to be_empty
288
232
  expect(csv["note"].compact).not_to be_empty
289
233
  expect(csv["item_note"].compact).not_to be_empty
290
234
  m = csv.find{|row| row["manifestation_id"].to_i == manifestation.id }
235
+ expect(m["abstract"]).to eq "test\ntest"
291
236
  expect(m["description"]).to eq "test\ntest"
292
237
  expect(m["note"]).to eq "test\ntest"
293
238
  expect(m["item_note"]).to eq "test\ntest"
@@ -67,6 +67,8 @@ describe ResourceImportFile do
67
67
  item_10101.manifestation.frequency.name.should eq 'monthly'
68
68
  item_10101.manifestation.extent.should eq 'xv, 213 pages'
69
69
  item_10101.manifestation.dimensions.should eq '20cm'
70
+ expect(item_10101.memo).to eq '個別資料メモ1'
71
+ expect(item_10101.manifestation.memo).to eq '書誌メモ1'
70
72
 
71
73
  item_10102 = Item.find_by(item_identifier: '10102')
72
74
  item_10102.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
@@ -167,6 +169,22 @@ describe ResourceImportFile do
167
169
  expect(item_10103.manifestation.manifestation_custom_values.pluck(:value)).to eq ["カスタム項目テスト1", "カスタム項目テスト2"]
168
170
  expect(item_10103.item_custom_values.pluck(:value)).to eq ['カスタム項目テスト3', 'カスタム項目テスト4']
169
171
  end
172
+
173
+ it "should import multiple rows in a cell" do
174
+ file = ResourceImportFile.create(
175
+ resource_import: File.new("#{Rails.root}/../../examples/resource_import_file_sample5.tsv"),
176
+ default_shelf_id: 3,
177
+ user: users(:admin),
178
+ edit_mode: 'create'
179
+ )
180
+ file.import_start
181
+
182
+ manifestation = Manifestation.find_by(manifestation_identifier: 10201)
183
+ expect(manifestation.original_title).to eq "改行を含む\nタイトル"
184
+ expect(manifestation.abstract).to eq "改行を含む\n目次の\n情報"
185
+ expect(manifestation.note).to eq "改行を\n含む\n注記の\n情報"
186
+ expect(manifestation.description).to eq "改行を\n含む\n説明の情報"
187
+ end
170
188
  end
171
189
 
172
190
  describe "ISBN import" do
@@ -111,5 +111,11 @@ RSpec.describe 'Manifestations', type: :system do
111
111
  visit item_path(@item.id, locale: :ja)
112
112
  expect(page).not_to have_content @item.price
113
113
  end
114
+
115
+ it 'should add a link to url' do
116
+ @item.update(url: 'http://example.jp')
117
+ visit item_path(@item.id)
118
+ expect(page).to have_link 'http://example.jp'
119
+ end
114
120
  end
115
121
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "agent_import_results/index.txt.ruby" do
3
+ describe "agent_import_results/index.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do
@@ -0,0 +1,15 @@
1
+ require "rails_helper.rb"
2
+
3
+ describe "items/index.json.jbuilder", solr: true do
4
+ before(:each) do
5
+ item = FactoryBot.create(:item)
6
+ @items = assign(:items, [item] )
7
+ end
8
+
9
+ it "should export JSON format" do
10
+ params[:format] = "json"
11
+ render
12
+ expect(rendered).not_to match(/memo/)
13
+ end
14
+ end
15
+
@@ -0,0 +1,15 @@
1
+ require 'rails_helper'
2
+
3
+ describe "items/show.json.jbuilder" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ assign(:item, FactoryBot.create(:item))
8
+ end
9
+
10
+ it "renders a template" do
11
+ render
12
+ expect(rendered).to match(/item_identifier/)
13
+ expect(rendered).not_to match(/memo/)
14
+ end
15
+ end
@@ -12,11 +12,11 @@ describe "manifestations/index" do
12
12
  @reservable_facet = @carrier_type_facet = @language_facet = @library_facet = @pub_year_facet = []
13
13
  @seconds = 0
14
14
  @max_number_of_results = 500
15
- view.stub(:filtered_params).and_return(ActionController::Parameters.new(per_page: 50).permit(:per_page))
16
15
  end
17
16
 
18
17
  describe "sort_by menu" do
19
18
  it "should reflect per_page params for views" do
19
+ params[:per_page] = 50
20
20
  render
21
21
  expect(rendered).to have_selector "select#per_page option[value='50'][selected='selected']"
22
22
  end
@@ -5,7 +5,6 @@ describe "manifestations/index.rdf.builder" do
5
5
  manifestation = FactoryBot.create(:manifestation)
6
6
  @manifestations = assign(:manifestations, [manifestation] )
7
7
  @library_group = LibraryGroup.first
8
- view.stub(:filtered_params).and_return(ActionController::Parameters.new(per_page: 50).permit([:per_page]))
9
8
  end
10
9
 
11
10
  it "should export RDF format" do
@@ -1,6 +1,6 @@
1
1
  require "rails_helper.rb"
2
2
 
3
- describe "manifestations/index.txt.ruby" do
3
+ describe "manifestations/index.text.ruby" do
4
4
  before(:each) do
5
5
  manifestation = FactoryBot.create(:manifestation)
6
6
  manifestation.items << FactoryBot.create(:item, bookstore_id: 1, budget_type_id: 1, price: 100)
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "manifestations/show.txt.ruby" do
3
+ describe "manifestations/show.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "resource_import_results/index.txt.ruby" do
3
+ describe "resource_import_results/index.text.ruby" do
4
4
  fixtures :all
5
5
 
6
6
  before(:each) do