enju_oai 0.2.0.beta.2 → 0.2.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/oai_controller.rb +1 -0
- data/app/views/oai/_record_dcndl.xml.builder +164 -54
- data/lib/enju_oai/oai_controller.rb +1 -1
- data/lib/enju_oai/version.rb +1 -1
- data/spec/cassette_library/oai/list_records_xml_builder/when_metadataPrefix_is_dcndl/renders_well-formed_XML.yml +280 -0
- data/spec/controllers/oai_controller_spec.rb +8 -1
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/config/application.rb +1 -0
- data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
- data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
- data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
- data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
- data/spec/dummy/db/schema.rb +78 -5
- data/spec/fixtures/library_groups.yml +1 -6
- data/spec/rails_helper.rb +66 -0
- data/spec/spec_helper.rb +82 -47
- data/spec/views/oai/get_record.xml.builder +1 -1
- data/spec/views/oai/identify.xml.builder_spec.rb +1 -1
- data/spec/views/oai/list_identifiers.xml.builder_spec.rb +1 -1
- data/spec/views/oai/list_metadata_formats.xml.builder_spec.rb +1 -1
- data/spec/views/oai/list_records.xml.builder_spec.rb +30 -1
- metadata +360 -278
- data/spec/dummy/config/initializers/enju_leaf.rb +0 -2
- data/spec/dummy/db/migrate/20160813130535_add_email_to_library_group.rb +0 -5
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateMessageRequests < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :message_requests do |t|
|
4
|
+
t.integer :sender_id
|
5
|
+
t.integer :receiver_id
|
6
|
+
t.integer :message_template_id
|
7
|
+
t.datetime :sent_at
|
8
|
+
t.datetime :deleted_at
|
9
|
+
t.text :body
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :message_requests
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateMessageTransitions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :message_transitions do |t|
|
4
|
+
t.string :to_state
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
10
|
+
t.integer :sort_key
|
11
|
+
t.integer :message_id
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :message_transitions, :message_id
|
16
|
+
add_index :message_transitions, [:sort_key, :message_id], unique: true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateMessageRequestTransitions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :message_request_transitions do |t|
|
4
|
+
t.string :to_state
|
5
|
+
if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
|
6
|
+
t.text :metadata
|
7
|
+
else
|
8
|
+
t.text :metadata, default: "{}"
|
9
|
+
end
|
10
|
+
t.integer :sort_key
|
11
|
+
t.integer :message_request_id
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :message_request_transitions, :message_request_id
|
16
|
+
add_index :message_request_transitions, [:sort_key, :message_request_id], unique: true, name: "index_message_request_transitions_on_sort_key_and_request_id"
|
17
|
+
end
|
18
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160814165332) do
|
15
15
|
|
16
16
|
create_table "accepts", force: :cascade do |t|
|
17
17
|
t.integer "basket_id"
|
@@ -687,9 +687,9 @@ ActiveRecord::Schema.define(version: 20160813130535) do
|
|
687
687
|
add_index "library_group_translations", ["locale"], name: "index_library_group_translations_on_locale"
|
688
688
|
|
689
689
|
create_table "library_groups", force: :cascade do |t|
|
690
|
-
t.string "name",
|
690
|
+
t.string "name", null: false
|
691
691
|
t.text "display_name"
|
692
|
-
t.string "short_name",
|
692
|
+
t.string "short_name", null: false
|
693
693
|
t.text "my_networks"
|
694
694
|
t.text "login_banner"
|
695
695
|
t.text "note"
|
@@ -698,13 +698,17 @@ ActiveRecord::Schema.define(version: 20160813130535) do
|
|
698
698
|
t.datetime "created_at"
|
699
699
|
t.datetime "updated_at"
|
700
700
|
t.text "admin_networks"
|
701
|
-
t.string "url",
|
701
|
+
t.string "url", default: "http://localhost:3000/"
|
702
702
|
t.text "settings"
|
703
703
|
t.text "html_snippet"
|
704
|
-
t.
|
704
|
+
t.integer "max_number_of_results", default: 500
|
705
|
+
t.boolean "family_name_first", default: true
|
706
|
+
t.integer "pub_year_facet_range_interval", default: 10
|
707
|
+
t.integer "user_id"
|
705
708
|
end
|
706
709
|
|
707
710
|
add_index "library_groups", ["short_name"], name: "index_library_groups_on_short_name"
|
711
|
+
add_index "library_groups", ["user_id"], name: "index_library_groups_on_user_id"
|
708
712
|
|
709
713
|
create_table "licenses", force: :cascade do |t|
|
710
714
|
t.string "name", null: false
|
@@ -863,6 +867,75 @@ ActiveRecord::Schema.define(version: 20160813130535) do
|
|
863
867
|
t.datetime "updated_at"
|
864
868
|
end
|
865
869
|
|
870
|
+
create_table "message_request_transitions", force: :cascade do |t|
|
871
|
+
t.string "to_state"
|
872
|
+
t.text "metadata", default: "{}"
|
873
|
+
t.integer "sort_key"
|
874
|
+
t.integer "message_request_id"
|
875
|
+
t.datetime "created_at"
|
876
|
+
t.datetime "updated_at"
|
877
|
+
t.boolean "most_recent"
|
878
|
+
end
|
879
|
+
|
880
|
+
add_index "message_request_transitions", ["message_request_id"], name: "index_message_request_transitions_on_message_request_id"
|
881
|
+
add_index "message_request_transitions", ["sort_key", "message_request_id"], name: "index_message_request_transitions_on_sort_key_and_request_id", unique: true
|
882
|
+
|
883
|
+
create_table "message_requests", force: :cascade do |t|
|
884
|
+
t.integer "sender_id"
|
885
|
+
t.integer "receiver_id"
|
886
|
+
t.integer "message_template_id"
|
887
|
+
t.datetime "sent_at"
|
888
|
+
t.datetime "deleted_at"
|
889
|
+
t.text "body"
|
890
|
+
t.datetime "created_at"
|
891
|
+
t.datetime "updated_at"
|
892
|
+
end
|
893
|
+
|
894
|
+
create_table "message_templates", force: :cascade do |t|
|
895
|
+
t.string "status", null: false
|
896
|
+
t.text "title", null: false
|
897
|
+
t.text "body", null: false
|
898
|
+
t.integer "position"
|
899
|
+
t.string "locale", default: "en"
|
900
|
+
t.datetime "created_at"
|
901
|
+
t.datetime "updated_at"
|
902
|
+
end
|
903
|
+
|
904
|
+
add_index "message_templates", ["status"], name: "index_message_templates_on_status", unique: true
|
905
|
+
|
906
|
+
create_table "message_transitions", force: :cascade do |t|
|
907
|
+
t.string "to_state"
|
908
|
+
t.text "metadata", default: "{}"
|
909
|
+
t.integer "sort_key"
|
910
|
+
t.integer "message_id"
|
911
|
+
t.datetime "created_at"
|
912
|
+
t.datetime "updated_at"
|
913
|
+
t.boolean "most_recent"
|
914
|
+
end
|
915
|
+
|
916
|
+
add_index "message_transitions", ["message_id"], name: "index_message_transitions_on_message_id"
|
917
|
+
add_index "message_transitions", ["sort_key", "message_id"], name: "index_message_transitions_on_sort_key_and_message_id", unique: true
|
918
|
+
|
919
|
+
create_table "messages", force: :cascade do |t|
|
920
|
+
t.datetime "read_at"
|
921
|
+
t.integer "receiver_id"
|
922
|
+
t.integer "sender_id"
|
923
|
+
t.string "subject", null: false
|
924
|
+
t.text "body"
|
925
|
+
t.integer "message_request_id"
|
926
|
+
t.integer "parent_id"
|
927
|
+
t.datetime "created_at"
|
928
|
+
t.datetime "updated_at"
|
929
|
+
t.integer "lft"
|
930
|
+
t.integer "rgt"
|
931
|
+
t.integer "depth"
|
932
|
+
end
|
933
|
+
|
934
|
+
add_index "messages", ["message_request_id"], name: "index_messages_on_message_request_id"
|
935
|
+
add_index "messages", ["parent_id"], name: "index_messages_on_parent_id"
|
936
|
+
add_index "messages", ["receiver_id"], name: "index_messages_on_receiver_id"
|
937
|
+
add_index "messages", ["sender_id"], name: "index_messages_on_sender_id"
|
938
|
+
|
866
939
|
create_table "nii_types", force: :cascade do |t|
|
867
940
|
t.string "name", null: false
|
868
941
|
t.text "display_name"
|
@@ -7,12 +7,7 @@ one:
|
|
7
7
|
note:
|
8
8
|
my_networks: 0.0.0.0/0
|
9
9
|
url: "http://localhost:3000/"
|
10
|
-
|
11
|
-
"{\"max_number_of_results\":200,\"family_name_first\":true}"
|
12
|
-
<% else %>
|
13
|
-
"---\n:max_number_of_results: 200\n:family_name_first: true\n"
|
14
|
-
<% end %>
|
15
|
-
|
10
|
+
user_id: 1
|
16
11
|
|
17
12
|
# == Schema Information
|
18
13
|
#
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
SimpleCov.start 'rails'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
7
|
+
ENV["RAILS_ENV"] ||= 'test'
|
8
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'factory_girl'
|
11
|
+
require 'sunspot-rails-tester'
|
12
|
+
require 'vcr'
|
13
|
+
|
14
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
15
|
+
# in spec/support/ and its subdirectories.
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
|
+
|
18
|
+
RSpec.configure do |config|
|
19
|
+
# ## Mock Framework
|
20
|
+
#
|
21
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
22
|
+
#
|
23
|
+
# config.mock_with :mocha
|
24
|
+
# config.mock_with :flexmock
|
25
|
+
# config.mock_with :rr
|
26
|
+
|
27
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
28
|
+
config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
|
29
|
+
|
30
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
31
|
+
# examples within a transaction, remove the following line or assign false
|
32
|
+
# instead of true.
|
33
|
+
config.use_transactional_fixtures = true
|
34
|
+
|
35
|
+
# If true, the base class of anonymous controllers will be inferred
|
36
|
+
# automatically. This will be the default behavior in future versions of
|
37
|
+
# rspec-rails.
|
38
|
+
config.infer_base_class_for_anonymous_controllers = false
|
39
|
+
|
40
|
+
config.extend ControllerMacros, :type => :controller
|
41
|
+
|
42
|
+
$original_sunspot_session = Sunspot.session
|
43
|
+
|
44
|
+
config.before do
|
45
|
+
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
|
46
|
+
end
|
47
|
+
|
48
|
+
config.before :each, :solr => true do
|
49
|
+
Sunspot::Rails::Tester.start_original_sunspot_session
|
50
|
+
Sunspot.session = $original_sunspot_session
|
51
|
+
Sunspot.remove_all!
|
52
|
+
end
|
53
|
+
|
54
|
+
config.infer_spec_type_from_file_location!
|
55
|
+
end
|
56
|
+
|
57
|
+
FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
|
58
|
+
FactoryGirl.find_definitions
|
59
|
+
|
60
|
+
VCR.configure do |c|
|
61
|
+
c.cassette_library_dir = 'spec/cassette_library'
|
62
|
+
c.hook_into :webmock
|
63
|
+
c.configure_rspec_metadata!
|
64
|
+
c.allow_http_connections_when_no_cassette = true
|
65
|
+
c.ignore_localhost = true
|
66
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,57 +1,92 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
19
|
RSpec.configure do |config|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
28
33
|
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
32
|
-
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = false
|
41
|
+
end
|
33
42
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
=begin
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
49
|
+
# get run.
|
50
|
+
config.filter_run :focus
|
51
|
+
config.run_all_when_everything_filtered = true
|
38
52
|
|
39
|
-
|
53
|
+
# Allows RSpec to persist some state between runs in order to support
|
54
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
55
|
+
# you configure your source control system to ignore this file.
|
56
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
40
57
|
|
41
|
-
|
58
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
59
|
+
# recommended. For more details, see:
|
60
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
61
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
62
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
63
|
+
config.disable_monkey_patching!
|
42
64
|
|
43
|
-
|
44
|
-
|
65
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
66
|
+
# file, and it's useful to allow more verbose output when running an
|
67
|
+
# individual spec file.
|
68
|
+
if config.files_to_run.one?
|
69
|
+
# Use the documentation formatter for detailed output,
|
70
|
+
# unless a formatter has already been configured
|
71
|
+
# (e.g. via a command-line flag).
|
72
|
+
config.default_formatter = 'doc'
|
45
73
|
end
|
46
74
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
75
|
+
# Print the 10 slowest examples and example groups at the
|
76
|
+
# end of the spec run, to help surface which specs are running
|
77
|
+
# particularly slow.
|
78
|
+
config.profile_examples = 10
|
52
79
|
|
53
|
-
|
54
|
-
|
80
|
+
# Run specs in random order to surface order dependencies. If you find an
|
81
|
+
# order dependency and want to debug it, you can fix the order by providing
|
82
|
+
# the seed, which is printed after each run.
|
83
|
+
# --seed 1234
|
84
|
+
config.order = :random
|
55
85
|
|
56
|
-
|
57
|
-
|
86
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
87
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
88
|
+
# test failures related to randomization by passing the same `--seed` value
|
89
|
+
# as the one that triggered the failure.
|
90
|
+
Kernel.srand config.seed
|
91
|
+
=end
|
92
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require '
|
2
|
+
require 'rails_helper'
|
3
3
|
|
4
4
|
describe "oai/list_records.xml.builder" do
|
5
5
|
fixtures :all
|
@@ -54,4 +54,33 @@ describe "oai/list_records.xml.builder" do
|
|
54
54
|
expect(rendered).to match /<NIItype>Journal Article<\/NIItype>/
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
describe "when metadataPrefix is dcndl" do
|
59
|
+
before(:each) do
|
60
|
+
assign(:oai, { :errors => [], :metadataPrefix => 'dcndl' } )
|
61
|
+
end
|
62
|
+
it "renders the XML template" do
|
63
|
+
render
|
64
|
+
expect(rendered).to match /dcndl/
|
65
|
+
end
|
66
|
+
it "renders well-formed XML", vcr: true do
|
67
|
+
NdlBook.import_from_sru_response('R100000002-I000008369884-00')
|
68
|
+
manifestations = Manifestation.all
|
69
|
+
manifestations.stub(:last_page?){true}
|
70
|
+
manifestations.stub(:total_count){manifestations.size}
|
71
|
+
assign(:manifestations, manifestations)
|
72
|
+
render
|
73
|
+
doc = Nokogiri::XML(rendered)
|
74
|
+
expect(doc.errors).to be_empty
|
75
|
+
end
|
76
|
+
it "renders extent and dimensions" do
|
77
|
+
FactoryGirl.create(:manifestation, extent: "123p", dimensions: "23cm")
|
78
|
+
manifestations = Manifestation.all
|
79
|
+
manifestations.stub(:last_page?){true}
|
80
|
+
manifestations.stub(:total_count){manifestations.size}
|
81
|
+
assign(:manifestations, manifestations)
|
82
|
+
render
|
83
|
+
expect(rendered).to include "<dcterms:extent>123p ; 23cm</dcterms:extent>"
|
84
|
+
end
|
85
|
+
end
|
57
86
|
end
|