enju_circulation 0.0.43 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/app/controllers/checked_items_controller.rb +2 -4
  2. data/app/controllers/checkout_stat_has_manifestations_controller.rb +6 -6
  3. data/app/controllers/checkout_stat_has_users_controller.rb +6 -6
  4. data/app/controllers/checkout_types_controller.rb +2 -4
  5. data/app/controllers/item_has_use_restrictions_controller.rb +5 -5
  6. data/app/controllers/manifestation_checkout_stats_controller.rb +2 -4
  7. data/app/controllers/manifestation_reserve_stats_controller.rb +2 -4
  8. data/app/controllers/reserve_stat_has_manifestations_controller.rb +4 -2
  9. data/app/controllers/reserve_stat_has_users_controller.rb +6 -6
  10. data/app/controllers/user_group_has_checkout_types_controller.rb +2 -4
  11. data/app/models/carrier_type_has_checkout_type.rb +1 -0
  12. data/app/models/checked_item.rb +1 -0
  13. data/app/models/checkin.rb +1 -1
  14. data/app/models/checkout.rb +2 -3
  15. data/app/models/checkout_stat_has_manifestation.rb +3 -0
  16. data/app/models/checkout_stat_has_user.rb +3 -0
  17. data/app/models/checkout_type.rb +1 -0
  18. data/app/models/circulation_status.rb +2 -2
  19. data/app/models/item_has_use_restriction.rb +2 -0
  20. data/app/models/lending_policy.rb +2 -0
  21. data/app/models/manifestation_checkout_stat.rb +2 -0
  22. data/app/models/manifestation_reserve_stat.rb +2 -0
  23. data/app/models/reserve.rb +35 -16
  24. data/app/models/reserve_stat_has_manifestation.rb +3 -0
  25. data/app/models/reserve_stat_has_user.rb +3 -0
  26. data/app/models/use_restriction.rb +1 -1
  27. data/app/models/user_checkout_stat.rb +2 -1
  28. data/app/models/user_group_has_checkout_type.rb +4 -0
  29. data/app/models/user_reserve_stat.rb +2 -1
  30. data/lib/enju_circulation/version.rb +1 -1
  31. data/spec/controllers/carrier_type_has_checkout_types_controller_spec.rb +7 -7
  32. data/spec/controllers/checkout_stat_has_manifestations_controller_spec.rb +10 -10
  33. data/spec/controllers/checkout_stat_has_users_controller_spec.rb +3 -3
  34. data/spec/controllers/checkouts_controller_spec.rb +9 -7
  35. data/spec/controllers/circulation_statuses_controller_spec.rb +445 -0
  36. data/spec/controllers/item_has_use_restrictions_controller_spec.rb +10 -10
  37. data/spec/controllers/reserve_stat_has_manifestations_controller_spec.rb +10 -10
  38. data/spec/controllers/reserve_stat_has_users_controller_spec.rb +3 -3
  39. data/spec/controllers/reserves_controller_spec.rb +1 -1
  40. data/spec/controllers/use_restrictions_controller_spec.rb +4 -4
  41. data/spec/dummy/app/models/basket.rb +5 -2
  42. data/spec/dummy/db/development.sqlite3 +0 -0
  43. data/spec/dummy/db/test.sqlite3 +0 -0
  44. data/spec/dummy/solr/conf/admin-extra.html +31 -0
  45. data/spec/dummy/solr/conf/elevate.xml +36 -0
  46. data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  47. data/spec/dummy/solr/conf/protwords.txt +21 -0
  48. data/spec/dummy/solr/conf/schema.xml +238 -0
  49. data/spec/dummy/solr/conf/scripts.conf +24 -0
  50. data/spec/dummy/solr/conf/solrconfig.xml +934 -0
  51. data/spec/dummy/solr/conf/spellings.txt +2 -0
  52. data/spec/dummy/solr/conf/stopwords.txt +58 -0
  53. data/spec/dummy/solr/conf/synonyms.txt +31 -0
  54. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  55. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  56. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  57. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  58. data/spec/factories/circulation_status.rb +5 -0
  59. data/spec/models/basket_spec.rb +43 -0
  60. data/spec/models/checkin_spec.rb +13 -4
  61. data/spec/models/circulation_status_spec.rb +21 -0
  62. data/spec/spec_helper.rb +13 -0
  63. metadata +56 -18
