Skip to content

Commit

Permalink
update spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Aug 24, 2019
1 parent 9968841 commit 06d4a18
Show file tree
Hide file tree
Showing 251 changed files with 1,031 additions and 940 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ gem 'enju_seed', github: 'next-l/enju_seed'
gem 'enju_leaf', github: 'next-l/enju_leaf'
gem 'enju_library', github: 'next-l/enju_library'
gem 'enju_biblio', github: 'next-l/enju_biblio'
gem 'enju_subject', github: 'next-l/enju_subject'
gem 'enju_manifestation_viewer', github: 'next-l/enju_manifestation_viewer'
gem 'enju_circulation', github: 'next-l/enju_circulation'
gem 'enju_message', github: 'next-l/enju_message'
gem 'enju_event', github: 'next-l/enju_event'
gem 'paper_trail'
gem 'jbuilder'
gem 'rails', '~> 5.2'
group :test do
gem 'rails-controller-testing'
gem 'rspec_junit_formatter'
Expand Down
13 changes: 1 addition & 12 deletions app/controllers/inventory_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,11 @@ def index
# GET /inventory_files/1
# GET /inventory_files/1.json
def show
if @inventory_file.inventory.path
unless ENV['ENJU_STORAGE'] == 's3'
file = @inventory_file.inventory.path
end
end

respond_to do |format|
format.html # show.html.erb
format.json { render json: @inventory_file }
format.download {
if ENV['ENJU_STORAGE'] == 's3'
send_data Faraday.get(@inventory_file.inventory.expiring_url).body.force_encoding('UTF-8'),
filename: File.basename(@inventory_file.inventory_file_name), type: 'application/octet-stream'
else
send_file file, filename: @inventory_file.inventory_file_name, type: 'application/octet-stream'
end
send_data @inventory_file.inventory.download, filename: @inventory_file.inventory.filename.to_s, type: @inventory_file.inventory.content_type, disposition: disposition
}
end
end
Expand Down
10 changes: 5 additions & 5 deletions app/models/inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class Inventory < ActiveRecord::Base
#
# Table name: inventories
#
# id :integer not null, primary key
# item_id :integer
# inventory_file_id :integer
# id :bigint not null, primary key
# item_id :bigint
# inventory_file_id :bigint
# note :text
# created_at :datetime
# updated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
#
35 changes: 7 additions & 28 deletions app/models/inventory_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,20 @@ class InventoryFile < ActiveRecord::Base
has_many :inventories, dependent: :destroy
has_many :items, through: :inventories
belongs_to :user
validates_presence_of :user

