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.
- checksums.yaml +4 -4
- data/app/controllers/agent_import_results_controller.rb +1 -1
- data/app/controllers/agents_controller.rb +0 -6
- data/app/controllers/items_controller.rb +15 -10
- data/app/controllers/manifestations_controller.rb +68 -76
- data/app/controllers/resource_import_results_controller.rb +2 -2
- data/app/controllers/series_statements_controller.rb +0 -6
- data/app/helpers/manifestations_helper.rb +8 -8
- data/app/models/agent.rb +10 -1
- data/app/models/form_of_work.rb +1 -1
- data/app/models/frequency.rb +1 -1
- data/app/models/identifier.rb +1 -1
- data/app/models/import_request.rb +2 -3
- data/app/models/item.rb +6 -6
- data/app/models/item_custom_value.rb +1 -1
- data/app/models/manifestation.rb +10 -18
- data/app/models/manifestation_custom_value.rb +1 -1
- data/app/models/resource_import_file.rb +8 -4
- data/app/views/agent_import_results/{index.txt.ruby → index.text.ruby} +0 -0
- data/app/views/agent_relationship_types/index.html.erb +3 -3
- data/app/views/agents/index.rss.builder +2 -2
- data/app/views/items/_item.json.jbuilder +17 -0
- data/app/views/items/index.json.jbuilder +5 -0
- data/app/views/items/index.text.ruby +13 -0
- data/app/views/items/show.html.erb +125 -125
- data/app/views/items/show.json.jbuilder +1 -0
- data/app/views/layouts/agents.html.erb +2 -2
- data/app/views/layouts/manifestations.html.erb +2 -2
- data/app/views/manifestations/_carrier_type_facet.html.erb +1 -1
- data/app/views/manifestations/_classification_facet.html.erb +2 -2
- data/app/views/manifestations/_export_list.html.erb +4 -4
- data/app/views/manifestations/_form.html.erb +3 -3
- data/app/views/manifestations/_language_facet.html.erb +1 -1
- data/app/views/manifestations/_library_facet.html.erb +1 -1
- data/app/views/manifestations/_pub_year_facet.html.erb +1 -1
- data/app/views/manifestations/_reservable_facet.html.erb +2 -2
- data/app/views/manifestations/_show_detail_librarian.html.erb +12 -8
- data/app/views/manifestations/_show_detail_user.html.erb +12 -8
- data/app/views/manifestations/_title.html.erb +1 -1
- data/app/views/manifestations/index.html.erb +7 -7
- data/app/views/manifestations/index.rdf.builder +2 -2
- data/app/views/manifestations/index.rss.builder +2 -2
- data/app/views/manifestations/index.text.ruby +13 -0
- data/app/views/manifestations/{show.txt.ruby → show.text.ruby} +0 -0
- data/app/views/resource_import_results/{index.txt.ruby → index.text.ruby} +0 -0
- data/lib/enju_biblio/version.rb +1 -1
- data/lib/enju_biblio.rb +0 -2
- data/spec/controllers/items_controller_spec.rb +41 -0
- data/spec/controllers/manifestations_controller_spec.rb +2 -21
- data/spec/fixtures/items.yml +1 -0
- data/spec/fixtures/manifestations.yml +1 -0
- data/spec/models/manifestation_spec.rb +11 -66
- data/spec/models/resource_import_file_spec.rb +18 -0
- data/spec/system/items_spec.rb +6 -0
- data/spec/views/agent_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
- data/spec/views/items/index.json.jbuilder_spec.rb +15 -0
- data/spec/views/items/show.json.jbuilder_spec.rb +15 -0
- data/spec/views/manifestations/index.html.erb_spec.rb +1 -1
- data/spec/views/manifestations/index.rdf.builder_spec.rb +0 -1
- data/spec/views/manifestations/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
- data/spec/views/manifestations/{show.txt.ruby_spec.rb → show.text.ruby_spec.rb} +1 -1
- data/spec/views/resource_import_results/{index.txt.ruby_spec.rb → index.text.ruby_spec.rb} +1 -1
- metadata +37 -34
- data/app/views/items/index.txt.erb +0 -4
- data/app/views/manifestations/explain.sru +0 -9
- data/app/views/manifestations/index.sru.builder +0 -101
- data/app/views/manifestations/index.txt.ruby +0 -7
- data/lib/enju_biblio/porta_cql.rb +0 -282
- 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(
|
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(
|
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
|
File without changes
|
File without changes
|
data/lib/enju_biblio/version.rb
CHANGED
data/lib/enju_biblio.rb
CHANGED
@@ -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
|
55
|
-
get :index, format:
|
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
|
data/spec/fixtures/items.yml
CHANGED
@@ -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,
|
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
|
data/spec/system/items_spec.rb
CHANGED
@@ -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
|
@@ -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.
|
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)
|