Skip to content

Commit

Permalink
Merge branch 'master' of github.com:next-l/enju_inter_library_loan
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Feb 6, 2015
2 parents 454cbbb + 80d4b80 commit bafd82f
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 98 deletions.
16 changes: 13 additions & 3 deletions app/controllers/inter_library_loans_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class InterLibraryLoansController < ApplicationController
load_and_authorize_resource
before_filter :get_item
before_filter :store_page, :only => :index
before_action :set_inter_library_loan, only: [:show, :edit, :update, :destroy]
before_action :check_policy, only: [:index, :new, :create]
before_action :get_item
before_action :store_page, :only => :index

# GET /inter_library_loans
# GET /inter_library_loans.json
Expand Down Expand Up @@ -120,6 +121,15 @@ def destroy
end

private
def set_inter_library_loan
@inter_library_loan = InterLibraryLoan.find(params[:id])
authorize @inter_library_loan
end

def check_policy
authorize InterLibraryLoan
end

def inter_library_loan_params
params.require(:inter_library_loan).permit(:item_id, :borrowing_library_id)
end
Expand Down
14 changes: 0 additions & 14 deletions app/models/enju_inter_library_loan/ability.rb

This file was deleted.

10 changes: 9 additions & 1 deletion app/policies/inter_library_loan_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
class InterLibraryLoanPolicy < AdminPolicy
class InterLibraryLoanPolicy < ApplicationPolicy
def index?
user.try(:has_role?, 'Librarian')
end

def show?
user.try(:has_role?, 'Librarian')
end

def create?
user.try(:has_role?, 'Librarian')
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/inter_library_loans/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<%= l(inter_library_loan.shipped_at) if inter_library_loan.shipped_at -%><br />
<%= l(inter_library_loan.received_at) if inter_library_loan.received_at -%>
</td>
<%- if can? :destroy, inter_library_loan -%>
<%- if policy(inter_library_loan).destroy? -%>
<td>
<%= link_to t('page.show'), inter_library_loan -%>
<%= link_to t('page.edit'), edit_inter_library_loan_path(inter_library_loan) -%>
Expand All @@ -43,7 +43,7 @@

<div id="submenu" class="ui-corner-all ui-widget-content">
<ul>
<%- if can? :create, InterLibraryLoan -%>
<%- if policy(InterLibraryLoan).create? -%>
<li><%= link_to t('page.new', :model => t('activerecord.models.inter_library_loan')), new_inter_library_loan_path -%></li>
<%- end -%>
</ul>
Expand Down
10 changes: 6 additions & 4 deletions enju_inter_library_loan.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
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.1.0.pre63"
#s.add_dependency "enju_library", "~> 0.1.0.pre39"
#s.add_dependency "enju_biblio", "~> 0.2.0.pre1"
#s.add_dependency "enju_library", "~> 0.2.0.pre1"
s.add_dependency "statesman", "~> 1.1"

s.add_development_dependency "sqlite3"
Expand All @@ -27,8 +27,10 @@ Gem::Specification.new do |s|
s.add_development_dependency "factory_girl_rails"
s.add_development_dependency "sunspot_solr", "~> 2.1"
s.add_development_dependency "sunspot-rails-tester"
#s.add_development_dependency "enju_leaf", "~> 1.1.0.rc16"
#s.add_development_dependency "enju_circulation", "~> 0.1.0.pre41"
#s.add_development_dependency "enju_leaf", "~> 1.2.0.pre1"
#s.add_development_dependency "enju_circulation", "~> 0.2.0.pre1"
s.add_development_dependency "simplecov"
s.add_development_dependency "annotate"
s.add_development_dependency "redis-rails"
s.add_development_dependency "resque-scheduler", "~> 3.1"
end
12 changes: 6 additions & 6 deletions spec/controllers/inter_library_loans_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
sign_in FactoryGirl.create(:user)
end

it "assigns empty as @inter_library_loans" do
it "assigns nil as @inter_library_loans" do
get :index
assigns(:inter_library_loans).should be_empty
assigns(:inter_library_loans).should be_nil
end
end

describe "When not logged in" do
it "assigns empty as @inter_library_loans" do
it "assigns nil as @inter_library_loans" do
get :index
assigns(:inter_library_loans).should be_empty
assigns(:inter_library_loans).should be_nil
end
end
end
Expand Down Expand Up @@ -123,15 +123,15 @@

it "should not assign the requested inter_library_loan as @inter_library_loan" do
get :new
assigns(:inter_library_loan).should_not be_valid
assigns(:inter_library_loan).should be_nil
response.should be_forbidden
end
end

describe "When not logged in" do
it "should not assign the requested inter_library_loan as @inter_library_loan" do
get :new
assigns(:inter_library_loan).should_not be_valid
assigns(:inter_library_loan).should be_nil
response.should redirect_to(new_user_session_url)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery

enju_leaf
Expand Down
27 changes: 0 additions & 27 deletions spec/dummy/app/policies/admin_policy.rb

This file was deleted.

41 changes: 0 additions & 41 deletions spec/dummy/app/policies/application_policy.rb

This file was deleted.

3 changes: 3 additions & 0 deletions spec/dummy/config/initializers/resque.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'resque/server'
require 'resque/scheduler/server'
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }

0 comments on commit bafd82f

Please sign in to comment.