@@ -0,0 +1,2 @@
1
+ pizza
2
+ history
@@ -0,0 +1,58 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ #-----------------------------------------------------------------------
17
+ # a couple of test stopwords to test that the words are really being
18
+ # configured from this file:
19
+ stopworda
20
+ stopwordb
21
+
22
+ #Standard english stop words taken from Lucene's StopAnalyzer
23
+ a
24
+ an
25
+ and
26
+ are
27
+ as
28
+ at
29
+ be
30
+ but
31
+ by
32
+ for
33
+ if
34
+ in
35
+ into
36
+ is
37
+ it
38
+ no
39
+ not
40
+ of
41
+ on
42
+ or
43
+ s
44
+ such
45
+ t
46
+ that
47
+ the
48
+ their
49
+ then
50
+ there
51
+ these
52
+ they
53
+ this
54
+ to
55
+ was
56
+ will
57
+ with
58
+
@@ -0,0 +1,31 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ #-----------------------------------------------------------------------
14
+ #some test synonym mappings unlikely to appear in real input text
15
+ aaa => aaaa
16
+ bbb => bbbb1 bbbb2
17
+ ccc => cccc1,cccc2
18
+ a\=>a => b\=>b
19
+ a\,a => b\,b
20
+ fooaaa,baraaa,bazaaa
21
+
22
+ # Some synonym groups specific to this example
23
+ GB,gib,gigabyte,gigabytes
24
+ MB,mib,megabyte,megabytes
25
+ Television, Televisions, TV, TVs
26
+ #notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming
27
+ #after us won't split it into two words.
28
+
29
+ # Synonym mappings can be used for spelling correction too
30
+ pixima => pixma
31
+
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :circulation_status do |f|
3
+ f.sequence(:name){|n| "circulation_status_#{n}"}
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Basket do
5
+ fixtures :all
6
+
7
+ it "should not create basket when user is not active" do
8
+ Basket.create(:user => users(:user4)).id.should be_nil
9
+ end
10
+
11
+ it "should not check out items that are already checked out" do
12
+ items(:item_00021).checkouts.count.should eq 0
13
+ basket_1 = Basket.new
14
+ basket_1.user = users(:admin)
15
+ basket_1.save
16
+ checked_item_1 = basket_1.checked_items.new
17
+ checked_item_1.item = items(:item_00011)
18
+ checked_item_1.save
19
+ basket_2 = Basket.new
20
+ basket_2.user = users(:user1)
21
+ basket_2.save
22
+ checked_item_2 = basket_2.checked_items.new
23
+ checked_item_2.item = items(:item_00011)
24
+ checked_item_2.save
25
+ basket_1.basket_checkout(users(:librarian1))
26
+ lambda{basket_2.basket_checkout(users(:librarian1))}.should raise_exception ActiveRecord::RecordInvalid
27
+ items(:item_00011).checkouts.first.user.should eq users(:admin)
28
+ end
29
+ end
30
+
31
+ # == Schema Information
32
+ #
33
+ # Table name: baskets
34
+ #
35
+ # id :integer not null, primary key
36
+ # user_id :integer
37
+ # note :text
38
+ # type :string(255)
39
+ # lock_version :integer default(0), not null
40
+ # created_at :datetime
41
+ # updated_at :datetime
42
+ #
43
+
@@ -4,11 +4,19 @@ require 'spec_helper'
4
4
  describe Checkin do
5
5
  fixtures :all
6
6
 
7
+ before(:each) do
8
+ @basket = Basket.new
9
+ @basket.user = users(:librarian1)
10
+ @basket.save
11
+ end
12
+
7
13
  it "should save checkout history if save_checkout_history is true" do
8
14
  user = users(:user1)
9
15
  checkouts_count = user.checkouts.count
10
- checkin = Checkin.new(:item => user.checkouts.not_returned.first.item, :basket => Basket.create(:user => users(:librarian1)))
11
- checkin.item_identifier = checkin.item.item_identifier
16
+ checkin = Checkin.new
17
+ checkin.item = user.checkouts.not_returned.first.item
18
+ checkin.basket = @basket
19
+ #checkin.item_identifier = checkin.item.item_identifier
12
20
  checkin.save!
13
21
  checkin.item_checkin(user)
14
22
  user.checkouts.count.should eq checkouts_count
@@ -17,8 +25,9 @@ describe Checkin do
17
25
  it "should not save checkout history if save_checkout_history is false" do
18
26
  user = users(:librarian1)
19
27
  checkouts_count = user.checkouts.count
20
- checkin = Checkin.new(:item => user.checkouts.not_returned.first.item, :basket => Basket.create(:user => users(:librarian1)))
21
- checkin.item_identifier = checkin.item.item_identifier
28
+ checkin = Checkin.new
29
+ checkin.item = user.checkouts.not_returned.first.item
30
+ checkin.basket = @basket
22
31
  checkin.save!
23
32
  checkin.item_checkin(user)
24
33
  user.checkouts.count.should eq checkouts_count - 1
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe CirculationStatus do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: circulation_statuses
12
+ #
13
+ # id :integer not null, primary key
14
+ # name :string(255) not null
15
+ # display_name :text
16
+ # note :text
17
+ # position :integer
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
+ #
21
+
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test'
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
  require 'rspec/rails'
