repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/realize_spec.rb | spec/models/realize_spec.rb | require 'rails_helper'
describe Realize do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: realizes
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# expression_id :bigint not null
# realize_type_id :bigint
#
# Indexes
#
# index_realizes_on_agent_id (agent_id)
# index_realizes_on_expression_id_and_agent_id (expression_id,agent_id) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/use_resetriction_spec.rb | spec/models/use_resetriction_spec.rb | require 'rails_helper'
describe UseRestriction do
# pending "add some examples to (or delete) #{__FILE__}"
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/agent_import_result_spec.rb | spec/models/agent_import_result_spec.rb | require 'rails_helper'
describe AgentImportResult do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_import_results
#
# id :bigint not null, primary key
# agent_import_file_id :bigint
# agent_id :bigint
# body :text
# created_at :datetime not null
# updated_at :datetime not null
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/series_statement_merge_spec.rb | spec/models/series_statement_merge_spec.rb | require 'rails_helper'
describe SeriesStatementMerge do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: series_statement_merges
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# series_statement_id :bigint not null
# series_statement_merge_list_id :bigint not null
#
# Indexes
#
# index_series_statement_merges_on_list_id (series_statement_merge_list_id)
# index_series_statement_merges_on_series_statement_id (series_statement_id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/checkout_stat_has_user_spec.rb | spec/models/checkout_stat_has_user_spec.rb | require 'rails_helper'
describe CheckoutStatHasUser do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: checkout_stat_has_users
#
# id :bigint not null, primary key
# checkouts_count :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
# user_checkout_stat_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_checkout_stat_has_users_on_user_checkout_stat_id (user_checkout_stat_id)
# index_checkout_stat_has_users_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_checkout_stat_id => user_checkout_stats.id)
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/request_type_spec.rb | spec/models/request_type_spec.rb | require 'rails_helper'
describe RequestType do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: request_types
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_request_types_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/event_import_file_spec.rb | spec/models/event_import_file_spec.rb | require 'rails_helper'
describe EventImportFile do
fixtures :all
#pending "add some examples to (or delete) #{__FILE__}"
describe "When it is written in utf-8" do
before(:each) do
@file = EventImportFile.create!(
default_library_id: 3,
default_event_category: EventCategory.find(3),
user: users(:admin)
)
@file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/event_import_file_sample1.tsv"), filename: 'attachment.txt')
end
it "should be imported" do
closing_days_size = Event.closing_days.size
old_events_count = Event.count
old_import_results_count = EventImportResult.count
expect(@file.import_start).to eq({ imported: 2, failed: 2 })
expect(Event.count).to eq old_events_count + 2
expect(Event.closing_days.size).to eq closing_days_size + 1
expect(EventImportResult.count).to eq old_import_results_count + 5
expect(Event.order(:id).last.library.name).to eq 'hachioji'
expect(Event.order(:id).last.name).to eq 'event3'
expect(Event.where(name: 'event2').first).to be_nil
event3 = Event.where(name: 'event3').first
expect(event3.display_name).to eq 'イベント3'
expect(event3.event_category.name).to eq 'book_talk'
event4 = Event.where(name: '休館日1').first
expect(event4.event_category.name).to eq 'closed'
# @file.event_import_fingerprint.should be_truthy
expect(@file.executed_at).to be_truthy
@file.reload
expect(@file.error_message).to eq "The following column(s) were ignored: invalid"
end
it "should send message when import is completed" do
old_message_count = Message.count
@file.user = User.find_by(username: 'librarian1')
@file.import_start
expect(Message.count).to eq old_message_count + 1
expect(Message.order(:created_at).last.subject).to eq "Import completed: #{@file.id}"
end
end
describe "When it is written in shift_jis" do
before(:each) do
@file = EventImportFile.create!(
default_library: Library.find(3),
default_event_category: EventCategory.find(3),
user: users(:admin)
)
@file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/event_import_file_sample2.tsv"), filename: 'attachment.txt')
end
it "should be imported" do
old_event_count = Event.count
old_import_results_count = EventImportResult.count
@file.import_start
Event.order('id DESC').first.name.should eq 'event3'
Event.count.should eq old_event_count + 2
EventImportResult.count.should eq old_import_results_count + 5
Event.order('id DESC').first.start_at.should eq Time.zone.parse('2014-07-01').beginning_of_day
Event.order('id DESC').first.end_at.should eq Time.zone.parse('2014-07-31 14:00')
end
end
describe "When it is an invalid file" do
before(:each) do
@file = EventImportFile.create!(
user: users(:admin)
)
@file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/invalid_file.tsv"), filename: 'attachment.txt')
end
it "should not be imported" do
old_event_count = Event.count
old_import_results_count = EventImportResult.count
lambda {@file.import_start}.should raise_error(RuntimeError)
Event.count.should eq Event.count
EventImportResult.count.should eq EventImportResult.count
end
end
describe "when its mode is 'update'" do
it "should update events" do
file = EventImportFile.create!(
user: users(:admin)
)
file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/event_update_file.tsv"), filename: 'attachment.txt')
file.modify
event1 = Event.find(1)
event1.name.should eq '変更後のイベント名'
event1.start_at.should eq Time.zone.parse('2012-04-01').beginning_of_day
event1.end_at.should eq Time.zone.parse('2012-04-02')
event2 = Event.find(2)
event2.end_at.should eq Time.zone.parse('2012-04-03')
event2.all_day.should be_falsy
event2.library.name.should eq 'mita'
event3 = Event.find(3)
event3.name.should eq 'ミーティング'
end
end
describe "when its mode is 'destroy'" do
it "should destroy events" do
old_event_count = Event.count
file = EventImportFile.create!(
user: users(:admin)
)
file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/event_destroy_file.tsv"), filename: 'attachment.txt')
file.remove
Event.count.should eq old_event_count - 2
end
end
it "should import in background" do
file = EventImportFile.create!(
user: users(:admin)
)
file.attachment.attach(io: File.new("#{Rails.root}/spec/fixtures/files/event_import_file_sample1.tsv"), filename: 'attachment.txt')
EventImportFileJob.perform_later(file).should be_truthy
end
end
# == Schema Information
#
# Table name: event_import_files
#
# id :bigint not null, primary key
# edit_mode :string
# error_message :text
# event_import_fingerprint :string
# executed_at :datetime
# note :text
# user_encoding :string
# created_at :datetime not null
# updated_at :datetime not null
# default_event_category_id :bigint
# default_library_id :bigint
# parent_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_event_import_files_on_parent_id (parent_id)
# index_event_import_files_on_user_id (user_id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/manifestation_custom_property_spec.rb | spec/models/manifestation_custom_property_spec.rb | require 'rails_helper'
RSpec.describe ManifestationCustomProperty, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: manifestation_custom_properties
#
# id :bigint not null, primary key
# display_name(表示名) :text not null
# name(ラベル名) :string not null
# note(備考) :text
# position :integer default(1), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_manifestation_custom_properties_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/item_custom_property_spec.rb | spec/models/item_custom_property_spec.rb | require 'rails_helper'
RSpec.describe ItemCustomProperty, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: item_custom_properties
#
# id :bigint not null, primary key
# display_name(表示名) :text not null
# name(ラベル名) :string not null
# note(備考) :text
# position :integer default(1), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_item_custom_properties_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/inventory_file_spec.rb | spec/models/inventory_file_spec.rb | require 'rails_helper'
describe InventoryFile do
fixtures :users
before(:each) do
@file = InventoryFile.create(user: users(:admin), shelf: Shelf.find_by(name: 'first_shelf'))
@file.attachment.attach(io: File.new("#{Rails.root.to_s}/spec/fixtures/files/inventory_file_sample.tsv"), filename: 'attachment.txt')
end
it "should be imported" do
expect(@file.import).to be_truthy
end
it "should export results" do
expect(@file.export).to be_truthy
end
end
# == Schema Information
#
# Table name: inventory_files
#
# id :bigint not null, primary key
# inventory_fingerprint :string
# note :text
# created_at :datetime not null
# updated_at :datetime not null
# shelf_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_inventory_files_on_shelf_id (shelf_id)
# index_inventory_files_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (shelf_id => shelves.id)
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/medium_of_performance_spec.rb | spec/models/medium_of_performance_spec.rb | require 'rails_helper'
describe MediumOfPerformance do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: medium_of_performances
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_medium_of_performances_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/identifier_spec.rb | spec/models/identifier_spec.rb | require 'rails_helper'
describe Identifier do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: identifiers
#
# id :bigint not null, primary key
# body :string not null
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# identifier_type_id :bigint not null
# manifestation_id :bigint
#
# Indexes
#
# index_identifiers_on_body_and_identifier_type_id (body,identifier_type_id)
# index_identifiers_on_manifestation_id (manifestation_id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/language_spec.rb | spec/models/language_spec.rb | require 'rails_helper'
describe Language do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: languages
#
# id :bigint not null, primary key
# display_name :text
# iso_639_1 :string
# iso_639_2 :string
# iso_639_3 :string
# name :string not null
# native_name :string
# note :text
# position :integer
#
# Indexes
#
# index_languages_on_iso_639_1 (iso_639_1)
# index_languages_on_iso_639_2 (iso_639_2)
# index_languages_on_iso_639_3 (iso_639_3)
# index_languages_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/reserve_stat_has_user_spec.rb | spec/models/reserve_stat_has_user_spec.rb | require 'rails_helper'
describe ReserveStatHasUser do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: reserve_stat_has_users
#
# id :bigint not null, primary key
# reserves_count :integer
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
# user_reserve_stat_id :bigint not null
#
# Indexes
#
# index_reserve_stat_has_users_on_user_id (user_id)
# index_reserve_stat_has_users_on_user_reserve_stat_id (user_reserve_stat_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
# fk_rails_... (user_reserve_stat_id => user_reserve_stats.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/lccn_record_spec.rb | spec/models/lccn_record_spec.rb | require 'rails_helper'
RSpec.describe LccnRecord, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: lccn_records
#
# id :bigint not null, primary key
# body :string not null
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_id :bigint not null
#
# Indexes
#
# index_lccn_records_on_body (body) UNIQUE
# index_lccn_records_on_manifestation_id (manifestation_id)
#
# Foreign Keys
#
# fk_rails_... (manifestation_id => manifestations.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/content_type_spec.rb | spec/models/content_type_spec.rb | require 'rails_helper'
describe ContentType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: content_types
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_content_types_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/resource_export_file_spec.rb | spec/models/resource_export_file_spec.rb | require 'rails_helper'
describe ResourceExportFile do
fixtures :all
it "should export ncid" do
manifestation = FactoryBot.create(:manifestation)
type = IdentifierType.find_or_create_by(name: "ncid")
identifier = FactoryBot.create(:identifier, identifier_type: type, body: "a11223344")
manifestation.identifiers << identifier
export_file = ResourceExportFile.new
export_file.user = users(:admin)
export_file.save!
export_file.export!
CSV.parse(export_file.attachment.download, headers: true, col_sep: "\t").each do |row|
expect(row).to have_key "library"
expect(row).to have_key "shelf"
expect(row).to have_key "ncid"
if row['manifestation_id'] == identifier.manifestation_id
expect(row["ncid"]).to eq identifier.body
end
end
end
end
# == Schema Information
#
# Table name: resource_export_files
#
# id :bigint not null, primary key
# executed_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/user_import_result_spec.rb | spec/models/user_import_result_spec.rb | require 'rails_helper'
describe UserImportResult do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: user_import_results
#
# id :bigint not null, primary key
# body :text
# error_message :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint
# user_import_file_id :bigint
#
# Indexes
#
# index_user_import_results_on_user_id (user_id)
# index_user_import_results_on_user_import_file_id (user_import_file_id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/user_import_file_spec.rb | spec/models/user_import_file_spec.rb | require 'rails_helper'
describe UserImportFile do
fixtures :all
describe "when its mode is 'create'" do
before(:each) do
@file = UserImportFile.new attachment: fixture_file_upload("/user_import_file_sample.tsv")
@file.default_user_group = UserGroup.find(2)
@file.default_library = Library.find(3)
@file.user = users(:admin)
@file.save
end
it "should be imported" do
file = UserImportFile.new attachment: fixture_file_upload("user_import_file_sample.tsv")
file.default_user_group = UserGroup.find(2)
file.default_library = Library.find(3)
file.user = users(:admin)
file.save
old_users_count = User.count
old_import_results_count = UserImportResult.count
file.current_state.should eq 'pending'
file.import_start.should eq({ user_imported: 5, user_found: 0, failed: 0, error: 3 })
User.order('id DESC')[1].username.should eq 'user005'
User.order('id DESC')[2].username.should eq 'user003'
User.count.should eq old_users_count + 5
user001 = User.find_by(username: 'user001')
user001.profile.keyword_list.should eq "日本史\n地理"
user001.profile.full_name.should eq '田辺 浩介'
user001.profile.full_name_transcription.should eq 'たなべ こうすけ'
user001.profile.required_role.name.should eq 'User'
user001.locked_at.should be_truthy
user002 = User.find_by(username: 'user002')
user002.profile.user_group.name.should eq 'faculty'
user002.profile.expired_at.to_i.should eq Time.zone.parse('2013-12-01').end_of_day.to_i
user002.valid_password?('4NsxXPLy')
user002.profile.user_number.should eq '001002'
user002.profile.library.name.should eq 'hachioji'
user002.profile.locale.should eq 'en'
user002.profile.required_role.name.should eq 'Librarian'
user002.locked_at.should be_nil
user003 = User.find_by(username: 'user003')
user003.profile.note.should eq 'テストユーザ'
user003.role.name.should eq 'Librarian'
user003.profile.user_number.should eq '001003'
user003.profile.library.name.should eq 'kamata'
user003.profile.locale.should eq 'ja'
user003.profile.checkout_icalendar_token.should eq 'secrettoken'
user003.profile.save_checkout_history.should be_truthy
user003.profile.share_bookmarks.should be_falsy
User.where(username: 'user000').first.should be_nil
UserImportResult.count.should eq old_import_results_count + 10
UserImportResult.order('id DESC')[0].error_message.should eq 'line 10: User number has already been taken'
UserImportResult.order('id DESC')[1].error_message.should eq 'line 9: User number is invalid'
UserImportResult.order('id DESC')[2].error_message.should eq 'line 8: Password is too short (minimum is 6 characters)'
user005 = User.find_by(username: 'user005')
user005.role.name.should eq 'User'
user005.profile.library.name.should eq 'hachioji'
user005.profile.locale.should eq 'en'
user005.profile.user_number.should eq '001005'
user005.profile.user_group.name.should eq 'faculty'
user006 = User.find_by(username: 'user006')
user006.role.name.should eq 'User'
user006.profile.library.name.should eq 'hachioji'
user006.profile.locale.should eq 'en'
user006.profile.user_number.should be_nil
user006.profile.user_group.name.should eq UserGroup.find(2).name
file.executed_at.should be_truthy
file.reload
file.error_message.should eq "The following column(s) were ignored: save_search_history, invalid\nline 8: Password is too short (minimum is 6 characters)\nline 9: User number is invalid\nline 10: User number has already been taken"
file.current_state.should eq 'failed'
end
it "should send message when import is completed" do
old_message_count = Message.count
@file.user = User.find_by(username: 'librarian1')
@file.import_start
Message.count.should eq old_message_count + 1
Message.order(:created_at).last.subject.should eq "Import completed: #{@file.id}"
end
it "should not import users that have higher roles than current user's role" do
old_users_count = User.count
old_import_results_count = UserImportResult.count
@file.user = User.where(username: 'librarian1').first
@file.import_start.should eq({ user_imported: 4, user_found: 0, failed: 1, error: 3 })
User.order('id DESC')[1].username.should eq 'user005'
User.count.should eq old_users_count + 4
UserImportResult.count.should eq old_import_results_count + 10
end
end
describe "when its mode is 'update'" do
before(:each) do
FactoryBot.create(:user,
username: 'user001',
profile: FactoryBot.create(:profile)
)
end
it "should update users" do
@file = UserImportFile.create!(
attachment: fixture_file_upload("user_update_file.tsv"),
user: users(:admin),
default_library: libraries(:library_00001),
default_user_group: user_groups(:user_group_00001)
)
old_message_count = Message.count
result = @file.modify
result.should have_key(:user_updated)
user001 = User.where(username: 'user001').first
user001.email.should eq 'user001@example.jp'
user001.profile.full_name.should eq '田辺 浩介'
user001.profile.full_name_transcription.should eq 'たなべこうすけ'
user001.profile.user_number.should eq 'user_number_1'
user001.profile.note.should eq 'test'
user001.profile.keyword_list.should eq 'keyword1 keyword2'
Message.count.should eq old_message_count + 1
end
it "should not overwrite with null value" do
user = User.where(username: 'user001').first
user.profile.update!(
user_number: '001',
full_name: 'User 001',
full_name_transcription: 'User 001',
locale: 'ja',
note: 'Note',
keyword_list: 'keyword1 keyword2',
date_of_birth: 10.years.ago
)
file = UserImportFile.create!(
attachment: fixture_file_upload("user_update_file2.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
result = file.modify
result.should have_key(:user_updated)
user001 = User.friendly.find('user001')
user001.email.should eq 'user001@example.jp'
user001.profile.user_number.should eq '001'
user001.profile.full_name.should eq 'User 001'
user001.profile.full_name_transcription.should eq 'User 001'
user001.profile.keyword_list.should eq 'keyword1 keyword2'
end
it "should update user_number" do
file = UserImportFile.create!(
attachment: fixture_file_upload("user_update_file3.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
result = file.modify
result.should have_key(:user_updated)
user001 = User.where(username: 'user001').first
user001.profile.user_number.should eq '0001'
end
it "should update user's lock status" do
file = UserImportFile.create!(
attachment: fixture_file_upload("user_update_file4.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
result = file.modify
result.should have_key(:user_updated)
user001 = User.where(username: 'user001').first
user001.access_locked?.should be_truthy
end
it "should update user's password" do
file = UserImportFile.create!(
attachment: fixture_file_upload("user_update_file4.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
result = file.modify
result.should have_key(:user_updated)
user001 = User.find_by(username: 'user001')
user001.access_locked?.should be_truthy
expect(user001.valid_password?('testpassword')).to be_truthy
user002 = User.find_by(username: 'librarian1')
expect(user002.valid_password?('librarian1password')).to be_truthy
end
end
describe "when its mode is 'destroy'" do
before(:each) do
file = UserImportFile.create!(
attachment: fixture_file_upload("user_import_file_sample.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
file.import_start
end
it "should remove users" do
old_count = User.count
file = UserImportFile.create!(
attachment: fixture_file_upload("user_delete_file.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
old_message_count = Message.count
file.remove
User.count.should eq old_count - 2
Message.count.should eq old_message_count + 1
end
it "should not remove users if there are checkouts" do
user001 = User.where(username: 'user001').first
FactoryBot.create(:checkout, user: user001, item: FactoryBot.create(:item))
old_count = User.count
file = UserImportFile.create!(
attachment: fixture_file_upload("user_delete_file.tsv"),
user: users(:admin),
default_user_group: UserGroup.find(2),
default_library: Library.find(3)
)
file.remove
User.where(username: 'user001').should_not be_blank
User.count.should eq old_count - 2
end
end
it "should import in background" do
file = UserImportFile.new attachment: fixture_file_upload("user_import_file_sample.tsv"), user: users(:admin)
file.user = users(:admin)
file.default_user_group = UserGroup.find(2)
file.default_library = Library.find(3)
file.save
UserImportFileJob.perform_later(file).should be_truthy
end
end
# == Schema Information
#
# Table name: user_import_files
#
# id :bigint not null, primary key
# edit_mode :string
# error_message :text
# executed_at :datetime
# note :text
# user_encoding :string
# user_import_fingerprint :string
# created_at :datetime not null
# updated_at :datetime not null
# default_library_id :bigint
# default_user_group_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_user_import_files_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/user_spec.rb | spec/models/user_spec.rb | require 'rails_helper'
describe User do
#pending "add some examples to (or delete) #{__FILE__}"
fixtures :all
it 'should create an user' do
FactoryBot.create(:user)
end
it 'should destroy an user' do
user = FactoryBot.create(:user)
user.destroy.should be_truthy
end
it 'should respond to has_role(Administrator)' do
admin = FactoryBot.create(:admin)
admin.has_role?('Administrator').should be_truthy
end
it 'should respond to has_role(Librarian)' do
librarian = FactoryBot.create(:librarian)
librarian.has_role?('Administrator').should be_falsy
librarian.has_role?('Librarian').should be_truthy
librarian.has_role?('User').should be_truthy
end
it 'should respond to has_role(User)' do
user = FactoryBot.create(:user)
user.has_role?('Administrator').should be_falsy
user.has_role?('Librarian').should be_falsy
user.has_role?('User').should be_truthy
end
it 'should lock an user' do
user = FactoryBot.create(:user)
user.locked = '1'
user.save
user.active_for_authentication?.should be_falsy
end
it 'should unlock an user' do
user = FactoryBot.create(:user)
user.lock_access!
user.locked = '0'
user.save
user.active_for_authentication?.should be_truthy
end
it "should create user" do
user = FactoryBot.create(:user)
assert !user.new_record?, "#{user.errors.full_messages.to_sentence}"
end
it "should require username" do
old_count = User.count
user = FactoryBot.build(:user, username: nil)
user.save
user.errors[:username].should be_truthy
User.count.should eq old_count
end
it "should require password" do
user = FactoryBot.build(:user, password: nil)
user.save
user.errors[:password].should be_truthy
end
it "should not require password_confirmation on create" do
user = FactoryBot.build(:user, password: 'new_password', password_confirmation: nil)
user.save
user.errors[:email].should be_empty
end
it "should reset password" do
users(:user1).password = 'new password'
users(:user1).password_confirmation = 'new password'
users(:user1).save
users(:user1).valid_password?('new password').should be_truthy
end
it "should set temporary_password" do
user = users(:user1)
old_password = user.encrypted_password
user.set_auto_generated_password
user.save
old_password.should_not eq user.encrypted_password
user.valid_password?('user1password').should be_falsy
end
it "should get highest_role" do
users(:admin).role.name.should eq 'Administrator'
end
it "should lock all expired users" do
User.lock_expired_users
users(:user4).active_for_authentication?.should be_falsy
end
it "should lock_expired users" do
user = users(:user1)
users(:user1).active_for_authentication?.should be_truthy
user.expired_at = 1.day.ago
user.save
users(:user1).active_for_authentication?.should be_falsy
end
if defined?(EnjuQuestion)
it "should reset answer_feed_token" do
users(:user1).reset_answer_feed_token
users(:user1).answer_feed_token.should be_truthy
end
it "should delete answer_feed_token" do
users(:user1).delete_answer_feed_token
users(:user1).answer_feed_token.should be_nil
end
end
describe ".export" do
it "should export all user's information" do
lines = User.export
CSV.parse(lines, col_sep: "\t")
expect(lines).not_to be_empty
expect(lines.split(/\n/).size).to eq User.count + 1
end
end
end
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# confirmed_at :datetime
# email :string default(""), not null
# encrypted_password :string default(""), not null
# expired_at :datetime
# failed_attempts :integer default(0)
# locked_at :datetime
# remember_created_at :datetime
# reset_password_sent_at :datetime
# reset_password_token :string
# unlock_token :string
# username :string
# created_at :datetime not null
# updated_at :datetime not null
# profile_id :bigint not null
#
# Indexes
#
# index_users_on_email (email)
# index_users_on_profile_id (profile_id)
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_unlock_token (unlock_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (profile_id => profiles.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/resourcesync_spec.rb | spec/models/resourcesync_spec.rb | require 'rails_helper'
describe Resourcesync do
fixtures :all
it "generate_capabilitylist" do
expect(Resourcesync.new.generate_capabilitylist).to be_truthy
end
it "generate_resourcelist_index" do
expect(Resourcesync.new.generate_resourcelist_index(Manifestation.all)).to be_truthy
end
it "generate_resourcelist" do
expect(Resourcesync.new.generate_resourcelist(Manifestation.all)).to be_truthy
end
it "generate_changelist_index" do
expect(Resourcesync.new.generate_changelist_index(Manifestation.all)).to be_truthy
end
it "generate_changelist" do
expect(Resourcesync.new.generate_changelist(Manifestation.all)).to be_truthy
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/checkout_type_spec.rb | spec/models/checkout_type_spec.rb | require 'rails_helper'
describe CheckoutType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: checkout_types
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_checkout_types_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/periodical_spec.rb | spec/models/periodical_spec.rb | require 'rails_helper'
RSpec.describe Periodical, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: periodicals
#
# id :bigint not null, primary key
# original_title :text not null
# created_at :datetime not null
# updated_at :datetime not null
# frequency_id :bigint not null
# manifestation_id :bigint not null
#
# Indexes
#
# index_periodicals_on_frequency_id (frequency_id)
# index_periodicals_on_manifestation_id (manifestation_id)
#
# Foreign Keys
#
# fk_rails_... (frequency_id => frequencies.id)
# fk_rails_... (manifestation_id => manifestations.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/user_group_has_checkout_type_spec.rb | spec/models/user_group_has_checkout_type_spec.rb | require 'rails_helper'
describe UserGroupHasCheckoutType do
fixtures :all
it "should respond to update_current_checkout_count" do
UserGroupHasCheckoutType.update_current_checkout_count.should be_truthy
end
end
# == Schema Information
#
# Table name: user_group_has_checkout_types
#
# id :bigint not null, primary key
# checkout_limit :integer default(0), not null
# checkout_period :integer default(0), not null
# checkout_renewal_limit :integer default(0), not null
# current_checkout_count :integer
# fixed_due_date :datetime
# note :text
# position :integer
# reservation_expired_period :integer default(7), not null
# reservation_limit :integer default(0), not null
# set_due_date_before_closing_day :boolean default(FALSE), not null
# created_at :datetime not null
# updated_at :datetime not null
# checkout_type_id :bigint not null
# user_group_id :bigint not null
#
# Indexes
#
# index_user_group_has_checkout_types_on_checkout_type_id (checkout_type_id)
# index_user_group_has_checkout_types_on_user_group_id (user_group_id,checkout_type_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (checkout_type_id => checkout_types.id)
# fk_rails_... (user_group_id => user_groups.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/models/checkin_spec.rb | spec/models/checkin_spec.rb | require 'rails_helper'
describe Checkin do
fixtures :all
before(:each) do
@basket = Basket.new
@basket.user = users(:librarian1)
@basket.save
end
it "should save checkout history if save_checkout_history is true" do
user = users(:user1)
checkouts_count = user.checkouts.count
checkin = Checkin.new
checkin.item = user.checkouts.not_returned.first.item
checkin.basket = @basket
checkin.librarian = users(:librarian1)
# checkin.item_identifier = checkin.item.item_identifier
checkin.save!
checkin.item_checkin(user)
expect(user.checkouts.count).to eq checkouts_count
end
it "should not save checkout history if save_checkout_history is false" do
user = users(:librarian1)
checkouts_count = user.checkouts.count
checkin = Checkin.new
checkin.item = user.checkouts.not_returned.first.item
checkin.basket = @basket
checkin.librarian = users(:librarian1)
checkin.save!
checkin.item_checkin(user)
expect(user.checkouts.count).to eq checkouts_count - 1
end
end
# == Schema Information
#
# Table name: checkins
#
# id :bigint not null, primary key
# lock_version :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
# basket_id :bigint
# item_id :bigint not null
# librarian_id :bigint
#
# Indexes
#
# index_checkins_on_basket_id (basket_id)
# index_checkins_on_item_id_and_basket_id (item_id,basket_id) UNIQUE
# index_checkins_on_librarian_id (librarian_id)
#
# Foreign Keys
#
# fk_rails_... (item_id => items.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/user_export_files/new.html.erb_spec.rb | spec/views/user_export_files/new.html.erb_spec.rb | require 'rails_helper'
describe "user_export_files/new" do
before(:each) do
assign(:user_export_file, UserExportFile.new)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders new user form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: user_export_files_path, method: "post" do
assert_select "input", name: "commit"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/my_accounts/show.html.erb_spec.rb | spec/views/my_accounts/show.html.erb_spec.rb | require 'rails_helper'
describe "my_accounts/show" do
fixtures :all
before(:each) do
@profile = assign(:profile, profiles(:profile_admin))
end
describe "when logged in as Librarian" do
before(:each) do
@profile = assign(:profile, profiles(:profile_librarian2))
user = users(:librarian1)
view.stub(:current_user).and_return(user)
end
it "renders attributes in <p>" do
allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Checkout/)
end
it "cannot be deletable by other librarian" do
allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
render
end
end
describe "when logged in as User" do
before(:each) do
@profile = assign(:profile, profiles(:profile_user2))
user = users(:librarian1)
view.stub(:current_user).and_return(user)
end
it "renders attributes in <p>" do
allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
render
rendered.should match(/Checkout/)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/checkouts/show.html.erb_spec.rb | spec/views/checkouts/show.html.erb_spec.rb | require 'rails_helper'
describe "checkouts/show" do
fixtures :checkouts, :users, :user_has_roles, :roles, :profiles
before(:each) do
@checkout = assign(:checkout, checkouts(:checkout_00001))
assign(:library_group, LibraryGroup.site_config)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Due date/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Item identifier/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/checkouts/edit.html.erb_spec.rb | spec/views/checkouts/edit.html.erb_spec.rb | require 'rails_helper'
describe "checkouts/edit" do
fixtures :checkouts, :users, :user_has_roles, :roles
before(:each) do
@checkout = assign(:checkout, checkouts(:checkout_00001))
assign(:new_due_date, 1.day.from_now)
assign(:library_group, LibraryGroup.site_config)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders the edit checkout form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: checkouts_path(@checkout), method: "post" do
assert_select "input#checkout_user_id", name: "checkout[user_id]"
assert_select "input#checkout_item_id", name: "checkout[item_id]"
assert_select "input#checkout_due_date", name: "checkout[due_date]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/checkouts/index.html.erb_spec.rb | spec/views/checkouts/index.html.erb_spec.rb | require 'rails_helper'
describe "checkouts/index" do
fixtures :all
before(:each) do
assign(:checkouts, Checkout.page(1))
assign(:checkouts_facet, [])
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders a list of checkouts" do
allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr:nth-child(2)>td:nth-child(2)", /00001/
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/library_groups/show.html.erb_spec.rb | spec/views/library_groups/show.html.erb_spec.rb | require 'rails_helper'
describe "library_groups/show" do
before(:each) do
@library_group = LibraryGroup.site_config
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
allow(view).to receive(:policy).and_return double(update?: true)
render
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/library_groups/edit.html.erb_spec.rb | spec/views/library_groups/edit.html.erb_spec.rb | require 'rails_helper'
describe "library_groups/edit" do
fixtures :all
before(:each) do
@library_group = LibraryGroup.site_config
@available_languages = Language.where(iso_639_1: I18n.available_locales.map {|l| l.to_s})
@countries = Country.all
end
it "renders selector for multilpe book jacket sources." do
render
expect(rendered).to have_css "select#library_group_book_jacket_source"
expect(rendered).to have_css "select#library_group_book_jacket_source option", minimum: 2
expect(rendered).to have_css 'select#library_group_book_jacket_source option[value="google"]'
expect(rendered).to have_css 'select#library_group_book_jacket_source option[value="openbd"]'
expect(rendered).to have_css 'select#library_group_book_jacket_source option[value="hanmotocom"]'
end
it "renders color forms." do
render
expect(rendered).to have_css "input#library_group_colors_attributes_0_code"
expect(rendered).not_to have_css "input#library_group_colors_attributes_0__destroy", visible: false
expect(rendered).not_to have_xpath '//a[@data-association="color" and @class="add_fields"]'
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/periodicals/show.html.erb_spec.rb | spec/views/periodicals/show.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "periodicals/show", type: :view do
fixtures :all
before(:each) do
assign(:periodical, periodicals(:periodical_00001))
end
it "renders attributes in <p>" do
render
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/periodicals/new.html.erb_spec.rb | spec/views/periodicals/new.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "periodicals/new", type: :view do
before(:each) do
assign(:periodical, Periodical.new())
end
it "renders new periodical form" do
render
assert_select "form[action=?][method=?]", periodicals_path, "post" do
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/periodicals/edit.html.erb_spec.rb | spec/views/periodicals/edit.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "periodicals/edit", type: :view do
fixtures :all
let(:periodical) {
periodicals(:periodical_00001)
}
before(:each) do
assign(:periodical, periodical)
end
it "renders the edit periodical form" do
render
assert_select "form[action=?][method=?]", periodical_path(periodical), "post" do
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/periodicals/index.html.erb_spec.rb | spec/views/periodicals/index.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "periodicals/index", type: :view do
fixtures :all
before(:each) do
assign(:periodicals,
Periodical.page(1)
)
end
it "renders a list of periodicals" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/checked_items/new.html.erb_spec.rb | spec/views/checked_items/new.html.erb_spec.rb | require 'rails_helper'
describe "checked_items/new" do
fixtures :all
it "renders new checkout form" do
profile = FactoryBot.create(:profile, user_number: "foo")
user = FactoryBot.create(:user, profile: profile, username: "bar")
basket = FactoryBot.create(:basket, user: user)
assign(:basket, basket)
assign(:checked_item, CheckedItem.new)
assign(:checked_items, basket.checked_items)
render
expect(rendered).to match /bar/
expect(rendered).to match /foo/
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/reserves/index.html.erb_spec.rb | spec/views/reserves/index.html.erb_spec.rb | require 'rails_helper'
describe "reserves/index" do
fixtures :users, :roles, :user_has_roles, :reserves
before(:each) do
view.extend EnjuLeaf::ApplicationHelper
assign(:reserves, Reserve.page(1))
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders a list of reserves" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td:nth-child(1)", text: reserves(:reserve_00001).id.to_s
assert_select "tr>td:nth-child(2)", text: /#{reserves(:reserve_00001).user.username}/
assert_select "tr>td:nth-child(2)", text: /#{reserves(:reserve_00002).manifestation.original_title}/
end
it "renders a list of reserves when a reserve does not have expired_at" do
reserve = FactoryBot.create(:reserve, expired_at: nil)
assign(:reserves, Reserve.page(2))
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
rendered.should match /<td/
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/show.html.erb_spec.rb | spec/views/manifestations/show.html.erb_spec.rb | require 'rails_helper'
describe "manifestations/show" do
fixtures :all
before(:each) do
assign(:manifestation, FactoryBot.create(:manifestation))
assign(:library_group, library_groups(:one))
allow(view).to receive(:policy).and_return double(create?: false, udpate?: false, destroy?: false)
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
end
describe "identifier_link" do
it "renders a link to CiNii Books" do
assign(:manifestation, manifestations(:manifestation_00217))
render
rendered.should include '<a href="https://ci.nii.ac.jp/ncid/BN15603730">BN15603730</a>'
end
end
describe "when logged in as Librarian" do
before(:each) do
user = assign(:profile, FactoryBot.create(:librarian))
view.stub(:current_user).and_return(user)
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
end
it "should have an ISBD separator for extent and dimensions" do
assign(:manifestation, FactoryBot.create(:manifestation, extent: "extent value", dimensions: "dimensions value"))
render
expect(rendered).to match /\s+;\s+/
end
end
describe "when logged in as User" do
before(:each) do
user = assign(:profile, FactoryBot.create(:user))
view.stub(:current_user).and_return(user)
end
it "should have an ISBD separator for extent and dimensions" do
assign(:manifestation, FactoryBot.create(:manifestation, extent: "extent value", dimensions: "dimensions value"))
render
expect(rendered).to match /\s+;\s+/
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/show.text.ruby_spec.rb | spec/views/manifestations/show.text.ruby_spec.rb | require 'rails_helper'
describe "manifestations/show.text.ruby" do
fixtures :all
before(:each) do
assign(:manifestation, manifestations(:manifestation_00001))
end
it "renders show" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
expect(rendered).to match(/text/)
expect(rendered.split("\n").count).to eq 9
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/index.text.ruby_spec.rb | spec/views/manifestations/index.text.ruby_spec.rb | require "rails_helper.rb"
describe "manifestations/index.text.ruby" do
before(:each) do
manifestation = FactoryBot.create(:manifestation)
manifestation.items << FactoryBot.create(:item, bookstore_id: 1, budget_type_id: 1, price: 100)
@manifestations = assign(:manifestations, [ manifestation ] )
end
it "should excludes librarian specific fields" do
params[:format] = "text"
render
csv = CSV.parse(rendered, headers: true, col_sep: "\t")
expect(csv["bookstore"].compact).to be_empty
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/index.rdf.builder_spec.rb | spec/views/manifestations/index.rdf.builder_spec.rb | require "rails_helper.rb"
describe "manifestations/index.rdf.builder" do
before(:each) do
manifestation = FactoryBot.create(:manifestation)
@manifestations = assign(:manifestations, [ manifestation ] )
@library_group = LibraryGroup.first
end
it "should export RDF format" do
params[:format] = "rdf"
render
doc = Nokogiri::XML(rendered)
nodes = doc.css('item')
expect(nodes).not_to be_empty
nodes.each do |node|
rdf_ns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
expect(node.attribute_with_ns("about", rdf_ns).value).not_to be_empty
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/show.ttl.ruby_spec.rb | spec/views/manifestations/show.ttl.ruby_spec.rb | require "rails_helper.rb"
describe "manifestations/show.ttl.ruby" do
before(:each) do
@manifestation = assign(:manifestation, FactoryBot.create(:manifestation))
@library_group = LibraryGroup.first
end
it "should export TTL format" do
render
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/show.json.jbuilder_spec.rb | spec/views/manifestations/show.json.jbuilder_spec.rb | require 'rails_helper'
describe "manifestations/show.json.jbuilder" do
fixtures :all
before(:each) do
assign(:manifestation, FactoryBot.create(:manifestation))
allow(view).to receive(:policy).and_return double(show?: true, create?: false, udpate?: false, destroy?: false)
end
it "renders a template" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/original_title/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/index.ttl.ruby_spec.rb | spec/views/manifestations/index.ttl.ruby_spec.rb | require "rails_helper.rb"
describe "manifestations/index.ttl.ruby" do
before(:each) do
manifestation = FactoryBot.create(:manifestation)
@manifestations = assign(:manifestations, [ manifestation ])
@library_group = LibraryGroup.first
end
it "should export TTL format" do
render
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestations/index.html.erb_spec.rb | spec/views/manifestations/index.html.erb_spec.rb | require "rails_helper.rb"
describe "manifestations/index" do
before(:each) do
@manifestations = assign(:manifestations,
Kaminari.paginate_array( [
FactoryBot.create(:manifestation),
], total_count: 1).page(1)
)
@index_agent = {}
@count = { query_result: 1 }
@reservable_facet = @carrier_type_facet = @language_facet = @library_facet = @pub_year_facet = []
@seconds = 0
@max_number_of_results = 500
end
describe "sort_by menu" do
it "should reflect per_page params for views" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
params[:per_page] = 50
render
expect(rendered).to have_selector "select#per_page option[value='50'][selected='selected']"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/loc_search/index.html.erb_spec.rb | spec/views/loc_search/index.html.erb_spec.rb | require "spec_helper.rb"
describe "loc_search/index" do
describe "loc search menu" do
it "should reflect query params for views", vcr: true do
params[:query] = "test"
assign(:query, "test")
books = LocSearch.search(params[:query])
assign(:books, Kaminari.paginate_array(books[:items], total_count: books[:total_entries]).page(1).per(10))
render
expect(rendered).to include "https://catalog.loc.gov/vwebv/search?searchArg=test&searchCode=GKEY%5E*&searchType=0"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/accepts/show.html.erb_spec.rb | spec/views/accepts/show.html.erb_spec.rb | require 'rails_helper'
describe "accepts/show" do
fixtures :all
before(:each) do
@accept = assign(:accept, accepts(:one))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/accepts/new.html.erb_spec.rb | spec/views/accepts/new.html.erb_spec.rb | require 'rails_helper'
describe "accepts/new" do
fixtures :all
before(:each) do
assign(:accept, Accept.new(
item_id: 1
))
assign(:basket, FactoryBot.create(:basket))
assign(:accepts, Accept.page(1))
end
it "renders new accept form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: accepts_path, method: "post" do
assert_select "input#accept_item_identifier", name: "accept[item_identifier]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/accepts/edit.html.erb_spec.rb | spec/views/accepts/edit.html.erb_spec.rb | require 'rails_helper'
describe "accepts/edit" do
before(:each) do
@accept = assign(:accept, FactoryBot.create(:accept))
end
it "renders the edit accept form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: accepts_path(@accept), method: "post" do
assert_select "input#accept_item_id", name: "accept[item_id]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/accepts/index.html.erb_spec.rb | spec/views/accepts/index.html.erb_spec.rb | require 'rails_helper'
describe "accepts/index" do
fixtures :all
before(:each) do
assign(:accepts, Accept.page(1))
basket = FactoryBot.create(:basket)
assign(:basket, basket)
assign(:accept, basket.accepts.new)
end
it "renders a list of accepts" do
allow(view).to receive(:policy).and_return double(create?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/opensearch.xml.builder_spec.rb | spec/views/page/opensearch.xml.builder_spec.rb | require 'rails_helper'
describe "page/opensearch" do
fixtures :all
before(:each) do
assign(:library_group, LibraryGroup.site_config)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders the XML template" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Library Catalog/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/import.html.erb_spec.rb | spec/views/page/import.html.erb_spec.rb | require 'rails_helper'
describe "page/import" do
fixtures :all
before(:each) do
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Import from TSV file/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/export.html.erb_spec.rb | spec/views/page/export.html.erb_spec.rb | require 'rails_helper'
describe "page/export" do
fixtures :all
before(:each) do
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Export/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/about.html.erb_spec.rb | spec/views/page/about.html.erb_spec.rb | require 'rails_helper'
describe "page/about" do
fixtures :all
before(:each) do
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/About this system/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/statistics.html.erb_spec.rb | spec/views/page/statistics.html.erb_spec.rb | require 'rails_helper'
describe "page/statistics" do
fixtures :all
before(:each) do
@profile = assign(:profile, profiles(:profile_admin))
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Statistics/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/configuration.html.erb_spec.rb | spec/views/page/configuration.html.erb_spec.rb | require 'rails_helper'
describe "page/configuration" do
fixtures :all
before(:each) do
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/System configuration/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/advanced_search.html.erb_spec.rb | spec/views/page/advanced_search.html.erb_spec.rb | require 'rails_helper'
describe "page/advanced_search" do
fixtures :all
context :login_with_admin do
before(:each) do
assign(:libraries, Library.all)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Advanced search/)
end
end
context :guest do
before(:each) do
assign(:libraries, Library.all)
view.stub(:current_user).and_return(nil)
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Advanced search/)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/page/index.html.erb_spec.rb | spec/views/page/index.html.erb_spec.rb | require 'rails_helper'
describe "page/index" do
fixtures :all
before(:each) do
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
assign(:tags, Tag.all)
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Catalog search/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/withdraws/show.html.erb_spec.rb | spec/views/withdraws/show.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "withdraws/show", type: :view do
before(:each) do
@withdraw = assign(:withdraw, FactoryBot.create(:withdraw))
end
it "renders attributes in <p>" do
render
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/withdraws/new.html.erb_spec.rb | spec/views/withdraws/new.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "withdraws/new", type: :view do
fixtures :all
before(:each) do
assign(:withdraw, Withdraw.new(
item_id: 1
))
assign(:basket, baskets(:basket_00001))
assign(:withdraws, Withdraw.page(1))
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders new withdraw form" do
render
assert_select "form", action: withdraws_path, method: "post" do
assert_select "input#withdraw_item_identifier", name: "withdraw[item_identifier]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/withdraws/edit.html.erb_spec.rb | spec/views/withdraws/edit.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "withdraws/edit", type: :view do
before(:each) do
@withdraw = assign(:withdraw, FactoryBot.create(:withdraw))
end
it "renders the edit withdraw form" do
render
assert_select "form[action=?][method=?]", withdraw_path(@withdraw), "post" do
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/withdraws/index.html.erb_spec.rb | spec/views/withdraws/index.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "withdraws/index", type: :view do
fixtures :all
before(:each) do
FactoryBot.create(:withdraw)
assign(:withdraws, Withdraw.page(1))
basket = FactoryBot.create(:basket)
assign(:basket, basket)
assign(:withdraw, basket.withdraws.new)
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders a list of withdraws" do
allow(view).to receive(:policy).and_return double(destroy?: true)
render
assert_select "tr>td"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/libraries/show.html.erb_spec.rb | spec/views/libraries/show.html.erb_spec.rb | require 'rails_helper'
describe "libraries/show" do
fixtures :all
before(:each) do
@events = Kaminari::paginate_array([]).page(1)
assign(:library, FactoryBot.create(:library, street: "\tStreet 1-2"))
end
it "renders a library detail" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true)
render
expect(rendered).to include "library"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/budget_types/show.html.erb_spec.rb | spec/views/budget_types/show.html.erb_spec.rb | require 'rails_helper'
describe "budget_types/show" do
before(:each) do
@budget_type = assign(:budget_type, BudgetType.create(
name: "Name",
display_name: "MyText",
note: "MyText",
position: 1
))
end
it "renders attributes in <p>" do
allow(view).to receive(:policy).and_return double(update?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Name/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/MyText/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/MyText/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/budget_types/new.html.erb_spec.rb | spec/views/budget_types/new.html.erb_spec.rb | require 'rails_helper'
describe "budget_types/new" do
before(:each) do
assign(:budget_type, BudgetType.new(
name: "MyString",
display_name: "MyText",
note: "MyText",
position: 1
))
end
it "renders new budget_type form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: budget_types_path, method: "post" do
assert_select "input#budget_type_name", name: "budget_type[name]"
assert_select "textarea#budget_type_display_name", name: "budget_type[display_name]"
assert_select "textarea#budget_type_note", name: "budget_type[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/budget_types/edit.html.erb_spec.rb | spec/views/budget_types/edit.html.erb_spec.rb | require 'rails_helper'
describe "budget_types/edit" do
before(:each) do
@budget_type = assign(:budget_type, FactoryBot.create(:budget_type))
end
it "renders the edit budget_type form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", action: budget_types_path(@budget_type), method: "post" do
assert_select "input#budget_type_name", name: "budget_type[name]"
assert_select "textarea#budget_type_display_name", name: "budget_type[display_name]"
assert_select "textarea#budget_type_note", name: "budget_type[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/budget_types/index.html.erb_spec.rb | spec/views/budget_types/index.html.erb_spec.rb | require 'rails_helper'
describe "budget_types/index" do
before(:each) do
assign(:budget_types, BudgetType.all)
end
it "renders a list of budget_types" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", text: "Public fund".to_s, count: 2
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/user_import_results/index.html.erb_spec.rb | spec/views/user_import_results/index.html.erb_spec.rb | require 'rails_helper'
describe "user_import_results/index" do
fixtures :all
before(:each) do
assign(:user_import_results, UserImportResult.page(1))
view.stub(:current_user).and_return(User.find_by(username: 'enjuadmin'))
end
it "renders a list of user_import_results" do
render
expect(rendered).to match /enjuadmin/
end
context "with @user_import_file" do
before(:each) do
@user_import_file = UserImportFile.find(1)
@user_import_results = UserImportResult.where(user_import_file_id: 1).page(1)
end
it "renders a list of user_import_results for the user_import_file" do
render
expect(view).to render_template "user_import_results/_list_lines"
expect(rendered).to match /<td>1<\/td>/
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/cinii_books/index.html.erb_spec.rb | spec/views/cinii_books/index.html.erb_spec.rb | require "spec_helper"
describe "cinii_books/index" do
describe "cinii books search menu" do
it "should reflect query params for views", vcr: true do
params[:query] = "test"
assign(:query, "test")
books = CiniiBook.search(params[:query])
assign(:books, Kaminari.paginate_array(books[:items], total_count: books[:total_entries]).page(1).per(10))
render
expect(rendered).to include "https://ci.nii.ac.jp/books/search?q=test"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestation_custom_properties/show.html.erb_spec.rb | spec/views/manifestation_custom_properties/show.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "manifestation_custom_properties/show", type: :view do
before(:each) do
@manifestation_custom_property = assign(:manifestation_custom_property, ManifestationCustomProperty.create!(
name: "name",
note: "MyText"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/name/)
expect(rendered).to match(/MyText/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestation_custom_properties/new.html.erb_spec.rb | spec/views/manifestation_custom_properties/new.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "manifestation_custom_properties/new", type: :view do
before(:each) do
assign(:manifestation_custom_property, ManifestationCustomProperty.new(
name: "my_string",
note: "MyText"
))
end
it "renders new manifestation_custom_property form" do
render
assert_select "form[action=?][method=?]", manifestation_custom_properties_path, "post" do
assert_select "input[name=?]", "manifestation_custom_property[name]"
assert_select "textarea[name=?]", "manifestation_custom_property[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestation_custom_properties/edit.html.erb_spec.rb | spec/views/manifestation_custom_properties/edit.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "manifestation_custom_properties/edit", type: :view do
before(:each) do
@manifestation_custom_property = assign(:manifestation_custom_property, ManifestationCustomProperty.create!(
name: "my_string",
note: "MyText"
))
end
it "renders the edit manifestation_custom_property form" do
render
assert_select "form[action=?][method=?]", manifestation_custom_property_path(@manifestation_custom_property), "post" do
assert_select "input[name=?]", "manifestation_custom_property[name]"
assert_select "textarea[name=?]", "manifestation_custom_property[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/manifestation_custom_properties/index.html.erb_spec.rb | spec/views/manifestation_custom_properties/index.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "manifestation_custom_properties/index", type: :view do
before(:each) do
assign(:manifestation_custom_properties, [
ManifestationCustomProperty.create!(
name: "name1",
display_name: "カスタム項目1",
note: "MyText"
),
ManifestationCustomProperty.create!(
name: "name2",
display_name: "カスタム項目2",
note: "MyText"
)
])
end
it "renders a list of manifestation_custom_properties" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
assert_select "tr>td", text: "name1".to_s, count: 1
assert_select "tr>td", text: "MyText".to_s, count: 2
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/item_custom_properties/show.html.erb_spec.rb | spec/views/item_custom_properties/show.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "item_custom_properties/show", type: :view do
before(:each) do
@item_custom_property = assign(:item_custom_property, ItemCustomProperty.create!(
name: "name",
note: "MyText"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/name/)
expect(rendered).to match(/MyText/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/item_custom_properties/new.html.erb_spec.rb | spec/views/item_custom_properties/new.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "item_custom_properties/new", type: :view do
before(:each) do
assign(:item_custom_property, ItemCustomProperty.new(
name: "my_string",
note: "MyText"
))
end
it "renders new item_custom_property form" do
render
assert_select "form[action=?][method=?]", item_custom_properties_path, "post" do
assert_select "input[name=?]", "item_custom_property[name]"
assert_select "textarea[name=?]", "item_custom_property[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/item_custom_properties/edit.html.erb_spec.rb | spec/views/item_custom_properties/edit.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "item_custom_properties/edit", type: :view do
before(:each) do
@item_custom_property = assign(:item_custom_property, ItemCustomProperty.create!(
name: "my_string",
note: "MyText"
))
end
it "renders the edit item_custom_property form" do
render
assert_select "form[action=?][method=?]", item_custom_property_path(@item_custom_property), "post" do
assert_select "input[name=?]", "item_custom_property[name]"
assert_select "textarea[name=?]", "item_custom_property[note]"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/views/item_custom_properties/index.html.erb_spec.rb | spec/views/item_custom_properties/index.html.erb_spec.rb | require 'rails_helper'
RSpec.describe "item_custom_properties/index", type: :view do
before(:each) do
assign(:item_custom_properties, [
ItemCustomProperty.create!(
name: "name1",
display_name: "カスタム項目1",
note: "MyText"
),
ItemCustomProperty.create!(
name: "name2",
display_name: "カスタム項目2",
note: "MyText"
)
])
end
it "renders a list of item_custom_properties" do
allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
render
assert_select "tr>td", text: "name1".to_s, count: 1
assert_select "tr>td", text: "MyText".to_s, count: 2
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/resource_export_mailer_spec.rb | spec/mailers/resource_export_mailer_spec.rb | require "rails_helper"
RSpec.describe ResourceExportMailer, type: :mailer do
fixtures :all
it "should send completed mail" do
mailer = ResourceExportMailer.completed(resource_export_files(:resource_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send failed mail" do
mailer = ResourceExportMailer.failed(resource_export_files(:resource_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/user_export_mailer_spec.rb | spec/mailers/user_export_mailer_spec.rb | require "rails_helper"
RSpec.describe UserExportMailer, type: :mailer do
fixtures :all
it "should send completed mail" do
mailer = UserExportMailer.completed(user_export_files(:user_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send failed mail" do
mailer = UserExportMailer.failed(user_export_files(:user_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/notifier_spec.rb | spec/mailers/notifier_spec.rb | require "rails_helper"
RSpec.describe Notifier, type: :mailer do
fixtures :all
it "should send message_notification mail" do
mailer = Notifier.message_notification(messages(:user1_to_user2_1).id)
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send manifestation_info mail" do
mailer = Notifier.manifestation_info(User.first.id, Manifestation.first.id)
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/reserve_mailer_spec.rb | spec/mailers/reserve_mailer_spec.rb | require "rails_helper"
RSpec.describe ReserveMailer, type: :mailer do
fixtures :all
it "should send accepted mail" do
mailer = ReserveMailer.accepted(reserves(:reserve_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send expired mail" do
mailer = ReserveMailer.expired(reserves(:reserve_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/event_export_mailer_spec.rb | spec/mailers/event_export_mailer_spec.rb | require "rails_helper"
RSpec.describe EventExportMailer, type: :mailer do
fixtures :all
it "should send completed mail" do
mailer = EventExportMailer.completed(event_export_files(:event_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send failed mail" do
mailer = EventExportMailer.failed(event_export_files(:event_export_file_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/checkout_mailer_spec.rb | spec/mailers/checkout_mailer_spec.rb | require "rails_helper"
RSpec.describe CheckoutMailer, type: :mailer do
fixtures :all
it "should send due_date mail" do
mailer = CheckoutMailer.due_date(checkouts(:checkout_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
it "should send overdue mail" do
mailer = CheckoutMailer.overdue(checkouts(:checkout_00001))
expect(mailer.body.to_s).to match(/^Enju Library\n/)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/previews/user_export_mailer_preview.rb | spec/mailers/previews/user_export_mailer_preview.rb | # Preview all emails at http://localhost:3000/rails/mailers/user_export_mailer
class UserExportMailerPreview < ActionMailer::Preview
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/previews/event_export_mailer_preview.rb | spec/mailers/previews/event_export_mailer_preview.rb | # Preview all emails at http://localhost:3000/rails/mailers/event_export_mailer
class EventExportMailerPreview < ActionMailer::Preview
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/previews/reserve_mailer_preview.rb | spec/mailers/previews/reserve_mailer_preview.rb | # Preview all emails at http://localhost:3000/rails/mailers/reserve_mailer
class ReserveMailerPreview < ActionMailer::Preview
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/spec/mailers/previews/resource_export_mailer_preview.rb | spec/mailers/previews/resource_export_mailer_preview.rb | # Preview all emails at http://localhost:3000/rails/mailers/resource_export_mailer
class ResourceExportMailerPreview < ActionMailer::Preview
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/openurl.rb | lib/openurl.rb | #-------------------------------------------
# OpenurlQuerySyntaxErrorクラス
# 文法上の誤りをエラーとする
#-------------------------------------------
class OpenurlQuerySyntaxError < RuntimeError; end
#-------------------------------------------
# Openurlクラス
#-------------------------------------------
class Openurl
# 一致条件ごとの分類
MATCH_EXACT = [ :ndl_dpid ] # 完全一致
MATCH_PART = [ :aulast, :aufirst, :au, :title, :atitle, :jtitle, :btitle, :pub ] # 部分一致
MATCH_AHEAD = [ :issn, :isbn, :ndl_jpno ] # 前方一致
# ある項目に対して複数語指定時の検索方法ごとの分類
LOGIC_MULTI_AND = [ :au, :title, :atitle, :jtitle, :btitle, :pub ] # AND検索
LOGIC_MULTI_OR = [ :ndl_dpid ] # OR検索
# 桁チェックが必要な項目
NUM_CHECK = { issn: 8, isbn: 13 }
# 集約される項目
SYNONYMS = [ :title, :aulast, :aufirst ]
# enjuのフィールド名(検索用)管理
ENJU_FIELD = { aulast: "au_text", # aulast=au
aufirst: "au_text", # aufirst=au
au: "au_text",
title: "btitle_text", # title=btitle
atitle: "atitle_text",
btitle: "btitle_text",
jtitle: "jtitle_text",
pub: "publisher_text",
issn: "issn_sm",
isbn: "isbn_sm",
ndl_jpno: "ndl_jpno_text", # TODO: 現在対応項目はないので保留。
ndl_dpid: "ndl_dpid_sm", # TODO: 現在対応項目はないので保留。これのみ完全一致であることに注意。
associate: "" # TODO: フィールド名ではないので削除?
}
def initialize(params)
# @openurl_queryに検索項目ごとの検索文を格納
if params.key?(:any)
# anyの場合は他に条件が指定されていても無視
@openurl_query = [ params[:any].strip ]
else
@openurl_query = to_sunspot(params)
end
@manifestations = []
end
attr_reader :openurl_query, :manifestations, :query_text
# 検索
def search
search = Sunspot.new_search(Manifestation)
role = Role.default
@query_text = build_query
query = @query_text
search.build do
fulltext query
with(:required_role_id).less_than_or_equal_to role.id
end
search.execute!.results
end
private
# 検索文を結合,
def build_query
@openurl_query.join(" AND ")
end
# params OpenURLのリクエストのパラメータ
# 個々のパラメータに合わせて検索文を組立てメソッドを呼ぶ。この時、引数は、enjuのフィールド名と値。
def to_sunspot(params)
query = []
params.each_pair do |key, _value|
key = key.to_sym
if MATCH_EXACT.include?(key) # 完全一致
query << to_sunspot_match_exact(ENJU_FIELD[key], params[key].strip)
elsif MATCH_PART.include?(key) # 部分一致
query << to_sunspot_match_part(key, ENJU_FIELD[key], params[key].strip)
elsif MATCH_AHEAD.include?(key) # 前方一致
query << to_sunspot_match_ahead(key, ENJU_FIELD[key], params[key].strip)
end
end
# queryにあるau_textの統合
@openurl_query = unite_au_query(query)
end
# 完全一致の項目の検索文組立て
# TODO 完全一致の項目はndl_dpidだけで、これはデータプロバイダについて議論中なので保留する
def to_sunspot_match_exact(field, val)
# 途中に空白がある場合は複数語が指定されているとみなし、ORでつなぐ。
if /\s+/ =~ val
"%s:%s" % [ field, val.gsub(/\s+/, " OR ") ]
else
"%s:%s" % [ field, val ]
end
end
# 部分一致の項目の検索文組立て
# key パラメータのキー(複数指定の検索方法判断に使う)
# field 項目名
# val 値
def to_sunspot_match_part(key, field, val)
# 途中に空白がある場合は複数語が指定されているとみなし、ANDでつなぐ。
if /\s+/ =~ val
if LOGIC_MULTI_AND.include?(key)
"%s:(%s)" % [ field, val.gsub(/\s+/, " AND ") ]
else
raise OpenurlQuerySyntaxError, "the key \"#{key}\" not allow multi words"
end
else
"%s:%s" % [ field, val ] # fieldに対して語が1つならばこれ
end
end
# 前方一致の項目の検索文組立て
def to_sunspot_match_ahead(key, field, val)
# 既定の桁より大きい場合、または、数値でない文字列の場合エラー
# 数値でない文字列には空白がある場合も含むので複数指定はエラーとなる
# このチェックはANY検索の時外す
if NUM_CHECK.include?(key)
if [ :issn, :isbn ].include?(key.to_sym)
val.gsub!("-", "")
end
raise OpenurlQuerySyntaxError unless /\A\d{1,#{NUM_CHECK[key]}}X?\Z/i =~ val
end
"%s:%s*" % [ field, val ]
end
# au項目の統合
# au、aufirst、aulastはau_textに統合する
def unite_au_query(query)
new_query = []
au_item = []
str = "au_text:"
au_flg = false
reg = Regexp.compile(/\A#{str}/)
query.each do |q|
if reg =~ q
au_flg = true
au_item.push(q[str.length..q.length])
else
new_query.push(q)
end
end
if au_flg
if au_item.size > 1
str = str + "(%s)" % [ au_item.join(" AND ") ]
else
str += au_item[0]
end
new_query.push(str)
end
new_query
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/identifier_type.rb | lib/tasks/identifier_type.rb | def update_identifier_type
identifier_types = YAML.safe_load(open("db/fixtures/enju_biblio/identifier_types.yml").read)
identifier_types.each do |line|
l = line[1].select! { |k, v| %w(name display_name note).include?(k) }
identifier_type = IdentifierType.where(name: l["name"]).first
if identifier_type
identifier_type.update!(l)
else
IdentifierType.create!(l)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/content_type.rb | lib/tasks/content_type.rb | def update_content_type
content_types = YAML.safe_load(open("db/fixtures/enju_biblio/content_types.yml").read)
content_types.each do |line|
l = line[1].select! { |k, v| %w(name display_name note).include?(k) }
case l["name"]
when "text"
when "performed_music"
content_type = ContentType.where(name: "audio").first
content_type.update!(l) if content_type
when "two_dimensional_moving_image"
content_type = ContentType.where(name: "video").first
content_type.update!(l) if content_type
end
content_type = ContentType.where(name: l["name"]).first
ContentType.create!(l) unless content_type
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/item.rb | lib/tasks/item.rb | def update_item
if defined?(Exemplify)
Exemplify.find_each do |exemplify|
if exemplify.item
exemplify.item.update_column(:manifestation_id, exemplify.manifestation_id) unless exemplify.item.manifestation_id
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/circulation_status.rb | lib/tasks/circulation_status.rb | def update_circulation_status
YAML.safe_load(open("db/fixtures/enju_circulation/circulation_statuses.yml").read).each do |line|
l = line[1].select! { |k, v| %w(name display_name).include?(k) }
CirculationStatus.where(name: l["name"]).first.try(:update_attributes!, l)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/checkout.rb | lib/tasks/checkout.rb | def update_checkout
Checkout.find_each do |checkout|
checkout.update_column(:shelf_id, checkout.item.try(:shelf_id)) if checkout.shelf_id.nil?
checkout.update_column(:library_id, checkout.librarian.try(:profile).try(:library_id)) if checkout.library_id.nil?
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/subject_type.rb | lib/tasks/subject_type.rb | def update_subject_type
concept = SubjectType.where(name: "Concept").first
concept&.update_column(:name, "concept")
event = SubjectType.where(name: "Event").first
event&.update_column(:name, "event")
object = SubjectType.where(name: "Object").first
object&.update_column(:name, "object")
place = SubjectType.where(name: "Place").first
place&.update_column(:name, "place")
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/use_restriction.rb | lib/tasks/use_restriction.rb | def update_use_restriction
YAML.safe_load(open("db/fixtures/enju_circulation/use_restrictions.yml").read).each do |line|
l = line[1].select! { |k, v| %w(name display_name).include?(k) }
UseRestriction.where(name: l["name"]).first.try(:update_attributes!, l)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/subject_heading_type.rb | lib/tasks/subject_heading_type.rb | def update_subject_heading_type
unknown = SubjectHeadingType.where(name: "unknown").first
unless unknown
SubjectHeadingType.create!(name: "unknown")
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/color.rb | lib/tasks/color.rb | def update_color
colors = YAML.safe_load(open("db/fixtures/enju_library/colors.yml").read)
library_group = LibraryGroup.site_config
colors.each do |line|
l = line[1].select! { |k, v| %w(property code).include?(k) }
color = Color.where(property: l["property"]).first
unless color
color = Color.create!(l)
library_group.colors << color
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/carrier_type.rb | lib/tasks/carrier_type.rb | def update_carrier_type
CarrierType.find_each do |carrier_type|
case carrier_type.name
when "volume"
carrier_type = CarrierType.find_by(name: "volume")
if carrier_type
unless carrier_type.attachment.attached?
carrier_type.attachment.attach(io: File.open("#{Rails.root}/app/assets/images/icons/book.png"), filename: "book.png")
carrier_type.save!
end
end
when "audio_disc"
carrier_type = CarrierType.find_by(name: "audio_disc")
if carrier_type
unless carrier_type.attachment.attached?
carrier_type.attachment.attach(io: File.open("#{Rails.root}/app/assets/images/icons/cd.png"), filename: "cd.png")
carrier_type.save!
end
end
when "videodisc"
carrier_type = CarrierType.find_by(name: "videodisc")
if carrier_type
unless carrier_type.attachment.attached?
carrier_type.attachment.attach(io: File.open("#{Rails.root}/app/assets/images/icons/dvd.png"), filename: "dvd.png")
carrier_type.save!
end
end
when "online_resource"
carrier_type = CarrierType.find_by(name: "online_resource")
if carrier_type
unless carrier_type.attachment.attached?
carrier_type.attachment.attach(io: File.open("#{Rails.root}/app/assets/images/icons/monitor.png"), filename: "monitor.png")
carrier_type.save!
end
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/lib/tasks/attachment.rb | lib/tasks/attachment.rb | def migrate_attachment
option = {
path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
}
AgentImportFile.where.not(agent_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:agent_import,
file,
option
).path),
filename: file.agent_import_file_name
)
end
CarrierType.where.not(attachment_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:attachment,
file,
option
).path),
filename: file.attachment_file_name
)
end
EventExportFile.where.not(event_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:event_export,
file,
option
).path),
filename: file.event_export_file_name
)
end
EventImportFile.where.not(event_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:event_import,
file,
option
).path),
filename: file.event_import_file_name
)
end
InventoryFile.where.not(inventory_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:inventory,
file,
option
).path),
filename: file.inventory_file_name
)
end
LibraryGroup.where.not(header_logo_file_name: nil).find_each do |file|
file.header_logo.attach(
io: File.open(Paperclip::Attachment.new(
:header_logo,
file,
option
).path),
filename: file.header_logo_file_name
)
end
Manifestation.where.not(attachment_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:attachment,
file,
option
).path),
filename: file.attachment_file_name
)
end
PictureFile.where.not(picture_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:picture,
file,
option
).path),
filename: file.picture_file_name
)
file.save
end
ResourceExportFile.where.not(resource_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:resource_export,
file,
option
).path),
filename: file.resource_export_file_name
)
end
ResourceImportFile.where.not(resource_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:resource_import,
file,
option
).path),
filename: file.resource_import_file_name
)
end
UserExportFile.where.not(user_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:user_export,
file,
option
).path),
filename: file.user_export_file_name
)
end
UserImportFile.where.not(user_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: File.open(Paperclip::Attachment.new(
:user_import,
file,
option
).path),
filename: file.user_import_file_name
)
end
end
def migrate_attachment_s3
AgentImportFile.where.not(agent_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:agent_import,
file,
option
).expiring_url).open,
filename: file.agent_import_file_name
)
end
CarrierType.where.not(attachment_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:attachment,
file,
option
).expiring_url).open,
filename: file.attachment_file_name
)
end
EventExportFile.where.not(event_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:event_export,
file,
option
).expiring_url).open,
filename: file.event_export_file_name
)
end
EventImportFile.where.not(event_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:event_import,
file,
option
).expiring_url).open,
filename: file.event_import_file_name
)
end
InventoryFile.where.not(inventory_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:inventory,
file,
option
).expiring_url).open,
filename: file.inventory_file_name
)
end
LibraryGroup.where.not(header_logo_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:header_logo,
file,
option
).expiring_url).open,
filename: file.header_logo_file_name
)
end
Manifestation.where.not(attachment_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:attachment,
file,
option
).expiring_url).open,
filename: file.attahcment_file_name
)
end
PictureFile.where.not(picture_file_name: nil).find_each do |file|
puts file.id
puts Paperclip::Attachment.new(
:picture,
file,
option
).expiring_url
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:picture,
file,
option
).expiring_url).open,
filename: file.picture_file_name
)
file.save
end
ResourceExportFile.where.not(resource_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:resource_export,
file,
option
).expiring_url).open,
filename: file.resource_export_file_name
)
end
ResourceImportFile.where.not(resource_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:resource_import,
file,
option
).expiring_url).open,
filename: file.resource_import_file_name
)
end
UserExportFile.where.not(user_export_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:user_export,
file,
option
).expiring_url).open,
filename: file.user_export_file_name
)
end
UserImportFile.where.not(user_import_file_name: nil).find_each do |file|
file.attachment.attach(
io: URI(Paperclip::Attachment.new(
:user_import,
file,
option
).expiring_url).open,
filename: file.user_import_file_name
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.