if ENV['ENJU_STORAGE'] == 's3'
has_attached_file :inventory, storage: :s3,
s3_credentials: {
access_key: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
s3_permissions: :private
else
has_attached_file :inventory,
path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
end
validates_attachment_content_type :inventory, content_type: ['text/csv', 'text/plain', 'text/tab-separated-values']
validates_attachment_presence :inventory
has_one_attached :inventory

paginates_per 10

def import
self.reload
file = File.open(self.inventory.path)
reader = file.read
reader.split.each do |row|
item = Item.where(item_identifier: row.to_s.strip).first
inventory.download.split.each do |row|
item = Item.find_by(item_identifier: row.to_s.strip)
if item
unless self.items.where(id: item.id).select('items.id').first
self.items << item
end
end
end
file.close
true
end
end
Expand All @@ -42,14 +24,11 @@ def import
#
# Table name: inventory_files
#
# id :integer not null, primary key
# filename :string
# content_type :string
# size :integer
# user_id :integer
# id :bigint not null, primary key
# user_id :bigint
# note :text
# created_at :datetime
# updated_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# inventory_file_name :string
# inventory_content_type :string
# inventory_file_size :integer
Expand Down
20 changes: 0 additions & 20 deletions app/views/inventory_files/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@
<%= form_for(@inventory_file) do |f| -%>
<%= f.error_messages -%>

<div class="field">
<%= f.label :inventory_file_name -%> <br />
<%= f.text_field :inventory_file_name -%>
</div>
<div class="field">
<%= f.label :inventory_content_type -%> <br />
<%= f.text_field :inventory_content_type -%>
</div>
<div class="field">
<%= f.label :inventory_file_size -%> <br />
<%= f.text_field :inventory_file_size -%>
</div>
<div class="field">
<%= f.label :inventory_fingerprint -%> <br />
<%= f.text_field :inventory_fingerprint -%>
</div>
<div class="field">
<%= f.label :user_id -%> <br />
<%= f.text_field :user_id -%>
</div>
<div class="field">
<%= f.label :note -%> <br />
<%= f.text_area :note -%>
Expand Down
9 changes: 4 additions & 5 deletions app/views/inventory_files/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@
<th><%= t('activerecord.attributes.inventory_file.inventory_file_name') -%> </th>
<th><%= t('activerecord.attributes.inventory_file.inventory_content_type') -%> </th>
<th><%= t('activerecord.attributes.inventory_file.inventory_file_size') -%> </th>
<th><%= t('activerecord.attributes.inventory_file.inventory_fingerprint') -%> </th>
<th><%= t('activerecord.models.user') -%> </th>
<th></th>
</tr>

<%- @inventory_files.each do |inventory_file| -%>
<% next unless inventory_file.inventory.attached? -%>
<tr class="line<%= cycle("0", "1") -%>">
<td>
<%= link_to inventory_file.inventory_file_name, inventory_file -%>
<%= link_to inventory_file.inventory.filename, inventory_file -%>
<br />
<%= inventory_file.created_at -%>
</td>
<td><%= inventory_file.inventory_content_type -%> </td>
<td><%= inventory_file.inventory_file_size -%> </td>
<td><%= inventory_file.inventory_fingerprint -%> </td>
<td><%= inventory_file.inventory.content_type -%> </td>
<td><%= inventory_file.inventory.byte_size -%> </td>
<td><%= link_to inventory_file.user.username, inventory_file.user.profile if inventory_file.user.try(:profile) -%> </td>
<td>
<%= link_to t('page.edit'), edit_inventory_file_path(inventory_file) -%>
Expand Down
11 changes: 3 additions & 8 deletions app/views/inventory_files/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@

<p>
<strong><%= t('activerecord.attributes.inventory_file.inventory_file_name') -%> :</strong>
<%= @inventory_file.inventory_file_name -%>
<%= @inventory_file.inventory.filename -%>
</p>

<p>
<strong><%= t('activerecord.attributes.inventory_file.inventory_content_type') -%> :</strong>
<%= @inventory_file.inventory_content_type -%>
<%= @inventory_file.inventory.content_type -%>
</p>

<p>
<strong><%= t('activerecord.attributes.inventory_file.inventory_file_size') -%> :</strong>
<%= @inventory_file.inventory_file_size -%>
</p>

<p>
<strong><%= t('activerecord.attributes.inventory_file.inventory_fingerprint') -%> :</strong>
<%= @inventory_file.inventory_fingerprint -%>
<%= @inventory_file.inventory.byte_size -%>
</p>

<p>
Expand Down
13 changes: 3 additions & 10 deletions db/migrate/20081117143156_create_inventory_files.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
class CreateInventoryFiles < ActiveRecord::Migration[4.2]
def self.up
class CreateInventoryFiles < ActiveRecord::Migration[5.2]
def change
create_table :inventory_files do |t|
t.string :filename
t.string :content_type
t.integer :size
t.references :user, index: true
t.references :user
t.text :note

t.timestamps
end
end

def self.down
drop_table :inventory_files
end
end
2 changes: 1 addition & 1 deletion db/migrate/20081117143455_create_inventories.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateInventories < ActiveRecord::Migration[4.2]
class CreateInventories < ActiveRecord::Migration[5.2]
def self.up
create_table :inventories do |t|
t.references :item, index: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddAttachmentsInventoryToInventoryFile < ActiveRecord::Migration[4.2]
class AddAttachmentsInventoryToInventoryFile < ActiveRecord::Migration[5.2]
def self.up
add_column :inventory_files, :inventory_file_name, :string
add_column :inventory_files, :inventory_content_type, :string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddFingerprintToInventoryFile < ActiveRecord::Migration[4.2]
class AddFingerprintToInventoryFile < ActiveRecord::Migration[5.2]
def change
add_column :inventory_files, :inventory_fingerprint, :string
end
Expand Down
2 changes: 1 addition & 1 deletion enju_inventory.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.description = "Inventory management for Next-L Enju"

s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
s.test_files = Dir["spec/**/*"] - Dir["spec/dummy/log/*"] - Dir["spec/dummy/solr/{data,pids,default,development,test}/*"] - Dir["spec/dummy/tmp/*"] - Dir["spec/dummy/private/**/*"]
s.test_files = Dir["spec/**/*"] - Dir["spec/dummy/log/*"] - Dir["spec/dummy/solr/{data,pids,default,development,test}/*"] - Dir["spec/dummy/tmp/*"]

s.add_dependency "enju_biblio", "~> 0.5.0.beta.1"

Expand Down
3 changes: 1 addition & 2 deletions spec/dummy/db/migrate/001_create_agents.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateAgents < ActiveRecord::Migration[4.2]
class CreateAgents < ActiveRecord::Migration[5.2]
def change
create_table :agents do |t|
t.string :last_name
Expand All @@ -13,7 +13,6 @@ def change
t.text :full_name_transcription
t.text :full_name_alternative
t.timestamps
t.datetime :deleted_at
t.string :zip_code_1
t.string :zip_code_2
t.text :address_1
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/002_devise_create_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class DeviseCreateUsers < ActiveRecord::Migration[4.2]
class DeviseCreateUsers < ActiveRecord::Migration[5.2]
def change
create_table(:users) do |t|
## Database authenticatable
Expand Down
3 changes: 1 addition & 2 deletions spec/dummy/db/migrate/005_create_manifestations.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateManifestations < ActiveRecord::Migration[4.2]
class CreateManifestations < ActiveRecord::Migration[5.2]
def change
create_table :manifestations do |t|
t.text :original_title, null: false
Expand All @@ -9,7 +9,6 @@ def change
t.datetime :date_of_publication
t.datetime :copyright_date
t.timestamps
t.datetime :deleted_at
t.string :access_address
t.integer :language_id, default: 1, null: false
t.integer :carrier_type_id, default: 1, null: false
Expand Down
3 changes: 1 addition & 2 deletions spec/dummy/db/migrate/006_create_items.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class CreateItems < ActiveRecord::Migration[4.2]
class CreateItems < ActiveRecord::Migration[5.2]
def change
create_table :items do |t|
t.string :call_number
t.string :item_identifier
t.timestamps
t.datetime :deleted_at
t.integer :shelf_id, default: 1, null: false
t.boolean :include_supplements, default: false, null: false
t.text :note
Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/db/migrate/012_create_owns.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
class CreateOwns < ActiveRecord::Migration[4.2]
class CreateOwns < ActiveRecord::Migration[5.2]
def change
create_table :owns do |t|
t.references :agent, null: false
t.references :item, null: false
t.integer :position
t.timestamps
end
add_index :owns, :agent_id
add_index :owns, :item_id
end
end
4 changes: 1 addition & 3 deletions spec/dummy/db/migrate/015_create_creates.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
class CreateCreates < ActiveRecord::Migration[4.2]
class CreateCreates < ActiveRecord::Migration[5.2]
def change
create_table :creates do |t|
t.references :agent, null: false
t.references :work, null: false
t.integer :position
t.timestamps
end
add_index :creates, :agent_id
add_index :creates, :work_id
end
end
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/032_create_checkins.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateCheckins < ActiveRecord::Migration[4.2]
class CreateCheckins < ActiveRecord::Migration[5.2]
def change
create_table :checkins do |t|
t.references :librarian, index: true
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/033_create_checkouts.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateCheckouts < ActiveRecord::Migration[4.2]
class CreateCheckouts < ActiveRecord::Migration[5.2]
def self.up
create_table :checkouts do |t|
t.references :user, index: true, foreign_key: true
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/035_create_reserves.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateReserves < ActiveRecord::Migration[4.2]
class CreateReserves < ActiveRecord::Migration[5.2]
def self.up
create_table :reserves do |t|
t.references :user, index: true, foreign_key: true, null: false
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/041_create_roles.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateRoles < ActiveRecord::Migration[4.2]
class CreateRoles < ActiveRecord::Migration[5.2]
def change
create_table "roles" do |t|
t.column :name, :string, null: false
Expand Down
4 changes: 1 addition & 3 deletions spec/dummy/db/migrate/047_create_produces.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
class CreateProduces < ActiveRecord::Migration[4.2]
class CreateProduces < ActiveRecord::Migration[5.2]
def change
create_table :produces do |t|
t.references :agent, null: false
t.references :manifestation, null: false
t.integer :position
t.timestamps
end
add_index :produces, :agent_id
add_index :produces, :manifestation_id
end
end
4 changes: 1 addition & 3 deletions spec/dummy/db/migrate/059_create_libraries.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class CreateLibraries < ActiveRecord::Migration[4.2]
class CreateLibraries < ActiveRecord::Migration[5.2]
def change
create_table :libraries do |t|
t.string :name, index: true, null: false
t.text :display_name
t.string :short_display_name, null: false
t.string :zip_code
t.text :street
Expand All @@ -20,7 +19,6 @@ def change
t.references :country

t.timestamps
t.datetime :deleted_at
end
end
end
4 changes: 1 addition & 3 deletions spec/dummy/db/migrate/069_create_shelves.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
class CreateShelves < ActiveRecord::Migration[4.2]
class CreateShelves < ActiveRecord::Migration[5.2]
def change
create_table :shelves do |t|
t.string :name, null: false
t.text :display_name
t.text :note
t.references :library, index: true, null: false
t.integer :items_count, default: 0, null: false
t.integer :position
t.timestamps
t.datetime :deleted_at
end
end
end
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/073_create_carrier_types.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateCarrierTypes < ActiveRecord::Migration[4.2]
class CreateCarrierTypes < ActiveRecord::Migration[5.2]
def change
create_table :carrier_types do |t|
t.string :name, null: false
Expand Down
Loading

0 comments on commit 06d4a18

Please sign in to comment.