5
5
  require 'factory_girl'
6
+ require 'sunspot-rails-tester'
6
7
 
7
8
  # Requires supporting ruby files with custom matchers and macros, etc,
8
9
  # in spec/support/ and its subdirectories.
@@ -27,6 +28,18 @@ RSpec.configure do |config|
27
28
  config.use_transactional_fixtures = true
28
29
 
29
30
  config.extend ControllerMacros, :type => :controller
31
+
32
+ $original_sunspot_session = Sunspot.session
33
+
34
+ config.before do
35
+ Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
36
+ end
37
+
38
+ config.before :each, :solr => true do
39
+ Sunspot::Rails::Tester.start_original_sunspot_session
40
+ Sunspot.session = $original_sunspot_session
41
+ #Sunspot.remove_all!
42
+ end
30
43
  end
31
44
 
32
45
  FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_circulation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.45
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-25 00:00:00.000000000 Z
12
+ date: 2012-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -171,22 +171,6 @@ dependencies:
171
171
  - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
- - !ruby/object:Gem::Dependency
175
- name: sunspot_solr
176
- requirement: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ! '>='
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- type: :runtime
183
- prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
- requirements:
187
- - - ! '>='
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
174
  - !ruby/object:Gem::Dependency
191
175
  name: will_paginate
192
176
  requirement: !ruby/object:Gem::Requirement
@@ -315,6 +299,22 @@ dependencies:
315
299
  - - ! '>='
316
300
  - !ruby/object:Gem::Version
317
301
  version: '0'
302
+ - !ruby/object:Gem::Dependency
303
+ name: sunspot_solr
304
+ requirement: !ruby/object:Gem::Requirement
305
+ none: false
306
+ requirements:
307
+ - - ! '>='
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ none: false
314
+ requirements:
315
+ - - ! '>='
316
+ - !ruby/object:Gem::Version
317
+ version: '0'
318
318
  description: Circulation management for Next-L Enju
319
319
  email:
320
320
  - tanabe@mwr.mediacom.keio.ac.jp
@@ -536,6 +536,7 @@ files:
536
536
  - spec/controllers/checkout_stat_has_users_controller_spec.rb
537
537
  - spec/controllers/checkout_types_controller_spec.rb
538
538
  - spec/controllers/checkouts_controller_spec.rb
539
+ - spec/controllers/circulation_statuses_controller_spec.rb
539
540
  - spec/controllers/item_has_use_restrictions_controller_spec.rb
540
541
  - spec/controllers/lending_policies_controller_spec.rb
541
542
  - spec/controllers/manifestation_checkout_stats_controller_spec.rb
@@ -600,6 +601,7 @@ files:
600
601
  - spec/dummy/config/locales/ja.yml
601
602
  - spec/dummy/config/routes.rb
602
603
  - spec/dummy/config.ru
604
+ - spec/dummy/db/development.sqlite3
603
605
  - spec/dummy/db/migrate/001_create_patrons.rb
604
606
  - spec/dummy/db/migrate/005_create_manifestations.rb
605
607
  - spec/dummy/db/migrate/006_create_items.rb
@@ -650,6 +652,20 @@ files:
650
652
  - spec/dummy/Rakefile
651
653
  - spec/dummy/script/delayed_job
652
654
  - spec/dummy/script/rails
655
+ - spec/dummy/solr/conf/admin-extra.html
656
+ - spec/dummy/solr/conf/elevate.xml
657
+ - spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt
658
+ - spec/dummy/solr/conf/protwords.txt
659
+ - spec/dummy/solr/conf/schema.xml
660
+ - spec/dummy/solr/conf/scripts.conf
661
+ - spec/dummy/solr/conf/solrconfig.xml
662
+ - spec/dummy/solr/conf/spellings.txt
663
+ - spec/dummy/solr/conf/stopwords.txt
664
+ - spec/dummy/solr/conf/synonyms.txt
665
+ - spec/dummy/solr/data/test/index/segments.gen
666
+ - spec/dummy/solr/data/test/index/segments_1
667
+ - spec/dummy/solr/data/test/spellchecker/segments.gen
668
+ - spec/dummy/solr/data/test/spellchecker/segments_1
653
669
  - spec/factories/basket.rb
654
670
  - spec/factories/carrier_type.rb
655
671
  - spec/factories/carrier_type_has_checkout_type.rb
@@ -657,6 +673,7 @@ files:
657
673
  - spec/factories/checkout_stat_has_manifestation.rb
658
674
  - spec/factories/checkout_stat_has_user.rb
659
675
  - spec/factories/checkout_type.rb
676
+ - spec/factories/circulation_status.rb
660
677
  - spec/factories/item.rb
661
678
  - spec/factories/item_has_use_restriction.rb
