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/controllers/import_requests_controller_spec.rb | spec/controllers/import_requests_controller_spec.rb | require 'rails_helper'
require 'sunspot/rails/spec_helper'
describe ImportRequestsController do
fixtures :all
disconnect_sunspot
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all import_requests as @import_requests' do
get :index
expect(assigns(:import_requests)).to eq(ImportRequest.page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all import_requests as @import_requests' do
get :index
expect(assigns(:import_requests)).to eq(ImportRequest.page(1))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns empty as @import_requests' do
get :index
expect(assigns(:import_requests)).to be_nil
end
end
describe 'When not logged in' do
it 'assigns empty as @import_requests' do
get :index
expect(assigns(:import_requests)).to be_nil
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested import_request as @import_request' do
import_request = import_requests(:one)
get :show, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested import_request as @import_request' do
import_request = import_requests(:one)
get :show, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested import_request as @import_request' do
import_request = import_requests(:one)
get :show, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
describe 'When not logged in' do
it 'assigns the requested import_request as @import_request' do
import_request = import_requests(:one)
get :show, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested import_request as @import_request' do
get :new
expect(assigns(:import_request)).to_not be_valid
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested import_request as @import_request' do
get :new
expect(assigns(:import_request)).to_not be_valid
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested import_request as @import_request' do
get :new
expect(assigns(:import_request)).to be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested import_request as @import_request' do
get :new
expect(assigns(:import_request)).to be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested import_request as @import_request' do
import_request = FactoryBot.create(:import_request, isbn: '9784797350999')
get :edit, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested import_request as @import_request' do
import_request = FactoryBot.create(:import_request, isbn: '9784797350999')
get :edit, params: { id: import_request.id }
expect(assigns(:import_request)).to eq(import_request)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested import_request as @import_request' do
import_request = FactoryBot.create(:import_request, isbn: '9784797350999')
get :edit, params: { id: import_request.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested import_request as @import_request' do
import_request = FactoryBot.create(:import_request, isbn: '9784797350999')
get :edit, params: { id: import_request.id }
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = { isbn: '9784873114422' }
@invalid_attrs = { isbn: 'invalid' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params', vcr: true do
it 'assigns a newly created import_request as @import_request' do
post :create, params: { import_request: @attrs }
assigns(:import_request).manifestation.save! # should be_valid
end
it 'redirects to the created import_request' do
post :create, params: { import_request: @attrs }
expect(response).to redirect_to manifestation_url(assigns(:import_request).manifestation)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved import_request as @import_request' do
post :create, params: { import_request: @invalid_attrs }
expect(assigns(:import_request)).to_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { import_request: @invalid_attrs }
expect(response).to render_template('new')
end
end
describe 'with isbn which is already imported', vcr: true do
it 'assigns a newly created import_request as @import_request' do
post :create, params: { import_request: { isbn: manifestations(:manifestation_00001).isbn_records.first.body } }
expect(assigns(:import_request)).to be_valid
end
it 'redirects to the created import_request', vcr: true do
post :create, params: { import_request: @attrs }
expect(response).to redirect_to manifestation_url(assigns(:import_request).manifestation)
end
end
it "should import without errors", vcr: true do
expect { post :create, params: { import_request: { isbn: "0744521815" } } }.not_to raise_error
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params', vcr: true do
it 'assigns a newly created import_request as @import_request' do
post :create, params: { import_request: @attrs }
expect(assigns(:import_request)).to be_valid
end
it 'redirects to the created import_request' do
post :create, params: { import_request: @attrs }
expect(response).to redirect_to manifestation_url(assigns(:import_request).manifestation)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved import_request as @import_request' do
post :create, params: { import_request: @invalid_attrs }
expect(assigns(:import_request)).to_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { import_request: @invalid_attrs }
expect(response).to render_template('new')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created import_request as @import_request' do
post :create, params: { import_request: @attrs }
expect(assigns(:import_request)).to be_nil
end
it 'should be forbidden' do
post :create, params: { import_request: @attrs }
expect(response).to be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved import_request as @import_request' do
post :create, params: { import_request: @invalid_attrs }
expect(assigns(:import_request)).to be_nil
end
it 'should be forbidden' do
post :create, params: { import_request: @invalid_attrs }
expect(response).to be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created import_request as @import_request' do
post :create, params: { import_request: @attrs }
expect(assigns(:import_request)).to be_nil
end
it 'should be forbidden' do
post :create, params: { import_request: @attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved import_request as @import_request' do
post :create, params: { import_request: @invalid_attrs }
expect(assigns(:import_request)).to be_nil
end
it 'should be forbidden' do
post :create, params: { import_request: @invalid_attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@import_request = import_requests(:one)
@attrs = { isbn: '9784797350999' }
@invalid_attrs = { isbn: 'invalid' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
end
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
expect(assigns(:import_request)).to eq(@import_request)
end
end
describe 'with invalid params' do
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @invalid_attrs }
expect(response).to render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
end
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
expect(assigns(:import_request)).to eq(@import_request)
expect(response).to redirect_to(@import_request)
end
end
describe 'with invalid params' do
it 'assigns the import_request as @import_request' do
put :update, params: { id: @import_request, import_request: @invalid_attrs }
expect(assigns(:import_request)).to_not be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @import_request, import_request: @invalid_attrs }
expect(response).to render_template('edit')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
end
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
expect(assigns(:import_request)).to eq(@import_request)
expect(response).to be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @invalid_attrs }
expect(response).to be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested import_request' do
put :update, params: { id: @import_request.id, import_request: @attrs }
end
it 'should be redirected to new session url' do
put :update, params: { id: @import_request.id, import_request: @attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested import_request as @import_request' do
put :update, params: { id: @import_request.id, import_request: @invalid_attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@import_request = import_requests(:one)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested import_request' do
delete :destroy, params: { id: @import_request.id }
end
it 'redirects to the import_requests list' do
delete :destroy, params: { id: @import_request.id }
expect(response).to redirect_to(import_requests_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested import_request' do
delete :destroy, params: { id: @import_request.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @import_request.id }
expect(response).to redirect_to(import_requests_url)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested import_request' do
delete :destroy, params: { id: @import_request.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @import_request.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested import_request' do
delete :destroy, params: { id: @import_request.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @import_request.id }
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/realize_types_controller_spec.rb | spec/controllers/realize_types_controller_spec.rb | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
describe RealizeTypesController do
fixtures :all
login_fixture_admin
# This should return the minimal set of attributes required to create a valid
# RealizeType. As you add validations to RealizeType, be sure to
# update the return value of this method accordingly.
def valid_attributes
FactoryBot.attributes_for(:realize_type)
end
describe 'GET index' do
it 'assigns all realize_types as @realize_types' do
realize_type = RealizeType.create! valid_attributes
get :index
expect(assigns(:realize_types)).to eq(RealizeType.order(:position))
end
end
describe 'GET show' do
it 'assigns the requested realize_type as @realize_type' do
realize_type = RealizeType.create! valid_attributes
get :show, params: { id: realize_type.id }
expect(assigns(:realize_type)).to eq(realize_type)
end
end
describe 'GET new' do
it 'assigns a new realize_type as @realize_type' do
get :new
expect(assigns(:realize_type)).to be_a_new(RealizeType)
end
end
describe 'GET edit' do
it 'assigns the requested realize_type as @realize_type' do
realize_type = RealizeType.create! valid_attributes
get :edit, params: { id: realize_type.id }
expect(assigns(:realize_type)).to eq(realize_type)
end
end
describe 'POST create' do
describe 'with valid params' do
it 'creates a new RealizeType' do
expect do
post :create, params: { realize_type: valid_attributes }
end.to change(RealizeType, :count).by(1)
end
it 'assigns a newly created realize_type as @realize_type' do
post :create, params: { realize_type: valid_attributes }
expect(assigns(:realize_type)).to be_a(RealizeType)
expect(assigns(:realize_type)).to be_persisted
end
it 'redirects to the created realize_type' do
post :create, params: { realize_type: valid_attributes }
expect(response).to redirect_to(RealizeType.last)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved realize_type as @realize_type' do
# Trigger the behavior that occurs when invalid params are submitted
RealizeType.any_instance.stub(:save).and_return(false)
post :create, params: { realize_type: { name: 'test' } }
expect(assigns(:realize_type)).to be_a_new(RealizeType)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
RealizeType.any_instance.stub(:save).and_return(false)
post :create, params: { realize_type: { name: 'test' } }
# expect(response).to render_template("new")
end
end
end
describe 'PUT update' do
describe 'with valid params' do
it 'updates the requested realize_type' do
realize_type = RealizeType.create! valid_attributes
# Assuming there are no other realize_types in the database, this
# specifies that the RealizeType created on the previous line
# receives the :update message with whatever params are
# submitted in the request.
# RealizeType.any_instance.should_receive(:update).with('name' => 'test')
put :update, params: { id: realize_type.id, realize_type: { 'name' => 'test' } }
end
it 'assigns the requested realize_type as @realize_type' do
realize_type = RealizeType.create! valid_attributes
put :update, params: { id: realize_type.id, realize_type: valid_attributes }
expect(assigns(:realize_type)).to eq(realize_type)
end
it 'redirects to the realize_type' do
realize_type = RealizeType.create! valid_attributes
put :update, params: { id: realize_type.id, realize_type: valid_attributes }
expect(response).to redirect_to(realize_type)
end
it 'moves its position when specified' do
realize_type = RealizeType.create! valid_attributes
position = realize_type.position
put :update, params: { id: realize_type.id, move: 'higher' }
expect(response).to redirect_to realize_types_url
assigns(:realize_type).reload.position.should eq position - 1
end
end
describe 'with invalid params' do
it 'assigns the realize_type as @realize_type' do
realize_type = RealizeType.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
RealizeType.any_instance.stub(:save).and_return(false)
put :update, params: { id: realize_type.id, realize_type: { name: 'test' } }
expect(assigns(:realize_type)).to eq(realize_type)
end
it "re-renders the 'edit' template" do
realize_type = RealizeType.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
RealizeType.any_instance.stub(:save).and_return(false)
put :update, params: { id: realize_type.id, realize_type: { name: 'test' } }
# expect(response).to render_template("edit")
end
end
end
describe 'DELETE destroy' do
it 'destroys the requested realize_type' do
realize_type = RealizeType.create! valid_attributes
expect do
delete :destroy, params: { id: realize_type.id }
end.to change(RealizeType, :count).by(-1)
end
it 'redirects to the realize_types list' do
realize_type = RealizeType.create! valid_attributes
delete :destroy, params: { id: realize_type.id }
expect(response).to redirect_to(realize_types_url)
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/controllers/user_export_files_controller_spec.rb | spec/controllers/user_export_files_controller_spec.rb | require 'rails_helper'
describe UserExportFilesController do
fixtures :all
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all user_export_files as @user_export_files' do
get :index
assigns(:user_export_files).should eq(UserExportFile.order('id DESC').page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns empty as @user_export_files' do
get :index
assigns(:user_export_files).should be_nil
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns empty as @user_export_files' do
get :index
assigns(:user_export_files).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'assigns empty as @user_export_files' do
get :index
assigns(:user_export_files).should be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_export_file as @user_export_file' do
get :show, params: { id: user_export_files(:user_export_file_00003).id }
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
expect(response).to be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_export_file as @user_export_file' do
get :show, params: { id: user_export_files(:user_export_file_00003).id }
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_export_file as @user_export_file' do
get :show, params: { id: user_export_files(:user_export_file_00003).id }
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'assigns the requested user_export_file as @user_export_file' do
get :show, params: { id: user_export_files(:user_export_file_00003).id }
assigns(:user_export_file).should eq(user_export_files(:user_export_file_00003))
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_export_file as @user_export_file' do
get :new
assigns(:user_export_file).should be_valid
expect(response).to be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested user_export_file as @user_export_file' do
get :new
assigns(:user_export_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested user_export_file as @user_export_file' do
get :new
assigns(:user_export_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_export_file as @user_export_file' do
get :new
assigns(:user_export_file).should be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should create agent_export_file' do
post :create, params: { user_export_file: { mode: 'export' } }
assigns(:user_export_file).should be_valid
assigns(:user_export_file).user.username.should eq @user.username
expect(response).to redirect_to user_export_file_url(assigns(:user_export_file))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should create agent_export_file' do
post :create, params: { user_export_file: { mode: 'export' } }
assigns(:user_export_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should be forbidden' do
post :create, params: { user_export_file: { mode: 'export' } }
assigns(:user_export_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should be redirected to new session url' do
post :create, params: { user_export_file: { mode: 'export' } }
assigns(:user_export_file).should be_nil
expect(response).to redirect_to new_user_session_url
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_export_file as @user_export_file' do
user_export_file = user_export_files(:user_export_file_00001)
get :edit, params: { id: user_export_file.id }
assigns(:user_export_file).should eq(user_export_file)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_export_file as @user_export_file' do
user_export_file = user_export_files(:user_export_file_00001)
get :edit, params: { id: user_export_file.id }
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_export_file as @user_export_file' do
user_export_file = user_export_files(:user_export_file_00001)
get :edit, params: { id: user_export_file.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_export_file as @user_export_file' do
user_export_file = user_export_files(:user_export_file_00001)
get :edit, params: { id: user_export_file.id }
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'PUT update' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should update user_export_file' do
put :update, params: { id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' } }
expect(response).to redirect_to user_export_file_url(assigns(:user_export_file))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should update user_export_file' do
put :update, params: { id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' } }
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not update user_export_file' do
put :update, params: { id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' } }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not update user_export_file' do
put :update, params: { id: user_export_files(:user_export_file_00003).id, user_export_file: { mode: 'export' } }
expect(response).to redirect_to new_user_session_url
end
end
end
describe 'DELETE destroy' do
before(:each) do
@user_export_file = user_export_files(:user_export_file_00001)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested user_export_file' do
delete :destroy, params: { id: @user_export_file.id }
end
it 'redirects to the user_export_files list' do
delete :destroy, params: { id: @user_export_file.id }
expect(response).to redirect_to(user_export_files_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested user_export_file' do
delete :destroy, params: { id: @user_export_file.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_export_file.id }
expect(response).to be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested user_export_file' do
delete :destroy, params: { id: @user_export_file.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_export_file.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested user_export_file' do
delete :destroy, params: { id: @user_export_file.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_export_file.id }
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/participates_controller_spec.rb | spec/controllers/participates_controller_spec.rb | require 'rails_helper'
require 'sunspot/rails/spec_helper'
describe ParticipatesController do
fixtures :all
disconnect_sunspot
def valid_attributes
FactoryBot.attributes_for(:participate)
end
describe "GET index" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns all participates as @participates" do
get :index
assigns(:participates).should eq(Participate.page(1))
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns all participates as @participates" do
get :index
assigns(:participates).should eq(Participate.page(1))
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns empty as @participates" do
get :index
assigns(:participates).should be_nil
end
end
describe "When not logged in" do
it "assigns empty as @participates" do
get :index
assigns(:participates).should be_nil
end
end
end
describe "GET show" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :show, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :show, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :show, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
describe "When not logged in" do
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :show, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
end
describe "GET new" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested participate as @participate" do
get :new
assigns(:participate).should_not be_valid
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested participate as @participate" do
get :new
assigns(:participate).should_not be_valid
end
end
describe "When logged in as User" do
login_fixture_user
it "should not assign the requested participate as @participate" do
get :new
assigns(:participate).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not assign the requested participate as @participate" do
get :new
assigns(:participate).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET edit" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :edit, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :edit, params: { id: participate.id }
assigns(:participate).should eq(participate)
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :edit, params: { id: participate.id }
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not assign the requested participate as @participate" do
participate = FactoryBot.create(:participate)
get :edit, params: { id: participate.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe "POST create" do
before(:each) do
@attrs = valid_attributes
@invalid_attrs = { event_id: '' }
end
describe "When logged in as Administrator" do
login_fixture_admin
describe "with valid params" do
it "assigns a newly created participate as @participate" do
post :create, params: { participate: @attrs }
assigns(:participate).should be_valid
end
it "redirects to the created participate" do
post :create, params: { participate: @attrs }
response.should redirect_to(participate_url(assigns(:participate)))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved participate as @participate" do
post :create, params: { participate: @invalid_attrs }
assigns(:participate).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { participate: @invalid_attrs }
response.should render_template("new")
end
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
describe "with valid params" do
it "assigns a newly created participate as @participate" do
post :create, params: { participate: @attrs }
assigns(:participate).should be_valid
end
it "redirects to the created participate" do
post :create, params: { participate: @attrs }
response.should redirect_to(participate_url(assigns(:participate)))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved participate as @participate" do
post :create, params: { participate: @invalid_attrs }
assigns(:participate).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { participate: @invalid_attrs }
response.should render_template("new")
end
end
end
describe "When logged in as User" do
login_fixture_user
describe "with valid params" do
it "assigns a newly created participate as @participate" do
post :create, params: { participate: @attrs }
assigns(:participate).should be_nil
end
it "should be forbidden" do
post :create, params: { participate: @attrs }
response.should be_forbidden
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved participate as @participate" do
post :create, params: { participate: @invalid_attrs }
assigns(:participate).should be_nil
end
it "should be forbidden" do
post :create, params: { participate: @invalid_attrs }
response.should be_forbidden
end
end
end
describe "When not logged in" do
describe "with valid params" do
it "assigns a newly created participate as @participate" do
post :create, params: { participate: @attrs }
assigns(:participate).should be_nil
end
it "should be forbidden" do
post :create, params: { participate: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved participate as @participate" do
post :create, params: { participate: @invalid_attrs }
assigns(:participate).should be_nil
end
it "should be forbidden" do
post :create, params: { participate: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe "PUT update" do
before(:each) do
@participate = FactoryBot.create(:participate)
@attrs = valid_attributes
@invalid_attrs = { event_id: '' }
end
describe "When logged in as Administrator" do
login_fixture_admin
describe "with valid params" do
it "updates the requested participate" do
put :update, params: { id: @participate.id, participate: @attrs }
end
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @attrs }
assigns(:participate).should eq(@participate)
response.should redirect_to(@participate)
end
end
describe "with invalid params" do
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
end
it "re-renders the 'edit' template" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
response.should render_template("edit")
end
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
describe "with valid params" do
it "updates the requested participate" do
put :update, params: { id: @participate.id, participate: @attrs }
end
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @attrs }
assigns(:participate).should eq(@participate)
response.should redirect_to(@participate)
end
end
describe "with invalid params" do
it "assigns the participate as @participate" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
assigns(:participate).should_not be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
response.should render_template("edit")
end
end
end
describe "When logged in as User" do
login_fixture_user
describe "with valid params" do
it "updates the requested participate" do
put :update, params: { id: @participate.id, participate: @attrs }
end
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @attrs }
assigns(:participate).should eq(@participate)
response.should be_forbidden
end
end
describe "with invalid params" do
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
response.should be_forbidden
end
end
end
describe "When not logged in" do
describe "with valid params" do
it "updates the requested participate" do
put :update, params: { id: @participate.id, participate: @attrs }
end
it "should be forbidden" do
put :update, params: { id: @participate.id, participate: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe "with invalid params" do
it "assigns the requested participate as @participate" do
put :update, params: { id: @participate.id, participate: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe "DELETE destroy" do
before(:each) do
@participate = FactoryBot.create(:participate)
end
describe "When logged in as Administrator" do
login_fixture_admin
it "destroys the requested participate" do
delete :destroy, params: { id: @participate.id }
end
it "redirects to the participates list" do
delete :destroy, params: { id: @participate.id }
response.should redirect_to(participates_url)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "destroys the requested participate" do
delete :destroy, params: { id: @participate.id }
end
it "redirects to the participates list" do
delete :destroy, params: { id: @participate.id }
response.should redirect_to(participates_url)
end
end
describe "When logged in as User" do
login_fixture_user
it "destroys the requested participate" do
delete :destroy, params: { id: @participate.id }
end
it "should be forbidden" do
delete :destroy, params: { id: @participate.id }
response.should be_forbidden
end
end
describe "When not logged in" do
it "destroys the requested participate" do
delete :destroy, params: { id: @participate.id }
end
it "should be forbidden" do
delete :destroy, params: { id: @participate.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/event_export_files_controller_spec.rb | spec/controllers/event_export_files_controller_spec.rb | require 'rails_helper'
describe EventExportFilesController do
fixtures :all
describe "GET index" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns all event_export_files as @event_export_files" do
get :index
assigns(:event_export_files).should eq(EventExportFile.order('id DESC').page(1))
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns all event_export_files as @event_export_files" do
get :index
assigns(:event_export_files).should eq(EventExportFile.order('id DESC').page(1))
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns empty as @event_export_files" do
get :index
assigns(:event_export_files).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "assigns empty as @event_export_files" do
get :index
assigns(:event_export_files).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET show" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested event_export_file as @event_export_file" do
get :show, params: { id: event_export_files(:event_export_file_00003).id }
assigns(:event_export_file).should eq(event_export_files(:event_export_file_00003))
response.should be_successful
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested event_export_file as @event_export_file" do
get :show, params: { id: event_export_files(:event_export_file_00003).id }
assigns(:event_export_file).should eq(event_export_files(:event_export_file_00003))
response.should be_successful
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested event_export_file as @event_export_file" do
get :show, params: { id: event_export_files(:event_export_file_00003).id }
assigns(:event_export_file).should eq(event_export_files(:event_export_file_00003))
response.should be_forbidden
end
end
describe "When not logged in" do
it "assigns the requested event_export_file as @event_export_file" do
get :show, params: { id: event_export_files(:event_export_file_00003).id }
assigns(:event_export_file).should eq(event_export_files(:event_export_file_00003))
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET new" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested event_export_file as @event_export_file" do
get :new
assigns(:event_export_file).should be_valid
response.should be_successful
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "should not assign the requested event_export_file as @event_export_file" do
get :new
assigns(:event_export_file).should be_valid
response.should be_successful
end
end
describe "When logged in as User" do
login_fixture_user
it "should not assign the requested event_export_file as @event_export_file" do
get :new
assigns(:event_export_file).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not assign the requested event_export_file as @event_export_file" do
get :new
assigns(:event_export_file).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "POST create" do
describe "When logged in as Librarian" do
login_fixture_librarian
it "should create agent_export_file" do
post :create, params: { event_export_file: { event_export_file_name: 'test.txt' } }
assigns(:event_export_file).should be_valid
assigns(:event_export_file).user.username.should eq @user.username
response.should redirect_to event_export_file_url(assigns(:event_export_file))
end
end
describe "When logged in as User" do
login_fixture_user
it "should be forbidden" do
post :create, params: { event_export_file: { event_export_file_name: 'test.txt' } }
assigns(:event_export_file).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "should be redirected to new session url" do
post :create, params: { event_export_file: { event_export_file_name: 'test.txt' } }
assigns(:event_export_file).should be_nil
response.should redirect_to new_user_session_url
end
end
end
describe "GET edit" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested event_export_file as @event_export_file" do
event_export_file = event_export_files(:event_export_file_00001)
get :edit, params: { id: event_export_file.id }
assigns(:event_export_file).should eq(event_export_file)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested event_export_file as @event_export_file" do
event_export_file = event_export_files(:event_export_file_00001)
get :edit, params: { id: event_export_file.id }
assigns(:event_export_file).should eq(event_export_file)
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested event_export_file as @event_export_file" do
event_export_file = event_export_files(:event_export_file_00001)
get :edit, params: { id: event_export_file.id }
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not assign the requested event_export_file as @event_export_file" do
event_export_file = event_export_files(:event_export_file_00001)
get :edit, params: { id: event_export_file.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe "PUT update" do
describe "When logged in as Administrator" do
login_fixture_admin
it "should update event_export_file" do
put :update, params: { id: event_export_files(:event_export_file_00003).id, event_export_file: { event_export_file_name: 'test.txt' } }
response.should redirect_to event_export_file_url(assigns(:event_export_file))
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "should update event_export_file" do
put :update, params: { id: event_export_files(:event_export_file_00003).id, event_export_file: { event_export_file_name: 'test.txt' } }
response.should redirect_to event_export_file_url(assigns(:event_export_file))
end
end
describe "When logged in as User" do
login_fixture_user
it "should not update event_export_file" do
put :update, params: { id: event_export_files(:event_export_file_00003).id, event_export_file: {} }
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not update event_export_file" do
put :update, params: { id: event_export_files(:event_export_file_00003).id, event_export_file: {} }
response.should redirect_to new_user_session_url
end
end
end
describe "DELETE destroy" do
before(:each) do
@event_export_file = event_export_files(:event_export_file_00001)
end
describe "When logged in as Administrator" do
login_fixture_admin
it "destroys the requested event_export_file" do
delete :destroy, params: { id: @event_export_file.id }
end
it "redirects to the event_export_files list" do
delete :destroy, params: { id: @event_export_file.id }
response.should redirect_to(event_export_files_url)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "destroys the requested event_export_file" do
delete :destroy, params: { id: @event_export_file.id }
end
it "redirects to the event_export_files list" do
delete :destroy, params: { id: @event_export_file.id }
response.should redirect_to(event_export_files_url)
end
end
describe "When logged in as User" do
login_fixture_user
it "destroys the requested event_export_file" do
delete :destroy, params: { id: @event_export_file.id }
end
it "should be forbidden" do
delete :destroy, params: { id: @event_export_file.id }
response.should be_forbidden
end
end
describe "When not logged in" do
it "destroys the requested event_export_file" do
delete :destroy, params: { id: @event_export_file.id }
end
it "should be forbidden" do
delete :destroy, params: { id: @event_export_file.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/carrier_types_controller_spec.rb | spec/controllers/carrier_types_controller_spec.rb | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
describe CarrierTypesController do
fixtures :all
# This should return the minimal set of attributes required to create a valid
# CarrierType. As you add validations to CarrierType, be sure to
# update the return value of this method accordingly.
def valid_attributes
FactoryBot.attributes_for(:carrier_type)
end
context 'When logged in as Administrator' do
login_fixture_admin
describe 'GET index' do
it 'assigns all carrier_types as @carrier_types' do
carrier_type = CarrierType.create! valid_attributes
get :index
expect(assigns(:carrier_types)).to eq(CarrierType.order(:position).page(1))
end
end
describe 'GET show' do
it 'assigns the requested carrier_type as @carrier_type' do
carrier_type = CarrierType.create! valid_attributes
get :show, params: { id: carrier_type.id }
expect(assigns(:carrier_type)).to eq(carrier_type)
end
end
describe 'GET new' do
it 'assigns a new carrier_type as @carrier_type' do
get :new
expect(assigns(:carrier_type)).to be_a_new(CarrierType)
end
end
describe 'GET edit' do
it 'assigns the requested carrier_type as @carrier_type' do
carrier_type = CarrierType.create! valid_attributes
get :edit, params: { id: carrier_type.id }
expect(assigns(:carrier_type)).to eq(carrier_type)
end
end
describe 'POST create' do
describe 'with valid params' do
it 'creates a new CarrierType' do
expect do
post :create, params: { carrier_type: valid_attributes }
end.to change(CarrierType, :count).by(1)
end
it 'assigns a newly created carrier_type as @carrier_type' do
post :create, params: { carrier_type: valid_attributes }
expect(assigns(:carrier_type)).to be_a(CarrierType)
expect(assigns(:carrier_type)).to be_persisted
end
it 'redirects to the created carrier_type' do
post :create, params: { carrier_type: valid_attributes }
expect(response).to redirect_to(CarrierType.last)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved carrier_type as @carrier_type' do
# Trigger the behavior that occurs when invalid params are submitted
CarrierType.any_instance.stub(:save).and_return(false)
post :create, params: { carrier_type: { name: 'test' } }
expect(assigns(:carrier_type)).to be_a_new(CarrierType)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
CarrierType.any_instance.stub(:save).and_return(false)
post :create, params: { carrier_type: { name: 'test' } }
expect(response).to render_template('new')
end
end
end
describe 'PUT update' do
describe 'with valid params' do
it 'updates the requested carrier_type' do
carrier_type = CarrierType.create! valid_attributes
# Assuming there are no other carrier_types in the database, this
# specifies that the CarrierType created on the previous line
# receives the :update message with whatever params are
# submitted in the request.
# CarrierType.any_instance.should_receive(:update).with('name' => 'test')
put :update, params: { id: carrier_type.id, carrier_type: { 'name' => 'test' } }
end
it 'assigns the requested carrier_type as @carrier_type' do
carrier_type = CarrierType.create! valid_attributes
put :update, params: { id: carrier_type.id, carrier_type: valid_attributes }
expect(assigns(:carrier_type)).to eq(carrier_type)
end
it 'redirects to the carrier_type' do
carrier_type = CarrierType.create! valid_attributes
put :update, params: { id: carrier_type.id, carrier_type: valid_attributes }
expect(response).to redirect_to(carrier_type)
end
it 'moves its position when specified' do
carrier_type = CarrierType.create! valid_attributes
position = carrier_type.position
put :update, params: { id: carrier_type.id, move: 'higher' }
expect(response).to redirect_to carrier_types_url
assigns(:carrier_type).reload.position.should eq position - 1
end
it 'deletes an attachment file' do
carrier_type = carrier_types(:carrier_type_00001)
carrier_type.attachment.attach(io: File.open(Rails.root.join('app/assets/images/icons/book.png')), filename: 'book.png')
carrier_type.save
expect(carrier_type.attachment.present?).to be_truthy
put :update, params: { id: carrier_type.id, carrier_type: { delete_attachment: '1' } }
expect(assigns(:carrier_type).attachment.present?).to be_falsy
end
end
describe 'with invalid params' do
it 'assigns the carrier_type as @carrier_type' do
carrier_type = CarrierType.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
CarrierType.any_instance.stub(:save).and_return(false)
put :update, params: { id: carrier_type.id, carrier_type: { name: 'test' } }
expect(assigns(:carrier_type)).to eq(carrier_type)
end
it "re-renders the 'edit' template" do
carrier_type = CarrierType.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
CarrierType.any_instance.stub(:save).and_return(false)
put :update, params: { id: carrier_type.id, carrier_type: { name: 'test' } }
expect(response).to render_template('edit')
end
end
end
describe 'DELETE destroy' do
it 'destroys the requested carrier_type' do
carrier_type = CarrierType.create! valid_attributes
expect do
delete :destroy, params: { id: carrier_type.id }
end.to change(CarrierType, :count).by(-1)
end
it 'redirects to the carrier_types list' do
carrier_type = CarrierType.create! valid_attributes
delete :destroy, params: { id: carrier_type.id }
expect(response).to redirect_to(carrier_types_url)
end
end
end
context 'When not logged in' do
describe 'GET show' do
it 'assigns the requested carrier_type as @carrier_type' do
carrier_type = CarrierType.create! valid_attributes
get :show, params: { id: carrier_type.id }
expect(assigns(:carrier_type)).to eq(carrier_type)
expect(response).to redirect_to(new_user_session_url)
end
it 'assigns the requested carrier_type as @carrier_type when the format is download' do
carrier_type = CarrierType.create! valid_attributes
expect {
get :show, params: { id: carrier_type.id, format: :download }
}.to raise_error(ActionController::UnknownFormat)
#expect(assigns(:carrier_type)).to raise_error(ActionView::MissingTemplate)
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/spec/controllers/subject_types_controller_spec.rb | spec/controllers/subject_types_controller_spec.rb | require 'rails_helper'
require 'sunspot/rails/spec_helper'
describe SubjectTypesController do
fixtures :all
disconnect_sunspot
def valid_attributes
FactoryBot.attributes_for(:subject_type)
end
describe 'GET index' do
before(:each) do
FactoryBot.create(:subject_type)
end
describe 'When logged in as Administrator' do
login_admin
it 'assigns all subject_types as @subject_types' do
get :index
expect(assigns(:subject_types)).to eq(SubjectType.order(:position))
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns all subject_types as @subject_types' do
get :index
expect(assigns(:subject_types)).to eq(SubjectType.order(:position))
end
end
describe 'When logged in as User' do
login_user
it 'assigns all subject_types as @subject_types' do
get :index
expect(assigns(:subject_types)).to be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns all subject_types as @subject_types' do
get :index
expect(assigns(:subject_types)).to be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :show, params: { id: subject_type.id }
expect(assigns(:subject_type)).to eq(subject_type)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :show, params: { id: subject_type.id }
expect(assigns(:subject_type)).to eq(subject_type)
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :show, params: { id: subject_type.id }
expect(assigns(:subject_type)).to eq(subject_type)
end
end
describe 'When not logged in' do
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :show, params: { id: subject_type.id }
expect(assigns(:subject_type)).to eq(subject_type)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested subject_type as @subject_type' do
get :new
expect(assigns(:subject_type)).not_to be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'should not assign the requested subject_type as @subject_type' do
get :new
expect(assigns(:subject_type)).to be_nil
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_user
it 'should not assign the requested subject_type as @subject_type' do
get :new
expect(assigns(:subject_type)).to be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested subject_type as @subject_type' do
get :new
expect(assigns(:subject_type)).to be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :edit, params: { id: subject_type.id }
expect(assigns(:subject_type)).to eq(subject_type)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :edit, params: { id: subject_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :edit, params: { id: subject_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested subject_type as @subject_type' do
subject_type = FactoryBot.create(:subject_type)
get :edit, params: { id: subject_type.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = valid_attributes
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'assigns a newly created subject_type as @subject_type' do
post :create, params: { subject_type: @attrs }
expect(assigns(:subject_type)).to be_valid
end
it 'redirects to the created agent' do
post :create, params: { subject_type: @attrs }
response.should redirect_to(assigns(:subject_type))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved subject_type as @subject_type' do
post :create, params: { subject_type: @invalid_attrs }
expect(assigns(:subject_type)).not_to be_valid
end
it 'should be successful' do
post :create, params: { subject_type: @invalid_attrs }
response.should be_successful
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'assigns a newly created subject_type as @subject_type' do
post :create, params: { subject_type: @attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved subject_type as @subject_type' do
post :create, params: { subject_type: @invalid_attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'assigns a newly created subject_type as @subject_type' do
post :create, params: { subject_type: @attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved subject_type as @subject_type' do
post :create, params: { subject_type: @invalid_attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created subject_type as @subject_type' do
post :create, params: { subject_type: @attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved subject_type as @subject_type' do
post :create, params: { subject_type: @invalid_attrs }
expect(assigns(:subject_type)).to be_nil
end
it 'should be forbidden' do
post :create, params: { subject_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@subject_type = FactoryBot.create(:subject_type)
@attrs = valid_attributes
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'updates the requested subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
end
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
expect(assigns(:subject_type)).to eq(@subject_type)
end
it 'moves its position when specified' do
put :update, params: { id: @subject_type.id, subject_type: @attrs, move: 'lower' }
response.should redirect_to(subject_types_url)
end
end
describe 'with invalid params' do
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'updates the requested subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
end
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
expect(assigns(:subject_type)).to eq(@subject_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'updates the requested subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
end
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
expect(assigns(:subject_type)).to eq(@subject_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @subject_type.id, subject_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested subject_type as @subject_type' do
put :update, params: { id: @subject_type.id, subject_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@subject_type = FactoryBot.create(:subject_type)
end
describe 'When logged in as Administrator' do
login_admin
it 'destroys the requested subject_type' do
delete :destroy, params: { id: @subject_type.id }
end
it 'redirects to the subject_types list' do
delete :destroy, params: { id: @subject_type.id }
response.should redirect_to(subject_types_url)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'destroys the requested subject_type' do
delete :destroy, params: { id: @subject_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @subject_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_user
it 'destroys the requested subject_type' do
delete :destroy, params: { id: @subject_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @subject_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested subject_type' do
delete :destroy, params: { id: @subject_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @subject_type.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/user_checkout_stats_controller_spec.rb | spec/controllers/user_checkout_stats_controller_spec.rb | require 'rails_helper'
describe UserCheckoutStatsController do
fixtures :all
describe 'GET index' do
before(:each) do
FactoryBot.create(:user_checkout_stat)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all user_checkout_stats as @user_checkout_stats' do
get :index
assigns(:user_checkout_stats).should eq(UserCheckoutStat.order('id DESC').page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all user_checkout_stats as @user_checkout_stats' do
get :index
assigns(:user_checkout_stats).should eq(UserCheckoutStat.order('id DESC').page(1))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns all user_checkout_stats as @user_checkout_stats' do
get :index
assigns(:user_checkout_stats).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign user_checkout_stats as @user_checkout_stats' do
get :index
assigns(:user_checkout_stats).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :show, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :show, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :show, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :show, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
get :new
assigns(:user_checkout_stat).should_not be_valid
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
get :new
assigns(:user_checkout_stat).should_not be_valid
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested user_checkout_stat as @user_checkout_stat' do
get :new
assigns(:user_checkout_stat).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_checkout_stat as @user_checkout_stat' do
get :new
assigns(:user_checkout_stat).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :edit, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :edit, params: { id: user_checkout_stat.id }
assigns(:user_checkout_stat).should eq(user_checkout_stat)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :edit, params: { id: user_checkout_stat.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_checkout_stat as @user_checkout_stat' do
user_checkout_stat = FactoryBot.create(:user_checkout_stat)
get :edit, params: { id: user_checkout_stat.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = FactoryBot.attributes_for(:user_checkout_stat)
@invalid_attrs = { start_date: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should be_valid
end
it 'redirects to the created user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
response.should redirect_to(user_checkout_stat_url(assigns(:user_checkout_stat)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @invalid_attrs }
assigns(:user_checkout_stat).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { user_checkout_stat: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should be_valid
end
it 'redirects to the created user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
response.should redirect_to(user_checkout_stat_url(assigns(:user_checkout_stat)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @invalid_attrs }
assigns(:user_checkout_stat).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { user_checkout_stat: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should be_nil
end
it 'should be forbidden' do
post :create, params: { user_checkout_stat: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @invalid_attrs }
assigns(:user_checkout_stat).should be_nil
end
it 'should be forbidden' do
post :create, params: { user_checkout_stat: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should be_nil
end
it 'should be forbidden' do
post :create, params: { user_checkout_stat: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved user_checkout_stat as @user_checkout_stat' do
post :create, params: { user_checkout_stat: @invalid_attrs }
assigns(:user_checkout_stat).should be_nil
end
it 'should be forbidden' do
post :create, params: { user_checkout_stat: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@user_checkout_stat = FactoryBot.create(:user_checkout_stat)
@attrs = FactoryBot.attributes_for(:user_checkout_stat)
@invalid_attrs = { start_date: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
end
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should eq(@user_checkout_stat)
end
end
describe 'with invalid params' do
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
end
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should eq(@user_checkout_stat)
response.should redirect_to(@user_checkout_stat)
end
end
describe 'with invalid params' do
it 'assigns the user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat, user_checkout_stat: @invalid_attrs }
assigns(:user_checkout_stat).should_not be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @user_checkout_stat, user_checkout_stat: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
end
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
assigns(:user_checkout_stat).should eq(@user_checkout_stat)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested user_checkout_stat as @user_checkout_stat' do
put :update, params: { id: @user_checkout_stat.id, user_checkout_stat: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@user_checkout_stat = FactoryBot.create(:user_checkout_stat)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested user_checkout_stat' do
delete :destroy, params: { id: @user_checkout_stat.id }
end
it 'redirects to the user_checkout_stats list' do
delete :destroy, params: { id: @user_checkout_stat.id }
response.should redirect_to(user_checkout_stats_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested user_checkout_stat' do
delete :destroy, params: { id: @user_checkout_stat.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_checkout_stat.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested user_checkout_stat' do
delete :destroy, params: { id: @user_checkout_stat.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_checkout_stat.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested user_checkout_stat' do
delete :destroy, params: { id: @user_checkout_stat.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_checkout_stat.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/search_engines_controller_spec.rb | spec/controllers/search_engines_controller_spec.rb | require 'rails_helper'
require 'sunspot/rails/spec_helper'
describe SearchEnginesController do
fixtures :all
disconnect_sunspot
def valid_attributes
FactoryBot.attributes_for(:search_engine)
end
describe 'GET index' do
before(:each) do
FactoryBot.create(:search_engine)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all search_engines as @search_engines' do
get :index
assigns(:search_engines).should eq(SearchEngine.order(:position))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all search_engines as @search_engines' do
get :index
assigns(:search_engines).should eq(SearchEngine.order(:position))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns all search_engines as @search_engines' do
get :index
assigns(:search_engines).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns all search_engines as @search_engines' do
get :index
assigns(:search_engines).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :show, params: { id: search_engine.id }
assigns(:search_engine).should eq(search_engine)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :show, params: { id: search_engine.id }
assigns(:search_engine).should eq(search_engine)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :show, params: { id: search_engine.id }
assigns(:search_engine).should eq(search_engine)
end
end
describe 'When not logged in' do
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :show, params: { id: search_engine.id }
assigns(:search_engine).should eq(search_engine)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested search_engine as @search_engine' do
get :new
assigns(:search_engine).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested search_engine as @search_engine' do
get :new
assigns(:search_engine).should be_nil
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested search_engine as @search_engine' do
get :new
assigns(:search_engine).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested search_engine as @search_engine' do
get :new
assigns(:search_engine).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :edit, params: { id: search_engine.id }
assigns(:search_engine).should eq(search_engine)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :edit, params: { id: search_engine.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :edit, params: { id: search_engine.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested search_engine as @search_engine' do
search_engine = FactoryBot.create(:search_engine)
get :edit, params: { id: search_engine.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = valid_attributes
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created search_engine as @search_engine' do
post :create, params: { search_engine: @attrs }
assigns(:search_engine).should be_valid
end
it 'redirects to the created patron' do
post :create, params: { search_engine: @attrs }
response.should redirect_to(assigns(:search_engine))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved search_engine as @search_engine' do
post :create, params: { search_engine: @invalid_attrs }
assigns(:search_engine).should_not be_valid
end
it 'should be successful' do
post :create, params: { search_engine: @invalid_attrs }
response.should be_successful
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created search_engine as @search_engine' do
post :create, params: { search_engine: @attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved search_engine as @search_engine' do
post :create, params: { search_engine: @invalid_attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created search_engine as @search_engine' do
post :create, params: { search_engine: @attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved search_engine as @search_engine' do
post :create, params: { search_engine: @invalid_attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created search_engine as @search_engine' do
post :create, params: { search_engine: @attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved search_engine as @search_engine' do
post :create, params: { search_engine: @invalid_attrs }
assigns(:search_engine).should be_nil
end
it 'should be forbidden' do
post :create, params: { search_engine: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@search_engine = FactoryBot.create(:search_engine)
@attrs = valid_attributes
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
end
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
assigns(:search_engine).should eq(@search_engine)
end
it 'moves its position when specified' do
put :update, params: { id: @search_engine.id, search_engine: @attrs, move: 'lower' }
response.should redirect_to(search_engines_url)
end
end
describe 'with invalid params' do
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
end
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
assigns(:search_engine).should eq(@search_engine)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
end
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
assigns(:search_engine).should eq(@search_engine)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @search_engine.id, search_engine: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested search_engine as @search_engine' do
put :update, params: { id: @search_engine.id, search_engine: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@search_engine = FactoryBot.create(:search_engine)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested search_engine' do
delete :destroy, params: { id: @search_engine.id }
end
it 'redirects to the search_engines list' do
delete :destroy, params: { id: @search_engine.id }
response.should redirect_to(search_engines_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested search_engine' do
delete :destroy, params: { id: @search_engine.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @search_engine.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested search_engine' do
delete :destroy, params: { id: @search_engine.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @search_engine.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested search_engine' do
delete :destroy, params: { id: @search_engine.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @search_engine.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/my_accounts_controller_spec.rb | spec/controllers/my_accounts_controller_spec.rb | require 'rails_helper'
describe MyAccountsController do
fixtures :all
describe "GET show" do
describe "When logged in as Administrator" do
before(:each) do
sign_in User.friendly.find('enjuadmin')
end
it "assigns the requested user as @user" do
get :show, params: { id: 'admin' }
expect(response).to be_successful
end
end
describe "When not logged in" do
it "assigns the requested user as @user" do
get :show, params: { id: 'admin' }
expect(assigns(:user)).to be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe "GET edit" do
describe "When logged in as Administrator" do
before(:each) do
@user = FactoryBot.create(:admin)
sign_in @user
end
it "assigns the requested user as @user" do
get :edit
expect(assigns(:profile)).to eq(@user.profile)
end
end
describe "When logged in as Librarian" do
before(:each) do
@user = FactoryBot.create(:librarian)
sign_in @user
end
it "should assign the requested user as @user" do
get :edit
expect(assigns(:profile)).to eq(@user.profile)
end
end
describe "When logged in as User" do
before(:each) do
@user = FactoryBot.create(:user)
sign_in @user
end
it "should assign the requested user as @user" do
get :edit
expect(assigns(:profile)).to eq(@user.profile)
expect(response).to be_successful
end
end
describe "When not logged in" do
it "should not assign the requested user as @user" do
get :edit
expect(assigns(:user)).to be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe "PUT update" do
before(:each) do
@attrs = { user_attributes: { email: 'newaddress@example.jp', current_password: 'password' }, locale: 'en' }
@invalid_attrs = { user_attributes: { username: '' }, user_number: '日本語' }
@invalid_passwd_attrs = { user_attributes: { current_password: '' } }
end
describe "When logged in as Administrator" do
before(:each) do
@user = FactoryBot.create(:admin, password: 'password', password_confirmation: 'password')
sign_in @user
end
describe "with valid params" do
it "updates the requested user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
end
it "assigns the requested user as @user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
expect(assigns(:profile)).to eq(@user.profile)
end
it "redirects to the user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
expect(assigns(:profile)).to eq(@user.profile)
expect(response).to redirect_to(my_account_url)
end
end
describe "with invalid params" do
it "assigns the requested user as @user" do
put :update, params: { profile: @invalid_attrs }
expect(assigns(:profile)).to eq(@user.profile)
end
it "re-renders the 'edit' template" do
put :update, params: { profile: @invalid_attrs }
expect(response).to render_template("edit")
end
end
# describe "with invalid password params" do
# it "assigns the requested user as @user" do
# put :update, profile: @invalid_passwd_attrs
# expect(assigns(:profile).errors).not_to be_blank
# end
# end
end
describe "When logged in as Librarian" do
before(:each) do
@user = FactoryBot.create(:librarian, password: 'password', password_confirmation: 'password')
sign_in @user
end
describe "with valid params" do
it "updates the requested user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
end
it "assigns the requested user as @user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
expect(assigns(:profile)).to eq(@user.profile)
end
it "redirects to the user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
expect(assigns(:profile)).to eq(@user.profile)
expect(response).to redirect_to(my_account_url)
end
end
describe "with invalid params" do
it "assigns the user as @user" do
put :update, params: { profile: @invalid_attrs }
expect(assigns(:profile)).to_not be_valid
expect(response).to be_successful
end
it "should ignore username" do
put :update, params: { profile: @invalid_attrs }
expect(response).to render_template("edit")
expect(assigns(:profile).changed?).to be_truthy
end
end
end
describe "When logged in as User" do
before(:each) do
@user = FactoryBot.create(:user, password: 'password', password_confirmation: 'password')
sign_in @user
end
describe "with valid params" do
it "updates the requested user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
end
it "assigns the requested user as @user" do
@attrs[:user_attributes][:id] = @user.id
put :update, params: { profile: @attrs }
expect(assigns(:profile)).to eq(@user.profile)
expect(response).to redirect_to(my_account_url)
end
end
describe "with invalid params" do
it "assigns the requested user as @user" do
put :update, params: { profile: @invalid_attrs }
expect(assigns(:profile).user.username).to eq(@user.username)
expect(response).to redirect_to(my_account_url)
end
end
end
describe "When not logged in" do
describe "with valid params" do
it "updates the requested user" do
put :update, params: { profile: @attrs }
end
it "should be forbidden" do
put :update, params: { profile: @attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
describe "with invalid params" do
it "assigns the requested user as @user" do
put :update, params: { profile: @invalid_attrs }
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/classifications_controller_spec.rb | spec/controllers/classifications_controller_spec.rb | require 'rails_helper'
describe ClassificationsController do
fixtures :all
def valid_attributes
FactoryBot.attributes_for(:classification)
end
describe 'GET index', solr: true do
before do
Classification.reindex
end
describe 'When logged in as Administrator' do
login_admin
it 'assigns all classifications as @classifications' do
get :index
expect(assigns(:classifications)).not_to be_empty
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns all classifications as @classifications' do
get :index
expect(assigns(:classifications)).not_to be_empty
end
end
describe 'When logged in as User' do
login_user
it 'assigns all classifications as @classifications' do
get :index
expect(assigns(:classifications)).not_to be_empty
end
end
describe 'When not logged in' do
it 'assigns all classifications as @classifications' do
get :index
expect(assigns(:classifications)).not_to be_empty
end
it 'should get index with query' do
get :index, params: { query: '500' }
response.should be_successful
expect(assigns(:classifications)).not_to be_empty
end
end
end
describe 'GET show' do
before(:each) do
@classification = FactoryBot.create(:classification)
end
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested classification as @classification' do
get :show, params: { id: @classification.id }
expect(assigns(:classification)).to eq(@classification)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested classification as @classification' do
get :show, params: { id: @classification.id }
expect(assigns(:classification)).to eq(@classification)
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested classification as @classification' do
get :show, params: { id: @classification.id }
expect(assigns(:classification)).to eq(@classification)
end
end
describe 'When not logged in' do
it 'assigns the requested classification as @classification' do
get :show, params: { id: @classification.id }
expect(assigns(:classification)).to eq(@classification)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested classification as @classification' do
get :new
expect(assigns(:classification)).not_to be_valid
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested classification as @classification' do
get :new
expect(assigns(:classification)).to be_nil
end
end
describe 'When logged in as User' do
login_user
it 'should assign the requested classification as @classification' do
get :new
expect(assigns(:classification)).to be_nil
end
end
describe 'When not logged in' do
it 'should not assign the requested classification as @classification' do
get :new
expect(assigns(:classification)).to be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested classification as @classification' do
classification = FactoryBot.create(:classification)
get :edit, params: { id: classification.id }
expect(assigns(:classification)).to eq(classification)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested classification as @classification' do
classification = FactoryBot.create(:classification)
get :edit, params: { id: classification.id }
expect(assigns(:classification)).to eq(classification)
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested classification as @classification' do
classification = FactoryBot.create(:classification)
get :edit, params: { id: classification.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested classification as @classification' do
classification = FactoryBot.create(:classification)
get :edit, params: { id: classification.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = valid_attributes
@invalid_attrs = { category: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'assigns a newly created classification as @classification' do
post :create, params: { classification: @attrs }
expect(assigns(:classification)).to be_valid
end
it 'redirects to the created classification' do
post :create, params: { classification: @attrs }
response.should redirect_to(classification_url(assigns(:classification)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved classification as @classification' do
post :create, params: { classification: @invalid_attrs }
expect(assigns(:classification)).not_to be_valid
end
it "re-renders the 'new' template" do
post :create, params: { classification: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'assigns a newly created classification as @classification' do
post :create, params: { classification: @attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved classification as @classification' do
post :create, params: { classification: @invalid_attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'assigns a newly created classification as @classification' do
post :create, params: { classification: @attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved classification as @classification' do
post :create, params: { classification: @invalid_attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created classification as @classification' do
post :create, params: { classification: @attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved classification as @classification' do
post :create, params: { classification: @invalid_attrs }
expect(assigns(:classification)).to be_nil
end
it 'should be forbidden' do
post :create, params: { classification: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@classification = FactoryBot.create(:classification)
@attrs = valid_attributes
@invalid_attrs = { category: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'updates the requested classification' do
put :update, params: { id: @classification.id, classification: @attrs }
end
it 'assigns the requested classification as @classification' do
put :update, params: { id: @classification.id, classification: @attrs }
expect(assigns(:classification)).to eq(@classification)
end
end
describe 'with invalid params' do
it 'assigns the requested classification as @classification' do
put :update, params: { id: @classification.id, classification: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'updates the requested classification' do
put :update, params: { id: @classification.id, classification: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @classification.id, classification: @attrs }
expect(assigns(:classification)).to eq(@classification)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'should be forbidden' do
put :update, params: { id: @classification, classification: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'updates the requested classification' do
put :update, params: { id: @classification.id, classification: @attrs }
end
it 'assigns the requested classification as @classification' do
put :update, params: { id: @classification.id, classification: @attrs }
expect(assigns(:classification)).to eq(@classification)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested classification as @classification' do
put :update, params: { id: @classification.id, classification: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested classification' do
put :update, params: { id: @classification.id, classification: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @classification.id, classification: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested classification as @classification' do
put :update, params: { id: @classification.id, classification: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@classification = FactoryBot.create(:classification)
end
describe 'When logged in as Administrator' do
login_admin
it 'destroys the requested classification' do
delete :destroy, params: { id: @classification.id }
end
it 'redirects to the classifications list' do
delete :destroy, params: { id: @classification.id }
response.should redirect_to(classifications_url)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'destroys the requested classification' do
delete :destroy, params: { id: @classification.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @classification.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_user
it 'destroys the requested classification' do
delete :destroy, params: { id: @classification.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @classification.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested classification' do
delete :destroy, params: { id: @classification.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @classification.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/form_of_works_controller_spec.rb | spec/controllers/form_of_works_controller_spec.rb | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
describe FormOfWorksController do
fixtures :all
login_fixture_admin
# This should return the minimal set of attributes required to create a valid
# FormOfWork. As you add validations to FormOfWork, be sure to
# update the return value of this method accordingly.
def valid_attributes
FactoryBot.attributes_for(:form_of_work)
end
describe 'GET index' do
it 'assigns all form_of_works as @form_of_works' do
form_of_work = FormOfWork.create! valid_attributes
get :index
expect(assigns(:form_of_works)).to eq(FormOfWork.order(:position))
end
end
describe 'GET show' do
it 'assigns the requested form_of_work as @form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
get :show, params: { id: form_of_work.id }
expect(assigns(:form_of_work)).to eq(form_of_work)
end
end
describe 'GET new' do
it 'assigns a new form_of_work as @form_of_work' do
get :new
expect(assigns(:form_of_work)).to be_a_new(FormOfWork)
end
end
describe 'GET edit' do
it 'assigns the requested form_of_work as @form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
get :edit, params: { id: form_of_work.id }
expect(assigns(:form_of_work)).to eq(form_of_work)
end
end
describe 'POST create' do
describe 'with valid params' do
it 'creates a new FormOfWork' do
expect do
post :create, params: { form_of_work: valid_attributes }
end.to change(FormOfWork, :count).by(1)
end
it 'assigns a newly created form_of_work as @form_of_work' do
post :create, params: { form_of_work: valid_attributes }
expect(assigns(:form_of_work)).to be_a(FormOfWork)
expect(assigns(:form_of_work)).to be_persisted
end
it 'redirects to the created form_of_work' do
post :create, params: { form_of_work: valid_attributes }
expect(response).to redirect_to(FormOfWork.last)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved form_of_work as @form_of_work' do
# Trigger the behavior that occurs when invalid params are submitted
FormOfWork.any_instance.stub(:save).and_return(false)
post :create, params: { form_of_work: { name: 'test' } }
expect(assigns(:form_of_work)).to be_a_new(FormOfWork)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
FormOfWork.any_instance.stub(:save).and_return(false)
post :create, params: { form_of_work: { name: 'test' } }
# expect(response).to render_template("new")
end
end
end
describe 'PUT update' do
describe 'with valid params' do
it 'updates the requested form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
# Assuming there are no other form_of_works in the database, this
# specifies that the FormOfWork created on the previous line
# receives the :update message with whatever params are
# submitted in the request.
# FormOfWork.any_instance.should_receive(:update).with('name' => 'test')
put :update, params: { id: form_of_work.id, form_of_work: { 'name' => 'test' } }
end
it 'assigns the requested form_of_work as @form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
put :update, params: { id: form_of_work.id, form_of_work: valid_attributes }
expect(assigns(:form_of_work)).to eq(form_of_work)
end
it 'redirects to the form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
put :update, params: { id: form_of_work.id, form_of_work: valid_attributes }
expect(response).to redirect_to(form_of_work)
end
it 'moves its position when specified' do
form_of_work = FormOfWork.create! valid_attributes
position = form_of_work.position
put :update, params: { id: form_of_work.id, move: 'higher' }
expect(response).to redirect_to form_of_works_url
form_of_work.reload
form_of_work.position.should eq position - 1
end
end
describe 'with invalid params' do
it 'assigns the form_of_work as @form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
FormOfWork.any_instance.stub(:save).and_return(false)
put :update, params: { id: form_of_work.id, form_of_work: { name: 'test' } }
expect(assigns(:form_of_work)).to eq(form_of_work)
end
it "re-renders the 'edit' template" do
form_of_work = FormOfWork.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
FormOfWork.any_instance.stub(:save).and_return(false)
put :update, params: { id: form_of_work.id, form_of_work: { name: 'test' } }
# expect(response).to render_template("edit")
end
end
end
describe 'DELETE destroy' do
it 'destroys the requested form_of_work' do
form_of_work = FormOfWork.create! valid_attributes
expect do
delete :destroy, params: { id: form_of_work.id }
end.to change(FormOfWork, :count).by(-1)
end
it 'redirects to the form_of_works list' do
form_of_work = FormOfWork.create! valid_attributes
delete :destroy, params: { id: form_of_work.id }
expect(response).to redirect_to(form_of_works_url)
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/controllers/purchase_requests_controller_spec.rb | spec/controllers/purchase_requests_controller_spec.rb | require 'rails_helper'
describe PurchaseRequestsController do
fixtures :all
describe 'GET index', solr: true do
before do
PurchaseRequest.reindex
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all purchase_requests as @purchase_requests' do
get :index
assigns(:purchase_requests).should_not be_empty
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all purchase_requests as @purchase_requests' do
get :index
assigns(:purchase_requests).total_entries.should eq PurchaseRequest.count
assigns(:purchase_requests).should_not be_empty
end
it "should get other user's index with user_id" do
get :index, params: { user_id: users(:user1).username }
response.should be_successful
assigns(:purchase_requests).total_entries.should eq users(:user1).purchase_requests.count
assigns(:purchase_requests).should_not be_empty
end
it "should get other user's index with order_list_id" do
get :index, params: { order_list_id: 1 }
response.should be_successful
assigns(:purchase_requests).total_entries.should eq order_lists(:order_list_00001).purchase_requests.count
assigns(:purchase_requests).should_not be_empty
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns my purchase_requests as @purchase_requests' do
get :index
assigns(:purchase_requests).should_not be_empty
end
it 'should be get my index without user_id' do
get :index
assigns(:purchase_requests).should eq users(:user1).purchase_requests
assigns(:purchase_requests).total_entries.should eq users(:user1).purchase_requests.count
response.should be_successful
end
it 'should get my index' do
get :index, params: { user_id: users(:user1).username }
response.should redirect_to purchase_requests_url
assigns(:purchase_requests).should be_nil
end
it 'should not get index with order_list_id' do
get :index, params: { order_list_id: 1 }
response.should be_forbidden
assigns(:purchase_requests).should be_nil
end
it 'should get my index in txt format' do
get :index, params: { user_id: users(:user1).username, format: :txt }
response.should redirect_to purchase_requests_url(format: :txt)
assigns(:purchase_requests).should be_nil
end
it 'should get my index in rss format' do
get :index, params: { user_id: users(:user1).username, format: 'rss' }
response.should redirect_to purchase_requests_url(format: :rss)
assigns(:purchase_requests).should be_nil
end
it "should not get other user's index" do
get :index, params: { user_id: users(:librarian1).username }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns empty as @purchase_requests' do
get :index
assigns(:purchase_requests).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
before(:each) do
@purchase_request = purchase_requests(:purchase_request_00003)
end
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested purchase_request as @purchase_request' do
get :show, params: { id: @purchase_request.id }
assigns(:purchase_request).should eq(@purchase_request)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested purchase_request as @purchase_request' do
get :show, params: { id: @purchase_request.id }
assigns(:purchase_request).should eq(@purchase_request)
end
it 'should show purchase_request without user_id' do
get :show, params: { id: purchase_requests(:purchase_request_00002).id }
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested purchase_request as @purchase_request' do
get :show, params: { id: @purchase_request.id }
assigns(:purchase_request).should eq(@purchase_request)
end
it 'should show my purchase request' do
get :show, params: { id: @purchase_request.id }
response.should be_successful
end
it "should not show other user's purchase request" do
get :show, params: { id: purchase_requests(:purchase_request_00001).id }
response.should be_forbidden
end
render_views
it 'should not show add or delete order link' do
get :show, params: { id: @purchase_request.id }
response.should be_successful
response.body.should_not match /\/order\/new/
response.body.should_not match /delete.*\/order/
end
end
describe 'When not logged in' do
it 'assigns the requested purchase_request as @purchase_request' do
get :show, params: { id: @purchase_request.id }
assigns(:purchase_request).should eq(@purchase_request)
response.should redirect_to new_user_session_url
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested purchase_request as @purchase_request' do
get :new
assigns(:purchase_request).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested purchase_request as @purchase_request' do
get :new
assigns(:purchase_request).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested purchase_request as @purchase_request' do
get :new
assigns(:purchase_request).should_not be_valid
response.should be_successful
end
end
describe 'When not logged in' do
it 'should not assign the requested purchase_request as @purchase_request' do
get :new
assigns(:purchase_request).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should assign the requested purchase_request as @purchase_request' do
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
assigns(:purchase_request).should eq(purchase_requests(:purchase_request_00001))
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should assign the requested purchase_request as @purchase_request' do
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
assigns(:purchase_request).should eq(purchase_requests(:purchase_request_00001))
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should edit my purchase_request' do
get :edit, params: { id: purchase_requests(:purchase_request_00003).id }
response.should be_successful
end
it "should not edit other user's purchase_request" do
get :edit, params: { id: purchase_requests(:purchase_request_00002).id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested purchase_request as @purchase_request' do
get :edit, params: { id: purchase_requests(:purchase_request_00001).id }
response.should redirect_to new_user_session_url
end
end
end
describe 'POST create' do
before(:each) do
@attrs = FactoryBot.attributes_for(:purchase_request)
@invalid_attrs = { title: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created purchase_request as @purchase_request' do
post :create, params: { purchase_request: @attrs }
assigns(:purchase_request).should be_valid
end
it 'redirects to the created purchase_request' do
post :create, params: { purchase_request: @attrs }
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
post :create, params: { purchase_request: @invalid_attrs }
assigns(:purchase_request).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { purchase_request: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created purchase_request as @purchase_request' do
post :create, params: { purchase_request: @attrs }
assigns(:purchase_request).should be_valid
end
it 'redirects to the created purchase_request' do
post :create, params: { purchase_request: @attrs }
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
post :create, params: { purchase_request: @invalid_attrs }
assigns(:purchase_request).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { purchase_request: @invalid_attrs }
response.should render_template('new')
end
end
it "should create purchase_request with other user's user_id" do
post :create, params: { purchase_request: { title: 'test', user_id: users(:user1).id } }
response.should redirect_to purchase_request_url(assigns(:purchase_request))
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created purchase_request as @purchase_request' do
post :create, params: { purchase_request: @attrs }
assigns(:purchase_request).should be_valid
end
it 'redirects to the created purchase_request' do
post :create, params: { purchase_request: @attrs }
response.should redirect_to(purchase_request_url(assigns(:purchase_request)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
post :create, params: { purchase_request: @invalid_attrs }
assigns(:purchase_request).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { purchase_request: @invalid_attrs }
response.should render_template('new')
end
end
it 'should create purchase_request without user_id' do
post :create, params: { purchase_request: { title: 'test', user_id: users(:user1).id, pub_date: 2010 } }
assigns(:purchase_request).date_of_publication.should eq Time.zone.parse('2010-01-01')
response.should redirect_to purchase_request_url(assigns(:purchase_request))
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created purchase_request as @purchase_request' do
post :create, params: { purchase_request: @attrs }
assigns(:purchase_request).should be_nil
end
it 'should redirect to new_user_session_url' do
post :create, params: { purchase_request: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved purchase_request as @purchase_request' do
post :create, params: { purchase_request: @invalid_attrs }
assigns(:purchase_request).should be_nil
end
it 'should redirect to new_user_session_url' do
post :create, params: { purchase_request: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@purchase_request = purchase_requests(:purchase_request_00001)
@attrs = FactoryBot.attributes_for(:purchase_request)
@invalid_attrs = { title: '' }
end
describe 'When logged in as Administrator' do
before(:each) do
@user = FactoryBot.create(:admin)
sign_in @user
end
describe 'with valid params' do
it 'updates the requested purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
end
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
assigns(:purchase_request).should eq(@purchase_request)
response.should redirect_to purchase_request_url(assigns(:purchase_request))
end
end
describe 'with invalid params' do
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
end
it "re-renders the 'edit' template" do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
before(:each) do
@user = FactoryBot.create(:librarian)
sign_in @user
end
describe 'with valid params' do
it 'updates the requested purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
end
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
assigns(:purchase_request).should eq(@purchase_request)
response.should redirect_to purchase_request_url(assigns(:purchase_request))
end
end
describe 'with invalid params' do
it 'assigns the purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
assigns(:purchase_request).should_not be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
end
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
assigns(:purchase_request).should eq(@purchase_request)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
response.should be_forbidden
end
end
it 'should update my purchase_request' do
put :update, params: { id: purchase_requests(:purchase_request_00003).id, purchase_request: { note: 'test' } }
response.should redirect_to purchase_request_url(assigns(:purchase_request))
end
it "should not update other user's purchase_request" do
put :update, params: { id: purchase_requests(:purchase_request_00002).id, purchase_request: { note: 'test' } }
response.should be_forbidden
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @purchase_request.id, purchase_request: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested purchase_request as @purchase_request' do
put :update, params: { id: @purchase_request.id, purchase_request: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@purchase_request = purchase_requests(:purchase_request_00001)
end
describe 'When logged in as Administrator' do
login_admin
it 'destroys the requested purchase_request' do
delete :destroy, params: { id: @purchase_request.id }
end
it 'redirects to the purchase_requests list' do
delete :destroy, params: { id: @purchase_request.id }
response.should redirect_to purchase_requests_url
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested purchase_request' do
delete :destroy, params: { id: @purchase_request.id }
end
it 'redirects to the purchase_requests list' do
delete :destroy, params: { id: @purchase_request.id }
response.should redirect_to purchase_requests_url
end
it "should destroy other user's purchase request" do
delete :destroy, params: { id: purchase_requests(:purchase_request_00003).id }
response.should redirect_to purchase_requests_url
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested purchase_request' do
delete :destroy, params: { id: @purchase_request.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @purchase_request.id }
response.should be_forbidden
end
it 'should destroy my purchase_request' do
delete :destroy, params: { id: purchase_requests(:purchase_request_00003).id }
response.should redirect_to purchase_requests_url
end
it "should not destroy other user's purchase_request" do
delete :destroy, params: { id: purchase_requests(:purchase_request_00002).id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested purchase_request' do
delete :destroy, params: { id: @purchase_request.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @purchase_request.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/checkout_types_controller_spec.rb | spec/controllers/checkout_types_controller_spec.rb | require 'rails_helper'
describe CheckoutTypesController do
fixtures :all
describe 'GET index' do
before(:each) do
FactoryBot.create(:checkout_type)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all checkout_types as @checkout_types' do
get :index
assigns(:checkout_types).should eq(CheckoutType.order(:position))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all checkout_types as @checkout_types' do
get :index
assigns(:checkout_types).should eq(CheckoutType.order(:position))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns all checkout_types as @checkout_types' do
get :index
assigns(:checkout_types).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns all checkout_types as @checkout_types' do
get :index
assigns(:checkout_types).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :show, params: { id: checkout_type.id }
assigns(:checkout_type).should eq(checkout_type)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :show, params: { id: checkout_type.id }
assigns(:checkout_type).should eq(checkout_type)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :show, params: { id: checkout_type.id }
assigns(:checkout_type).should eq(checkout_type)
end
end
describe 'When not logged in' do
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :show, params: { id: checkout_type.id }
assigns(:checkout_type).should eq(checkout_type)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checkout_type as @checkout_type' do
get :new
assigns(:checkout_type).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested checkout_type as @checkout_type' do
get :new
assigns(:checkout_type).should be_nil
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested checkout_type as @checkout_type' do
get :new
assigns(:checkout_type).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested checkout_type as @checkout_type' do
get :new
assigns(:checkout_type).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :edit, params: { id: checkout_type.id }
assigns(:checkout_type).should eq(checkout_type)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :edit, params: { id: checkout_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :edit, params: { id: checkout_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested checkout_type as @checkout_type' do
checkout_type = FactoryBot.create(:checkout_type)
get :edit, params: { id: checkout_type.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = FactoryBot.attributes_for(:checkout_type)
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created checkout_type as @checkout_type' do
post :create, params: { checkout_type: @attrs }
assigns(:checkout_type).should be_valid
end
it 'redirects to the created patron' do
post :create, params: { checkout_type: @attrs }
response.should redirect_to(assigns(:checkout_type))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved checkout_type as @checkout_type' do
post :create, params: { checkout_type: @invalid_attrs }
assigns(:checkout_type).should_not be_valid
end
it 'should be successful' do
post :create, params: { checkout_type: @invalid_attrs }
response.should be_successful
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created checkout_type as @checkout_type' do
post :create, params: { checkout_type: @attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved checkout_type as @checkout_type' do
post :create, params: { checkout_type: @invalid_attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created checkout_type as @checkout_type' do
post :create, params: { checkout_type: @attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved checkout_type as @checkout_type' do
post :create, params: { checkout_type: @invalid_attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created checkout_type as @checkout_type' do
post :create, params: { checkout_type: @attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved checkout_type as @checkout_type' do
post :create, params: { checkout_type: @invalid_attrs }
assigns(:checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { checkout_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@checkout_type = FactoryBot.create(:checkout_type)
@attrs = FactoryBot.attributes_for(:checkout_type)
@invalid_attrs = { name: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
end
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
assigns(:checkout_type).should eq(@checkout_type)
end
it 'moves its position when specified' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs, move: 'lower' }
response.should redirect_to(checkout_types_url)
end
end
describe 'with invalid params' do
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
end
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
assigns(:checkout_type).should eq(@checkout_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
end
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
assigns(:checkout_type).should eq(@checkout_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @checkout_type.id, checkout_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested checkout_type as @checkout_type' do
put :update, params: { id: @checkout_type.id, checkout_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@checkout_type = FactoryBot.create(:checkout_type)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested checkout_type' do
delete :destroy, params: { id: @checkout_type.id }
end
it 'redirects to the checkout_types list' do
delete :destroy, params: { id: @checkout_type.id }
response.should redirect_to(checkout_types_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested checkout_type' do
delete :destroy, params: { id: @checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @checkout_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested checkout_type' do
delete :destroy, params: { id: @checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @checkout_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested checkout_type' do
delete :destroy, params: { id: @checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @checkout_type.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/donates_controller_spec.rb | spec/controllers/donates_controller_spec.rb | require 'rails_helper'
require 'sunspot/rails/spec_helper'
describe DonatesController do
fixtures :all
disconnect_sunspot
def valid_attributes
FactoryBot.attributes_for(:donate)
end
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all donates as @donates' do
get :index
expect(assigns(:donates)).to eq(Donate.order('id DESC').page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all donates as @donates' do
get :index
expect(assigns(:donates)).to eq(Donate.order('id DESC').page(1))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns all donates as @donates' do
get :index
expect(assigns(:donates)).to be_nil
end
end
describe 'When not logged in' do
it 'assigns all donates as @donates' do
get :index
expect(assigns(:donates)).to be_nil
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :show, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :show, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :show, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
describe 'When not logged in' do
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :show, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested donate as @donate' do
get :new
expect(assigns(:donate)).not_to be_valid
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested donate as @donate' do
get :new
expect(assigns(:donate)).not_to be_valid
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested donate as @donate' do
get :new
expect(assigns(:donate)).to be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested donate as @donate' do
get :new
expect(assigns(:donate)).to be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :edit, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :edit, params: { id: donate.id }
expect(assigns(:donate)).to eq(donate)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :edit, params: { id: donate.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested donate as @donate' do
donate = FactoryBot.create(:donate)
get :edit, params: { id: donate.id }
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = valid_attributes
@invalid_attrs = { item_id: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created donate as @donate' do
post :create, params: { donate: @attrs }
expect(assigns(:donate)).to be_valid
end
it 'redirects to the created donate' do
post :create, params: { donate: @attrs }
expect(response).to redirect_to(donate_url(assigns(:donate)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved donate as @donate' do
post :create, params: { donate: @invalid_attrs }
expect(assigns(:donate)).not_to be_valid
end
it "re-renders the 'new' template" do
post :create, params: { donate: @invalid_attrs }
expect(response).to render_template('new')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created donate as @donate' do
post :create, params: { donate: @attrs }
expect(assigns(:donate)).to be_valid
end
it 'redirects to the created donate' do
post :create, params: { donate: @attrs }
expect(response).to redirect_to(donate_url(assigns(:donate)))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved donate as @donate' do
post :create, params: { donate: @invalid_attrs }
expect(assigns(:donate)).not_to be_valid
end
it "re-renders the 'new' template" do
post :create, params: { donate: @invalid_attrs }
expect(response).to render_template('new')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created donate as @donate' do
post :create, params: { donate: @attrs }
expect(assigns(:donate)).to be_nil
end
it 'should be forbidden' do
post :create, params: { donate: @attrs }
expect(response).to be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved donate as @donate' do
post :create, params: { donate: @invalid_attrs }
expect(assigns(:donate)).to be_nil
end
it 'should be forbidden' do
post :create, params: { donate: @invalid_attrs }
expect(response).to be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created donate as @donate' do
post :create, params: { donate: @attrs }
expect(assigns(:donate)).to be_nil
end
it 'should be forbidden' do
post :create, params: { donate: @attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved donate as @donate' do
post :create, params: { donate: @invalid_attrs }
expect(assigns(:donate)).to be_nil
end
it 'should be forbidden' do
post :create, params: { donate: @invalid_attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@donate = FactoryBot.create(:donate)
@attrs = valid_attributes
@invalid_attrs = { item_id: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested donate' do
put :update, params: { id: @donate.id, donate: @attrs }
end
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @attrs }
expect(assigns(:donate)).to eq(@donate)
end
end
describe 'with invalid params' do
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @invalid_attrs }
expect(response).to render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested donate' do
put :update, params: { id: @donate.id, donate: @attrs }
end
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @attrs }
expect(assigns(:donate)).to eq(@donate)
expect(response).to redirect_to(@donate)
end
end
describe 'with invalid params' do
it 'assigns the donate as @donate' do
put :update, params: { id: @donate, donate: @invalid_attrs }
expect(assigns(:donate)).not_to be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @donate, donate: @invalid_attrs }
expect(response).to render_template('edit')
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested donate' do
put :update, params: { id: @donate.id, donate: @attrs }
end
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @attrs }
expect(assigns(:donate)).to eq(@donate)
expect(response).to be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @invalid_attrs }
expect(response).to be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested donate' do
put :update, params: { id: @donate.id, donate: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @donate.id, donate: @attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested donate as @donate' do
put :update, params: { id: @donate.id, donate: @invalid_attrs }
expect(response).to redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@donate = FactoryBot.create(:donate)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested donate' do
delete :destroy, params: { id: @donate.id }
end
it 'redirects to the donates list' do
delete :destroy, params: { id: @donate.id }
expect(response).to redirect_to(donates_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested donate' do
delete :destroy, params: { id: @donate.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @donate.id }
expect(response).to redirect_to(donates_url)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested donate' do
delete :destroy, params: { id: @donate.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @donate.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested donate' do
delete :destroy, params: { id: @donate.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @donate.id }
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/series_statement_merges_controller_spec.rb | spec/controllers/series_statement_merges_controller_spec.rb | require 'rails_helper'
describe SeriesStatementMergesController do
fixtures :all
describe 'GET index' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns all series_statement_merges as @series_statement_merges' do
get :index
assigns(:series_statement_merges).should eq(SeriesStatementMerge.page(1))
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns all series_statement_merges as @series_statement_merges' do
get :index
assigns(:series_statement_merges).should eq(SeriesStatementMerge.page(1))
end
end
describe 'When logged in as User' do
login_user
it 'should be forbidden' do
get :index
assigns(:series_statement_merges).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should be forbidden' do
get :index
assigns(:series_statement_merges).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :show, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :show, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :show, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
describe 'When not logged in' do
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :show, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested series_statement_merge as @series_statement_merge' do
get :new
assigns(:series_statement_merge).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested series_statement_merge as @series_statement_merge' do
get :new
assigns(:series_statement_merge).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as User' do
login_user
it 'should not assign the requested series_statement_merge as @series_statement_merge' do
get :new
assigns(:series_statement_merge).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested series_statement_merge as @series_statement_merge' do
get :new
assigns(:series_statement_merge).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_admin
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :edit, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :edit, params: { id: series_statement_merge.id }
assigns(:series_statement_merge).should eq(series_statement_merge)
end
end
describe 'When logged in as User' do
login_user
it 'assigns the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :edit, params: { id: series_statement_merge.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested series_statement_merge as @series_statement_merge' do
series_statement_merge = FactoryBot.create(:series_statement_merge)
get :edit, params: { id: series_statement_merge.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = FactoryBot.attributes_for(:series_statement_merge)
@invalid_attrs = { series_statement_merge_list_id: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'assigns a newly created series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @attrs }
assigns(:series_statement_merge).should be_valid
end
it 'redirects to the created series_statement' do
post :create, params: { series_statement_merge: @attrs }
response.should redirect_to(assigns(:series_statement_merge))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @invalid_attrs }
assigns(:series_statement_merge).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { series_statement_merge: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'assigns a newly created series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @attrs }
assigns(:series_statement_merge).should be_valid
end
it 'redirects to the created series_statement' do
post :create, params: { series_statement_merge: @attrs }
response.should redirect_to(assigns(:series_statement_merge))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @invalid_attrs }
assigns(:series_statement_merge).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { series_statement_merge: @invalid_attrs }
response.should render_template('new')
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'assigns a newly created series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @attrs }
assigns(:series_statement_merge).should be_nil
end
it 'should be forbidden' do
post :create, params: { series_statement_merge: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @invalid_attrs }
assigns(:series_statement_merge).should be_nil
end
it 'should be forbidden' do
post :create, params: { series_statement_merge: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @attrs }
assigns(:series_statement_merge).should be_nil
end
it 'should be forbidden' do
post :create, params: { series_statement_merge: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved series_statement_merge as @series_statement_merge' do
post :create, params: { series_statement_merge: @invalid_attrs }
assigns(:series_statement_merge).should be_nil
end
it 'should be forbidden' do
post :create, params: { series_statement_merge: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@series_statement_merge = FactoryBot.create(:series_statement_merge)
@attrs = FactoryBot.attributes_for(:series_statement_merge)
@invalid_attrs = { series_statement_merge_list_id: '' }
end
describe 'When logged in as Administrator' do
login_admin
describe 'with valid params' do
it 'updates the requested series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
end
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
assigns(:series_statement_merge).should eq(@series_statement_merge)
response.should redirect_to(@series_statement_merge)
end
end
describe 'with invalid params' do
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_librarian
describe 'with valid params' do
it 'updates the requested series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
end
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
assigns(:series_statement_merge).should eq(@series_statement_merge)
response.should redirect_to(@series_statement_merge)
end
end
describe 'with invalid params' do
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as User' do
login_user
describe 'with valid params' do
it 'updates the requested series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
end
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
assigns(:series_statement_merge).should eq(@series_statement_merge)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested series_statement_merge as @series_statement_merge' do
put :update, params: { id: @series_statement_merge.id, series_statement_merge: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@series_statement_merge = FactoryBot.create(:series_statement_merge)
end
describe 'When logged in as Administrator' do
login_admin
it 'destroys the requested series_statement_merge' do
delete :destroy, params: { id: @series_statement_merge.id }
end
it 'redirects to the series_statement_merges list' do
delete :destroy, params: { id: @series_statement_merge.id }
response.should redirect_to(series_statement_merges_url)
end
end
describe 'When logged in as Librarian' do
login_librarian
it 'destroys the requested series_statement_merge' do
delete :destroy, params: { id: @series_statement_merge.id }
end
it 'redirects to the series_statement_merges list' do
delete :destroy, params: { id: @series_statement_merge.id }
response.should redirect_to(series_statement_merges_url)
end
end
describe 'When logged in as User' do
login_user
it 'destroys the requested series_statement_merge' do
delete :destroy, params: { id: @series_statement_merge.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @series_statement_merge.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested series_statement_merge' do
delete :destroy, params: { id: @series_statement_merge.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @series_statement_merge.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb | spec/controllers/carrier_type_has_checkout_types_controller_spec.rb | require 'rails_helper'
describe CarrierTypeHasCheckoutTypesController do
fixtures :all
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all carrier_type_has_checkout_types as @carrier_type_has_checkout_types' do
get :index
assigns(:carrier_type_has_checkout_types).should eq(CarrierTypeHasCheckoutType.includes([ :carrier_type, :checkout_type ]).order('carrier_types.position, checkout_types.position').page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all carrier_type_has_checkout_types as @carrier_type_has_checkout_types' do
get :index
assigns(:carrier_type_has_checkout_types).should eq(CarrierTypeHasCheckoutType.includes([ :carrier_type, :checkout_type ]).order('carrier_types.position, checkout_types.position').page(1))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns all carrier_type_has_checkout_types as @carrier_type_has_checkout_types' do
get :index
assigns(:carrier_type_has_checkout_types).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns all carrier_type_has_checkout_types as @carrier_type_has_checkout_types' do
get :index
assigns(:carrier_type_has_checkout_types).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :show, params: { id: carrier_type_has_checkout_type.id }
assigns(:carrier_type_has_checkout_type).should eq(carrier_type_has_checkout_type)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :show, params: { id: carrier_type_has_checkout_type.id }
assigns(:carrier_type_has_checkout_type).should eq(carrier_type_has_checkout_type)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :show, params: { id: carrier_type_has_checkout_type.id }
assigns(:carrier_type_has_checkout_type).should eq(carrier_type_has_checkout_type)
end
end
describe 'When not logged in' do
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :show, params: { id: carrier_type_has_checkout_type.id }
assigns(:carrier_type_has_checkout_type).should eq(carrier_type_has_checkout_type)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
get :new
assigns(:carrier_type_has_checkout_type).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
get :new
assigns(:carrier_type_has_checkout_type).should be_nil
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
get :new
assigns(:carrier_type_has_checkout_type).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
get :new
assigns(:carrier_type_has_checkout_type).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :edit, params: { id: carrier_type_has_checkout_type.id }
assigns(:carrier_type_has_checkout_type).should eq(carrier_type_has_checkout_type)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :edit, params: { id: carrier_type_has_checkout_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :edit, params: { id: carrier_type_has_checkout_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
get :edit, params: { id: carrier_type_has_checkout_type.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = FactoryBot.attributes_for(:carrier_type_has_checkout_type)
@invalid_attrs = { carrier_type_id: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'assigns a newly created carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should be_valid
end
it 'redirects to the created patron' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
response.should redirect_to(assigns(:carrier_type_has_checkout_type))
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
assigns(:carrier_type_has_checkout_type).should_not be_valid
end
it 'should be successful' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
response.should be_successful
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'assigns a newly created carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'assigns a newly created carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'assigns a newly created carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
assigns(:carrier_type_has_checkout_type).should be_nil
end
it 'should be forbidden' do
post :create, params: { carrier_type_has_checkout_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'PUT update' do
before(:each) do
@carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
@attrs = FactoryBot.attributes_for(:carrier_type_has_checkout_type)
@invalid_attrs = { carrier_type_id: '' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'with valid params' do
it 'updates the requested carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
end
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should eq(@carrier_type_has_checkout_type)
end
end
describe 'with invalid params' do
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @invalid_attrs }
response.should render_template('edit')
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
describe 'with valid params' do
it 'updates the requested carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
end
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should eq(@carrier_type_has_checkout_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When logged in as User' do
login_fixture_user
describe 'with valid params' do
it 'updates the requested carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
end
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
assigns(:carrier_type_has_checkout_type).should eq(@carrier_type_has_checkout_type)
response.should be_forbidden
end
end
describe 'with invalid params' do
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @invalid_attrs }
response.should be_forbidden
end
end
end
describe 'When not logged in' do
describe 'with valid params' do
it 'updates the requested carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
end
it 'should be forbidden' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe 'with invalid params' do
it 'assigns the requested carrier_type_has_checkout_type as @carrier_type_has_checkout_type' do
put :update, params: { id: @carrier_type_has_checkout_type.id, carrier_type_has_checkout_type: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe 'DELETE destroy' do
before(:each) do
@carrier_type_has_checkout_type = FactoryBot.create(:carrier_type_has_checkout_type)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested carrier_type_has_checkout_type' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
end
it 'redirects to the carrier_type_has_checkout_types list' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
response.should redirect_to(carrier_type_has_checkout_types_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested carrier_type_has_checkout_type' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
response.should be_forbidden
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested carrier_type_has_checkout_type' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested carrier_type_has_checkout_type' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @carrier_type_has_checkout_type.id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/frequencies_controller_spec.rb | spec/controllers/frequencies_controller_spec.rb | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
describe FrequenciesController do
fixtures :all
login_fixture_admin
# This should return the minimal set of attributes required to create a valid
# Frequency. As you add validations to Frequency, be sure to
# update the return value of this method accordingly.
def valid_attributes
FactoryBot.attributes_for(:frequency)
end
describe 'GET index' do
it 'assigns all frequencies as @frequencies' do
frequency = Frequency.create! valid_attributes
get :index
assigns(:frequencies).should eq(Frequency.order(:position))
end
end
describe 'GET show' do
it 'assigns the requested frequency as @frequency' do
frequency = Frequency.create! valid_attributes
get :show, params: { id: frequency.id }
assigns(:frequency).should eq(frequency)
end
end
describe 'GET new' do
it 'assigns a new frequency as @frequency' do
get :new
assigns(:frequency).should be_a_new(Frequency)
end
end
describe 'GET edit' do
it 'assigns the requested frequency as @frequency' do
frequency = Frequency.create! valid_attributes
get :edit, params: { id: frequency.id }
assigns(:frequency).should eq(frequency)
end
it 'assigns the frequency even if it associates manifestation(s)' do
frequency = FactoryBot.create(:frequency)
manifestation = FactoryBot.create(:manifestation, frequency_id: frequency.id)
get :edit, params: { id: frequency.id }
expect(assigns(:frequency)).to eq frequency
expect(response).to be_successful
end
end
describe 'POST create' do
describe 'with valid params' do
it 'creates a new Frequency' do
expect do
post :create, params: { frequency: valid_attributes }
end.to change(Frequency, :count).by(1)
end
it 'assigns a newly created frequency as @frequency' do
post :create, params: { frequency: valid_attributes }
assigns(:frequency).should be_a(Frequency)
assigns(:frequency).should be_persisted
end
it 'redirects to the created frequency' do
post :create, params: { frequency: valid_attributes }
expect(response).to redirect_to(Frequency.last)
end
end
describe 'with invalid params' do
it 'assigns a newly created but unsaved frequency as @frequency' do
# Trigger the behavior that occurs when invalid params are submitted
Frequency.any_instance.stub(:save).and_return(false)
post :create, params: { frequency: { name: 'test' } }
assigns(:frequency).should be_a_new(Frequency)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Frequency.any_instance.stub(:save).and_return(false)
post :create, params: { frequency: { name: 'test' } }
expect(response).to render_template('new')
end
end
end
describe 'PUT update' do
describe 'with valid params' do
it 'updates the requested frequency' do
frequency = Frequency.create! valid_attributes
# Assuming there are no other frequencies in the database, this
# specifies that the Frequency created on the previous line
# receives the :update message with whatever params are
# submitted in the request.
# Frequency.any_instance.should_receive(:update).with('name' => 'test')
put :update, params: { id: frequency.id, frequency: { 'name' => 'test' } }
end
it 'assigns the requested frequency as @frequency' do
frequency = Frequency.create! valid_attributes
put :update, params: { id: frequency.id, frequency: valid_attributes }
assigns(:frequency).should eq(frequency)
end
it 'redirects to the frequency' do
frequency = Frequency.create! valid_attributes
put :update, params: { id: frequency.id, frequency: valid_attributes }
expect(response).to redirect_to(frequency)
end
it 'moves its position when specified' do
frequency = Frequency.create! valid_attributes
position = frequency.position
put :update, params: { id: frequency.id, move: 'higher' }
expect(response).to redirect_to frequencies_url
assigns(:frequency).reload.position.should eq position - 1
end
end
describe 'with invalid params' do
it 'assigns the frequency as @frequency' do
frequency = Frequency.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Frequency.any_instance.stub(:save).and_return(false)
put :update, params: { id: frequency.id, frequency: { name: 'test' } }
assigns(:frequency).should eq(frequency)
end
it "re-renders the 'edit' template" do
frequency = Frequency.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Frequency.any_instance.stub(:save).and_return(false)
put :update, params: { id: frequency.id, frequency: { name: 'test' } }
expect(response).to render_template('edit')
end
end
end
describe 'DELETE destroy' do
it 'destroys the requested frequency' do
frequency = Frequency.create! valid_attributes
expect do
delete :destroy, params: { id: frequency.id }
end.to change(Frequency, :count).by(-1)
end
it 'redirects to the frequencies list' do
frequency = Frequency.create! valid_attributes
delete :destroy, params: { id: frequency.id }
expect(response).to redirect_to(frequencies_url)
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/controllers/profiles_controller_spec.rb | spec/controllers/profiles_controller_spec.rb | require 'rails_helper'
describe ProfilesController do
fixtures :all
before(:each) do
@admin_profile = FactoryBot.create(:admin).profile
@librarian_profile = FactoryBot.create(:librarian).profile
end
describe "GET index" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns all profiles as @profiles" do
get :index
assigns(:profiles).should_not be_nil
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns all profiles as @profiles" do
get :index
assigns(:profiles).should_not be_nil
end
it "should get index with query" do
get :index, params: { query: 'user1' }
response.should be_successful
assigns(:profiles).should_not be_nil
end
it "should get sorted index" do
get :index, params: { query: 'user1', sort_by: 'username', order: 'desc' }
response.should be_successful
assigns(:profiles).should_not be_nil
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns all profiles as @profiles" do
get :index
assigns(:profiles).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "assigns all profiles as @profiles" do
get :index
assigns(:profiles).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET show" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested user as @profile" do
get :show, params: { id: profiles(:profile_admin).id }
assigns(:profile).should eq(profiles(:profile_admin))
end
it "assigns the another requested user as @profile" do
get :show, params: { id: @admin_profile.id }
expect(response).not_to be_forbidden
expect(assigns(:profile)).to eq @admin_profile
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested user as @profile" do
get :show, params: { id: profiles(:profile_librarian1).id }
assigns(:profile).should eq(profiles(:profile_librarian1))
end
it "should not assign the requested user as @admin" do
get :show, params: { id: @admin_profile.id }
response.should be_forbidden
end
it "should assign the requested user as @librarian" do
get :show, params: { id: @librarian_profile.id }
response.should_not be_forbidden
assigns(:profile).should eq @librarian_profile
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested user as @profile" do
get :show, params: { id: profiles(:profile_user1).id }
assigns(:profile).should eq(profiles(:profile_user1))
end
it "should redirect to my user account" do
get :show, params: { id: profiles(:profile_user1).id }
assert_redirected_to my_account_url
end
it "should show other user's account" do
get :show, params: { id: profiles(:profile_admin).id }
assigns(:profile).should eq(profiles(:profile_admin))
response.should be_forbidden
end
end
describe "When not logged in" do
it "assigns the requested user as @profile" do
get :show, params: { id: profiles(:profile_admin).id }
assigns(:profile).should eq nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET new" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested user as @profile" do
get :new
assigns(:profile).should_not be_valid
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "should not assign the requested user as @profile" do
get :new
assigns(:profile).should_not be_valid
end
end
describe "When logged in as User" do
login_fixture_user
it "should not assign the requested user as @profile" do
get :new
assigns(:profile).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not assign the requested user as @profile" do
get :new
assigns(:profile).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "GET edit" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested user as @profile" do
profile = FactoryBot.create(:profile)
get :edit, params: { id: profile.id }
assigns(:profile).should eq(profile)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "should assign the requested user as @profile" do
profile = FactoryBot.create(:profile)
get :edit, params: { id: profile.id }
assigns(:profile).should eq(profile)
end
it "should not get edit page for admin required user" do
get :edit, params: { id: @admin_profile.id }
response.should be_forbidden
# assigns(:profile).should_not eq(admin)
end
it "should get edit page for other librarian user" do
get :edit, params: { id: @librarian_profile.id }
response.should_not be_forbidden
assigns(:profile).should eq @librarian_profile
end
it "should get edit page for other librarian user" do
get :edit, params: { id: @admin_profile.id }
response.should be_forbidden
assigns(:profile).should eq @admin_profile
end
end
describe "When logged in as User" do
login_fixture_user
it "should not assign the requested user as @profile" do
profile = FactoryBot.create(:profile)
get :edit, params: { id: profile.id }
assigns(:profile).should eq(profile)
response.should be_forbidden
end
it "should edit myself" do
get :edit, params: { id: profiles(:profile_user1).id }
response.should redirect_to edit_my_account_url
end
end
describe "When not logged in" do
it "should not assign the requested user as @profile" do
profile = FactoryBot.create(:profile)
get :edit, params: { id: profile.id }
assigns(:profile).should eq nil
response.should redirect_to(new_user_session_url)
end
end
end
describe "POST create" do
before(:each) do
@attrs = FactoryBot.attributes_for(:profile)
@invalid_attrs = { user_group_id: '', user_number: '日本語' }
end
describe "When logged in as Administrator" do
login_fixture_admin
describe "with valid params" do
it "assigns a newly created user as @profile" do
post :create, params: { profile: @attrs }
assigns(:profile).should be_valid
end
it "redirects to the created user" do
post :create, params: { profile: @attrs }
response.should redirect_to(profile_url(assigns(:profile)))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved user as @profile" do
post :create, params: { profile: @invalid_attrs }
assigns(:profile).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { profile: @invalid_attrs }
response.should render_template("new")
end
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
describe "with valid params" do
it "assigns a newly created user as @profile" do
post :create, params: { profile: @attrs }
assigns(:profile).should be_valid
end
it "redirects to the created user" do
post :create, params: { profile: @attrs }
response.should redirect_to(profile_url(assigns(:profile)))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved user as @profile" do
post :create, params: { profile: @invalid_attrs }
assigns(:profile).should_not be_valid
end
it "re-renders the 'new' template" do
post :create, params: { profile: @invalid_attrs }
response.should render_template("new")
end
end
end
describe "When logged in as User" do
login_fixture_user
it "should not create user" do
post :create, params: { profile: { username: 'test10' } }
assigns(:profile).should be_nil
response.should be_forbidden
end
end
describe "When not logged in" do
it "should not create user" do
post :create, params: { profile: { username: 'test10' } }
response.should redirect_to new_user_session_url
end
end
end
describe "PUT update" do
before(:each) do
@profile = profiles(:profile_user1)
@attrs = { user_group_id: '3', locale: 'en' }
@invalid_attrs = { user_group_id: '', user_number: '日本語' }
end
describe "When logged in as Administrator" do
login_fixture_admin
describe "with valid params" do
it "updates the requested user" do
put :update, params: { id: @profile.id, profile: @attrs }
end
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @attrs }
assigns(:profile).should eq(@profile)
end
it "redirects to the user" do
put :update, params: { id: @profile.id, profile: @attrs }
assigns(:profile).should eq(@profile)
response.should redirect_to(@profile)
end
end
describe "with invalid params" do
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @invalid_attrs }
assigns(:profile).should eq(@profile)
end
it "re-renders the 'edit' template" do
put :update, params: { id: @profile, profile: @invalid_attrs }
response.should render_template("edit")
end
end
it "should update other user's role" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_attributes: { user_has_role_attributes: { role_id: 4 }, email: profiles(:profile_user1).user.email, locale: 'en', id: profiles(:profile_user1).user.id } } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).reload
assigns(:profile).user.role.should eq Role.where(name: 'Administrator').first
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
describe "with valid params" do
it "updates the requested user" do
put :update, params: { id: @profile.id, profile: @attrs }
end
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @attrs }
assigns(:profile).should eq(@profile)
end
it "redirects to the user" do
put :update, params: { id: @profile.id, profile: @attrs }
assigns(:profile).should eq(@profile)
response.should redirect_to(@profile)
end
end
describe "with invalid params" do
it "assigns the user as @profile" do
put :update, params: { id: @profile, profile: @invalid_attrs }
assigns(:profile).should_not be_valid
end
it "re-renders the 'edit' template" do
put :update, params: { id: @profile, profile: @invalid_attrs }
response.should render_template("edit")
end
end
it "should update other user" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_number: '00003', locale: 'en', user_group_id: 3, library_id: 3, note: 'test' } }
response.should redirect_to profile_url(assigns(:profile))
end
it "should not update other admin" do
put :update, params: { id: profiles(:profile_admin).id, profile: { user_number: '00003', locale: 'en', user_group_id: 3, library_id: 3, note: 'test' } }
response.should be_forbidden
end
it "should update other user's user_group" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_group_id: 3, library_id: 3, locale: 'en' } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).user_group_id.should eq 3
end
it "should update other user's note" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_group_id: 3, library_id: 3, note: 'test', locale: 'en' } }
response.should redirect_to profile_url(assigns(:profile))
assert_equal assigns(:profile).note, 'test'
end
it "should update other user's locked status" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_attributes: { id: 3, locked: '1', username: 'user1' } } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).user.locked_at.should be_truthy
assigns(:profile).user.access_locked?.should be_truthy
end
it "should unlock other user" do
profiles(:profile_user1).user.lock_access!
put :update, params: { id: profiles(:profile_user1).id, profile: { user_attributes: { id: 3, locked: '0', username: 'user1' } } }
response.should redirect_to profile_url(assigns(:profile))
expect(assigns(:profile).user.locked_at).to be_falsy
expect(assigns(:profile).user.access_locked?).to be_falsy
end
end
describe "When logged in as User" do
login_fixture_user
describe "with valid params" do
it "updates the requested user" do
put :update, params: { id: @profile.id, profile: @attrs }
end
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @attrs }
assigns(:profile).should be_valid
response.should redirect_to profile_url(assigns(:profile))
end
end
describe "with invalid params" do
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @invalid_attrs }
# assigns(:profile).should_not be_valid
# response.should be_successful
assigns(:profile).should be_valid
response.should redirect_to profile_url(assigns(:profile))
end
end
it "should update myself" do
put :update, params: { id: profiles(:profile_user1).id, profile: { keyword_list: 'test' } }
response.should redirect_to profile_url(assigns(:profile))
end
it "should not update my role" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_has_role_attributes: { role_id: 4 } } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).user.role.should_not eq Role.where(name: 'Administrator').first
end
it "should not update my user_group" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_group_id: 3, library_id: 3 } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).user_group_id.should eq 1
end
it "should not update my note" do
put :update, params: { id: profiles(:profile_user1).id, profile: { user_group_id: 3, library_id: 3, note: 'test' } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).note.should be_nil
end
it "should update my keyword_list" do
put :update, params: { id: profiles(:profile_user1).id, profile: { keyword_list: 'test' } }
response.should redirect_to profile_url(assigns(:profile))
assigns(:profile).keyword_list.should eq 'test'
assigns(:profile).user.role.name.should eq 'User'
end
it "should not update other user" do
put :update, params: { id: profiles(:profile_user2).id, profile: {} }
assigns(:profile).should be_valid
response.should be_forbidden
end
end
describe "When not logged in" do
describe "with valid params" do
it "updates the requested user" do
put :update, params: { id: @profile.id, profile: @attrs }
end
it "should be forbidden" do
put :update, params: { id: @profile.id, profile: @attrs }
response.should redirect_to(new_user_session_url)
end
end
describe "with invalid params" do
it "assigns the requested user as @profile" do
put :update, params: { id: @profile.id, profile: @invalid_attrs }
response.should redirect_to(new_user_session_url)
end
end
end
end
describe "DELETE destroy" do
describe "When logged in as Administrator" do
login_fixture_admin
it "destroys the requested user" do
delete :destroy, params: { id: profiles(:profile_user2).id }
end
it "redirects to the profiles list" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should redirect_to(profiles_url)
end
it "should destroy librarian" do
delete :destroy, params: { id: profiles(:profile_librarian2).id }
response.should redirect_to(profiles_url)
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "destroys the requested user" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should redirect_to(profiles_url)
end
it "redirects to the profiles list" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should redirect_to(profiles_url)
end
it "should not destroy librarian" do
delete :destroy, params: { id: profiles(:profile_librarian2).id }
response.should be_forbidden
end
it "should not destroy admin" do
delete :destroy, params: { id: profiles(:profile_admin).id }
response.should be_forbidden
end
it "should not destroy myself" do
delete :destroy, params: { id: profiles(:profile_librarian1).id }
response.should be_forbidden
end
it "should not be able to delete other librarian user" do
delete :destroy, params: { id: @librarian_profile.id }
response.should be_forbidden
end
end
describe "When logged in as User" do
login_fixture_user
it "destroys the requested user" do
delete :destroy, params: { id: profiles(:profile_user2).id }
end
it "should be forbidden" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should be_forbidden
end
it "should not destroy myself" do
delete :destroy, params: { id: profiles(:profile_user1).id }
response.should be_forbidden
end
end
describe "When not logged in" do
it "destroys the requested user" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should redirect_to(new_user_session_url)
end
it "should be forbidden" do
delete :destroy, params: { id: profiles(:profile_user2).id }
response.should redirect_to(new_user_session_url)
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/spec/controllers/inventories_controller_spec.rb | spec/controllers/inventories_controller_spec.rb | require 'rails_helper'
describe InventoriesController do
fixtures :all
describe "GET index" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns all inventories as @inventories" do
get :index
expect(assigns(:inventories)).to eq(Inventory.page(1))
expect(response).to be_successful
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns all inventories as @inventories" do
get :index
expect(assigns(:inventories)).to eq(Inventory.page(1))
expect(response).to be_successful
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns all empty as @inventories" do
get :index
expect(assigns(:inventories)).to be_nil
expect(response).to be_forbidden
end
end
describe "When not logged in" do
it "assigns all inventories as @inventories" do
get :index
expect(assigns(:inventories)).to be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe "GET show" do
describe "When logged in as Administrator" do
login_fixture_admin
it "assigns the requested inventory as @inventory" do
get :show, params: { id: 1 }
expect(assigns(:inventory)).to eq(Inventory.find(1))
expect(response).to be_successful
end
end
describe "When logged in as Librarian" do
login_fixture_librarian
it "assigns the requested inventory as @inventory" do
get :show, params: { id: 1 }
expect(assigns(:inventory)).to eq(Inventory.find(1))
expect(response).to be_successful
end
end
describe "When logged in as User" do
login_fixture_user
it "assigns the requested inventory as @inventory" do
get :show, params: { id: 1 }
expect(assigns(:inventory)).to eq(Inventory.find(1))
expect(response).to be_forbidden
end
end
describe "When not logged in" do
it "assigns the requested inventory as @inventory" do
get :show, params: { id: 1 }
expect(assigns(:inventory)).to eq(Inventory.find(1))
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/user_import_files_controller_spec.rb | spec/controllers/user_import_files_controller_spec.rb | require 'rails_helper'
describe UserImportFilesController do
fixtures :all
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all user_import_files as @user_import_files' do
get :index
assigns(:user_import_files).should eq(UserImportFile.order('id DESC').page(1))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns all user_import_files as @user_import_files' do
get :index
assigns(:user_import_files).should eq(UserImportFile.order('id DESC').page(1))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns empty as @user_import_files' do
get :index
assigns(:user_import_files).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'assigns empty as @user_import_files' do
get :index
assigns(:user_import_files).should be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_import_file as @user_import_file' do
get :show, params: { id: user_import_files(:two).id }
assigns(:user_import_file).should eq(user_import_files(:two))
expect(response).to be_successful
end
it 'assigns user_import_results' do
get :show, params: { id: user_import_files(:one).id }
expect(response).to be_successful
expect(assigns(:user_import_file)).to eq user_import_files(:one)
expect(assigns(:user_import_results)).to include user_import_results(:one)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_import_file as @user_import_file' do
get :show, params: { id: user_import_files(:two).id }
assigns(:user_import_file).should eq(user_import_files(:two))
expect(response).to be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_import_file as @user_import_file' do
get :show, params: { id: user_import_files(:two).id }
assigns(:user_import_file).should eq(user_import_files(:two))
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'assigns the requested user_import_file as @user_import_file' do
get :show, params: { id: user_import_files(:two).id }
assigns(:user_import_file).should eq(user_import_files(:two))
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_import_file as @user_import_file' do
get :new
assigns(:user_import_file).should_not be_valid
expect(response).to be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not assign the requested user_import_file as @user_import_file' do
get :new
assigns(:user_import_file).should_not be_valid
expect(response).to be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested user_import_file as @user_import_file' do
get :new
assigns(:user_import_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_import_file as @user_import_file' do
get :new
assigns(:user_import_file).should be_nil
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
describe 'When logged in as Librarian' do
before(:each) do
profile = FactoryBot.create(:profile)
@user = FactoryBot.create(:librarian)
@user.profile = profile
sign_in @user
end
it 'should create agent_import_file' do
post :create, params: { user_import_file: {
attachment: fixture_file_upload('user_import_file_sample.tsv', 'text/csv'),
default_library_id: 1,
default_user_group_id: 1
} }
assigns(:user_import_file).should be_valid
assigns(:user_import_file).user.username.should eq @user.username
expect(response).to redirect_to user_import_file_url(assigns(:user_import_file))
end
end
describe 'When logged in as User' do
before(:each) do
profile = FactoryBot.create(:profile)
@user = FactoryBot.create(:user)
@user.profile = profile
sign_in @user
end
it 'should be forbidden' do
post :create, params: { user_import_file: { attachment: fixture_file_upload('user_import_file_sample.tsv', 'text/csv') } }
assigns(:user_import_file).should be_nil
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should be redirected to new session url' do
post :create, params: { user_import_file: { attachment: fixture_file_upload('user_import_file_sample.tsv', 'text/csv') } }
assigns(:user_import_file).should be_nil
expect(response).to redirect_to new_user_session_url
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested user_import_file as @user_import_file' do
user_import_file = user_import_files(:one)
get :edit, params: { id: user_import_file.id }
assigns(:user_import_file).should eq(user_import_file)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested user_import_file as @user_import_file' do
user_import_file = user_import_files(:one)
get :edit, params: { id: user_import_file.id }
assigns(:user_import_file).should eq(user_import_file)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested user_import_file as @user_import_file' do
user_import_file = user_import_files(:one)
get :edit, params: { id: user_import_file.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested user_import_file as @user_import_file' do
user_import_file = user_import_files(:one)
get :edit, params: { id: user_import_file.id }
expect(response).to redirect_to(new_user_session_url)
end
end
end
describe 'PUT update' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should update user_import_file' do
user_import_file = UserImportFile.create!(
attachment: fixture_file_upload('user_import_file_sample.tsv', 'text/csv'),
user: users(:admin),
default_library_id: 1,
default_user_group_id: 1
)
put :update, params: { id: user_import_file.id, user_import_file: { note: 'test' } }
expect(response).to redirect_to user_import_file_url(assigns(:user_import_file))
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should update user_import_file' do
user_import_file = UserImportFile.create!(
attachment: fixture_file_upload('user_import_file_sample.tsv', 'text/csv'),
user: users(:admin),
default_library_id: 1,
default_user_group_id: 1
)
put :update, params: { id: user_import_file.id, user_import_file: { note: 'test' } }
expect(response).to redirect_to user_import_file_url(assigns(:user_import_file))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not update user_import_file' do
put :update, params: { id: user_import_files(:two).id, user_import_file: {} }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'should not update user_import_file' do
put :update, params: { id: user_import_files(:two).id, user_import_file: {} }
expect(response).to redirect_to new_user_session_url
end
end
end
describe 'DELETE destroy' do
before(:each) do
@user_import_file = user_import_files(:one)
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'destroys the requested user_import_file' do
delete :destroy, params: { id: @user_import_file.id }
end
it 'redirects to the user_import_files list' do
delete :destroy, params: { id: @user_import_file.id }
expect(response).to redirect_to(user_import_files_url)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'destroys the requested user_import_file' do
delete :destroy, params: { id: @user_import_file.id }
end
it 'redirects to the user_import_files list' do
delete :destroy, params: { id: @user_import_file.id }
expect(response).to redirect_to(user_import_files_url)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'destroys the requested user_import_file' do
delete :destroy, params: { id: @user_import_file.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_import_file.id }
expect(response).to be_forbidden
end
end
describe 'When not logged in' do
it 'destroys the requested user_import_file' do
delete :destroy, params: { id: @user_import_file.id }
end
it 'should be forbidden' do
delete :destroy, params: { id: @user_import_file.id }
expect(response).to redirect_to(new_user_session_url)
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/spec/controllers/checked_items_controller_spec.rb | spec/controllers/checked_items_controller_spec.rb | require 'rails_helper'
describe CheckedItemsController do
fixtures :all
describe 'GET index' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns all checked_items as @checked_items' do
get :index
assigns(:checked_items).should_not be_empty
response.should be_successful
end
it 'should get index without basket_id' do
get :index, params: { item_id: 1 }
assigns(:checked_items).should_not be_empty
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should be forbidden' do
get :index
assigns(:checked_items).should_not be_empty
response.should be_successful
end
describe 'When basket is specified' do
it 'assigns checked_items as @checked_items' do
get :index, params: { basket_id: 1 }
assigns(:checked_items).should_not be_empty
response.should be_successful
end
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns empty as @checked_items' do
get :index
assigns(:checked_items).should be_nil
response.should be_forbidden
end
it 'should not get index' do
get :index, params: { basket_id: 3, item_id: 3 }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns empty as @checked_items' do
get :index
assigns(:checked_items).should be_nil
response.should redirect_to(new_user_session_url)
end
it 'should not get index with basket_id and item_id' do
get :index, params: { basket_id: 1, item_id: 1 }
assigns(:checked_items).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET show' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checked_item as @checked_item' do
get :show, params: { id: 1 }
assigns(:checked_item).should eq(checked_items(:checked_item_00001))
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested checked_item as @checked_item' do
get :show, params: { id: 1 }
assigns(:checked_item).should eq(checked_items(:checked_item_00001))
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested checked_item as @checked_item' do
get :show, params: { id: 1 }
assigns(:checked_item).should eq(checked_items(:checked_item_00001))
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'assigns the requested checked_item as @checked_item' do
get :show, params: { id: 1 }
assigns(:checked_item).should eq(checked_items(:checked_item_00001))
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET new' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checked_item as @checked_item' do
get :new, params: { basket_id: 3 }
assigns(:checked_item).should_not be_valid
end
describe 'When basket is not specified' do
it 'should be forbidden' do
get :new
response.should redirect_to new_basket_url
end
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested checked_item as @checked_item' do
get :new, params: { basket_id: 3 }
assigns(:checked_item).should_not be_valid
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not assign the requested checked_item as @checked_item' do
get :new, params: { basket_id: 3 }
assigns(:checked_item).should be_nil
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested checked_item as @checked_item' do
get :new, params: { basket_id: 3 }
assigns(:checked_item).should be_nil
response.should redirect_to(new_user_session_url)
end
end
end
describe 'GET edit' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'assigns the requested checked_item as @checked_item' do
checked_item = checked_items(:checked_item_00001)
get :edit, params: { id: checked_item.id }
assigns(:checked_item).should eq(checked_item)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'assigns the requested checked_item as @checked_item' do
checked_item = checked_items(:checked_item_00001)
get :edit, params: { id: checked_item.id }
assigns(:checked_item).should eq(checked_item)
response.should be_successful
end
end
describe 'When logged in as User' do
login_fixture_user
it 'assigns the requested checked_item as @checked_item' do
checked_item = checked_items(:checked_item_00001)
get :edit, params: { id: checked_item.id }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not assign the requested checked_item as @checked_item' do
checked_item = checked_items(:checked_item_00001)
get :edit, params: { id: checked_item.id }
response.should redirect_to(new_user_session_url)
end
end
end
describe 'POST create' do
before(:each) do
@attrs = { item_identifier: '00011' }
@invalid_attrs = { item_identifier: 'invalid' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
describe 'When the item is missing' do
it 'assigns a newly created checked_item as @checked_item' do
post :create, params: { checked_item: { item_identifier: 'not found' }, basket_id: 1 }
assigns(:checked_item).should_not be_valid
assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.item_not_found')).should be_truthy
end
end
describe 'When the item is not for checkout' do
it 'assigns a newly created checked_item as @checked_item' do
post :create, params: { checked_item: { item_identifier: '00017' }, basket_id: 1 }
assigns(:checked_item).should_not be_valid
assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.not_available_for_checkout')).should be_truthy
end
end
describe 'When the item is already checked out' do
it 'assigns a newly created checked_item as @checked_item' do
post :create, params: { checked_item: { item_identifier: '00013' }, basket_id: 8 }
assigns(:checked_item).should_not be_valid
assigns(:checked_item).errors[:base].include?(I18n.t('activerecord.errors.messages.checked_item.already_checked_out')).should be_truthy
end
end
describe 'When the item is reserved' do
it 'assigns a newly created checked_item as @checked_item' do
old_count = items(:item_00021).manifestation.reserves.waiting.count
post :create, params: { checked_item: { item_identifier: '00021' }, basket_id: 11 }
expect(items(:item_00021).user_reservation(Basket.find(11).user)).to be_truthy
expect(assigns(:checked_item)).not_to be_valid
expect(assigns(:checked_item).errors[:base]).to include(I18n.t('activerecord.errors.messages.checked_item.reserved_item_included'))
assigns(:checked_item).item.manifestation.reserves.waiting.count.should eq old_count
assigns(:checked_item).librarian.should eq users(:admin)
end
end
it 'should not create checked_item without basket_id' do
post :create, params: { checked_item: { item_identifier: '00004' } }
response.should be_forbidden
end
it 'should not create checked_item without item_id' do
post :create, params: { checked_item: { item_identifier: '00004' }, basket_id: 1 }
response.should be_successful
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should create checked_item' do
post :create, params: { checked_item: @attrs, basket_id: 3 }
assigns(:checked_item).due_date.to_s.should eq Time.zone.now.tomorrow.end_of_day.to_s
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
it 'should create checked_item with item_identifier' do
post :create, params: { checked_item: { item_identifier: '00011' }, basket_id: 3 }
assigns(:checked_item).should be_truthy
assigns(:checked_item).due_date.should_not be_nil
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
it 'should override due_date' do
post :create, params: { checked_item: { item_identifier: '00011', due_date_string: 1.year.from_now.strftime('%Y-%m-%d') }, basket_id: 3 }
assigns(:checked_item).should be_truthy
assigns(:checked_item).due_date.to_s.should eq 1.year.from_now.end_of_day.to_s
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
it 'should not create checked_item with an invalid due_date' do
post :create, params: { checked_item: { item_identifier: '00011', due_date_string: 'invalid' }, basket_id: 3 }
assigns(:checked_item).should_not be_valid
assigns(:checked_item).due_date.should be_nil
response.should be_successful
end
it 'should not create checked_item if excessed checkout_limit' do
post :create, params: { checked_item: { item_identifier: '00011' }, basket_id: 1 }
response.should be_successful
assigns(:checked_item).errors['base'].include?(I18n.t('activerecord.errors.messages.checked_item.excessed_checkout_limit')).should be_truthy
end
it 'should show message when the item includes supplements' do
post :create, params: { checked_item: { item_identifier: '00006' }, basket_id: 3 }
assigns(:checked_item).due_date.should_not be_nil
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
flash[:message].index(I18n.t('item.this_item_include_supplement')).should be_truthy
end
it 'should create checked_item when ignore_restriction is checked' do
post :create, params: { checked_item: { item_identifier: '00011', ignore_restriction: '1' }, basket_id: 2 }
assigns(:checked_item).due_date.should_not be_nil
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not create checked_item' do
post :create, params: { checked_item: { item_identifier: '00004' }, basket_id: 3 }
response.should be_forbidden
end
end
describe 'When not logged in as' do
it 'should not create checked_item' do
post :create, params: { checked_item: { item_identifier: '00004' }, basket_id: 1 }
response.should redirect_to new_user_session_url
end
end
end
describe 'PUT update' do
before(:each) do
@attrs = { item_identifier: '00011' }
@invalid_attrs = { item_identifier: 'invalid' }
end
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should not update checked_item without basket_id' do
put :update, params: { id: 1, checked_item: {} }
response.should be_forbidden
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should not update checked_item without basket_id' do
put :update, params: { id: 1, checked_item: {} }
response.should be_forbidden
end
it 'should update checked_item' do
put :update, params: { id: 4, checked_item: {}, basket_id: 8 }
assigns(:checked_item).should be_valid
response.should redirect_to checked_item_url(assigns(:checked_item))
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not update checked_item' do
put :update, params: { id: 1, checked_item: {}, basket_id: 3 }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not update checked_item' do
put :update, params: { id: 1, checked_item: {}, basket_id: 1 }
response.should redirect_to new_user_session_url
end
end
end
describe 'DELETE destroy' do
describe 'When logged in as Administrator' do
login_fixture_admin
it 'should destroy checked_item' do
delete :destroy, params: { id: 1 }
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
end
describe 'When logged in as Librarian' do
login_fixture_librarian
it 'should destroy checked_item' do
delete :destroy, params: { id: 1 }
response.should redirect_to checked_items_url(basket_id: assigns(:checked_item).basket_id)
end
end
describe 'When logged in as User' do
login_fixture_user
it 'should not destroy checked_item' do
delete :destroy, params: { id: 3 }
response.should be_forbidden
end
end
describe 'When not logged in' do
it 'should not destroy checked_item' do
delete :destroy, params: { id: 1 }
response.should redirect_to new_user_session_url
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/spec/models/request_status_type_spec.rb | spec/models/request_status_type_spec.rb | require 'rails_helper'
describe RequestStatusType do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: request_status_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_status_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/purchase_request_spec.rb | spec/models/purchase_request_spec.rb | require 'rails_helper'
describe PurchaseRequest do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: purchase_requests
#
# id :bigint not null, primary key
# accepted_at :datetime
# author :text
# date_of_publication :datetime
# denied_at :datetime
# isbn :string
# note :text
# price :integer
# pub_date :string
# publisher :text
# state :string
# title :text not null
# url :string
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_purchase_requests_on_state (state)
# index_purchase_requests_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/agent_spec.rb | spec/models/agent_spec.rb | require 'rails_helper'
describe Agent do
# pending "add some examples to (or delete) #{__FILE__}"
fixtures :all
it "should set a default required_role to Guest" do
agent = FactoryBot.create(:agent)
agent.required_role.should eq Role.find_by(name: 'Guest')
end
it "should set birth_date" do
agent = FactoryBot.create(:agent, birth_date: '2000')
agent.date_of_birth.should eq Time.zone.parse('2000-01-01')
end
it "should set death_date" do
agent = FactoryBot.create(:agent, death_date: '2000')
agent.date_of_death.should eq Time.zone.parse('2000-01-01')
end
it "should not set death_date earlier than birth_date" do
agent = FactoryBot.create(:agent, birth_date: '2010', death_date: '2000')
agent.should_not be_valid
end
it "should be creator" do
agents(:agent_00001).creator?(manifestations(:manifestation_00001)).should be_truthy
end
it "should not be creator" do
agents(:agent_00010).creator?(manifestations(:manifestation_00001)).should be_falsy
end
it "should be publisher" do
agents(:agent_00001).publisher?(manifestations(:manifestation_00001)).should be_truthy
end
it "should not be publisher" do
agents(:agent_00010).publisher?(manifestations(:manifestation_00001)).should be_falsy
end
describe ".import_agents" do
it "should import agents" do
agent_list = [ { full_name: "Agent 1" }, { full_name: "Agent 2" } ]
agents = Agent.import_agents(agent_list)
expect(agents).to be_truthy
expect(agents.first).to be_truthy
expect(agents.first.full_name).to eq "Agent 1"
expect(agents.last).to be_truthy
expect(agents.last.full_name).to eq "Agent 2"
end
it "should import place" do
agent_list = [ { full_name: "Agent 1", place: "place" } ]
agents = Agent.import_agents(agent_list)
expect(agents.first).to be_truthy
expect(agents.first.place).to eq "place"
end
it "should unique the same agent" do
agent_list = [ { full_name: "Agent 1", place: "place" }, { full_name: "Agent 1" } ]
agents = Agent.import_agents(agent_list)
expect(agents.size).to be 1
end
it "should distinguish the agents even with the same full_name" do
agent_list = [ { full_name: "Agent 1", place: "place 1" }, { full_name: "Agent 1", place: "place 2" } ]
agents = Agent.import_agents(agent_list)
expect(agents.size).to be 2
end
end
end
# == Schema Information
#
# Table name: agents
#
# id :bigint not null, primary key
# address_1 :text
# address_1_note :text
# address_2 :text
# address_2_note :text
# agent_identifier :string
# birth_date :string
# corporate_name :string
# corporate_name_transcription :string
# date_of_birth :datetime
# date_of_death :datetime
# death_date :string
# email :text
# fax_number_1 :string
# fax_number_2 :string
# first_name :string
# first_name_transcription :string
# full_name :string
# full_name_alternative :text
# full_name_alternative_transcription :text
# full_name_transcription :text
# last_name :string
# last_name_transcription :string
# locality :text
# lock_version :integer default(0), not null
# middle_name :string
# middle_name_transcription :string
# note :text
# other_designation :text
# place :text
# postal_code :string
# region :text
# required_score :integer default(0), not null
# street :text
# telephone_number_1 :string
# telephone_number_2 :string
# url :text
# zip_code_1 :string
# zip_code_2 :string
# created_at :datetime not null
# updated_at :datetime not null
# agent_type_id :bigint default(1), not null
# country_id :bigint default(1), not null
# language_id :bigint default(1), not null
# profile_id :bigint
# required_role_id :bigint default(1), not null
#
# Indexes
#
# index_agents_on_agent_identifier (agent_identifier)
# index_agents_on_country_id (country_id)
# index_agents_on_full_name (full_name)
# index_agents_on_language_id (language_id)
# index_agents_on_profile_id (profile_id)
# index_agents_on_required_role_id (required_role_id)
#
# Foreign Keys
#
# fk_rails_... (required_role_id => roles.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/accept_spec.rb | spec/models/accept_spec.rb | require 'rails_helper'
describe Accept do
fixtures :all
it "should change circulation_status" do
expect(items(:item_00012).circulation_status.name).to eq 'Circulation Status Undefined'
expect(items(:item_00012).use_restriction.name).to eq 'Not For Loan'
accept = FactoryBot.create(:accept, item: items(:item_00012))
expect(accept.item.circulation_status.name).to eq 'Available On Shelf'
expect(accept.item.use_restriction.name).to eq 'Limited Circulation, Normal Loan Period'
end
end
# == Schema Information
#
# Table name: accepts
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# basket_id :bigint
# item_id :bigint
# librarian_id :bigint
#
# Indexes
#
# index_accepts_on_basket_id (basket_id)
# index_accepts_on_item_id (item_id) UNIQUE
# index_accepts_on_librarian_id (librarian_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_export_file_spec.rb | spec/models/user_export_file_spec.rb | require 'rails_helper'
describe UserExportFile do
fixtures :all
it "should export users" do
message_count = Message.count
file = UserExportFile.create(user: users(:admin))
file.export!
#UserExportFileJob.perform_later(file).should be_truthy
Message.count.should eq message_count + 1
Message.order(:created_at).last.subject.should eq "Export completed: #{file.id}"
end
end
# == Schema Information
#
# Table name: user_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
#
# Indexes
#
# index_user_export_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/realize_type_spec.rb | spec/models/realize_type_spec.rb | require 'rails_helper'
describe RealizeType do
it 'should create realize_type' do
FactoryBot.create(:realize_type)
end
end
# == Schema Information
#
# Table name: realize_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_realize_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/frequency_spec.rb | spec/models/frequency_spec.rb | require 'rails_helper'
describe Frequency do
fixtures :frequencies
it "should should have display_name" do
frequencies(:frequency_00001).display_name.should_not be_nil
end
end
# == Schema Information
#
# Table name: frequencies
#
# 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_frequencies_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_has_use_resetriction_spec.rb | spec/models/item_has_use_resetriction_spec.rb | require 'rails_helper'
describe ItemHasUseRestriction 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/country_spec.rb | spec/models/country_spec.rb | require 'rails_helper'
describe Country do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: countries
#
# id :bigint not null, primary key
# alpha_2 :string
# alpha_3 :string
# display_name :text
# name :string not null
# note :text
# numeric_3 :string
# position :integer
#
# Indexes
#
# index_countries_on_alpha_2 (alpha_2)
# index_countries_on_alpha_3 (alpha_3)
# index_countries_on_lower_name (lower((name)::text)) UNIQUE
# index_countries_on_numeric_3 (numeric_3)
#
| 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/withdraw_spec.rb | spec/models/withdraw_spec.rb | require 'rails_helper'
RSpec.describe Withdraw, type: :model do
fixtures :all
it "should change circulation_status" do
withdraw = FactoryBot.create(:withdraw)
expect(withdraw.item.circulation_status.name).to eq 'Removed'
expect(withdraw.item.use_restriction.name).to eq 'Not For Loan'
end
it "should not withdraw rented item" do
withdraw = Withdraw.new(librarian: users(:librarian1))
withdraw.item = items(:item_00013)
expect(withdraw.valid?).to be_falsy
expect(withdraw.errors.messages[:item_id]).to include('is rented.')
end
it "should not withdraw reserved item" do
reserve = FactoryBot.create(:reserve)
withdraw = FactoryBot.build(:withdraw, item: reserve.manifestation.items.first)
expect(withdraw.valid?).to be_falsy
expect(withdraw.errors.messages[:item_id]).to include('is reserved.')
end
end
# == Schema Information
#
# Table name: withdraws
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# basket_id :bigint
# item_id :bigint
# librarian_id :bigint
#
# Indexes
#
# index_withdraws_on_basket_id (basket_id)
# index_withdraws_on_item_id (item_id) UNIQUE
# index_withdraws_on_librarian_id (librarian_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/event_export_file_spec.rb | spec/models/event_export_file_spec.rb | require 'rails_helper'
describe EventExportFile do
fixtures :all
it "should export in background" do
message_count = Message.count
file = EventExportFile.new
file.user = users(:admin)
file.save
expect(EventExportFileJob.perform_later(file)).to be_truthy
# Message.count.should eq message_count + 1
# Message.order(:created_at).last.subject.should eq "Export completed: #{file.id}"
end
end
# == Schema Information
#
# Table name: event_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
#
# Indexes
#
# index_event_export_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/ndl_book_spec.rb | spec/models/ndl_book_spec.rb | require 'rails_helper'
describe NdlBook do
fixtures :all
it "should respond to per_page" do
NdlBook.per_page.should eq 10
end
context 'search' do
it 'should search bibliographic record', vcr: true do
NdlBook.search('library system')[:total_entries].should eq 2282
end
it "should not distinguish double byte space from one-byte space in a query", vcr: true do
NdlBook.search("カミュ ペスト")[:total_entries].should eq NdlBook.search("カミュ ペスト")[:total_entries]
end
end
context "import" do
it "should import bibliographic record", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000010980901')
expect(manifestation.manifestation_identifier).to eq 'https://ndlsearch.ndl.go.jp/books/R100000002-I000010980901'
expect(manifestation.isbn_records.pluck(:body)).to eq [ '9784839931995' ]
expect(manifestation.classifications.pluck(:category)).to eq [ "007.64" ]
expect(manifestation.ndl_bib_id_record.body).to eq "R100000002-I000010980901"
expect(manifestation.jpno_record.body).to eq "21816393"
expect(manifestation.language.name).to eq "Japanese"
expect(manifestation.creators.first.full_name).to eq '秋葉, 拓哉'
expect(manifestation.creators.first.full_name_transcription).to eq 'アキバ, タクヤ'
expect(manifestation.creators.first.ndla_record.body).to eq 'http://id.ndl.go.jp/auth/entity/01208840'
manifestation.price.should eq 3280
manifestation.start_page.should eq 1
manifestation.end_page.should eq 315
manifestation.height.should eq 24.0
manifestation.subjects.size.should eq 1
manifestation.subjects.first.subject_heading_type.name.should eq 'ndlsh'
manifestation.subjects.first.term.should eq 'プログラミング (コンピュータ)'
manifestation.classifications.first.category.should eq '007.64'
manifestation.statement_of_responsibility.should eq '秋葉拓哉, 岩田陽一, 北川宜稔 著; Usu-ya 編'
manifestation.extent.should eq "315p"
manifestation.dimensions.should eq "24cm"
end
it "should import bibliographic record that does not have any classifications", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000003641700')
manifestation.original_title.should eq "アンパンマンとどうぶつえん"
manifestation.title_transcription.should eq "アンパンマン ト ドウブツエン"
end
it "should import volume_number_string", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000011037191')
manifestation.volume_number_string.should eq '上'
end
it "should import title_alternative", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000010926074')
manifestation.title_alternative.should eq 'PLATINADATA'
manifestation.title_alternative_transcription.should eq 'PLATINA DATA'
end
it "should import series_statement", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000004152429')
manifestation.original_title.should eq "ズッコケ三人組のダイエット講座"
manifestation.series_statements.first.original_title.should eq "ポプラ社文庫. ズッコケ文庫"
manifestation.serial.should be_falsy
end
it "should import series_statement's creator", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000008369884')
manifestation.series_statements.first.original_title.should eq "新・図書館学シリーズ"
manifestation.series_statements.first.creator_string.should eq "高山正也, 植松貞夫 監修"
end
it "should import series_statement transctiption", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000011242276')
manifestation.series_statements.first.original_title.should eq "講談社現代新書"
manifestation.series_statements.first.title_transcription.should eq "コウダンシャ ゲンダイ シンショ"
end
it "should import series_statement if the resource is serial", vcr: true, solr: true do
manifestation = NdlBook.import_from_sru_response('R100000039-I3377584')
manifestation.original_title.should eq "週刊新潮"
manifestation.series_statements.first.original_title.should eq "週刊新潮"
manifestation.series_statements.first.series_master.should be_truthy
manifestation.serial.should be_truthy
manifestation.series_statements.first.root_manifestation.should eq manifestation
manifestation.root_series_statement.should eq manifestation.series_statements.first
manifestation.index!
search = Manifestation.search
search.build do
with(:resource_master).equal_to true
order_by(:created_at, :desc)
end
results = search.execute!.results
expect(results.map(&:original_title).include?("週刊新潮")).to be_truthy
end
it "should import pud_date is nil", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000000017951')
manifestation.original_title.should eq "西日本哲学会会報"
manifestation.pub_date.should be_nil
end
it "should import url contain whitespace", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000002109818')
manifestation.original_title.should eq 'ザ・スコット・フィッツジェラルド・ブック'
manifestation.pub_date.should eq '1991'
end
it "should import audio cd", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000010273695')
manifestation.original_title.should eq "劇場版天元突破グレンラガン螺巌篇サウンドトラック・プラス"
# 2024年の更新でSoundとして返ってくるようになった
manifestation.manifestation_content_type.name.should eq 'sounds'
end
it "should import video dvd", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000009149656')
manifestation.original_title.should eq "天元突破グレンラガン"
manifestation.manifestation_content_type.name.should eq 'two_dimensional_moving_image'
end
it "should not get volume number if book has not volume", vcr: true do
NdlBook.search('978-4-04-874013-5')[:items].first.title.should eq "天地明察"
end
it "should get volume number", vcr: true do
NdlBook.search('978-4-04-100292-6')[:items].first.volume.should eq "下"
end
it "should not get volume number if book has not volume", vcr: true do
NdlBook.search('978-4-04-874013-5')[:items].first.volume.should eq ""
end
it "should get series title", vcr: true do
book = NdlBook.search("4840114404")[:items].first
book.series_title.should eq "マジック・ツリーハウス ; 15"
end
it "should not get series title if book has not series title", vcr: true do
book = NdlBook.search("4788509105")[:items].first
book.series_title.should eq ""
end
it "should import publication_place", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000007725666')
manifestation.publication_place.should eq "つくば"
end
it "should import tactile_text", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000002368034')
# 2024年の更新でBookとして返ってくるようになった
# manifestation.manifestation_content_type.name.should eq 'tactile_text'
manifestation.manifestation_content_type.name.should eq 'text'
end
#it "should import computer_program", :vcr => true do
# manifestation = NdlBook.import_from_sru_response('R100000002-I000003048761')
# manifestation.manifestation_content_type.name.should eq 'computer_program'
#end
it "should import map", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I025478296')
manifestation.manifestation_content_type.name.should eq 'cartographic_image'
end
it "should import notated_music", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I025516419')
manifestation.manifestation_content_type.name.should eq 'notated_music'
end
it "should import photograph", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000010677225')
manifestation.manifestation_content_type.name.should eq 'still_image'
end
it "should import painting", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I000009199930')
manifestation.manifestation_content_type.name.should eq 'still_image'
end
it "should import picture postcard", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I024847245')
manifestation.manifestation_content_type.name.should eq 'still_image'
end
it "should import still_image", vcr: true do
manifestation = NdlBook.import_from_sru_response('R100000002-I024016497')
manifestation.manifestation_content_type.name.should eq 'still_image'
end
it "should import ndc8 classification", vcr: true do
manifestation = NdlBook.import_from_sru_response("R100000002-I000002467093")
manifestation.classifications.should_not be_empty
manifestation.classifications.first.classification_type.name.should eq "ndc8"
manifestation.classifications.first.category.should eq "547.48"
end
it "should import edition", vcr: true do
manifestation = NdlBook.import_from_sru_response("R100000002-I025107686")
manifestation.edition_string.should eq "改訂第2版"
end
it "should import volume title", vcr: true do
manifestation = NdlBook.import_from_sru_response("R100000002-I000011225479")
manifestation.original_title.should eq "じゃらん 関東・東北"
manifestation.title_transcription.should eq "ジャラン カントウ トウホク"
end
it "should import even with invalid url", vcr: true do
manifestation = NdlBook.import_from_sru_response("R100000002-I000003523406 ")
expect(manifestation.original_title).to eq "The little boat / written by Kathy Henderson ; illustrated by Patrick Benson."
expect(manifestation.language.name).to eq "English"
expect(manifestation.extent).to eq "1 v. (unpaged) : col. ill."
expect(manifestation.dimensions).to eq "25 x 29 cm."
end
it "should import with DDC [Fic]", vcr: true do
manifestation = NdlBook.import_from_sru_response("R100000002-I000008410444")
expect(manifestation.original_title).to eq "A single shard / Linda Sue Park."
end
it 'should get subject IDs from NDLA', vcr: true do
itemno = "R100000002-I028087126"
url = "https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&maximumRecords=1&query=%28itemno=#{itemno}%29&onlyBib=true"
xml = URI.parse(url).read
doc = Nokogiri::XML(Nokogiri::XML(xml).at('//xmlns:recordData').content)
ndl_book = NdlBook.new(doc)
ndl_book.subjects[0].should eq({ id: 'http://id.ndl.go.jp/auth/ndlsh/01058852', value: 'ウェブアプリケーション' })
ndl_book.subjects[1].should eq({ id: 'http://id.ndl.go.jp/auth/ndlsh/00569223', value: 'プログラミング (コンピュータ)' })
end
it 'should get author IDs from NDLA', vcr: true do
itemno = "R100000002-I028087126"
url = "https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&maximumRecords=1&query=%28itemno=#{itemno}%29&onlyBib=true"
xml = Faraday.get(url).body
doc = Nokogiri::XML(Nokogiri::XML(xml).at('//xmlns:recordData').content)
ndl_book = NdlBook.new(doc)
ndl_book.authors[0].should eq({ id: "http://id.ndl.go.jp/auth/entity/00730574", name: "山田, 祥寛", transcription: "ヤマダ, ヨシヒロ" })
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/models/library_spec.rb | spec/models/library_spec.rb | require 'rails_helper'
describe Library do
fixtures :all
before(:each) do
@library = FactoryBot.create(:library)
end
it "should should create default shelf" do
@library.shelves.first.should be_truthy
@library.shelves.first.name.should eq "#{@library.name}_default"
end
end
# == Schema Information
#
# Table name: libraries
#
# id :bigint not null, primary key
# call_number_delimiter :string default("|"), not null
# call_number_rows :integer default(1), not null
# display_name :text
# fax_number :string
# isil :string
# latitude :float
# locality :text
# longitude :float
# name :string not null
# note :text
# opening_hour :text
# position :integer
# region :text
# short_display_name :string not null
# street :text
# telephone_number_1 :string
# telephone_number_2 :string
# users_count :integer default(0), not null
# zip_code :string
# created_at :datetime not null
# updated_at :datetime not null
# country_id :bigint
# library_group_id :bigint not null
#
# Indexes
#
# index_libraries_on_isil (isil) UNIQUE WHERE (((isil)::text <> ''::text) AND (isil IS NOT NULL))
# index_libraries_on_library_group_id (library_group_id)
# index_libraries_on_lower_name (lower((name)::text)) UNIQUE
# index_libraries_on_name (name) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (library_group_id => library_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/user_reserve_stat_spec.rb | spec/models/user_reserve_stat_spec.rb | require 'rails_helper'
describe UserReserveStat do
fixtures :user_reserve_stats
it "calculates user count" do
old_message_count = Message.count
user_reserve_stats(:one).transition_to!(:started).should be_truthy
Message.count.should eq old_message_count + 1
Message.order(:id).last.subject.should eq '[Enju Library] 集計が完了しました'
end
it "should calculate in background" do
UserReserveStatJob.perform_later(user_reserve_stats(:one)).should be_truthy
end
end
# == Schema Information
#
# Table name: user_reserve_stats
#
# id :bigint not null, primary key
# completed_at :datetime
# end_date :datetime
# note :text
# start_date :datetime
# started_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_user_reserve_stats_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/doi_record_spec.rb | spec/models/doi_record_spec.rb | require 'rails_helper'
RSpec.describe DoiRecord, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: doi_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_doi_records_on_lower_body_manifestation_id (lower((body)::text), manifestation_id) UNIQUE
# index_doi_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/agent_relationship_spec.rb | spec/models/agent_relationship_spec.rb | require 'rails_helper'
describe AgentRelationship do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_relationships
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_relationship_type_id :bigint
# child_id :bigint
# parent_id :bigint
#
# Indexes
#
# index_agent_relationships_on_child_id (child_id)
# index_agent_relationships_on_parent_id (parent_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/subscribe_spec.rb | spec/models/subscribe_spec.rb | require 'rails_helper'
describe Subscribe do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: subscribes
#
# id :bigint not null, primary key
# end_at :datetime not null
# start_at :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# subscription_id :bigint not null
# work_id :bigint not null
#
# Indexes
#
# index_subscribes_on_subscription_id (subscription_id)
# index_subscribes_on_work_id (work_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/event_category_spec.rb | spec/models/event_category_spec.rb | require 'rails_helper'
describe EventCategory do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: event_categories
#
# id :bigint not null, primary key
# name :string not null
# display_name :text
# note :text
# position :integer
# 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/carrier_type_has_checkout_type_spec.rb | spec/models/carrier_type_has_checkout_type_spec.rb | require 'rails_helper'
describe CarrierTypeHasCheckoutType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: carrier_type_has_checkout_types
#
# id :bigint not null, primary key
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# carrier_type_id :bigint not null
# checkout_type_id :bigint not null
#
# Indexes
#
# index_carrier_type_has_checkout_types_on_carrier_type_id (carrier_type_id,checkout_type_id) UNIQUE
# index_carrier_type_has_checkout_types_on_checkout_type_id (checkout_type_id)
#
# Foreign Keys
#
# fk_rails_... (carrier_type_id => carrier_types.id)
# fk_rails_... (checkout_type_id => checkout_types.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_reserve_stat_spec.rb | spec/models/manifestation_reserve_stat_spec.rb | require 'rails_helper'
describe ManifestationReserveStat do
fixtures :manifestation_reserve_stats
it "calculates manifestation count" do
old_message_count = Message.count
manifestation_reserve_stats(:one).transition_to!(:started).should be_truthy
Message.count.should eq old_message_count + 1
Message.order(:id).last.subject.should eq '[Enju Library] 集計が完了しました'
end
it "should calculate in background" do
ManifestationReserveStatJob.perform_later(manifestation_reserve_stats(:one)).should be_truthy
end
end
# == Schema Information
#
# Table name: manifestation_reserve_stats
#
# id :bigint not null, primary key
# completed_at :datetime
# end_date :datetime
# note :text
# start_date :datetime
# started_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_manifestation_reserve_stats_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/order_list_spec.rb | spec/models/order_list_spec.rb | require 'rails_helper'
describe OrderList do
fixtures :all
it "should calculate total price" do
order_list = order_lists(:order_list_00001)
order_list.total_price.should eq 0
order_list.purchase_requests << purchase_requests(:purchase_request_00006)
order_list.total_price.should eq purchase_requests(:purchase_request_00006).price
end
end
# == Schema Information
#
# Table name: order_lists
#
# id :bigint not null, primary key
# note :text
# ordered_at :datetime
# title :text not null
# created_at :datetime not null
# updated_at :datetime not null
# bookstore_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_order_lists_on_bookstore_id (bookstore_id)
# index_order_lists_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (bookstore_id => bookstores.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/participate_spec.rb | spec/models/participate_spec.rb | require 'rails_helper'
describe Participate do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: participates
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# event_id :bigint not null
#
# Indexes
#
# index_participates_on_agent_id (agent_id)
# index_participates_on_event_id (event_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/bookstore_spec.rb | spec/models/bookstore_spec.rb | require 'rails_helper'
describe Bookstore do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: bookstores
#
# id :bigint not null, primary key
# name :text not null
# zip_code :string
# address :text
# note :text
# telephone_number :string
# fax_number :string
# url :string
# position :integer
# 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/budget_type_spec.rb | spec/models/budget_type_spec.rb | require 'rails_helper'
describe BudgetType do
it 'should create budget_type' do
FactoryBot.create(:budget_type)
end
end
# == Schema Information
#
# Table name: budget_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_budget_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/search_engine_spec.rb | spec/models/search_engine_spec.rb | require 'rails_helper'
describe SearchEngine do
fixtures :search_engines
it "should respond to search_params" do
search_engines(:search_engine_00001).search_params('test').should eq({ submit: 'Search', locale: 'ja', keyword: 'test' })
end
end
# == Schema Information
#
# Table name: search_engines
#
# id :bigint not null, primary key
# name :string not null
# display_name :text
# url :string not null
# base_url :text not null
# http_method :text not null
# query_param :text not null
# additional_param :text
# note :text
# position :integer
# 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/picture_file_spec.rb | spec/models/picture_file_spec.rb | require 'rails_helper'
describe PictureFile do
fixtures :all
it "should move position" do
picture_file = PictureFile.find(1)
expect(picture_file.first?).to be_truthy
picture_file.move_lower
expect(picture_file.last?).to be_truthy
end
end
# == Schema Information
#
# Table name: picture_files
#
# id :bigint not null, primary key
# picture_attachable_type :string
# picture_fingerprint :string
# picture_width :integer
# position :integer
# title :text
# created_at :datetime not null
# updated_at :datetime not null
# picture_attachable_id :bigint
#
# Indexes
#
# index_picture_files_on_picture_attachable_id_and_type (picture_attachable_id,picture_attachable_type)
#
| 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/shelf_spec.rb | spec/models/shelf_spec.rb | require 'rails_helper'
describe Shelf do
fixtures :all
it "should respond to web_shelf" do
shelves(:shelf_00001).web_shelf?.should be_truthy
shelves(:shelf_00002).web_shelf?.should_not be_truthy
end
end
# == Schema Information
#
# Table name: shelves
#
# id :bigint not null, primary key
# closed :boolean default(FALSE), not null
# display_name :text
# items_count :integer default(0), not null
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# library_id :bigint not null
#
# Indexes
#
# index_shelves_on_library_id (library_id)
# index_shelves_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/user_group_spec.rb | spec/models/user_group_spec.rb | require 'rails_helper'
describe UserGroup do
fixtures :user_groups
it "should contain string in its display_name" do
user_group = user_groups(:user_group_00001)
user_group.display_name = "en:test"
user_group.valid?.should be_truthy
end
it "should not contain invalid yaml in its display_name" do
user_group = user_groups(:user_group_00001)
user_group.display_name = "en:test\r\nja: テスト"
user_group.valid?.should be_falsy
end
end
# == Schema Information
#
# Table name: user_groups
#
# id :bigint not null, primary key
# display_name :text
# expired_at :datetime
# name :string not null
# note :text
# number_of_day_to_notify_due_date :integer default(0), not null
# number_of_day_to_notify_overdue :integer default(0), not null
# number_of_time_to_notify_overdue :integer default(0), not null
# position :integer
# valid_period_for_new_user :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_user_groups_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/basket_spec.rb | spec/models/basket_spec.rb | require 'rails_helper'
describe Basket do
fixtures :all
it "should not create basket when user is not active" do
Basket.create(user: users(:user4)).id.should be_nil
end
it "should save shelf and library" do
items(:item_00011).checkouts.count.should eq 0
basket_1 = Basket.new
basket_1.user = users(:admin)
basket_1.save
checked_item_1 = basket_1.checked_items.new
checked_item_1.item = items(:item_00011)
checked_item_1.save
basket_1.basket_checkout(users(:librarian1))
items(:item_00011).checkouts.order('id DESC').first.shelf.name.should eq items(:item_00001).shelf.name
items(:item_00011).checkouts.order('id DESC').first.library.name.should eq users(:librarian1).profile.library.name
end
it "should not check out items that are already checked out" do
items(:item_00011).checkouts.count.should eq 0
basket_1 = Basket.new
basket_1.user = users(:admin)
basket_1.save
checked_item_1 = basket_1.checked_items.new
checked_item_1.item = items(:item_00011)
checked_item_1.save
basket_2 = Basket.new
basket_2.user = users(:user1)
basket_2.save
checked_item_2 = basket_2.checked_items.new
checked_item_2.item = items(:item_00011)
checked_item_2.save
basket_1.basket_checkout(users(:librarian1))
lambda {basket_2.basket_checkout(users(:librarian1))}.should raise_exception ActiveRecord::RecordInvalid
items(:item_00011).checkouts.order('id DESC').first.user.should eq users(:admin)
end
it "should change reservation status" do
basket = Basket.new
basket.user = users(:librarian2)
basket.save
checked_item = basket.checked_items.new
checked_item.item = items(:item_00023)
checked_item.save
checked_item.item.circulation_status.name.should eq 'Available On Shelf'
basket.basket_checkout(users(:librarian1))
checked_item.item.circulation_status.name.should eq 'On Loan'
end
it "should checkout retained item" do
checkout = users(:user1).checkouts.order(:created_at).first
reserve = users(:user2).reserves.create!(manifestation: checkout.item.manifestation)
basket1 = Basket.new(user: users(:librarian1))
checkin = Checkin.create!(basket: basket1, librarian: users(:librarian1), item: checkout.item)
checkin.item_checkin(checkin.librarian)
basket2 = Basket.create!(user: users(:user2))
basket2.checked_items.create(item: checkout.item)
basket2.basket_checkout(basket2.user)
expect(checkout.item.circulation_status.name).to eq 'On Loan'
expect(checkout.item.manifestation.reserves.order(created_at: :desc).first.current_state).to eq 'completed'
end
end
# == Schema Information
#
# Table name: baskets
#
# id :bigint not null, primary key
# lock_version :integer default(0), not null
# note :text
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint
#
# Indexes
#
# index_baskets_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/agent_import_file_spec.rb | spec/models/agent_import_file_spec.rb | require 'rails_helper'
describe AgentImportFile do
fixtures :all
describe "when its mode is 'create'" do
before(:each) do
@file = AgentImportFile.create! attachment: fixture_file_upload("agent_import_file_sample1.tsv"), user: users(:admin)
end
it "should be imported" do
old_agents_count = Agent.count
old_import_results_count = AgentImportResult.count
@file.current_state.should eq 'pending'
@file.import_start.should eq({ agent_imported: 3, user_imported: 0, failed: 0 })
Agent.order('id DESC')[0].full_name.should eq '原田 ushi 隆史'
Agent.order('id DESC')[1].full_name.should eq '田辺浩介'
Agent.order('id DESC')[2].date_of_birth.should eq Time.zone.parse('1978-01-01')
Agent.count.should eq old_agents_count + 3
@file.agent_import_results.order(:id).first.body.split("\t").first.should eq 'full_name'
AgentImportResult.count.should eq old_import_results_count + 5
@file.executed_at.should be_truthy
end
end
describe "when it is written in shift_jis" do
before(:each) do
@file = AgentImportFile.create!(
attachment: fixture_file_upload("agent_import_file_sample3.tsv"),
user: users(:admin)
)
end
it "should be imported" do
old_agents_count = Agent.count
old_import_results_count = AgentImportResult.count
@file.current_state.should eq 'pending'
@file.import_start.should eq({ agent_imported: 4, user_imported: 0, failed: 0 })
Agent.count.should eq old_agents_count + 4
Agent.order('id DESC')[0].full_name.should eq '原田 ushi 隆史'
Agent.order('id DESC')[1].full_name.should eq '田辺浩介'
AgentImportResult.count.should eq old_import_results_count + 5
@file.executed_at.should be_truthy
end
end
describe "when its mode is 'update'" do
it "should update users" do
file = AgentImportFile.create!(
attachment: fixture_file_upload("agent_update_file.tsv"),
user: users(:admin)
)
file.modify
agent_1 = Agent.find(1)
agent_1.full_name.should eq 'たなべこうすけ'
agent_1.address_1.should eq '東京都'
agent_2 = Agent.find(2)
agent_2.full_name.should eq '田辺浩介'
agent_2.address_1.should eq '岡山県'
end
end
describe "when its mode is 'destroy'" do
it "should remove users" do
old_count = Agent.count
file = AgentImportFile.create!(
attachment: fixture_file_upload("agent_delete_file.tsv"),
user: users(:admin)
)
file.remove
Agent.count.should eq old_count - 7
end
end
it "should import in background" do
file = AgentImportFile.create attachment: fixture_file_upload("agent_import_file_sample1.tsv")
file.user = users(:admin)
file.save
AgentImportFileJob.perform_later(file).should be_truthy
end
end
# == Schema Information
#
# Table name: agent_import_files
#
# id :bigint not null, primary key
# agent_import_fingerprint :string
# edit_mode :string
# error_message :text
# executed_at :datetime
# note :text
# user_encoding :string
# created_at :datetime not null
# updated_at :datetime not null
# parent_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_agent_import_files_on_parent_id (parent_id)
# index_agent_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/message_spec.rb | spec/models/message_spec.rb | require 'rails_helper'
describe Message do
fixtures :all
before(:each) do
@message = FactoryBot.create(:message)
end
it 'should require body' do
@message.errors[:body].should be_truthy
end
it 'should require recipient' do
@message.errors[:recipient].should be_truthy
end
it 'should require subject' do
@message.errors[:subject].should be_truthy
end
it 'should return sender_name' do
@message.sender.username.should be_truthy
end
it 'should return receiver_name' do
@message.receiver = users(:user1)
@message.receiver.username.should be_truthy
end
it 'should set read_at' do
message = messages(:user2_to_user1_1)
message.transition_to!(:read)
message.read_at.should be_truthy
message.read?.should be_truthy
message.current_state.should eq 'read'
end
it 'should require valid recipient' do
@message.recipient = 'invalidusername'
@message.save.should be_falsy
end
end
# == Schema Information
#
# Table name: messages
#
# id :bigint not null, primary key
# body :text
# depth :integer
# lft :integer
# read_at :datetime
# rgt :integer
# subject :string not null
# created_at :datetime not null
# updated_at :datetime not null
# message_request_id :bigint
# parent_id :bigint
# receiver_id :bigint
# sender_id :bigint
#
# Indexes
#
# index_messages_on_message_request_id (message_request_id)
# index_messages_on_parent_id (parent_id)
# index_messages_on_receiver_id (receiver_id)
# index_messages_on_sender_id (sender_id)
#
# Foreign Keys
#
# fk_rails_... (parent_id => messages.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/inventory_spec.rb | spec/models/inventory_spec.rb | require 'rails_helper'
describe Inventory do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: inventories
#
# id :bigint not null, primary key
# current_shelf_name :string
# item_identifier :string
# note :text
# created_at :datetime not null
# updated_at :datetime not null
# inventory_file_id :bigint
# item_id :bigint
#
# Indexes
#
# index_inventories_on_current_shelf_name (current_shelf_name)
# index_inventories_on_inventory_file_id (inventory_file_id)
# index_inventories_on_item_id (item_id)
# index_inventories_on_item_identifier (item_identifier)
#
| 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/produce_spec.rb | spec/models/produce_spec.rb | require 'rails_helper'
describe Produce do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: produces
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# manifestation_id :bigint not null
# produce_type_id :bigint
#
# Indexes
#
# index_produces_on_agent_id (agent_id)
# index_produces_on_manifestation_id_and_agent_id (manifestation_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/agent_type_spec.rb | spec/models/agent_type_spec.rb | require 'rails_helper'
describe AgentType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_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_agent_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/checked_item_spec.rb | spec/models/checked_item_spec.rb | require 'rails_helper'
describe CheckedItem do
fixtures :all
it "should respond to available_for_checkout?" do
checked_items(:checked_item_00001).available_for_checkout?.should_not be_truthy
end
it "should change circulation_status when a missing item is found" do
basket = Basket.new
basket.user = users(:admin)
checked_item = CheckedItem.new
checked_item.item = items(:item_00024)
checked_item.basket = basket
checked_item.save!
items(:item_00024).circulation_status.name.should eq 'Available On Shelf'
end
it "should checkout an item that its reservation is expired" do
item = items(:item_00024)
reserve = FactoryBot.create(:reserve, manifestation: item.manifestation)
reserve.transition_to!(:expired)
checked_item = CheckedItem.new
checked_item.item = item
checked_item.basket = Basket.new(user: users(:admin))
expect(checked_item.save).to be_truthy
end
end
# == Schema Information
#
# Table name: checked_items
#
# id :bigint not null, primary key
# due_date :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# basket_id :bigint not null
# item_id :bigint not null
# librarian_id :bigint
# user_id :bigint
#
# Indexes
#
# index_checked_items_on_basket_id (basket_id)
# index_checked_items_on_item_id_and_basket_id (item_id,basket_id) UNIQUE
# index_checked_items_on_librarian_id (librarian_id)
# index_checked_items_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (basket_id => baskets.id)
# fk_rails_... (item_id => items.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/library_group_spec.rb | spec/models/library_group_spec.rb | require 'rails_helper'
describe LibraryGroup do
fixtures :library_groups, :users
before(:each) do
@library_group = LibraryGroup.find(1)
end
it "should get library_group_config" do
LibraryGroup.site_config.should be_truthy
end
it "should set 1000 as max_number_of_results" do
expect(LibraryGroup.site_config.max_number_of_results).to eq 1000
end
it "should allow access from allowed networks" do
@library_group.my_networks = "127.0.0.1"
@library_group.network_access_allowed?("192.168.0.1").should be_falsy
end
it "should accept 0 as max_number_of_results" do
@library_group.update(max_number_of_results: 0).should be_truthy
end
it "should serialize settings" do
expect(@library_group.book_jacket_unknown_resource).to eq 'unknown.png'
end
end
# == Schema Information
#
# Table name: library_groups
#
# id :bigint not null, primary key
# admin_networks :text
# allow_bookmark_external_url :boolean default(FALSE), not null
# book_jacket_source :string
# csv_charset_conversion :boolean default(FALSE), not null
# display_name :text
# email :string
# family_name_first :boolean default(TRUE)
# footer_banner :text
# html_snippet :text
# login_banner :text
# max_number_of_results :integer default(1000)
# my_networks :text
# name :string not null
# note :text
# old_login_banner :text
# position :integer
# pub_year_facet_range_interval :integer default(10)
# screenshot_generator :string
# settings :jsonb not null
# short_name :string not null
# url :string default("http://localhost:3000/")
# created_at :datetime not null
# updated_at :datetime not null
# country_id :bigint
#
# Indexes
#
# index_library_groups_on_email (email)
# index_library_groups_on_lower_name (lower((name)::text)) UNIQUE
# index_library_groups_on_short_name (short_name)
#
| 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/create_spec.rb | spec/models/create_spec.rb | require 'rails_helper'
describe Create do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: creates
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# create_type_id :bigint
# work_id :bigint not null
#
# Indexes
#
# index_creates_on_agent_id (agent_id)
# index_creates_on_work_id_and_agent_id (work_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/manifestation_relationship_spec.rb | spec/models/manifestation_relationship_spec.rb | require 'rails_helper'
describe ManifestationRelationship do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: manifestation_relationships
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# child_id :bigint
# manifestation_relationship_type_id :bigint
# parent_id :bigint
#
# Indexes
#
# index_manifestation_relationships_on_child_id (child_id)
# index_manifestation_relationships_on_parent_id (parent_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/series_statement_spec.rb | spec/models/series_statement_spec.rb | require 'rails_helper'
describe SeriesStatement do
fixtures :all
it "should create manifestation" do
series_statement = FactoryBot.create(:series_statement)
series_statement.root_manifestation.should be_nil
end
end
# == Schema Information
#
# Table name: series_statements
#
# id :bigint not null, primary key
# creator_string :text
# note :text
# numbering :text
# numbering_subseries :text
# original_title :text
# position :integer
# series_master :boolean
# series_statement_identifier :string
# title_alternative :text
# title_subseries :text
# title_subseries_transcription :text
# title_transcription :text
# volume_number_string :text
# volume_number_transcription_string :text
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_id :bigint
# root_manifestation_id :bigint
#
# Indexes
#
# index_series_statements_on_manifestation_id (manifestation_id)
# index_series_statements_on_root_manifestation_id (root_manifestation_id)
# index_series_statements_on_series_statement_identifier (series_statement_identifier)
#
| 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_relationship_type_spec.rb | spec/models/manifestation_relationship_type_spec.rb | require 'rails_helper'
describe ManifestationRelationshipType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: manifestation_relationship_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_manifestation_relationship_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/agent_merge_spec.rb | spec/models/agent_merge_spec.rb | require 'rails_helper'
describe AgentMerge do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_merges
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# agent_merge_list_id :bigint not null
#
# Indexes
#
# index_agent_merges_on_agent_id (agent_id)
# index_agent_merges_on_agent_merge_list_id (agent_merge_list_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/own_spec.rb | spec/models/own_spec.rb | require 'rails_helper'
describe Own do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: owns
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# item_id :bigint not null
#
# Indexes
#
# index_owns_on_agent_id (agent_id)
# index_owns_on_item_id_and_agent_id (item_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/agent_relationship_type_spec.rb | spec/models/agent_relationship_type_spec.rb | require 'rails_helper'
describe AgentRelationshipType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_relationship_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_agent_relationship_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/agent_merge_list_spec.rb | spec/models/agent_merge_list_spec.rb | require 'rails_helper'
describe AgentMergeList do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: agent_merge_lists
#
# id :bigint not null, primary key
# title :string
# 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/form_of_work_spec.rb | spec/models/form_of_work_spec.rb | require 'rails_helper'
describe FormOfWork do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: form_of_works
#
# 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_form_of_works_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/order_spec.rb | spec/models/order_spec.rb | require 'rails_helper'
describe Order do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: orders
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# order_list_id :bigint not null
# purchase_request_id :bigint not null
#
# Indexes
#
# index_orders_on_order_list_id (order_list_id)
# index_orders_on_purchase_request_id (purchase_request_id)
#
# Foreign Keys
#
# fk_rails_... (order_list_id => order_lists.id)
# fk_rails_... (purchase_request_id => purchase_requests.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/series_statement_merge_list_spec.rb | spec/models/series_statement_merge_list_spec.rb | require 'rails_helper'
describe SeriesStatementMergeList do
fixtures :all
it "should merge series_statement" do
series_statement_merge_list = series_statement_merge_lists(:series_statement_merge_list_00001)
end
end
# == Schema Information
#
# Table name: series_statement_merge_lists
#
# id :bigint not null, primary key
# title :string
# 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/carrier_type_spec.rb | spec/models/carrier_type_spec.rb | require 'rails_helper'
describe CarrierType do
fixtures :carrier_types
it "should respond to mods_type" do
carrier_types(:carrier_type_00001).mods_type.should eq 'text'
carrier_types(:carrier_type_00002).mods_type.should eq 'software, multimedia'
end
end
# == Schema Information
#
# Table name: carrier_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_carrier_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/circulation_status_spec.rb | spec/models/circulation_status_spec.rb | require 'rails_helper'
describe CirculationStatus do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: circulation_statuses
#
# 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_circulation_statuses_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/manifestation_spec.rb | spec/models/manifestation_spec.rb | require 'rails_helper'
describe Manifestation, solr: true do
fixtures :all
before(:context) do
Manifestation.reindex
end
context "search" do
it "should set year_of_publication" do
manifestation = FactoryBot.create(:manifestation, pub_date: '2000')
manifestation.year_of_publication.should eq 2000
manifestation.date_of_publication.should eq Time.zone.parse('2000-01-01')
end
it "should set date_of_publication" do
manifestation = FactoryBot.create(:manifestation, pub_date: '2000-01')
manifestation.year_of_publication.should eq 2000
manifestation.month_of_publication.should eq 1
manifestation.date_of_publication.should eq Time.zone.parse('2000-01-01')
end
it "should set volume_number" do
manifestation = FactoryBot.create(:manifestation, volume_number_string: '第1巻', issue_number_string: '20号分冊1', edition_string: '第3版')
manifestation.volume_number.should eq 1
manifestation.issue_number.should eq 20
manifestation.edition.should eq 3
end
it "should search title in openurl" do
openurl = Openurl.new({ title: "プログラミング" })
results = openurl.search
openurl.query_text.should eq "btitle_text:プログラミング"
results.size.should eq 8
openurl = Openurl.new({ jtitle: "テスト" })
results = openurl.search
results.size.should eq 3
openurl.query_text.should eq "jtitle_text:テスト"
openurl = Openurl.new({ atitle: "2005" })
results = openurl.search
results.size.should eq 1
openurl.query_text.should eq "atitle_text:2005"
openurl = Openurl.new({ atitle: "テスト", jtitle: "テスト雑誌" })
results = openurl.search
results.size.should eq 2
end
it "should search agent in openurl" do
openurl = Openurl.new({ aulast: "Administrator" })
results = openurl.search
openurl.query_text.should eq "au_text:Administrator"
results.size.should eq 2
openurl = Openurl.new({ aufirst: "名称" })
results = openurl.search
openurl.query_text.should eq "au_text:名称"
results.size.should eq 1
openurl = Openurl.new({ au: "テスト" })
results = openurl.search
openurl.query_text.should eq "au_text:テスト"
results.size.should eq 1
openurl = Openurl.new({ pub: "Administrator" })
results = openurl.search
openurl.query_text.should eq "publisher_text:Administrator"
results.size.should eq 4
end
it "should search isbn in openurl" do
openurl = Openurl.new({ api: "openurl", isbn: "4798" })
results = openurl.search
openurl.query_text.should eq "isbn_sm:4798*"
results.size.should eq 2
end
it "should search issn in openurl" do
openurl = Openurl.new({ api: "openurl", issn: "0913" })
results = openurl.search
openurl.query_text.should eq "issn_sm:0913*"
results.size.should eq 1
end
it "should search any in openurl" do
openurl = Openurl.new({ any: "テスト" })
results = openurl.search
results.size.should eq 9
end
it "should search multi in openurl" do
openurl = Openurl.new({ btitle: "CGI Perl プログラミング" })
results = openurl.search
results.size.should eq 3
openurl = Openurl.new({ jtitle: "テスト", pub: "テスト" })
results = openurl.search
results.size.should eq 2
end
it "shoulld get search_error in openurl" do
lambda {Openurl.new({ isbn: "12345678901234" })}.should raise_error(OpenurlQuerySyntaxError)
lambda {Openurl.new({ issn: "1234abcd" })}.should raise_error(OpenurlQuerySyntaxError)
lambda {Openurl.new({ aufirst: "テスト 名称" })}.should raise_error(OpenurlQuerySyntaxError)
end
it "should_get_number_of_pages" do
manifestations(:manifestation_00001).number_of_pages.should eq 100
end
it "should have parent_of_series" do
manifestations(:manifestation_00001).parent_of_series.should be_truthy
end
it "should respond to extract_text" do
manifestations(:manifestation_00001).extract_text.should be_nil
end
it "should respond to title" do
manifestations(:manifestation_00001).title.should be_truthy
end
it "should respond to pickup" do
lambda {Manifestation.pickup}.should_not raise_error # (ActiveRecord::RecordNotFound)
end
it "should be periodical if its series_statement is periodical" do
manifestations(:manifestation_00202).serial?.should be_truthy
end
it "should validate access_address" do
manifestation = manifestations(:manifestation_00202)
manifestation.access_address = 'http:/www.example.jp'
manifestation.should_not be_valid
end
it "should search custom identifiers" do
Manifestation.search do
fulltext 'identifier_text:custom1111'
end.results.count.should eq 1
end
# it "should set series_statement if the manifestation is periodical" do
# manifestation = series_statements(:two).manifestations.new
# manifestation.set_series_statements([series_statements(:two)])
# #manifestation.original_title.should eq 'テスト雑誌2月号'
# #manifestation.serial_number.should eq 3
# #manifestation.issue_number.should eq 3
# #manifestation.volume_number.should eq 1
# end
end
context ".export" do
it "should export a header line" do
lines = Manifestation.export
csv = CSV.parse(lines, headers: true, col_sep: "\t")
csv["manifestation_id"].compact.should_not be_empty
csv["manifestation_identifier"].compact.should_not be_empty
csv["manifestation_created_at"].compact.should_not be_empty
csv["manifestation_updated_at"].compact.should_not be_empty
csv["item_id"].compact.should_not be_empty
csv["item_created_at"].compact.should_not be_empty
csv["item_updated_at"].compact.should_not be_empty
csv["subject:unknown"].compact.inject(0) {|count, a| count += 1 if a == 'next-l'; count}.should eq manifestations(:manifestation_00001).items.count
csv["classification:ndc9"].compact.inject(0) {|count, a| count += 1 if a == '400'; count}.should eq manifestations(:manifestation_00001).items.count
csv["extent"].compact.should_not be_empty
csv["dimensions"].compact.should_not be_empty
expect(csv["manifestation_memo"].compact).to be_empty
expect(csv["item_memo"].compact).to be_empty
expect(csv["manifestation_price"].compact.first).to eq "1980"
expect(csv["item_price"].compact.first).to eq nil
expect(csv["library"].compact.first).to eq "web"
expect(csv["shelf"].compact.first).to eq "web"
expect(csv["jpno"].compact).not_to be_empty
expect(csv["ncid"].compact).not_to be_empty
expect(csv["lccn"].compact).not_to be_empty
# expect(csv["doi"].compact).not_to be_empty
expect(csv["identifier:jpno"].compact).to be_empty
expect(csv["identifier:ncid"].compact).to be_empty
expect(csv["identifier:lccn"].compact).to be_empty
end
it "should export edition fields" do
manifestation = FactoryBot.create(:manifestation, edition: 2, edition_string: "Revised Ed.")
lines = Manifestation.export
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["edition"].compact).not_to be_empty
expect(csv["edition_string"].compact).not_to be_empty
m = csv.find {|row| row["manifestation_id"].to_i == manifestation.id }
expect(m["edition"]).to eq "2"
expect(m["edition_string"]).to eq "Revised Ed."
end
it "should export title_transcription fields" do
manifestation = FactoryBot.create(:manifestation, title_transcription: "Transcripted title")
lines = Manifestation.export
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["title_transcription"].compact).not_to be_empty
m = csv.find {|row| row["manifestation_id"].to_i == manifestation.id }
expect(m["title_transcription"]).to eq "Transcripted title"
end
it "should export volume fields" do
manifestation = FactoryBot.create(:manifestation, volume_number: 15, volume_number_string: "Vol.15")
lines = Manifestation.export
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["volume_number"].compact).not_to be_empty
expect(csv["volume_number_string"].compact).not_to be_empty
m = csv.find {|row| row["manifestation_id"].to_i == manifestation.id }
expect(m["volume_number"]).to eq "15"
expect(m["volume_number_string"]).to eq "Vol.15"
end
it "should export multiple identifiers" do
manifestation = FactoryBot.create(:manifestation)
manifestation.isbn_records.create(body: "978-4043898039")
manifestation.isbn_records.create(body: "978-4840239219")
lines = Manifestation.export()
csv = CSV.parse(lines, headers: true, col_sep: "\t")
m = csv.find {|row| row["manifestation_id"].to_i == manifestation.id }
expect(m["isbn"].split('//').sort).to eq [ '9784043898039', '9784840239219' ]
expect(m["identifier:isbn"]).to be_nil
end
it "should respect the role of the user" do
FactoryBot.create(:item, bookstore_id: 1, price: 100, budget_type_id: 1)
lines = Manifestation.export(role: 'Guest')
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["bookstore"].compact).to be_empty
expect(csv["item_price"].compact).to be_empty
expect(csv["budget_type"].compact).to be_empty
lines = Manifestation.export(role: 'Librarian')
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["bookstore"].compact).not_to be_empty
expect(csv["item_price"].compact).not_to be_empty
expect(csv["budget_type"].compact).not_to be_empty
end
it 'should escape LF/CR to "\n"' do
manifestation = FactoryBot.create(:manifestation,
abstract: "test\ntest",
description: "test\ntest",
note: "test\ntest"
)
item = FactoryBot.create(:item, manifestation: manifestation, note: "test\ntest")
lines = Manifestation.export
csv = CSV.parse(lines, headers: true, col_sep: "\t")
expect(csv["abstract"].compact).not_to be_empty
expect(csv["description"].compact).not_to be_empty
expect(csv["note"].compact).not_to be_empty
expect(csv["item_note"].compact).not_to be_empty
m = csv.find {|row| row["manifestation_id"].to_i == manifestation.id }
expect(m["description"]).to eq "test\ntest"
expect(m["abstract"]).to eq "test\ntest"
expect(m["note"]).to eq "test\ntest"
expect(m["item_note"]).to eq "test\ntest"
end
it 'should export custom properties"' do
item = FactoryBot.create(:item)
item.item_custom_values << FactoryBot.build(:item_custom_value)
item.manifestation.manifestation_custom_values << FactoryBot.build(:manifestation_custom_value)
lines = Manifestation.export(role: 'Librarian')
csv = CSV.parse(lines, headers: true, col_sep: "\t")
m = csv.find {|row| row["manifestation_id"].to_i == item.manifestation.id }
item.item_custom_values.each do |custom_value|
expect(m["item:#{custom_value.item_custom_property.name}"]).to eq custom_value.value
end
item.manifestation.manifestation_custom_values.each do |custom_value|
expect(m["manifestation:#{custom_value.manifestation_custom_property.name}"]).to eq custom_value.value
end
end
it 'should respond to reservable?' do
expect(manifestations(:manifestation_00001).reservable?).to be_truthy
expect(manifestations(:manifestation_00101).reservable?).to be_falsy
end
end
it 'should extract fulltext' do
manifestation = FactoryBot.create(:manifestation)
manifestation.attachment.attach(io: File.open("spec/fixtures/files/resource_import_file_sample1.tsv"), filename: 'sample.txt')
expect(manifestation.extract_text).to match(/資料ID/)
end
it 'should respond to find_by_isbn' do
expect(Manifestation.find_by_isbn('9784797340044').id).to eq 193
end
end
# == Schema Information
#
# Table name: manifestations
#
# id :bigint not null, primary key
# abstract :text
# access_address :string
# available_at :datetime
# classification_number :string
# date_accepted :datetime
# date_captured :datetime
# date_copyrighted :datetime
# date_of_publication :datetime
# date_submitted :datetime
# depth :integer
# description :text
# dimensions :text
# edition :integer
# edition_string :string
# end_page :integer
# extent :text
# fulltext :text
# fulltext_content :boolean
# height :integer
# issue_number :integer
# issue_number_string :string
# lock_version :integer default(0), not null
# manifestation_identifier :string
# memo :text
# month_of_publication :integer
# note :text
# original_title :text not null
# price :integer
# pub_date :string
# publication_place :text
# repository_content :boolean default(FALSE), not null
# required_score :integer default(0), not null
# serial :boolean
# serial_number :integer
# serial_number_string :string
# start_page :integer
# statement_of_responsibility :text
# subscription_master :boolean default(FALSE), not null
# title_alternative :text
# title_alternative_transcription :text
# title_transcription :text
# valid_until :datetime
# volume_number :integer
# volume_number_string :string
# width :integer
# year_of_publication :integer
# created_at :datetime not null
# updated_at :datetime not null
# carrier_type_id :bigint default(1), not null
# content_type_id :bigint default(1)
# frequency_id :bigint default(1), not null
# language_id :bigint default(1), not null
# nii_type_id :bigint
# required_role_id :bigint default(1), not null
#
# Indexes
#
# index_manifestations_on_access_address (access_address)
# index_manifestations_on_date_of_publication (date_of_publication)
# index_manifestations_on_manifestation_identifier (manifestation_identifier)
# index_manifestations_on_nii_type_id (nii_type_id)
# index_manifestations_on_updated_at (updated_at)
#
# Foreign Keys
#
# fk_rails_... (required_role_id => roles.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/import_request_spec.rb | spec/models/import_request_spec.rb | require 'rails_helper'
describe ImportRequest do
fixtures :all
context "import" do
it "should import bibliographic record", vcr: true do
old_count = Manifestation.count
import_request = ImportRequest.create(isbn: '9784797350999')
import_request.import!
expect(Manifestation.count).to eq old_count + 1
expect(import_request.manifestation.original_title).to eq "暗号技術入門 : 秘密の国のアリス"
expect(import_request.manifestation.creators.order(:created_at).first.ndla_record.body).to eq "http://id.ndl.go.jp/auth/entity/00325825"
end
it "should not import author that has the same identifier", vcr: true do
import_request1 = ImportRequest.create(isbn: '9784797350999')
import_request1.import!
import_request2 = ImportRequest.create(isbn: '9784815621353')
import_request2.import!
expect(NdlaRecord.where(body: "http://id.ndl.go.jp/auth/entity/00325825").count).to eq 1
expect(NdlaRecord.find_by(body: "http://id.ndl.go.jp/auth/entity/00325825").agent.works.count).to eq 2
end
end
end
# == Schema Information
#
# Table name: import_requests
#
# id :bigint not null, primary key
# isbn :string
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_import_requests_on_isbn (isbn)
# index_import_requests_on_manifestation_id (manifestation_id)
# index_import_requests_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/subscription_spec.rb | spec/models/subscription_spec.rb | require 'rails_helper'
describe Subscription do
fixtures :subscriptions, :manifestations, :subscribes
it "should_respond_to_subscribed" do
subscriptions(:subscription_00001).subscribed(manifestations(:manifestation_00001)).should be_truthy
end
end
# == Schema Information
#
# Table name: subscriptions
#
# id :bigint not null, primary key
# note :text
# subscribes_count :integer default(0), not null
# title :text not null
# created_at :datetime not null
# updated_at :datetime not null
# order_list_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_subscriptions_on_order_list_id (order_list_id)
# index_subscriptions_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/donate_spec.rb | spec/models/donate_spec.rb | require 'rails_helper'
describe Donate do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: donates
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# agent_id :bigint not null
# item_id :bigint not null
#
# Indexes
#
# index_donates_on_agent_id (agent_id)
# index_donates_on_item_id (item_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/news_post_spec.rb | spec/models/news_post_spec.rb | require 'rails_helper'
describe NewsPost do
end
# == Schema Information
#
# Table name: news_posts
#
# id :bigint not null, primary key
# body :text
# draft :boolean default(FALSE), not null
# end_date :datetime
# note :text
# position :integer
# start_date :datetime
# title :text
# url :string
# created_at :datetime not null
# updated_at :datetime not null
# required_role_id :bigint default(1), not null
# user_id :bigint not null
#
# Indexes
#
# index_news_posts_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (required_role_id => roles.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/license_spec.rb | spec/models/license_spec.rb | require 'rails_helper'
describe License do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: licenses
#
# id :bigint not null, primary key
# display_name :string
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_licenses_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_import_result_spec.rb | spec/models/resource_import_result_spec.rb | require 'rails_helper'
describe ResourceImportResult do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: resource_import_results
#
# id :bigint not null, primary key
# body :text
# error_message :text
# created_at :datetime not null
# updated_at :datetime not null
# item_id :bigint
# manifestation_id :bigint
# resource_import_file_id :bigint
#
# Indexes
#
# index_resource_import_results_on_item_id (item_id)
# index_resource_import_results_on_manifestation_id (manifestation_id)
# index_resource_import_results_on_resource_import_file_id (resource_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/role_spec.rb | spec/models/role_spec.rb | require 'spec_helper'
describe Role do
#pending "add some examples to (or delete) #{__FILE__}"
fixtures :roles
it "should not be saved if name is blank" do
role = Role.first
role.name = ''
lambda {role.save!}.should raise_error(ActiveRecord::RecordInvalid)
end
it "should not be saved if name is not unique" do
role = Role.first
lambda {Role.create!(name: role.name)}.should raise_error(ActiveRecord::RecordInvalid)
end
it "should respond to localized_name" do
roles(:role_00001).display_name.should eq 'Guest'
end
it "should respond to default" do
Role.default.should eq roles(:role_00001)
end
end
# == Schema Information
#
# Table name: roles
#
# id :bigint not null, primary key
# display_name :string
# name :string not null
# note :text
# position :integer
# score :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_roles_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_result_spec.rb | spec/models/event_import_result_spec.rb | require 'rails_helper'
describe EventImportResult do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: event_import_results
#
# id :bigint not null, primary key
# event_import_file_id :bigint
# event_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/manifestation_custom_value_spec.rb | spec/models/manifestation_custom_value_spec.rb | require 'rails_helper'
RSpec.describe ManifestationCustomValue, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: manifestation_custom_values
#
# id :bigint not null, primary key
# value :text
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_custom_property_id :bigint not null
# manifestation_id :bigint not null
#
# Indexes
#
# index_manifestation_custom_values_on_custom_property_id (manifestation_custom_property_id)
# index_manifestation_custom_values_on_manifestation_id (manifestation_id)
# index_manifestation_custom_values_on_property_manifestation (manifestation_custom_property_id,manifestation_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (manifestation_custom_property_id => manifestation_custom_properties.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_has_role_spec.rb | spec/models/user_has_role_spec.rb | require 'spec_helper'
describe UserHasRole do
#pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: user_has_roles
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# role_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_user_has_roles_on_role_id (role_id)
# index_user_has_roles_on_user_id_and_role_id (user_id,role_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (role_id => roles.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/user_checkout_stat_spec.rb | spec/models/user_checkout_stat_spec.rb | require 'rails_helper'
describe UserCheckoutStat do
fixtures :user_checkout_stats
it "calculates user count" do
old_message_count = Message.count
user_checkout_stats(:one).transition_to!(:started).should be_truthy
Message.count.should eq old_message_count + 1
Message.order(:id).last.subject.should eq '[Enju Library] 集計が完了しました'
end
it "should calculate in background" do
UserCheckoutStatJob.perform_later(user_checkout_stats(:one)).should be_truthy
end
end
# == Schema Information
#
# Table name: user_checkout_stats
#
# id :bigint not null, primary key
# completed_at :datetime
# end_date :datetime
# note :text
# start_date :datetime
# started_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_user_checkout_stats_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/profile_spec.rb | spec/models/profile_spec.rb | require 'rails_helper'
describe Profile do
#pending "add some examples to (or delete) #{__FILE__}"
fixtures :all
it 'should create a profile' do
FactoryBot.create(:profile)
end
it 'should destroy a profile' do
profile = FactoryBot.create(:profile)
profile.destroy.should be_truthy
end
it 'should not set expired_at if its user group does not have valid period' do
profile = FactoryBot.create(:profile)
profile.expired_at.should be_nil
end
it 'should set expired_at if its user group has valid period' do
profile = FactoryBot.build(:profile)
user_group = FactoryBot.create(:user_group, valid_period_for_new_user: 10)
user_group.profiles << profile
profile.user_group.valid_period_for_new_user.should eq 10
profile.expired_at.should eq 10.days.from_now.end_of_day
end
it "should create profile" do
profile = FactoryBot.create(:profile)
assert !profile.new_record?, "#{profile.errors.full_messages.to_sentence}"
end
it "should create profile with empty user_number" do
profile1 = FactoryBot.create(:profile, user_number: "")
profile2 = FactoryBot.create(:profile, user_number: "")
profile1.should be_valid
profile2.should be_valid
end
if defined?(EnjuCirculation)
it "should reset checkout_icalendar_token" do
profiles(:profile_user1).reset_checkout_icalendar_token
profiles(:profile_user1).checkout_icalendar_token.should be_truthy
end
it "should delete checkout_icalendar_token" do
profiles(:profile_user1).delete_checkout_icalendar_token
profiles(:profile_user1).checkout_icalendar_token.should be_nil
end
end
end
# == Schema Information
#
# Table name: profiles
#
# id :bigint not null, primary key
# checkout_icalendar_token :string
# date_of_birth :datetime
# expired_at :datetime
# full_name :text
# full_name_transcription :text
# keyword_list :text
# locale :string
# note :text
# save_checkout_history :boolean default(FALSE), not null
# share_bookmarks :boolean
# user_number :string
# created_at :datetime not null
# updated_at :datetime not null
# library_id :bigint
# required_role_id :bigint
# user_group_id :bigint
#
# Indexes
#
# index_profiles_on_checkout_icalendar_token (checkout_icalendar_token) UNIQUE
# index_profiles_on_library_id (library_id)
# index_profiles_on_user_group_id (user_group_id)
# index_profiles_on_user_number (user_number) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (required_role_id => roles.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/cinii_book_spec.rb | spec/models/cinii_book_spec.rb | require 'rails_helper'
describe CiniiBook do
fixtures :all
it "should search bibliographic records", vcr: true do
CiniiBook.search("library system")[:total_entries].should eq 3934
end
it "should search with ncid", vcr: true do
result = CiniiBook.search("BA85746967")
result.should be_truthy
result[:items].should be_truthy
result[:items].first.ncid.should eq "BA85746967"
end
it "should import a bibliographic record", vcr: true do
book = CiniiBook.import_ncid("BA85746967")
book.should be_truthy
book.should be_valid
book.original_title.should eq "固体高分子形燃料電池要素材料・水素貯蔵材料の知的設計 = Intelligent/directed materials design for polymer electrolyte fuel cells and hydrogen storage applications"
book.title_transcription.should include("コタイ コウブンシケイ ネンリョウ デンチ ヨウソ ザイリョウ スイソ チョゾウ ザイリョウ ノ チテキ セッケイ")
book.title_alternative.should include("固体高分子形燃料電池要素材料水素貯蔵材料の知的設計")
book.title_alternative.should include("Computational materials design, case study I")
book.statement_of_responsibility.should eq "笠井秀明, 津田宗幸著 = Hideaki Kasai, Muneyuki Tsuda"
book.publishers.first.full_name.should eq "大阪大学出版会"
book.language.iso_639_2.should eq "jpn"
book.date_of_publication.year.should eq 2008
book.extent.should eq "iv, 144p"
book.dimensions.should eq "21cm"
expect(book.ncid_record.body).to eq "BA85746967"
expect(book.isbn_records.first.body).to eq "9784872592542"
book.creators.size.should eq 2
book.creators[0].full_name.should eq "笠井, 秀明"
book.creators[1].full_name.should eq "津田, 宗幸"
book.subjects.map {|e| e.term }.should include("工業材料")
book.subjects.map {|e| e.term }.should include("燃料電池")
book.subjects.map {|e| e.term }.should include("水素エネルギー")
book.subjects.map {|e| e.term }.should include("シミュレーション")
book.series_statements.size.should eq 2
book.series_statements[0].series_statement_identifier.should eq "https://ci.nii.ac.jp/ncid/BA61636068"
book.series_statements[0].original_title.should eq "大阪大学新世紀レクチャー"
book.series_statements[0].title_transcription.should eq "オオサカ ダイガク シンセイキ レクチャー"
book.series_statements[1].original_title.should eq "計算機マテリアルデザイン先端研究事例"
book.series_statements[1].title_transcription.should eq "ケイサンキ マテリアル デザイン センタン ケンキュウ ジレイ"
end
it "should import a bibliographic record with dual languages", vcr: true do
book = CiniiBook.import_ncid("BB13942810")
book.should be_truthy
book.should be_valid
book.original_title.should eq "赤毛のアン = Anne of Green Gables"
book.language.iso_639_2.should eq "jpn"
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/reserve_stat_has_manifestation_spec.rb | spec/models/reserve_stat_has_manifestation_spec.rb | require 'rails_helper'
describe ReserveStatHasManifestation do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: reserve_stat_has_manifestations
#
# id :bigint not null, primary key
# reserves_count :integer
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_id :bigint not null
# manifestation_reserve_stat_id :bigint not null
#
# Indexes
#
# index_reserve_stat_has_manifestations_on_m_reserve_stat_id (manifestation_reserve_stat_id)
# index_reserve_stat_has_manifestations_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/checkout_stat_has_manifestation_spec.rb | spec/models/checkout_stat_has_manifestation_spec.rb | require 'rails_helper'
describe CheckoutStatHasManifestation do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: checkout_stat_has_manifestations
#
# id :bigint not null, primary key
# checkouts_count :integer
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_checkout_stat_id :bigint not null
# manifestation_id :bigint not null
#
# Indexes
#
# index_checkout_stat_has_manifestations_on_checkout_stat_id (manifestation_checkout_stat_id)
# index_checkout_stat_has_manifestations_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/produce_type_spec.rb | spec/models/produce_type_spec.rb | require 'rails_helper'
describe ProduceType do
it 'should create produce_type' do
FactoryBot.create(:produce_type)
end
end
# == Schema Information
#
# Table name: produce_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_produce_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/news_feed_spec.rb | spec/models/news_feed_spec.rb | require 'rails_helper'
describe NewsFeed do
fixtures :news_feeds
it "should get content", vcr: true do
feed = news_feeds(:news_feed_00001)
feed.force_reload
feed.content.should be_truthy
end
it "should not get content if the feed is invalid", vcr: true do
feed = news_feeds(:news_feed_00002)
feed.force_reload
feed.content.should be_nil
end
it "should reload content", vcr: true do
news_feeds(:news_feed_00001).force_reload.should be_truthy
end
it "should fetch feeds", vcr: true do
expect(NewsFeed.fetch_feeds).to be_nil
end
end
# == Schema Information
#
# Table name: news_feeds
#
# id :bigint not null, primary key
# library_group_id :bigint default(1), not null
# title :string
# url :string
# body :text
# position :integer
# 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/periodical_and_manifestation_spec.rb | spec/models/periodical_and_manifestation_spec.rb | require 'rails_helper'
RSpec.describe PeriodicalAndManifestation, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: periodical_and_manifestations
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# manifestation_id :bigint not null
# periodical_id :bigint not null
#
# Indexes
#
# index_periodical_and_manifestations_on_manifestation_id (manifestation_id)
# index_periodical_and_manifestations_on_periodical_id (periodical_id)
#
# Foreign Keys
#
# fk_rails_... (manifestation_id => manifestations.id)
# fk_rails_... (periodical_id => periodicals.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/identifier_type_spec.rb | spec/models/identifier_type_spec.rb | require 'rails_helper'
describe IdentifierType do
# pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: identifier_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_identifier_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_import_file_spec.rb | spec/models/resource_import_file_spec.rb | require 'rails_helper'
describe ResourceImportFile do
fixtures :all
describe "when its mode is 'create'" do
describe "when it is written in utf-8" do
before(:each) do
@file = ResourceImportFile.create(
attachment: fixture_file_upload("resource_import_file_sample1.tsv"),
default_shelf_id: 3,
user: users(:admin),
edit_mode: 'create'
)
end
it "should be imported", vcr: true do
old_manifestations_count = Manifestation.count
old_items_count = Item.count
old_agents_count = Agent.count
old_import_results_count = ResourceImportResult.count
old_message_count = Message.count
@file.import_start.should eq({ manifestation_imported: 10, item_imported: 10, manifestation_found: 6, item_found: 3, failed: 7 })
manifestation = Item.find_by(item_identifier: '11111').manifestation
manifestation.publishers.first.full_name.should eq 'test4'
manifestation.publishers.first.full_name_transcription.should eq 'てすと4'
manifestation.publishers.second.full_name_transcription.should eq 'てすと5'
manifestation.produces.first.produce_type.name.should eq 'publisher'
manifestation.creates.first.create_type.name.should eq 'author'
expect(manifestation.issn_records.pluck(:body)).to eq [ '03875806' ]
Manifestation.count.should eq old_manifestations_count + 10
Item.count.should eq old_items_count + 10
Agent.count.should eq old_agents_count + 9
@file.resource_import_results.order(:id).first.body.split("\t").first.should eq 'imported_manifestation_id'
ResourceImportResult.count.should eq old_import_results_count + 23
manifestation_101 = Manifestation.find_by(manifestation_identifier: '101')
manifestation_101.series_statements.count.should eq 1
manifestation_101.series_statements.first.original_title.should eq '主シリーズ'
manifestation_101.series_statements.first.title_transcription.should eq 'しゅしりーず'
manifestation_101.series_statements.first.title_subseries.should eq '副シリーズ'
manifestation_101.series_statements.first.title_subseries_transcription.should eq 'ふくしりーず'
manifestation_101.items.order(:id).last.call_number.should eq '007|A'
manifestation_101.serial.should be_falsy
expect(manifestation_101.required_role.name).to eq 'Administrator'
expect(manifestation_101.date_of_publication).to eq Time.zone.parse('2001-01-01')
expect(manifestation_101.year_of_publication).to eq 2001
item_10101 = Item.find_by(item_identifier: '10101')
item_10101.manifestation.creators.size.should eq 2
item_10101.manifestation.creates.order(:id).first.create_type.name.should eq 'author'
item_10101.manifestation.creates.order(:id).second.agent.full_name.should eq 'test1'
item_10101.manifestation.creates.order(:id).second.create_type.name.should eq 'illustrator'
item_10101.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
item_10101.budget_type.name.should eq 'Public fund'
item_10101.bookstore.name.should eq 'Example store'
item_10101.manifestation.classifications.count.should eq 1
item_10101.manifestation.classifications.first.classification_type.name.should eq 'ndc9'
item_10101.manifestation.classifications.first.category.should eq '007'
item_10101.manifestation.language.name.should eq 'Japanese'
item_10101.manifestation.statement_of_responsibility.should eq '著者A; 著者B'
item_10101.binding_item_identifier.should eq '9001'
item_10101.binding_call_number.should eq '330|A'
item_10101.binded_at.should eq Time.zone.parse('2014-08-16')
item_10101.manifestation.publication_place.should eq '東京'
item_10101.include_supplements.should eq true
item_10101.note.should eq 'カバーなし'
item_10101.url.should eq 'http://example.jp/item/1'
item_10101.manifestation.carrier_type.name.should eq 'volume'
item_10101.manifestation.manifestation_content_type.name.should eq 'text'
item_10101.manifestation.frequency.name.should eq 'monthly'
item_10101.manifestation.extent.should eq 'xv, 213 pages'
item_10101.manifestation.dimensions.should eq '20cm'
expect(item_10101.memo).to eq '個別資料メモ1'
expect(item_10101.manifestation.memo).to eq '書誌メモ1'
expect(item_10101.manifestation.required_role.name).to eq 'Guest'
expect(item_10101.required_role.name).to eq 'Guest'
expect(item_10101.manifestation.pub_date).to eq '2001'
expect(item_10101.manifestation.year_of_publication).to eq 2001
item_10102 = Item.find_by(item_identifier: '10102')
item_10102.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
item_10102.manifestation.language.name.should eq 'Japanese'
item_10102.manifestation.height.should eq 257
item_10102.manifestation.width.should eq 182
item_10102.manifestation.depth.should eq 12
item_10102.manifestation.start_page.should eq 1
item_10102.manifestation.end_page.should eq 200
item_10102.manifestation.series_statements.first.creator_string.should eq 'シリーズの著者'
item_10102.manifestation.series_statements.first.volume_number_string.should eq 'シリーズ1号'
expect(item_10102.manifestation.required_role.name).to eq 'Librarian'
expect(item_10102.required_role.name).to eq 'Guest'
Manifestation.find_by(manifestation_identifier: '103').original_title.should eq 'ダブル"クォート"を含む資料'
item = Item.find_by(item_identifier: '11111')
item.shelf.name.should eq Shelf.find(3).name
item.manifestation.price.should eq 1000
item.price.should eq 0
item.manifestation.publishers.size.should eq 2
item_10103 = Item.find_by(item_identifier: '10103')
item_10103.budget_type.should be_nil
item_10103.bookstore.name.should eq 'Example store'
# 同じTSVファイル内では上書きされない
expect(item_10103.manifestation.required_role.name).to eq 'Administrator'
expect(item_10103.required_role.name).to eq 'Guest'
item_10104 = Item.find_by(item_identifier: '10104')
item_10104.manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
item_10104.budget_type.name.should eq 'Public fund'
item_10104.bookstore.should be_nil
item_10104.call_number.should eq '007|A'
item_10104.manifestation.carrier_type.name.should eq 'online_resource'
item_10104.manifestation.manifestation_content_type.name.should eq 'still_image'
item_10104.manifestation.frequency.name.should eq 'unknown'
item_10104.manifestation.volume_number_string.should eq '第3巻'
item_10104.manifestation.volume_number.should eq 3
item_10104.manifestation.issue_number_string.should eq '第10号'
item_10104.manifestation.issue_number.should eq 10
item_10104.manifestation.edition_string.should eq '初版'
item_10104.manifestation.edition.should eq 1
item_10104.manifestation.serial_number.should eq 120
expect(item_10104.manifestation.doi_record.body).to eq 'example/2014.08.18'
item_10104.manifestation.height.should be_nil
item_10104.manifestation.width.should be_nil
item_10104.manifestation.depth.should be_nil
item_10104.manifestation.subjects.order(:id).map {|s| { s.subject_heading_type.name => s.term }}.should eq [ { "ndlsh" => "コンピュータ" }, { "ndlsh" => "図書館" } ]
item_10104.manifestation.classifications.order(:id).map {|c| { c.classification_type.name => c.category }}.should eq [ { "ndc9" => "007" }, { "ddc" => "003" }, { "ddc" => "004" } ]
expect(item_10104.manifestation.required_role.name).to eq 'Guest'
expect(item_10104.required_role.name).to eq 'Guest'
manifestation_104 = Manifestation.find_by(manifestation_identifier: '104')
expect(manifestation_104.isbn_records.pluck(:body)).to eq [ '9784797327038' ]
expect(manifestation_104.original_title).to eq 'test10'
manifestation_104.creators.pluck(:full_name).should eq [ 'test3' ]
manifestation_104.publishers.pluck(:full_name).should eq [ 'test4' ]
expect(item_10104.manifestation.pub_date).to eq '2001-1-1'
expect(item_10104.manifestation.date_of_publication).to eq Time.zone.parse('2001-01-01')
manifestation_105 = Manifestation.find_by(manifestation_identifier: '105')
manifestation_105.serial.should be_truthy
ResourceImportResult.where(manifestation_id: manifestation_101.id).order(:id).last.error_message.should eq "line 22: #{I18n.t('import.manifestation_found')}"
ResourceImportResult.where(item_id: item_10101.id).order(:id).last.error_message.should eq "line 9: #{I18n.t('import.item_found')}"
Item.find_by(item_identifier: '11113').manifestation.original_title.should eq 'test10'
Item.find_by(item_identifier: '11114').manifestation.id.should eq 1
item_10102 = Item.find_by(item_identifier: '10102')
expect(item_10102.manifestation.manifestation_custom_values.pluck(:value)).to eq [ 'カスタム項目テスト1', 'カスタム項目テスト2' ]
expect(item_10102.item_custom_values.pluck(:value)).to eq []
item_10103 = Item.find_by(item_identifier: '10103')
expect(item_10103.manifestation.manifestation_custom_values.pluck(:value)).to eq [ "カスタム項目テスト1", "カスタム項目テスト2" ]
expect(item_10103.item_custom_values.pluck(:value)).to eq [ 'カスタム項目テスト3', 'カスタム項目テスト4' ]
Manifestation.search { keywords "10101" }.total.should > 0
Manifestation.search { keywords "10101", fields: [ :item_identifier ] }.total.should > 0
Manifestation.search { keywords "item_identifier_sm:10101" }.total.should > 0
Message.count.should eq old_message_count + 1
Message.order(:created_at).last.subject.should eq "Resource import completed: #{@file.id}"
@file.executed_at.should be_truthy
@file.reload
@file.error_message.should eq "The following column(s) were ignored: invalid"
end
it "should import multiple ISBNs", vcr: true do
file = ResourceImportFile.create(user: users(:admin))
file.attachment.attach(io: StringIO.new("original_title\tisbn\noriginal_title_multiple_isbns\t978-4840239219//978-4043898039\n"), filename: 'test.txt')
result = file.import_start
expect(result[:manifestation_imported]).to eq 1
resource_import_result = file.resource_import_results.last
expect(resource_import_result.manifestation).not_to be_blank
manifestation = resource_import_result.manifestation
expect(manifestation.isbn_records.pluck(:body)).to include("9784840239219")
expect(manifestation.isbn_records.pluck(:body)).to include("9784043898039")
end
it "should import multiple rows in a cell" do
file = ResourceImportFile.create(
attachment: fixture_file_upload("resource_import_file_sample5.tsv"),
default_shelf_id: 3,
user: users(:admin),
edit_mode: 'create'
)
file.import_start
manifestation = Manifestation.find_by(manifestation_identifier: 10201)
expect(manifestation.original_title).to eq "改行を含む\nタイトル"
expect(manifestation.abstract).to eq "改行を含む\n目次の\n情報"
expect(manifestation.note).to eq "改行を\n含む\n注記の\n情報"
expect(manifestation.description).to eq "改行を\n含む\n説明の情報"
end
end
describe "ISBN import" do
context "with record not found" do
it "should record an error message", vcr: true do
file = ResourceImportFile.create(user: users(:admin))
file.attachment.attach(io: StringIO.new("isbn\n9780007264551"), filename: 'test.txt')
result = file.import_start
expect(result[:failed]).to eq 1
resource_import_result = file.resource_import_results.last
expect(resource_import_result.error_message).not_to be_empty
end
end
context "with ISBN invalid" do
it "should record an error message", vcr: true do
file = ResourceImportFile.create(user: users(:admin))
file.attachment.attach(io: StringIO.new("isbn\n978000726455x"), filename: 'test.txt')
result = file.import_start
expect(result[:failed]).to eq 1
resource_import_result = file.resource_import_results.last
expect(resource_import_result.error_message).not_to be_empty
end
end
end
describe "NCID import" do
it "should import ncid value" do
file = ResourceImportFile.create(user: users(:admin))
file.attachment.attach(io: StringIO.new("original_title\tncid\noriginal_title_ncid\tBA67656964\n"), filename: 'test.txt')
result = file.import_start
expect(result[:manifestation_imported]).to eq 1
resource_import_result = file.resource_import_results.last
expect(resource_import_result.error_message).to be_blank
expect(resource_import_result.manifestation).not_to be_blank
manifestation = resource_import_result.manifestation
expect(manifestation.ncid_record.body).to eq "BA67656964"
end
end
describe "NDLBibID" do
it "should import NDLBibID", vcr: true do
file = ResourceImportFile.create(user: users(:admin))
file.attachment.attach(io: StringIO.new("ndl_bib_id\n000000471440\n"), filename: 'test.txt')
result = file.import_start
expect(result[:manifestation_imported]).to eq 1
resource_import_result = file.resource_import_results.last
manifestation = resource_import_result.manifestation
expect(manifestation.manifestation_identifier).to eq "https://ndlsearch.ndl.go.jp/books/R100000002-I000000471440"
end
end
describe "when it is written in shift_jis" do
before(:each) do
@file = ResourceImportFile.create!(
attachment: fixture_file_upload("resource_import_file_sample2.tsv"),
user: users(:admin)
)
end
it "should be imported", vcr: true do
old_manifestations_count = Manifestation.count
old_items_count = Item.count
old_agents_count = Agent.count
old_import_results_count = ResourceImportResult.count
@file.import_start.should eq({ manifestation_imported: 10, item_imported: 10, manifestation_found: 6, item_found: 3, failed: 7 })
manifestation = Item.find_by(item_identifier: '11111').manifestation
manifestation.publishers.first.full_name.should eq 'test4'
manifestation.publishers.first.full_name_transcription.should eq 'てすと4'
manifestation.publishers.second.full_name_transcription.should eq 'てすと5'
Manifestation.count.should eq old_manifestations_count + 10
Item.count.should eq old_items_count + 10
Agent.count.should eq old_agents_count + 9
ResourceImportResult.count.should eq old_import_results_count + 23
Item.find_by(item_identifier: '10101').manifestation.creators.size.should eq 2
Item.find_by(item_identifier: '10101').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
Item.find_by(item_identifier: '10102').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
Item.find_by(item_identifier: '10104').manifestation.date_of_publication.should eq Time.zone.parse('2001-01-01')
Manifestation.find_by(manifestation_identifier: '103').original_title.should eq 'ダブル"クォート"を含む資料'
item = Item.find_by(item_identifier: '11111')
item.shelf.name.should eq Shelf.find_by(name: 'web').name
item.manifestation.price.should eq 1000
item.price.should eq 0
item.manifestation.publishers.size.should eq 2
@file.executed_at.should be_truthy
end
end
describe "when it has only isbn" do
before(:each) do
@file = ResourceImportFile.create!(
attachment: fixture_file_upload("isbn_sample.txt"),
user: users(:admin)
)
end
it "should be imported", vcr: true do
old_manifestations_count = Manifestation.count
old_agents_count = Agent.count
@file.import_start
Manifestation.count.should eq old_manifestations_count + 1
Agent.count.should eq old_agents_count + 5
Manifestation.order(:id).last.publication_place.should eq '東京'
end
end
describe "when it has only ncid" do
before(:each) do
@file = ResourceImportFile.create!(
attachment: fixture_file_upload("ncid_sample.txt"),
user: users(:admin)
)
end
it "should be imported", vcr: true do
old_manifestations_count = Manifestation.count
old_agents_count = Agent.count
@file.import_start
Manifestation.count.should eq old_manifestations_count + 2
Agent.count.should eq old_agents_count + 16
end
end
describe "when it has only jpno" do
before(:each) do
@file = ResourceImportFile.create!(
attachment: fixture_file_upload("jpno_sample.txt"),
user: users(:admin)
)
end
it "should be imported", vcr: true do
old_manifestations_count = Manifestation.count
old_agents_count = Agent.count
@file.import_start
Manifestation.count.should eq old_manifestations_count + 2
Agent.count.should eq old_agents_count + 11
end
end
describe "when it contains item related fields" do
it "should create an item as well" do
import_file = <<-EOF
original_title call_number item_note
resource_import_file_test1 007.6 note for the item.
EOF
file = ResourceImportFile.create(
user: users(:admin)
)
file.attachment.attach(io: StringIO.new(import_file), filename: 'test.txt')
old_manifestations_count = Manifestation.count
old_items_count = Item.count
result = file.import_start
expect(Manifestation.count).to eq old_manifestations_count + 1
expect(Item.count).to eq old_items_count + 1
expect(file.resource_import_results.last.item).to be_valid
expect(file.resource_import_results.last.item.call_number).to eq "007.6"
expect(file.resource_import_results.last.item.note).to eq "note for the item."
end
end
describe "when it contains edition fields" do
it "should be imported" do
import_file = <<-EOF
original_title edition edition_string
resource_import_file_test_edition 2 Revised Ed.
EOF
file = ResourceImportFile.create(
user: users(:admin)
)
file.attachment.attach(io: StringIO.new(import_file), filename: 'test.txt')
old_manifestations_count = Manifestation.count
result = file.import_start
expect(Manifestation.count).to eq old_manifestations_count + 1
manifestation = Manifestation.all.find {|m| m.original_title == "resource_import_file_test_edition" }
expect(manifestation.edition).to eq 2
expect(manifestation.edition_string).to eq "Revised Ed."
end
end
describe "when it contains transcription fields" do
it "should be imported" do
import_file = <<-EOF
original_title title_transcription
resource_import_file_test_transcription transcription
EOF
file = ResourceImportFile.create(
user: users(:admin)
)
file.attachment.attach(io: StringIO.new(import_file), filename: 'test.txt')
old_manifestations_count = Manifestation.count
result = file.import_start
expect(Manifestation.count).to eq old_manifestations_count + 1
manifestation = Manifestation.all.find {|m| m.original_title == "resource_import_file_test_transcription" }
expect(manifestation.title_transcription).to eq "transcription"
end
end
describe "when it contains escaped fields" do
it "should be imported as escaped" do
import_file = <<-EOF
original_title description note call_number item_note
resource_import_file_test_description test\\ntest test\\ntest test_description test\\ntest
EOF
file = ResourceImportFile.create(
user: users(:admin)
)
file.attachment.attach(io: StringIO.new(import_file), filename: 'test.txt')
old_manifestations_count = Manifestation.count
result = file.import_start
expect(Manifestation.count).to eq old_manifestations_count + 1
manifestation = Manifestation.all.find {|m| m.original_title == "resource_import_file_test_description" }
expect(manifestation.description).to eq "test\ntest"
expect(manifestation.note).to eq "test\ntest"
expect(manifestation.items.first.note).to eq "test\ntest"
end
end
describe "when it contains custom properties" do
xit "should be imported" do
end
end
end
describe "when its mode is 'update'" do
before(:each) do
@file = ResourceImportFile.create!(
attachment: fixture_file_upload("item_update_file.tsv"),
user: users(:admin),
edit_mode: 'update'
)
end
it "should update items", vcr: true do
@file.modify
expect(@file.resource_import_results.first).to be_truthy
expect(@file.resource_import_results.first.body).to match /item_identifier/
item_00001 = Item.find_by(item_identifier: '00001')
item_00001.manifestation.creators.order('agents.id').pluck(:full_name).should eq [ 'たなべ', 'こうすけ' ]
item_00001.binding_item_identifier.should eq '900001'
item_00001.binding_call_number.should eq '336|A'
item_00001.binded_at.should eq Time.zone.parse('2014-08-16')
item_00001.manifestation.subjects.order(:id).map {|subject| { subject.subject_heading_type.name => subject.term }}.should eq [ { "ndlsh" => "test1" }, { "ndlsh" => "test2" } ]
expect(item_00001.manifestation.isbn_records.pluck(:body)).to eq [ "4798002062" ]
expect(item_00001.manifestation.required_role.name).to eq 'Librarian'
expect(item_00001.required_role.name).to eq 'Guest'
item_00002 = Item.find_by(item_identifier: '00002')
expect(item_00002.manifestation.publishers.pluck(:full_name)).to eq [ 'test2' ]
expect(item_00002.manifestation.required_role.name).to eq 'Guest'
expect(item_00002.required_role.name).to eq 'Guest'
item_00003 = Item.find_by(item_identifier: '00003')
item_00003.acquired_at.should eq Time.zone.parse('2012-01-01')
item_00003.include_supplements.should be_truthy
expect(item_00003.manifestation.required_role.name).to eq 'User'
expect(item_00003.required_role.name).to eq 'Administrator'
Item.find_by(item_identifier: '00004').include_supplements.should be_falsy
item_00025 = Item.find_by(item_identifier: '00025')
expect(item_00025.manifestation.original_title).to eq "テスト4"
expect(item_00025.manifestation.subjects.pluck(:term)).to eq [ 'test2', 'test3' ]
expect(item_00025.call_number).to eq "547|ヤ"
end
it "should update custom values", vcr: true do
@file.import_start
item_00001 = Item.find_by(item_identifier: '00001')
expect(item_00001.manifestation.manifestation_custom_values.pluck(:manifestation_custom_property_id, :value)).to eq [ [ 2, "カスタム項目5" ] ]
expect(item_00001.item_custom_values.order(:item_custom_property_id).first.value).to eq "カスタム項目6"
end
# it "should update series_statement", vcr: true do
# manifestation = Manifestation.find(10)
# file = ResourceImportFile.create attachment: fixture_file_upload("update_series_statement.tsv"), edit_mode: 'update'
# file.modify
# manifestation.reload
# manifestation.series_statements.should eq [SeriesStatement.find(2)]
# end
describe "NCID import" do
it "should import ncid value" do
file = ResourceImportFile.create(user: users(:admin), edit_mode: 'update')
file.attachment.attach(io: StringIO.new("manifestation_id\tncid\n1\tBA67656964\n"), filename: 'test.txt')
result = file.import_start
# expect(result[:manifestation_found]).to eq 1
expect(file.error_message).to be_nil
resource_import_result = file.resource_import_results.last
expect(resource_import_result.error_message).to be_blank
expect(resource_import_result.manifestation).not_to be_blank
manifestation = resource_import_result.manifestation
expect(manifestation.ncid_record.body).to eq "BA67656964"
end
end
end
describe "when its mode is 'destroy'" do
it "should remove items", vcr: true do
old_count = Item.count
file = ResourceImportFile.create!(
user: users(:admin),
edit_mode: 'destroy'
)
file.attachment.attach(io: File.open("spec/fixtures/files/item_delete_file.tsv"), filename: 'test.txt')
file.remove
Item.count.should eq old_count - 1
end
end
it "should import in background", vcr: true do
file = ResourceImportFile.create!(
user: users(:admin)
)
file.attachment.attach(io: File.open("spec/fixtures/files/resource_import_file_sample1.tsv"), filename: 'test.txt')
ResourceImportFileJob.perform_later(file).should be_truthy
end
end
# == Schema Information
#
# Table name: resource_import_files
#
# id :bigint not null, primary key
# edit_mode :string
# error_message :text
# executed_at :datetime
# note :text
# resource_import_fingerprint :string
# user_encoding :string
# created_at :datetime not null
# updated_at :datetime not null
# default_shelf_id :bigint
# parent_id :bigint
# user_id :bigint not null
#
# Indexes
#
# index_resource_import_files_on_parent_id (parent_id)
# index_resource_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/checkout_spec.rb | spec/models/checkout_spec.rb | require 'rails_helper'
describe Checkout do
# pending "add some examples to (or delete) #{__FILE__}"
fixtures :all
it "should respond to renewable?" do
checkouts(:checkout_00001).save
expect(checkouts(:checkout_00001).errors[:base]).to eq []
checkouts(:checkout_00002).save
expect(checkouts(:checkout_00002).errors[:base]).to eq [ I18n.t('checkout.this_item_is_reserved') ]
end
it "should respond to reserved?" do
checkouts(:checkout_00001).reserved?.should be_falsy
checkouts(:checkout_00002).reserved?.should be_truthy
end
it "should respond to overdue?" do
checkouts(:checkout_00001).overdue?.should be_falsy
checkouts(:checkout_00006).overdue?.should be_truthy
end
it "should respond to is_today_due_date?" do
checkouts(:checkout_00001).is_today_due_date?.should be_falsy
end
it "should get new due_date" do
old_due_date = checkouts(:checkout_00001).due_date
new_due_date = checkouts(:checkout_00001).get_new_due_date
new_due_date.should eq Time.zone.now.advance(days: UserGroupHasCheckoutType.find(3).checkout_period).beginning_of_day
end
it "should respond to not_returned" do
Checkout.not_returned.size.should > 0
end
it "should respond to overdue" do
Checkout.overdue(Time.zone.now).size.should > 0
Checkout.not_returned.size.should > Checkout.overdue(Time.zone.now).size
end
it "should respond to send_due_date_notification" do
expect(Checkout.send_due_date_notification).to eq 5
end
it "should respond to send_overdue_notification" do
expect(Checkout.send_overdue_notification).to eq 1
end
it "should destroy all history" do
user = users(:user1)
old_count = Checkout.count
Checkout.remove_all_history(user)
expect(user.checkouts.returned.count).to eq 0
expect(Checkout.count).to eq old_count
end
end
# == Schema Information
#
# Table name: checkouts
#
# id :bigint not null, primary key
# checkout_renewal_count :integer default(0), not null
# due_date :datetime
# lock_version :integer default(0), not null
# created_at :datetime not null
# updated_at :datetime not null
# basket_id :bigint
# checkin_id :bigint
# item_id :bigint not null
# librarian_id :bigint
# library_id :bigint
# shelf_id :bigint
# user_id :bigint
#
# Indexes
#
# index_checkouts_on_basket_id (basket_id)
# index_checkouts_on_checkin_id (checkin_id)
# index_checkouts_on_item_id (item_id)
# index_checkouts_on_item_id_and_basket_id_and_user_id (item_id,basket_id,user_id) UNIQUE
# index_checkouts_on_librarian_id (librarian_id)
# index_checkouts_on_library_id (library_id)
# index_checkouts_on_shelf_id (shelf_id)
# index_checkouts_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (checkin_id => checkins.id)
# fk_rails_... (item_id => items.id)
# fk_rails_... (library_id => libraries.id)
# 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/manifestation_checkout_stat_spec.rb | spec/models/manifestation_checkout_stat_spec.rb | require 'rails_helper'
describe ManifestationCheckoutStat do
fixtures :manifestation_checkout_stats
it "calculates manifestation count" do
old_message_count = Message.count
manifestation_checkout_stats(:one).transition_to!(:started).should be_truthy
Message.count.should eq old_message_count + 1
Message.order(:id).last.subject.should eq '[Enju Library] 集計が完了しました'
end
it "should calculate in background" do
ManifestationCheckoutStatJob.perform_later(manifestation_checkout_stats(:one)).should be_truthy
end
end
# == Schema Information
#
# Table name: manifestation_checkout_stats
#
# id :bigint not null, primary key
# completed_at :datetime
# end_date :datetime
# note :text
# start_date :datetime
# started_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_manifestation_checkout_stats_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/reserve_spec.rb | spec/models/reserve_spec.rb | require 'rails_helper'
describe Reserve do
fixtures :all
it "should have next reservation" do
expect(reserves(:reserve_00014).state_machine.current_state).to eq "retained"
expect(reserves(:reserve_00014).next_reservation).to eq reserves(:reserve_00015)
reserves(:reserve_00014).transition_to!(:canceled)
expect(reserves(:reserve_00015).state_machine.current_state).to eq "retained"
expect(reserves(:reserve_00015).next_reservation).to eq reserves(:reserve_00016)
end
it "should notify a next reservation" do
old_count = Message.count
reserve = reserves(:reserve_00014)
item = reserve.next_reservation.item
reserve.transition_to!(:expired)
reserve.current_state.should eq 'expired'
item.should eq reserve.item
Message.count.should eq old_count + 4
end
it "should expire reservation" do
reserves(:reserve_00001).transition_to!(:expired)
reserves(:reserve_00001).request_status_type.name.should eq 'Expired'
end
it "should cancel reservation" do
reserves(:reserve_00001).transition_to!(:canceled)
reserves(:reserve_00001).canceled_at.should be_truthy
reserves(:reserve_00001).request_status_type.name.should eq 'Cannot Fulfill Request'
end
it "should not have next reservation" do
reserves(:reserve_00002).next_reservation.should be_nil
end
it "should send accepted message" do
old_admin_count = User.where(username: 'enjuadmin').first.received_messages.count
old_user_count = reserves(:reserve_00002).user.received_messages.count
reserves(:reserve_00002).send_message.should be_truthy
# 予約者と図書館の両方に送られる
User.where(username: 'enjuadmin').first.received_messages.count.should eq old_admin_count + 1
reserves(:reserve_00002).user.received_messages.count.should eq old_user_count + 1
end
it "should send expired message" do
old_count = Message.count
reserves(:reserve_00006).send_message.should be_truthy
Message.count.should eq old_count + 2
end
it "should have reservations that will be expired" do
reserve = FactoryBot.create(:reserve)
item = FactoryBot.create(:item, manifestation_id: reserve.manifestation.id)
item.retain(reserve.user)
reserve.reload
reserve.expired_at = Date.yesterday
reserve.save!(validate: false)
expect(Reserve.will_expire_retained(Time.zone.now)).to include reserve
end
it "should have completed reservation" do
reserve = FactoryBot.create(:reserve)
item = FactoryBot.create(:item, manifestation_id: reserve.manifestation.id)
item.checkout!(reserve.user)
expect(Reserve.completed).to include reserve
end
it "should expire all reservations" do
assert Reserve.expire.should be_truthy
end
it "should send accepted notification" do
assert Reserve.expire.should be_truthy
end
it "should nullify the first reservation's item_id if the second reservation is retained" do
reservation = reserves(:reserve_00015)
old_reservation = reserves(:reserve_00014)
old_count = Message.count
reservation.item = old_reservation.item
expect(reservation).not_to be_retained
reservation.transition_to!(:retained)
old_reservation.reload
old_reservation.item.should be_nil
reservation.retained_at.should be_truthy
# old_reservation.retained_at.should be_nil
# old_reservation.postponed_at.should be_truthy
old_reservation.current_state.should eq 'postponed'
Message.count.should eq old_count + 4
reservation.item.retained?.should be_truthy
end
it "should not be valid if item_identifier is invalid" do
reservation = reserves(:reserve_00014)
reservation.item_identifier = 'invalid'
reservation.save
assert reservation.valid?.should eq false
end
it "should be valid if the reservation is completed and its item is destroyed" do
reservation = reserves(:reserve_00010)
reservation.item.destroy
reservation.reload
assert reservation.should be_valid
end
it "should be treated as Waiting" do
reserve = FactoryBot.create(:reserve)
expect(Reserve.waiting).to include reserve
reserve = FactoryBot.create(:reserve, expired_at: nil)
expect(Reserve.waiting).to include reserve
end
it "should not retain against reserves with already retained" do
reserve = FactoryBot.create(:reserve)
manifestation = reserve.manifestation
item = FactoryBot.create(:item, manifestation_id: manifestation.id)
expect {item.retain(reserve.user)}.not_to raise_error
expect(reserve.retained?).to be true
expect(item.retained?).to be true
item = FactoryBot.create(:item, manifestation_id: manifestation.id)
expect {item.retain(reserve.user)}.not_to raise_error
expect(reserve.retained?).to be true
expect(item.retained?).to be false
end
end
# == Schema Information
#
# Table name: reserves
#
# id :bigint not null, primary key
# canceled_at :datetime
# checked_out_at :datetime
# expiration_notice_to_library :boolean default(FALSE)
# expiration_notice_to_patron :boolean default(FALSE)
# expired_at :datetime
# lock_version :integer default(0), not null
# postponed_at :datetime
# retained_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# item_id :bigint
# manifestation_id :bigint not null
# pickup_location_id :bigint
# request_status_type_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_reserves_on_item_id (item_id)
# index_reserves_on_manifestation_id (manifestation_id)
# index_reserves_on_pickup_location_id (pickup_location_id)
# index_reserves_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (manifestation_id => manifestations.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/item_custom_value_spec.rb | spec/models/item_custom_value_spec.rb | require 'rails_helper'
RSpec.describe ItemCustomValue, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
# == Schema Information
#
# Table name: item_custom_values
#
# id :bigint not null, primary key
# value :text
# created_at :datetime not null
# updated_at :datetime not null
# item_custom_property_id :bigint not null
# item_id :bigint not null
#
# Indexes
#
# index_item_custom_values_on_custom_item_property_and_item_id (item_custom_property_id,item_id) UNIQUE
# index_item_custom_values_on_custom_property_id (item_custom_property_id)
# index_item_custom_values_on_item_id (item_id)
#
# Foreign Keys
#
# fk_rails_... (item_custom_property_id => item_custom_properties.id)
# 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/models/create_type_spec.rb | spec/models/create_type_spec.rb | require 'rails_helper'
describe CreateType do
it 'should create create_type' do
FactoryBot.create(:create_type)
end
end
# == Schema Information
#
# Table name: create_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_create_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/item_spec.rb | spec/models/item_spec.rb | require 'rails_helper'
describe Item do
# pending "add some examples to (or delete) #{__FILE__}"
fixtures :all
it "should be rent" do
items(:item_00001).rent?.should be_truthy
end
it "should not be rent" do
items(:item_00010).rent?.should be_falsy
end
it "should be checked out" do
items(:item_00010).checkout!(users(:admin)).should be_truthy
items(:item_00010).circulation_status.name.should eq 'On Loan'
end
it "should be checked in" do
items(:item_00001).checkin!.should be_truthy
expect(items(:item_00001).circulation_status.name).to eq 'Available On Shelf'
end
it "should be retained" do
old_count = Message.count
items(:item_00013).retain(users(:librarian1)).should be_truthy
expect(items(:item_00013).reserves.first.current_state).to eq 'retained'
expect(Message.count).to eq old_count + 4
end
it "should not be checked out when it is reserved" do
items(:item_00012).available_for_checkout?.should be_falsy
end
it "should not be able to checkout a removed item" do
Item.for_checkout.include?(items(:item_00023)).should be_falsy
end
end
# == Schema Information
#
# Table name: items
#
# id :bigint not null, primary key
# acquired_at :datetime
# binded_at :datetime
# binding_call_number :string
# binding_item_identifier :string
# call_number :string
# include_supplements :boolean default(FALSE), not null
# item_identifier :string
# lock_version :integer default(0), not null
# memo :text
# missing_since :date
# note :text
# price :integer
# required_score :integer default(0), not null
# url :string
# created_at :datetime not null
# updated_at :datetime not null
# bookstore_id :bigint
# budget_type_id :bigint
# checkout_type_id :bigint default(1), not null
# circulation_status_id :bigint default(5), not null
# manifestation_id :bigint not null
# required_role_id :bigint default(1), not null
# shelf_id :bigint default(1), not null
#
# Indexes
#
# index_items_on_binding_item_identifier (binding_item_identifier)
# index_items_on_bookstore_id (bookstore_id)
# index_items_on_checkout_type_id (checkout_type_id)
# index_items_on_circulation_status_id (circulation_status_id)
# index_items_on_item_identifier (item_identifier) UNIQUE WHERE (((item_identifier)::text <> ''::text) AND (item_identifier IS NOT NULL))
# index_items_on_manifestation_id (manifestation_id)
# index_items_on_required_role_id (required_role_id)
# index_items_on_shelf_id (shelf_id)
#
# Foreign Keys
#
# fk_rails_... (manifestation_id => manifestations.id)
# fk_rails_... (required_role_id => roles.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/event_spec.rb | spec/models/event_spec.rb | require 'rails_helper'
describe Event do
fixtures :events
it "should set_all_day" do
event = events(:event_00001)
event.all_day = true
event.set_all_day
expect(event.all_day).to be_truthy
end
it "should set all_day and beginning_of_day" do
event = events(:event_00008)
event.all_day = true
event.set_all_day
expect(event.start_at).to eq event.end_at.beginning_of_day
end
it "should export events" do
lines = Event.export
CSV.parse(lines, col_sep: "\t")
expect(lines).not_to be_empty
expect(lines.split(/\n/).size).to eq Event.all.count + 1
end
end
# == Schema Information
#
# Table name: events
#
# id :bigint not null, primary key
# all_day :boolean default(FALSE), not null
# display_name :text
# end_at :datetime
# name :string not null
# note :text
# start_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# event_category_id :bigint not null
# library_id :bigint not null
# place_id :bigint
#
# Indexes
#
# index_events_on_event_category_id (event_category_id)
# index_events_on_library_id (library_id)
# index_events_on_place_id (place_id)
#
# Foreign Keys
#
# fk_rails_... (event_category_id => event_categories.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/loc_search_spec.rb | spec/models/loc_search_spec.rb | require "rails_helper"
describe LocSearch do
fixtures :all
context ".import_from_sru_response" do
it "should create a valid manifestation", vcr: true do
manifestation = LocSearch.import_from_sru_response("2007012024")
expect(manifestation.manifestation_identifier).to eq "14780655"
expect(manifestation.original_title).to eq "Everything is miscellaneous : the power of the new digital disorder"
expect(manifestation.manifestation_content_type.name).to eq "text"
expect(manifestation.carrier_type.name).to eq "volume"
expect(manifestation.publishers.count).to eq 1
expect(manifestation.publishers.first.full_name).to eq "Times Books"
expect(manifestation.publication_place).to eq "New York"
expect(manifestation.creators.size).to eq 1
expect(manifestation.creators.first.agent_type.name).to eq "person"
expect(manifestation.creators.first.full_name).to eq "Weinberger, David, 1950-"
expect(manifestation.edition_string).to eq "1st ed."
expect(manifestation.language.iso_639_2).to eq "eng"
expect(manifestation.date_of_publication.year).to eq 2007
expect(manifestation.start_page).to eq 1
expect(manifestation.end_page).to eq 277
expect(manifestation.height).to eq 25
expect(manifestation.note).to eq "Includes bibliographical references (p. [235]-257) and index."
expect(manifestation.description).to eq "Philosopher Weinberger shows how the digital revolution is radically changing the way we make sense of our lives. Human beings constantly collect, label, and organize data--but today, the shift from the physical to the digital is mixing, burning, and ripping our lives apart. In the past, everything had its one place--the physical world demanded it--but now everything has its places: multiple categories, multiple shelves. Everything is suddenly miscellaneous. Weinberger charts the new principles of digital order that are remaking business, education, politics, science, and culture. He examines how Rand McNally decides what information not to include in a physical map (and why Google Earth is winning that battle), how Staples stores emulate online shopping to increase sales, why your children's teachers will stop having them memorize facts, and how the shift to digital music stands as the model for the future.--From publisher description.\nFrom A to Z, Everything Is Miscellaneous will completely reshape the way you think - and what you know - about the world. Includes information on alphabetical order, Amaxon.com, animals, Aristotle, authority, Bettmann Archive, blogs (weblogs), books, broadcasting, British Broadcasting Corporation (BBC), business, card catalog, categories and categorization, clusters, companies, Colon Classification, conversation, Melvil Dewey, Dewey Decimal Classification system, Encyclopaedia Britannica, encyclopedia, essentialism, experts, faceted classification system, first order of order, Flickr.com, Google, Great Books of the Western World, ancient Greeks, health and medical information, identifiers, index, inventory tracking, knowledge, labels, leaf and leaves, libraries, Library of Congress, links, Carolus Linnaeus, lumping and splitting, maps and mapping, marketing, meaning, metadata, multiple listing services (MLS), names of people, neutrality or neutral point of view, New York Public Library, Online Computer Library Center (OCLC), order and organization, people, physical space, everything having place, Plato, race, S.R. Ranganathan, Eleanor Rosch, Joshua Schacter, science, second order of order, simplicity, social constructivism, social knowledge, social networks, sorting, species, standardization, tags, taxonomies, third order of roder, topical categorization, tree, Uniform Product Code (UPC), users, Jimmy Wales, web, Wikipedia, etc."
expect(manifestation.statement_of_responsibility).to eq "David Weinberger."
expect(manifestation.subjects.size).to eq 6
expect(manifestation.subjects.first.subject_heading_type.name).to eq "lcsh"
expect(manifestation.subjects.first.subject_type.name).to eq "concept"
RSpec.describe manifestation.subjects.collect(&:term) do
it { is_expected.to include("Knowledge management") }
it { is_expected.to include("Information technology--Management") }
it { is_expected.to include("Information technology--Social aspects") }
it { is_expected.to include("Personal information management") }
it { is_expected.to include("Information resources management") }
it { is_expected.to include("Order") }
end
expect(manifestation.classifications.size).to eq 1
classification = manifestation.classifications.first
expect(classification.classification_type.name).to eq "ddc"
expect(classification.category).to eq "303.48"
expect(manifestation.isbn_records.first.body).to eq "9780805080438"
expect(manifestation.lccn_record.body).to eq "2007012024"
end
it "should parse title information properly", vcr: true do
manifestation = LocSearch.import_from_sru_response("2012532441")
expect(manifestation.original_title).to eq "The data journalism handbook"
expect(manifestation.title_alternative).to eq "How journalists can use data to improve the news"
end
it "should distinguish title information with subject", vcr: true do
m = LocSearch.import_from_sru_response("2008273186")
expect(m.original_title).to eq "Flexible Rails : Flex 3 on Rails 2"
end
it "should create multiple series_statements", vcr: true do
m = LocSearch.import_from_sru_response("2012471967")
expect(m.series_statements.size).to eq 2
RSpec.describe m.series_statements.collect(&:original_title) do
it { is_expected.to include("The Pragmatic Programmers") }
it { is_expected.to include("The Facets of Ruby Series") }
end
end
it "should create lcsh subjects only", vcr: true do
m = LocSearch.import_from_sru_response("2011281911")
expect(m.subjects.size).to eq 2
RSpec.describe m.subjects.collect(&:term) do
it { is_expected.to include("Computer software--Development") }
it { is_expected.to include("Ruby (Computer program language)") }
end
end
it "should support name and title subjects", vcr: true do
m = LocSearch.import_from_sru_response("2013433146")
expect(m.subjects.size).to eq 3
RSpec.describe m.subjects.collect(&:term) do
it { is_expected.to include("Montgomery, L. M. (Lucy Maud), 1874-1942. Anne of Green Gables") }
it { is_expected.to include("Montgomery, L. M. (Lucy Maud), 1874-1942--Criticism and interpretation") }
it { is_expected.to include("Montgomery, L. M. (Lucy Maud), 1874-1942--Influence") }
end
end
it "should import note fields", vcr: true do
m = LocSearch.import_from_sru_response("2010526151")
expect(m.note).not_to be_nil
expect(m.note).not_to be_empty
expect(m.note).to eq %Q["This is a book about the design of user interfaces for search and discovery"--Pref.;\n"January 2010"--T.p. verso.;\nIncludes bibliographical references and index.]
end
it "should import publication year", vcr: true do
m = LocSearch.import_from_sru_response("2001315134")
expect(m.date_of_publication.year).to eq 2000
end
it "should import e-resource", vcr: true do
m = LocSearch.import_from_sru_response("2005568297")
expect(m.carrier_type).to eq CarrierType.where(name: "online_resource").first
expect(m.access_address).to eq "http://portal.acm.org/dl.cfm"
end
it "should import e-resource (packaged)", vcr: true do
m = LocSearch.import_from_sru_response("2006575029")
expect(m.original_title).to eq "Microsoft Encarta 2006 premium"
expect(m.statement_of_responsibility).to eq "Microsoft Corporation"
expect(m.carrier_type).to eq CarrierType.where(name: "online_resource").first
expect(m.manifestation_content_type).to eq ContentType.where(name: "other").first
end
it "should import audio book", vcr: true do
m = LocSearch.import_from_sru_response("2007576782") # RDA metadata
expect(m.manifestation_content_type).to eq ContentType.where(name: "spoken_word").first
expect(m.carrier_type).to eq CarrierType.where(name: "audio_disc").first
end
it "should import video publication", vcr: true do
m = LocSearch.import_from_sru_response("2013602064")
expect(m.manifestation_content_type).to eq ContentType.where(name: "two_dimensional_moving_image").first
expect(m.carrier_type).to eq CarrierType.where(name: "videodisc").first
end
it "should import serial", vcr: true do
m = LocSearch.import_from_sru_response("00200486")
expect(m.original_title).to eq "Science and technology of advanced materials"
expect(m.serial).to be_truthy
expect(m.issn_records.first.body).to eq "14686996"
expect(m.identifier_contents(:issn_l).first).to eq "14686996"
expect(m.frequency.name).to eq "bimonthly"
series_statement = m.series_statements.first
expect(series_statement.original_title).to eq "Science and technology of advanced materials"
expect(series_statement.series_master).to be_truthy
end
it "should import another serial", vcr: true do
m = LocSearch.import_from_sru_response("88651712")
expect(m.original_title).to eq "Superconductor science & technology"
expect(m.title_alternative).to eq "Supercond. sci. technol ; Superconductor science and technology"
expect(m.serial).to be_truthy
expect(m.issn_records.first.body).to eq "09532048"
expect(m.identifier_contents(:issn_l).first).to eq "09532048"
expect(m.frequency.name).to eq "monthly"
series_statement = m.series_statements.first
expect(series_statement.original_title).to eq m.original_title
expect(series_statement.title_alternative).to eq m.title_alternative
expect(series_statement.series_master).to be_truthy
end
it "should import a manifestation that has invalid classification", vcr: true do
m = LocSearch.import_from_sru_response("2014381788")
expect(m).to be_valid
expect(m.classifications).to be_empty
end
it "should import notated music", vcr: true do
m = LocSearch.import_from_sru_response("2014563060")
expect(m.manifestation_content_type).to eq ContentType.where(name: 'notated_music').first
expect(m.language_id).to eq 1 # language: unknown
end
it "should import lccn exact math", vcr: true do
m = LocSearch.import_from_sru_response("93028401")
expect(m).to be_valid
expect(m.original_title).to eq "How to lie with statistics"
end
it "should import extent", vcr: true do
m = LocSearch.import_from_sru_response("94041789")
expect(m).to be_valid
expect(m.original_title).to eq "The little boat"
expect(m.extent).to eq "1 v. (unpaged) : col. ill."
expect(m.dimensions).to eq "25 x 29 cm."
end
end
context ".search", vcr: true do
it "should return a search result", vcr: true do
result = LocSearch.search('library')
expect(result[:total_entries]).to eq 10000
end
end
context "::ModsRecord" do
it "should parse MODS metadata", vcr: true do
results = LocSearch.search("bath.lccn=2007012024")
metadata = results[ :items ].first
expect(metadata.lccn).to eq "2007012024"
expect(metadata.title).to eq "Everything is miscellaneous : the power of the new digital disorder"
expect(metadata.creator).to eq "David Weinberger."
expect(metadata.pubyear).to eq "2007"
expect(metadata.publisher).to eq "Times Books"
expect(metadata.isbn).to eq "9780805080438"
end
end
context ".make_sru_request_uri" do
it "should construct a valid uri" do
url = LocSearch.make_sru_request_uri("test")
uri = URI.parse(url)
expect(Hash[uri.query.split(/\&/).collect {|e| e.split(/=/) }]).to eq({
"query" => "test",
"version" => "1.1",
"operation" => "searchRetrieve",
"maximumRecords" => "10",
"recordSchema" => "mods"
})
end
it "should support pagination" do
url = LocSearch.make_sru_request_uri("test", page: 2)
uri = URI.parse(url)
expect(Hash[uri.query.split(/\&/).collect {|e| e.split(/=/) }]).to eq({
"query" => "test",
"version" => "1.1",
"operation" => "searchRetrieve",
"maximumRecords" => "10",
"recordSchema" => "mods",
"startRecord" => "11",
})
end
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.