enju_library 0.1.0.pre38 → 0.1.0.pre39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +8 -1
  3. data/app/controllers/shelves_controller.rb +1 -1
  4. data/app/models/accept.rb +2 -9
  5. data/app/models/basket.rb +2 -23
  6. data/lib/enju_library/version.rb +1 -1
  7. data/spec/controllers/shelves_controller_spec.rb +2 -2
  8. data/spec/dummy/config/database.yml +23 -18
  9. data/spec/dummy/db/migrate/035_create_reserves.rb +0 -1
  10. data/spec/dummy/db/migrate/113_create_events.rb +2 -2
  11. data/spec/dummy/db/migrate/133_create_agent_merges.rb +15 -0
  12. data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +13 -0
  13. data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +0 -1
  14. data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +5 -1
  15. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +5 -1
  16. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +5 -1
  17. data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +5 -1
  18. data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +5 -1
  19. data/spec/dummy/db/migrate/20140523171309_create_event_import_file_transitions.rb +5 -1
  20. data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +5 -1
  21. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +5 -1
  22. data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +5 -1
  23. data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +5 -1
  24. data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +5 -1
  25. data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +5 -1
  26. data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +5 -1
  27. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +5 -1
  28. data/spec/dummy/db/migrate/20140812152348_create_event_export_files.rb +11 -0
  29. data/spec/dummy/db/migrate/20140812153137_create_event_export_file_transitions.rb +18 -0
  30. data/spec/dummy/db/migrate/20140814070854_add_default_event_category_id_to_event_import_file.rb +5 -0
  31. data/spec/dummy/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
  32. data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
  33. data/spec/dummy/db/migrate/20141014065831_add_shelf_id_to_checkout.rb +6 -0
  34. data/spec/dummy/db/migrate/20141020120523_add_library_id_to_checkout.rb +6 -0
  35. data/spec/dummy/db/schema.rb +662 -621
  36. data/spec/fixtures/checked_items.yml +4 -4
  37. data/spec/fixtures/checkouts.yml +12 -12
  38. data/spec/fixtures/manifestations.yml +114 -114
  39. data/spec/fixtures/reserves.yml +17 -33
  40. data/spec/fixtures/users.yml +1 -1
  41. data/spec/spec_helper.rb +2 -0
  42. metadata +50 -6
  43. data/spec/dummy/db/migrate/20130303104849_add_state_index_to_reserve.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da7e421bdf2cdce81552af80572af9ed81eab021
4
- data.tar.gz: f2f65789832c45e843b23b6d753eb02b45085114
3
+ metadata.gz: 0eb95937df49250022c8fa869d621a055aee64ea
4
+ data.tar.gz: f79f75f76a9c942e58080e518ff17ff9d7c77793
5
5
  SHA512:
6
- metadata.gz: 6f36f883a1d110611fba8382e9d2f56e0517d30b85079d1484dc08a0c5966a709894f2a7b3988b026888e9e857136a856f55acb89504d4a31c604c5decbd84d5
7
- data.tar.gz: 4e017ebc908ee99903eb603ca97da627a4c84a19ac83b30da97b74468dbfb4f4af81426e8e57036534d002002593d9a16946585c72b8b2ae8413d9916d154955
6
+ metadata.gz: 3e57afb48c4d56db84dcafef4048723221436c416557e31ea6578add5b0c4b346d511e7ea6925f83d6166b3bbf8aef2653ed856e7101ee6fa6c652f0581faaac
7
+ data.tar.gz: f261b8c0a726b360341f520f6bfccf2817695870938eb703acf16f3092abdba96abbe433cd9d07d1b5c0bd106c49230bee4387c1759ecc6b9c79f5d6c2fc1850
data/README.rdoc CHANGED
@@ -1,3 +1,10 @@
1
- = EnjuLibrary {<img src="https://secure.travis-ci.org/next-l/enju_library.png?branch=master" alt="Build Status" />}[http://travis-ci.org/next-l/enju_library]
1
+ = EnjuLibrary
2
+ {<img src="https://travis-ci.org/next-l/enju_library.png?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_library]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_library/badge.png?branch=1.1" alt="Coverage Status" />}[https://coveralls.io/r/next-l/enju_library?branch=1.1]
4
+ {<img src="https://hakiri.io/github/next-l/enju_library/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_library/1.1]
2
5
 
3
6
  This project rocks and uses MIT-LICENSE.
7
+
8
+ == 製作者・貢献者 (Authors and contributors)
9
+ * {TANABE, Kosuke}[https://github.com/nabeta] ({@nabeta}[https://twitter.com/nabeta])
10
+ * {Project Next-L}[http://www.next-l.jp] ({@ProjectNextL}[https://twitter.com/ProjectNextL])
@@ -10,7 +10,7 @@ class ShelvesController < ApplicationController
10
10
  if @library
11
11
  @shelves = @library.shelves
12
12
  else
13
- @shelves = Shelf.real
13
+ @shelves = Shelf.real.order(:position)
14
14
  end
15
15
  render partial: 'select_form'
16
16
  return
data/app/models/accept.rb CHANGED
@@ -5,6 +5,8 @@ class Accept < ActiveRecord::Base
5
5
  belongs_to :item, touch: true
6
6
  belongs_to :librarian, class_name: 'User'
7
7
 
8
+ enju_circulation_accept_model if defined?(EnjuCirculation)
9
+
8
10
  validates_uniqueness_of :item_id, message: I18n.t('accept.already_accepted')
9
11
  validates_presence_of :item_id, message: I18n.t('accept.item_not_found')
10
12
  validates_presence_of :basket_id
@@ -14,15 +16,6 @@ class Accept < ActiveRecord::Base
14
16
  attr_accessor :item_identifier
15
17
 
16
18
  paginates_per 10
17
-
18
- def accept!
19
- if defined?(EnjuCirculation)
20
- circulation_status = CirculationStatus.where(name: 'Available On Shelf').first
21
- item.update_column(:circulation_status_id, circulation_status.id) if circulation_status
22
- use_restriction = UseRestriction.where(name: 'Limited Circulation, Normal Loan Period').first
23
- item.use_restriction = use_restriction if use_restriction
24
- end
25
- end
26
19
  end
27
20
 
28
21
  # == Schema Information
data/app/models/basket.rb CHANGED
@@ -5,6 +5,8 @@ class Basket < ActiveRecord::Base
5
5
  belongs_to :user, validate: true
6
6
  has_many :accepts
7
7
 
8
+ enju_circulation_basket_model if defined?(EnjuCirculation)
9
+
8
10
  validates_associated :user, on: :create
9
11
  # 貸出完了後にかごのユーザidは破棄する
10
12
  validates_presence_of :user, on: :create
@@ -24,29 +26,6 @@ class Basket < ActiveRecord::Base
24
26
  Basket.will_expire(Time.zone.now.beginning_of_day).destroy_all
25
27
  logger.info "#{Time.zone.now} baskets expired!"
26
28
  end
27
-
28
- if defined?(EnjuCirculation)
29
- has_many :checked_items, dependent: :destroy
30
- has_many :items, through: :checked_items
31
- has_many :checkouts
32
- has_many :checkins
33
-
34
- def basket_checkout(librarian)
35
- return nil if checked_items.size == 0
36
- Item.transaction do
37
- checked_items.each do |checked_item|
38
- checkout = user.checkouts.new
39
- checkout.librarian = librarian
40
- checkout.item = checked_item.item
41
- checkout.basket = self
42
- checkout.due_date = checked_item.due_date
43
- checked_item.item.checkout!(user)
44
- checkout.save!
45
- end
46
- CheckedItem.destroy_all(:basket_id => id)
47
- end
48
- end
49
- end
50
29
  end
51
30
 
52
31
  # == Schema Information
@@ -1,3 +1,3 @@
1
1
  module EnjuLibrary
2
- VERSION = "0.1.0.pre38"
2
+ VERSION = "0.1.0.pre39"
3
3
  end
@@ -48,13 +48,13 @@ describe ShelvesController do
48
48
 
49
49
  it "assigns all shelves as @shelves with library_id" do
50
50
  get :index, :library_id => 'kamata'
51
- assigns(:shelves).should eq(Library.find('kamata').shelves.page(1))
51
+ assigns(:shelves).map(&:id).should eq(Library.find('kamata').shelves.order(:position).page(1).pluck(:id))
52
52
  response.should be_success
53
53
  end
54
54
 
55
55
  it "assigns all shelves as @shelves with select mode" do
56
56
  get :index, :mode => 'select'
57
- assigns(:shelves).should eq(Shelf.real)
57
+ assigns(:shelves).should eq(Shelf.real.order(:position))
58
58
  response.should be_success
59
59
  end
60
60
  end
@@ -1,25 +1,30 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
1
+ sqlite: &sqlite
7
2
  adapter: sqlite3
8
- database: db/development.sqlite3
3
+ database: db/<%= Rails.env %>.sqlite3
4
+
5
+ mysql: &mysql
6
+ adapter: mysql2
7
+ username: root
8
+ password:
9
+ database: enju_<%= Rails.env %>
10
+
11
+ postgresql: &postgresql
12
+ adapter: postgresql
13
+ username: postgres
14
+ password:
15
+ database: enju_<%= Rails.env %>
16
+
17
+ defaults: &defaults
9
18
  pool: 5
10
19
  timeout: 5000
20
+ host: localhost
21
+ <<: *<%= ENV['DB'] || "sqlite" %>
22
+
23
+ development:
24
+ <<: *defaults
11
25
 
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
26
  test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
27
+ <<: *defaults
20
28
 
21
29
  production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
30
+ <<: *defaults
@@ -10,7 +10,6 @@ class CreateReserves < ActiveRecord::Migration
10
10
  t.datetime :canceled_at
11
11
  t.datetime :expired_at
12
12
  t.datetime :deleted_at
13
- t.string :state
14
13
  t.boolean :expiration_notice_to_patron, :default => false
15
14
  t.boolean :expiration_notice_to_library, :default => false
16
15
  end
@@ -1,8 +1,8 @@
1
1
  class CreateEvents < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :events do |t|
4
- t.integer :library_id, :default => 1, :null => false
5
- t.integer :event_category_id, :default => 1, :null => false
4
+ t.integer :library_id, :null => false
5
+ t.integer :event_category_id, :null => false
6
6
  t.string :name
7
7
  t.text :note
8
8
  t.datetime :start_at
@@ -0,0 +1,15 @@
1
+ class CreateAgentMerges < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :agent_merges do |t|
4
+ t.integer :agent_id, :agent_merge_list_id, :null => false
5
+
6
+ t.timestamps
7
+ end
8
+ add_index :agent_merges, :agent_id
9
+ add_index :agent_merges, :agent_merge_list_id
10
+ end
11
+
12
+ def self.down
13
+ drop_table :agent_merges
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class CreateAgentMergeLists < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :agent_merge_lists do |t|
4
+ t.string :title
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :agent_merge_lists
12
+ end
13
+ end
@@ -3,7 +3,6 @@ class CreateAgentImportResults < ActiveRecord::Migration
3
3
  create_table :agent_import_results do |t|
4
4
  t.integer :agent_import_file_id
5
5
  t.integer :agent_id
6
- t.integer :user_id
7
6
  t.text :body
8
7
 
9
8
  t.timestamps
@@ -2,7 +2,11 @@ class CreateReserveTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :reserve_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :reserve_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateMessageTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :message_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :message_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateMessageRequestTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :message_request_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :message_request_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateResourceImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :resource_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :resource_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateImportRequestTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :import_request_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :import_request_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateEventImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :event_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :event_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateAgentImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :agent_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :agent_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserCheckoutStatTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_checkout_stat_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_checkout_stat_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserReserveStatTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_reserve_stat_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_reserve_stat_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateManifestationCheckoutStatTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :manifestation_checkout_stat_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :manifestation_checkout_stat_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateManifestationReserveStatTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :manifestation_reserve_stat_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :manifestation_reserve_stat_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateResourceExportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :resource_export_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :resource_export_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserExportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_export_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_export_file_id
8
12
  t.timestamps
@@ -0,0 +1,11 @@
1
+ class CreateEventExportFiles < ActiveRecord::Migration
2
+ def change
3
+ create_table :event_export_files do |t|
4
+ t.integer :user_id
5
+ t.attachment :event_export
6
+ t.datetime :executed_at
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ class CreateEventExportFileTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :event_export_file_transitions do |t|
4
+ t.string :to_state
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
10
+ t.integer :sort_key
11
+ t.integer :event_export_file_id
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :event_export_file_transitions, :event_export_file_id, name: "index_event_export_file_transitions_on_file_id"
16
+ add_index :event_export_file_transitions, [:sort_key, :event_export_file_id], unique: true, name: "index_event_export_file_transitions_on_sort_key_and_file_id"
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ class AddDefaultEventCategoryIdToEventImportFile < ActiveRecord::Migration
2
+ def change
3
+ add_column :event_import_files, :default_event_category_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddFullNameTranscriptionToProfile < ActiveRecord::Migration
2
+ def change
3
+ add_column :profiles, :full_name_transcription, :text
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddDateOfBirthToProfile < ActiveRecord::Migration
2
+ def change
3
+ add_column :profiles, :date_of_birth, :datetime
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddShelfIdToCheckout < ActiveRecord::Migration
2
+ def change
3
+ add_column :checkouts, :shelf_id, :integer
4
+ add_index :checkouts, :shelf_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddLibraryIdToCheckout < ActiveRecord::Migration
2
+ def change
3
+ add_column :checkouts, :library_id, :integer
4
+ add_index :checkouts, :library_id
5
+ end
6
+ end