662
679
  - spec/factories/lending_policy.rb
@@ -712,6 +729,7 @@ files:
712
729
  - spec/fixtures/user_has_roles.yml
713
730
  - spec/fixtures/user_reserve_stats.yml
714
731
  - spec/fixtures/users.yml
732
+ - spec/models/basket_spec.rb
715
733
  - spec/models/carrier_type_has_checkout_type_spec.rb
716
734
  - spec/models/checked_item_spec.rb
717
735
  - spec/models/checkin_spec.rb
@@ -719,6 +737,7 @@ files:
719
737
  - spec/models/checkout_stat_has_manifestation_spec.rb
720
738
  - spec/models/checkout_stat_has_user_spec.rb
721
739
  - spec/models/checkout_type_spec.rb
740
+ - spec/models/circulation_status_spec.rb
722
741
  - spec/models/item_has_use_resetriction_spec.rb
723
742
  - spec/models/lending_policy_spec.rb
724
743
  - spec/models/manifestation_checkout_stat_spec.rb
@@ -765,6 +784,7 @@ test_files:
765
784
  - spec/controllers/checkout_stat_has_users_controller_spec.rb
766
785
  - spec/controllers/checkout_types_controller_spec.rb
767
786
  - spec/controllers/checkouts_controller_spec.rb
787
+ - spec/controllers/circulation_statuses_controller_spec.rb
768
788
  - spec/controllers/item_has_use_restrictions_controller_spec.rb
769
789
  - spec/controllers/lending_policies_controller_spec.rb
770
790
  - spec/controllers/manifestation_checkout_stats_controller_spec.rb
@@ -829,6 +849,7 @@ test_files:
829
849
  - spec/dummy/config/locales/ja.yml
830
850
  - spec/dummy/config/routes.rb
831
851
  - spec/dummy/config.ru
852
+ - spec/dummy/db/development.sqlite3
832
853
  - spec/dummy/db/migrate/001_create_patrons.rb
833
854
  - spec/dummy/db/migrate/005_create_manifestations.rb
834
855
  - spec/dummy/db/migrate/006_create_items.rb
@@ -879,6 +900,20 @@ test_files:
879
900
  - spec/dummy/Rakefile
880
901
  - spec/dummy/script/delayed_job
881
902
  - spec/dummy/script/rails
903
+ - spec/dummy/solr/conf/admin-extra.html
904
+ - spec/dummy/solr/conf/elevate.xml
905
+ - spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt
906
+ - spec/dummy/solr/conf/protwords.txt
907
+ - spec/dummy/solr/conf/schema.xml
908
+ - spec/dummy/solr/conf/scripts.conf
909
+ - spec/dummy/solr/conf/solrconfig.xml
910
+ - spec/dummy/solr/conf/spellings.txt
911
+ - spec/dummy/solr/conf/stopwords.txt
912
+ - spec/dummy/solr/conf/synonyms.txt
913
+ - spec/dummy/solr/data/test/index/segments.gen
914
+ - spec/dummy/solr/data/test/index/segments_1
915
+ - spec/dummy/solr/data/test/spellchecker/segments.gen
916
+ - spec/dummy/solr/data/test/spellchecker/segments_1
882
917
  - spec/factories/basket.rb
883
918
  - spec/factories/carrier_type.rb
884
919
  - spec/factories/carrier_type_has_checkout_type.rb
@@ -886,6 +921,7 @@ test_files:
886
921
  - spec/factories/checkout_stat_has_manifestation.rb
887
922
  - spec/factories/checkout_stat_has_user.rb
888
923
  - spec/factories/checkout_type.rb
924
+ - spec/factories/circulation_status.rb
889
925
  - spec/factories/item.rb
890
926
  - spec/factories/item_has_use_restriction.rb
891
927
  - spec/factories/lending_policy.rb
@@ -941,6 +977,7 @@ test_files:
941
977
  - spec/fixtures/user_has_roles.yml
942
978
  - spec/fixtures/user_reserve_stats.yml
943
979
  - spec/fixtures/users.yml
980
+ - spec/models/basket_spec.rb
944
981
  - spec/models/carrier_type_has_checkout_type_spec.rb
945
982
  - spec/models/checked_item_spec.rb
946
983
  - spec/models/checkin_spec.rb
@@ -948,6 +985,7 @@ test_files:
948
985
  - spec/models/checkout_stat_has_manifestation_spec.rb
949
986
  - spec/models/checkout_stat_has_user_spec.rb
950
987
  - spec/models/checkout_type_spec.rb
988
+ - spec/models/circulation_status_spec.rb
951
989
  - spec/models/item_has_use_resetriction_spec.rb
952
990
  - spec/models/lending_policy_spec.rb
953
991
  - spec/models/manifestation_checkout_stat_spec.rb