Skip to content

Commit

Permalink
Merge branch 'master' of github.com:next-l/enju_library
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Aug 14, 2019
2 parents faf1d91 + e51df6e commit 1b54b68
Show file tree
Hide file tree
Showing 43 changed files with 49 additions and 62 deletions.
2 changes: 1 addition & 1 deletion app/controllers/accepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def create
# PUT /accepts/1.json
def update
respond_to do |format|
if @accept.update_attributes(accept_params)
if @accept.update(accept_params)
format.html { redirect_to @accept, notice: t('controller.successfully_updated', model: t('activerecord.models.accept')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/bookstores_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update
end

respond_to do |format|
if @bookstore.update_attributes(bookstore_params)
if @bookstore.update(bookstore_params)
format.html { redirect_to @bookstore, notice: t('controller.successfully_updated', model: t('activerecord.models.bookstore')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/budget_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update
end

respond_to do |format|
if @budget_type.update_attributes(budget_type_params)
if @budget_type.update(budget_type_params)
format.html { redirect_to @budget_type, notice: t('controller.successfully_updated', model: t('activerecord.models.budget_type')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/libraries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def update
end

respond_to do |format|
if @library.update_attributes(library_params)
if @library.update(library_params)
format.html { redirect_to @library, notice: t('controller.successfully_updated', model: t('activerecord.models.library')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/library_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def edit
# PUT /library_groups/1.json
def update
respond_to do |format|
if @library_group.update_attributes(library_group_params)
if @library_group.update(library_group_params)
if @library_group.delete_header_logo == '1'
@library_group.header_logo.destroy
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/request_status_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update
end

respond_to do |format|
if @request_status_type.update_attributes(request_status_type_params)
if @request_status_type.update(request_status_type_params)
format.html { redirect_to @request_status_type, notice: t('controller.successfully_updated', model: t('activerecord.models.request_status_type')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/request_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update
end

respond_to do |format|
if @request_type.update_attributes(request_type_params)
if @request_type.update(request_type_params)
format.html { redirect_to @request_type, notice: t('controller.successfully_updated', model: t('activerecord.models.request_type')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_engines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update
end

respond_to do |format|
if @search_engine.update_attributes(search_engine_params)
if @search_engine.update(search_engine_params)
format.html { redirect_to @search_engine, notice: t('controller.successfully_updated', model: t('activerecord.models.search_engine')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/shelves_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def update
end

respond_to do |format|
if @shelf.update_attributes(shelf_params)
if @shelf.update(shelf_params)
format.html { redirect_to @shelf, notice: t('controller.successfully_updated', model: t('activerecord.models.shelf')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/subscribes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create
# PUT /subscribes/1.json
def update
respond_to do |format|
if @subscribe.update_attributes(subscribe_params)
if @subscribe.update(subscribe_params)
format.html { redirect_to @subscribe, notice: t('controller.successfully_updated', model: t('activerecord.models.subscribe')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/user_export_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create
# PUT /user_export_files/1.json
def update
respond_to do |format|
if @user_export_file.update_attributes(user_export_file_params)
if @user_export_file.update(user_export_file_params)
if @user_export_file.mode == 'export'
UserExportFileJob.perform_later(@user_export_file)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/user_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def update
end

respond_to do |format|
if @user_group.update_attributes(user_group_params)
if @user_group.update(user_group_params)
format.html { redirect_to @user_group, notice: t('controller.successfully_updated', model: t('activerecord.models.user_group')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/user_import_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def create
# PUT /user_import_files/1.json
def update
respond_to do |format|
if @user_import_file.update_attributes(user_import_file_params)
if @user_import_file.update(user_import_file_params)
if @user_import_file.mode == 'import'
UserImportFileJob.perform_later(@user_import_file)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/withdraws_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create
# PUT /withdraws/1.json
def update
respond_to do |format|
if @withdraw.update_attributes(withdraw_params)
if @withdraw.update(withdraw_params)
format.html { redirect_to @withdraw, notice: t('controller.successfully_updated', model: t('activerecord.models.withdraw')) }
format.json { head :no_content }
else
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/user_export_file_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserExportFileJob < ActiveJob::Base
class UserExportFileJob < ApplicationJob
queue_as :enju_leaf

def perform(user_export_file)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/user_import_file_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserImportFileJob < ActiveJob::Base
class UserImportFileJob < ApplicationJob
queue_as :enju_leaf

def perform(user_import_file)
Expand Down
2 changes: 1 addition & 1 deletion app/models/accept.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Accept < ActiveRecord::Base
class Accept < ApplicationRecord
default_scope { order('accepts.id DESC') }
belongs_to :basket
belongs_to :item, touch: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/basket.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Basket < ActiveRecord::Base
class Basket < ApplicationRecord
default_scope { order('baskets.id DESC') }
scope :will_expire, lambda {|date| where('created_at < ?', date)}
belongs_to :user, validate: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/bookstore.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Bookstore < ActiveRecord::Base
class Bookstore < ApplicationRecord
default_scope { order('bookstores.position') }
has_many :items

Expand Down
2 changes: 1 addition & 1 deletion app/models/budget_type.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BudgetType < ActiveRecord::Base
class BudgetType < ApplicationRecord
include MasterModel
validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
has_many :items
Expand Down
2 changes: 1 addition & 1 deletion app/models/color.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Color < ActiveRecord::Base
class Color < ApplicationRecord
#attr_accessible :code, :property

belongs_to :library_group
Expand Down
16 changes: 1 addition & 15 deletions app/models/library.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Library < ActiveRecord::Base
class Library < ApplicationRecord
include MasterModel
default_scope { order('libraries.position') }
scope :real, -> { where('id != 1') }
Expand Down Expand Up @@ -29,20 +29,6 @@ class Library < ActiveRecord::Base
validates :isil, format: { with: /\A[A-Za-z]{1,4}-[A-Za-z0-9\/:\-]{2,11}\z/ }, allow_blank: true
after_validation :geocode, if: :address_changed?
after_create :create_shelf
after_save :clear_all_cache
after_destroy :clear_all_cache

def self.all_cache
if Rails.env == 'production'
Rails.cache.fetch('library_all'){ Library.all }
else
Library.all
end
end

def clear_all_cache
Rails.cache.delete('library_all')
end

def create_shelf
shelf = Shelf.new
Expand Down
2 changes: 1 addition & 1 deletion app/models/library_group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class LibraryGroup < ActiveRecord::Base
class LibraryGroup < ApplicationRecord
#include Singleton
include MasterModel

Expand Down
2 changes: 1 addition & 1 deletion app/models/request_status_type.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RequestStatusType < ActiveRecord::Base
class RequestStatusType < ApplicationRecord
include MasterModel
validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
has_many :reserves
Expand Down
2 changes: 1 addition & 1 deletion app/models/request_type.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class RequestType < ActiveRecord::Base
class RequestType < ApplicationRecord
include MasterModel
validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
translates :display_name
Expand Down
8 changes: 1 addition & 7 deletions app/models/search_engine.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
class SearchEngine < ActiveRecord::Base
class SearchEngine < ApplicationRecord
acts_as_list

validates :name, presence: true
validates :query_param, presence: true
validates :http_method, presence: true, inclusion: %w(get post)
validates :url, presence: true, url: true, length: { maximum: 255 }
validates :base_url, presence: true, url: true, length: { maximum: 255 }
after_save :clear_all_cache
after_destroy :clear_all_cache

paginates_per 10
translates :display_name

def clear_all_cache
Rails.cache.delete('search_engine_all')
end

def search_params(query)
params = {}
if additional_param
Expand Down
2 changes: 1 addition & 1 deletion app/models/shelf.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Shelf < ActiveRecord::Base
class Shelf < ApplicationRecord
include MasterModel
scope :real, -> { where('library_id != 1') }
belongs_to :library, validate: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/subscribe.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Subscribe < ActiveRecord::Base
class Subscribe < ApplicationRecord
belongs_to :subscription, counter_cache: true, validate: true
belongs_to :work, class_name: 'Manifestation', validate: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/subscription.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Subscription < ActiveRecord::Base
class Subscription < ApplicationRecord
has_many :subscribes, dependent: :destroy
has_many :works, through: :subscribes
belongs_to :user, validate: true
Expand Down
2 changes: 1 addition & 1 deletion app/models/user_export_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserExportFile < ActiveRecord::Base
class UserExportFile < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries
include ExportFile

Expand Down
2 changes: 1 addition & 1 deletion app/models/user_export_file_transition.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserExportFileTransition < ActiveRecord::Base
class UserExportFileTransition < ApplicationRecord
include Statesman::Adapters::ActiveRecordTransition


Expand Down
2 changes: 1 addition & 1 deletion app/models/user_group.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserGroup < ActiveRecord::Base
class UserGroup < ApplicationRecord
include MasterModel
has_many :profiles

Expand Down
2 changes: 1 addition & 1 deletion app/models/user_import_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserImportFile < ActiveRecord::Base
class UserImportFile < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries
include ImportFile
default_scope {order('user_import_files.id DESC')}
Expand Down
2 changes: 1 addition & 1 deletion app/models/user_import_file_transition.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserImportFileTransition < ActiveRecord::Base
class UserImportFileTransition < ApplicationRecord
include Statesman::Adapters::ActiveRecordTransition


Expand Down
2 changes: 1 addition & 1 deletion app/models/user_import_result.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UserImportResult < ActiveRecord::Base
class UserImportResult < ApplicationRecord
scope :file_id, proc{ |file_id| where(user_import_file_id: file_id) }
scope :failed, -> { where(user_id: nil) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/withdraw.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Withdraw < ActiveRecord::Base
class Withdraw < ApplicationRecord
belongs_to :basket
belongs_to :item, touch: true
belongs_to :librarian, class_name: 'User'
Expand Down
2 changes: 1 addition & 1 deletion app/views/budget_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.text_field :name, required: true %>
</div>
<div class="field">
<%= f.label :display_name %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/request_status_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.text_field :name, required: true %>
</div>
<div class="field">
<%= f.label :display_name %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/request_types/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.text_field :name, required: true %>
</div>
<div class="field">
<%= f.label :display_name %><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_groups/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
<%= f.text_field :name, required: true %>
</div>
<div class="field">
<%= f.label :display_name %><br />
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/budget_types_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def valid_attributes
# specifies that the BudgetType created on the previous line
# receives the :update_attributes message with whatever params are
# submitted in the request.
BudgetType.any_instance.should_receive(:update_attributes).with('note' => 'test')
BudgetType.any_instance.should_receive(:update).with('note' => 'test')
put :update, params: { id: budget_type.id, budget_type: { note: 'test' } }
end

Expand Down
7 changes: 7 additions & 0 deletions spec/dummy/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
2 changes: 1 addition & 1 deletion spec/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class User < ActiveRecord::Base
class User < ApplicationRecord
devise :database_authenticatable, #:registerable,
:recoverable, :rememberable, :trackable, #, :validatable
:lockable, lock_strategy: :none, unlock_strategy: :none
Expand Down

0 comments on commit 1b54b68

Please sign in to comment.