supplejack_api 1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/Rakefile +42 -0
- data/app/assets/javascripts/supplejack_api/application.js +26 -0
- data/app/assets/stylesheets/supplejack_api/application.css +30 -0
- data/app/controllers/supplejack_api/admin/base_controller.rb +24 -0
- data/app/controllers/supplejack_api/admin/sessions_controller.rb +25 -0
- data/app/controllers/supplejack_api/admin/site_activities_controller.rb +21 -0
- data/app/controllers/supplejack_api/admin/users_controller.rb +55 -0
- data/app/controllers/supplejack_api/application_controller.rb +70 -0
- data/app/controllers/supplejack_api/concepts_controller.rb +52 -0
- data/app/controllers/supplejack_api/concerns/ignore_metrics.rb +14 -0
- data/app/controllers/supplejack_api/concerns/records_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/concerns/set_items_controller_metrics.rb +20 -0
- data/app/controllers/supplejack_api/concerns/user_sets_controller_metrics.rb +26 -0
- data/app/controllers/supplejack_api/harvester/concepts_controller.rb +41 -0
- data/app/controllers/supplejack_api/harvester/fragments_controller.rb +30 -0
- data/app/controllers/supplejack_api/harvester/records_controller.rb +68 -0
- data/app/controllers/supplejack_api/metrics_api_controller.rb +44 -0
- data/app/controllers/supplejack_api/partners_controller.rb +39 -0
- data/app/controllers/supplejack_api/records_controller.rb +71 -0
- data/app/controllers/supplejack_api/schema_controller.rb +19 -0
- data/app/controllers/supplejack_api/set_items_controller.rb +38 -0
- data/app/controllers/supplejack_api/sources_controller.rb +67 -0
- data/app/controllers/supplejack_api/status_controller.rb +67 -0
- data/app/controllers/supplejack_api/user_sets_controller.rb +97 -0
- data/app/controllers/supplejack_api/users_controller.rb +49 -0
- data/app/helpers/supplejack_api/application_helper.rb +39 -0
- data/app/helpers/supplejack_api/facets_helper.rb +30 -0
- data/app/mailers/supplejack_api/request_limit_mailer.rb +43 -0
- data/app/models/supplejack_api/api_concept/concept_fragment.rb +31 -0
- data/app/models/supplejack_api/api_record/record_fragment.rb +15 -0
- data/app/models/supplejack_api/concept.rb +46 -0
- data/app/models/supplejack_api/concept_search.rb +86 -0
- data/app/models/supplejack_api/concerns/queryable_by_date.rb +31 -0
- data/app/models/supplejack_api/concerns/record.rb +108 -0
- data/app/models/supplejack_api/concerns/record_fragmentable.rb +24 -0
- data/app/models/supplejack_api/concerns/searchable.rb +430 -0
- data/app/models/supplejack_api/concerns/user_set.rb +219 -0
- data/app/models/supplejack_api/daily_metrics.rb +20 -0
- data/app/models/supplejack_api/faceted_metrics.rb +55 -0
- data/app/models/supplejack_api/fragment.rb +82 -0
- data/app/models/supplejack_api/interaction_models/record.rb +60 -0
- data/app/models/supplejack_api/interaction_models/set.rb +13 -0
- data/app/models/supplejack_api/interaction_updaters/all_usage_metric.rb +41 -0
- data/app/models/supplejack_api/interaction_updaters/set_metrics.rb +32 -0
- data/app/models/supplejack_api/interaction_updaters/usage_metrics.rb +73 -0
- data/app/models/supplejack_api/partner.rb +24 -0
- data/app/models/supplejack_api/preview_record.rb +30 -0
- data/app/models/supplejack_api/record.rb +18 -0
- data/app/models/supplejack_api/record_search.rb +12 -0
- data/app/models/supplejack_api/schema_definition.rb +147 -0
- data/app/models/supplejack_api/search.rb +14 -0
- data/app/models/supplejack_api/set_item.rb +57 -0
- data/app/models/supplejack_api/site_activity.rb +59 -0
- data/app/models/supplejack_api/source.rb +28 -0
- data/app/models/supplejack_api/source_activity.rb +36 -0
- data/app/models/supplejack_api/source_authority.rb +42 -0
- data/app/models/supplejack_api/supplejack_schema.rb +37 -0
- data/app/models/supplejack_api/support/concept/searchable.rb +79 -0
- data/app/models/supplejack_api/support/concept/storable.rb +59 -0
- data/app/models/supplejack_api/support/fragment_helpers.rb +96 -0
- data/app/models/supplejack_api/support/harvestable.rb +105 -0
- data/app/models/supplejack_api/support/searchable.rb +115 -0
- data/app/models/supplejack_api/support/status_logger.rb +23 -0
- data/app/models/supplejack_api/support/storable.rb +49 -0
- data/app/models/supplejack_api/support/validation_logger.rb +23 -0
- data/app/models/supplejack_api/usage_metrics.rb +25 -0
- data/app/models/supplejack_api/user.rb +211 -0
- data/app/models/supplejack_api/user_activity.rb +65 -0
- data/app/models/supplejack_api/user_set.rb +17 -0
- data/app/serializers/supplejack_api/application_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_record_serializer.rb +23 -0
- data/app/serializers/supplejack_api/concept_search_serializer.rb +12 -0
- data/app/serializers/supplejack_api/concept_serializer.rb +100 -0
- data/app/serializers/supplejack_api/concerns/record_serializable.rb +119 -0
- data/app/serializers/supplejack_api/concerns/search_serializable.rb +24 -0
- data/app/serializers/supplejack_api/record_search_serializer.rb +64 -0
- data/app/serializers/supplejack_api/record_serializer.rb +13 -0
- data/app/serializers/supplejack_api/search_serializer.rb +13 -0
- data/app/serializers/supplejack_api/source_authority_serializer.rb +23 -0
- data/app/serializers/supplejack_api/user_serializer.rb +13 -0
- data/app/serializers/supplejack_api/user_set_record_serializer.rb +14 -0
- data/app/serializers/supplejack_api/user_set_serializer.rb +77 -0
- data/app/services/metrics_api/v3/api.rb +30 -0
- data/app/services/metrics_api/v3/endpoints/facets.rb +23 -0
- data/app/services/metrics_api/v3/endpoints/global.rb +26 -0
- data/app/services/metrics_api/v3/endpoints/helpers.rb +14 -0
- data/app/services/metrics_api/v3/endpoints/root.rb +97 -0
- data/app/services/metrics_api/v3/presenters/daily_metric.rb +23 -0
- data/app/services/metrics_api/v3/presenters/extended_metadata.rb +41 -0
- data/app/services/metrics_api/v3/presenters/record.rb +26 -0
- data/app/services/metrics_api/v3/presenters/view.rb +28 -0
- data/app/views/layouts/supplejack_api/_head.html.erb +17 -0
- data/app/views/layouts/supplejack_api/_top_nav.html.erb +33 -0
- data/app/views/layouts/supplejack_api/application.html.erb +33 -0
- data/app/views/supplejack_api/admin/sessions/new.html.erb +25 -0
- data/app/views/supplejack_api/admin/shared/_links.erb +34 -0
- data/app/views/supplejack_api/admin/site_activities/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/site_activities/index.html.erb +54 -0
- data/app/views/supplejack_api/admin/users/edit.html.erb +16 -0
- data/app/views/supplejack_api/admin/users/index.csv.erb +22 -0
- data/app/views/supplejack_api/admin/users/index.html.erb +57 -0
- data/app/views/supplejack_api/admin/users/show.html.erb +33 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at100percent_admin.text.erb +1 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent.text.erb +13 -0
- data/app/views/supplejack_api/request_limit_mailer/at90percent_admin.text.erb +1 -0
- data/app/workers/supplejack_api/daily_metrics_worker.rb +112 -0
- data/app/workers/supplejack_api/interaction_metrics_worker.rb +45 -0
- data/config/cucumber.yml +16 -0
- data/config/initializers/force_eagerload.rb +11 -0
- data/config/initializers/interaction_updaters.rb +7 -0
- data/config/routes.rb +81 -0
- data/db/binding_records.development.json +7 -0
- data/db/binding_records.staging.json +7 -0
- data/db/concepts.json +33 -0
- data/db/concepts_data.json +569745 -0
- data/db/source_authorities.json +119 -0
- data/lib/generators/supplejack_api/install_generator.rb +124 -0
- data/lib/mongoid/paperclip.rb +53 -0
- data/lib/mongoid/string.rb +20 -0
- data/lib/sunspot/mongoid.rb +51 -0
- data/lib/sunspot/resque_session_proxy.rb +72 -0
- data/lib/sunspot/sunspot_spellcheck.rb +98 -0
- data/lib/supplejack_api.rb +13 -0
- data/lib/supplejack_api/admin/sortable.rb +40 -0
- data/lib/supplejack_api/engine.rb +46 -0
- data/lib/supplejack_api/harvester_constraint.rb +28 -0
- data/lib/supplejack_api/stylesheets.rb +36 -0
- data/lib/supplejack_api/utils.rb +75 -0
- data/lib/supplejack_api/version.rb +11 -0
- data/lib/tasks/resque.rake +22 -0
- data/lib/url_validator.rb +38 -0
- data/spec/controllers/supplejack_api/admin/base_controller_spec.rb +55 -0
- data/spec/controllers/supplejack_api/admin/site_activities_controller_spec.rb +43 -0
- data/spec/controllers/supplejack_api/admin/users_controller_spec.rb +79 -0
- data/spec/controllers/supplejack_api/application_controller_spec.rb +133 -0
- data/spec/controllers/supplejack_api/concepts_controller_spec.rb +83 -0
- data/spec/controllers/supplejack_api/concerns/records_controller_metrics_spec.rb +60 -0
- data/spec/controllers/supplejack_api/harvester/concepts_controller_spec.rb +57 -0
- data/spec/controllers/supplejack_api/harvester/records_controller_spec.rb +138 -0
- data/spec/controllers/supplejack_api/metrics_api_controller_spec.rb +71 -0
- data/spec/controllers/supplejack_api/partners_controller_spec.rb +77 -0
- data/spec/controllers/supplejack_api/records_controller_spec.rb +143 -0
- data/spec/controllers/supplejack_api/set_items_controller_spec.rb +78 -0
- data/spec/controllers/supplejack_api/sources_controller_spec.rb +161 -0
- data/spec/controllers/supplejack_api/status_controller_spec.rb +120 -0
- data/spec/controllers/supplejack_api/user_sets_controller_spec.rb +233 -0
- data/spec/controllers/supplejack_api/users_controller_spec.rb +61 -0
- data/spec/dummy/README.rdoc +268 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +23 -0
- data/spec/dummy/app/assets/stylesheets/application.css +22 -0
- data/spec/dummy/app/controllers/application_controller.rb +10 -0
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/dummy/app/supplejack_api/concept_schema.rb +83 -0
- data/spec/dummy/app/supplejack_api/record_schema.rb +64 -0
- data/spec/dummy/app/supplejack_api/record_schema.txt +66 -0
- data/spec/dummy/app/views/layouts/application.html.erb +23 -0
- data/spec/dummy/app/workers/supplejack_api/clear_index_buffer.rb +32 -0
- data/spec/dummy/app/workers/supplejack_api/flush_old_records_worker.rb +17 -0
- data/spec/dummy/app/workers/supplejack_api/index_buffer.rb +49 -0
- data/spec/dummy/app/workers/supplejack_api/index_source_worker.rb +39 -0
- data/spec/dummy/app/workers/supplejack_api/index_worker.rb +82 -0
- data/spec/dummy/app/workers/supplejack_api/store_user_activity_worker.rb +24 -0
- data/spec/dummy/config.ru +11 -0
- data/spec/dummy/config/application.rb +76 -0
- data/spec/dummy/config/application.yml +31 -0
- data/spec/dummy/config/application.yml.example +36 -0
- data/spec/dummy/config/boot.rb +17 -0
- data/spec/dummy/config/environment.rb +12 -0
- data/spec/dummy/config/environments/development.rb +42 -0
- data/spec/dummy/config/environments/production.rb +76 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +14 -0
- data/spec/dummy/config/initializers/devise.rb +214 -0
- data/spec/dummy/config/initializers/inflections.rb +22 -0
- data/spec/dummy/config/initializers/kaminari_config.rb +17 -0
- data/spec/dummy/config/initializers/mime_types.rb +12 -0
- data/spec/dummy/config/initializers/mongoid.rb +9 -0
- data/spec/dummy/config/initializers/quiet_logger.rb +23 -0
- data/spec/dummy/config/initializers/resque.rb +18 -0
- data/spec/dummy/config/initializers/secret_token.rb +14 -0
- data/spec/dummy/config/initializers/session_store.rb +15 -0
- data/spec/dummy/config/initializers/simple_form.rb +149 -0
- data/spec/dummy/config/initializers/simple_form_foundation.rb +33 -0
- data/spec/dummy/config/initializers/state_machine.rb +8 -0
- data/spec/dummy/config/initializers/sunspot.rb +32 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +17 -0
- data/spec/dummy/config/locales/devise.en.yml +63 -0
- data/spec/dummy/config/locales/en.yml +66 -0
- data/spec/dummy/config/locales/simple_form.en.yml +33 -0
- data/spec/dummy/config/mongoid.travis.yml +34 -0
- data/spec/dummy/config/mongoid.yml +36 -0
- data/spec/dummy/config/resque-pool.yml +18 -0
- data/spec/dummy/config/resque_schedule.yml +12 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/config/secrets.yml +8 -0
- data/spec/dummy/config/sunspot.yml +38 -0
- data/spec/dummy/db/concepts.json +37 -0
- data/spec/dummy/db/source_authorities.json +116 -0
- data/spec/dummy/public/404.html +35 -0
- data/spec/dummy/public/422.html +35 -0
- data/spec/dummy/public/500.html +34 -0
- data/spec/dummy/public/favicon.ico +8 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/collection1/conf/elevate.xml +36 -0
- data/spec/dummy/solr/collection1/conf/mapping-FoldToASCII.txt +3813 -0
- data/spec/dummy/solr/collection1/conf/schema.xml +292 -0
- data/spec/dummy/solr/collection1/conf/solrconfig.xml +1780 -0
- data/spec/dummy/solr/collection1/conf/spellings.txt +2 -0
- data/spec/dummy/solr/collection1/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/collection1/conf/synonyms.txt +31 -0
- data/spec/factories/concepts.rb +16 -0
- data/spec/factories/daily_metrics.rb +10 -0
- data/spec/factories/faceted_metrics.rb +25 -0
- data/spec/factories/fragment.rb +14 -0
- data/spec/factories/partners.rb +14 -0
- data/spec/factories/record_interaction.rb +17 -0
- data/spec/factories/records.rb +47 -0
- data/spec/factories/set_interaction.rb +15 -0
- data/spec/factories/source_authorities.rb +19 -0
- data/spec/factories/sources.rb +16 -0
- data/spec/factories/usage_metrics.rb +20 -0
- data/spec/factories/user_activities.rb +14 -0
- data/spec/factories/user_sets.rb +27 -0
- data/spec/factories/users.rb +23 -0
- data/spec/helpers/application_helper_spec.rb +35 -0
- data/spec/models/concept_spec.rb +163 -0
- data/spec/models/fragment_spec.rb +15 -0
- data/spec/models/site_activity_spec.rb +103 -0
- data/spec/models/source_activity_spec.rb +56 -0
- data/spec/models/source_authority_spec.rb +42 -0
- data/spec/models/supplejack_api/api_concept/concept_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/api_record/record_fragment_spec.rb +189 -0
- data/spec/models/supplejack_api/concept_spec.rb +0 -0
- data/spec/models/supplejack_api/interaction_updaters/all_usage_metric_spec.rb +41 -0
- data/spec/models/supplejack_api/interaction_updaters/set_metrics_spec.rb +32 -0
- data/spec/models/supplejack_api/interaction_updaters/usage_metrics_spec.rb +44 -0
- data/spec/models/supplejack_api/partner_spec.rb +20 -0
- data/spec/models/supplejack_api/record_search_spec.rb +429 -0
- data/spec/models/supplejack_api/record_spec.rb +280 -0
- data/spec/models/supplejack_api/schema_definition_spec.rb +272 -0
- data/spec/models/supplejack_api/search_spec.rb +243 -0
- data/spec/models/supplejack_api/set_item_spec.rb +123 -0
- data/spec/models/supplejack_api/source_spec.rb +22 -0
- data/spec/models/supplejack_api/support/fragment_helpers_spec.rb +216 -0
- data/spec/models/supplejack_api/support/harvestable_spec.rb +177 -0
- data/spec/models/supplejack_api/support/searchable_spec.rb +85 -0
- data/spec/models/supplejack_api/support/storable_spec.rb +18 -0
- data/spec/models/supplejack_api/user_activity_spec.rb +88 -0
- data/spec/models/supplejack_api/user_set_spec.rb +559 -0
- data/spec/models/supplejack_api/user_spec.rb +348 -0
- data/spec/routing/concepts_routing_spec.rb +22 -0
- data/spec/routing/harvester_constraint_spec.rb +66 -0
- data/spec/routing/harvester_routing_spec.rb +51 -0
- data/spec/routing/partner_routing_spec.rb +34 -0
- data/spec/routing/records_routing_spec.rb +26 -0
- data/spec/routing/sets_routing_spec.rb +44 -0
- data/spec/routing/source_routing_spec.rb +38 -0
- data/spec/routing/users_routing_spec.rb +18 -0
- data/spec/serializers/concept_record_serializer_spec.rb +30 -0
- data/spec/serializers/supplejack_api/application_serializer_spec.rb +14 -0
- data/spec/serializers/supplejack_api/concept_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/concept_serializer_spec.rb +92 -0
- data/spec/serializers/supplejack_api/record_search_serializer_spec.rb +34 -0
- data/spec/serializers/supplejack_api/record_serializer_spec.rb +271 -0
- data/spec/serializers/supplejack_api/search_serializer_spec.rb +90 -0
- data/spec/serializers/supplejack_api/user_serializer_spec.rb +22 -0
- data/spec/serializers/supplejack_api/user_set_serializer_spec.rb +96 -0
- data/spec/services/metrics_api/v3/api_spec.rb +23 -0
- data/spec/services/metrics_api/v3/endpoints/facets_spec.rb +25 -0
- data/spec/services/metrics_api/v3/endpoints/global_spec.rb +22 -0
- data/spec/services/metrics_api/v3/endpoints/root_spec.rb +49 -0
- data/spec/services/metrics_api/v3/presenters/extended_metadata_spec.rb +49 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/support/api/schemas/metrics/daily_metrics_metadata.json +24 -0
- data/spec/support/api/schemas/metrics/extended_metrics.json +26 -0
- data/spec/support/api/schemas/metrics/extended_response.json +6 -0
- data/spec/support/api/schemas/metrics/facets_response.json +6 -0
- data/spec/support/api/schemas/metrics/record_metadata.json +33 -0
- data/spec/support/api/schemas/metrics/top_level_response.json +6 -0
- data/spec/support/api/schemas/metrics/view_metadata.json +33 -0
- data/spec/support/api_schema_matcher.rb +14 -0
- data/spec/support/devise.rb +10 -0
- data/spec/workers/supplejack_api/daily_metrics_worker_spec.rb +140 -0
- data/spec/workers/supplejack_api/flush_old_records_worker_spec.rb +20 -0
- data/spec/workers/supplejack_api/index_worker_spec.rb +52 -0
- data/spec/workers/supplejack_api/source_index_worker_spec.rb +61 -0
- metadata +1231 -0
@@ -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,16 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https//github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http//digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :concept, class: SupplejackApi::Concept do
|
11
|
+
concept_id 1
|
12
|
+
concept_type 'edm:Agent'
|
13
|
+
name 'Colin McCahon'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'faker'
|
2
|
+
|
3
|
+
module SupplejackApi
|
4
|
+
FactoryGirl.define do
|
5
|
+
factory :faceted_metrics, class: SupplejackApi::FacetedMetrics do
|
6
|
+
date {Date.current}
|
7
|
+
total_active_records 10
|
8
|
+
total_new_records 1
|
9
|
+
sequence(:name) {|n| "Display collection #{n}"}
|
10
|
+
category_counts do
|
11
|
+
{
|
12
|
+
'category-1' => 1,
|
13
|
+
'category-2' => 2
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
copyright_counts do
|
18
|
+
{
|
19
|
+
'copyright-1' => 1,
|
20
|
+
'copyright-2' => 2
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module SupplejackApi
|
2
|
+
FactoryGirl.define do
|
3
|
+
|
4
|
+
factory :fragment, class: SupplejackApi::ApiRecord::RecordFragment do
|
5
|
+
source_id 'source_name'
|
6
|
+
priority 0
|
7
|
+
title 'A record'
|
8
|
+
creator ['John Kennedy']
|
9
|
+
dnz_type 'Unknown'
|
10
|
+
primary_collection ['TAPUHI']
|
11
|
+
thumbnail {FactoryGirl.build(:thumbnail)}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :partner, class: SupplejackApi::Partner do
|
11
|
+
name 'Statistics New Zealand'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https//github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http//digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
module InteractionModels
|
10
|
+
FactoryGirl.define do
|
11
|
+
factory :record_interaction, class: SupplejackApi::InteractionModels::Record do
|
12
|
+
request_type 'search'
|
13
|
+
log_values ['Voyager 1', 'Sputnik', 'Explorer']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :record, class: SupplejackApi::Record do
|
11
|
+
transient do
|
12
|
+
display_collection 'test'
|
13
|
+
copyright ['0']
|
14
|
+
category ['0']
|
15
|
+
end
|
16
|
+
|
17
|
+
internal_identifier 'nlnz:1234'
|
18
|
+
record_id 54_321
|
19
|
+
status 'active'
|
20
|
+
source_url 'http://google.com/landing.html'
|
21
|
+
record_type 0
|
22
|
+
|
23
|
+
factory :record_with_fragment do
|
24
|
+
fragments do
|
25
|
+
[FactoryGirl.build(:record_fragment,
|
26
|
+
display_collection: display_collection,
|
27
|
+
copyright: copyright,
|
28
|
+
category: category)]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
factory :record_fragment, class: SupplejackApi::ApiRecord::RecordFragment do
|
34
|
+
source_id 'source_name'
|
35
|
+
priority 0
|
36
|
+
name 'John Doe'
|
37
|
+
address 'Wellington'
|
38
|
+
email ['johndoe@example.com']
|
39
|
+
children ['Sally Doe', 'James Doe']
|
40
|
+
contact nil
|
41
|
+
age 30
|
42
|
+
birth_date DateTime.now
|
43
|
+
nz_citizen true
|
44
|
+
display_collection 'test'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :set_interaction, class: SupplejackApi::InteractionModels::Set do
|
11
|
+
facet 'test'
|
12
|
+
interaction_type :creation
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :source_authority, class: SupplejackApi::SourceAuthority do
|
11
|
+
internal_identifier 'tepapa:1502'
|
12
|
+
concept_id 1
|
13
|
+
concept_score 50
|
14
|
+
source_id 'tepapa'
|
15
|
+
source_name 'Te Papa - Museum of New Zealand'
|
16
|
+
url 'http://collections.tepapa.govt.nz/Person/1502'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :source, class: SupplejackApi::Source do
|
11
|
+
name 'Sample source'
|
12
|
+
source_id '1234'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https//github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http//digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :usage_metrics, class: SupplejackApi::UsageMetrics do
|
11
|
+
record_field_value "Voyager 1"
|
12
|
+
searches 1
|
13
|
+
gets 1
|
14
|
+
user_set_views 1
|
15
|
+
total_views 1
|
16
|
+
records_added_to_user_sets 1
|
17
|
+
date Date.current
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :user_activity, class: SupplejackApi::UserActivity do
|
11
|
+
total 10
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :user_set, class: SupplejackApi::UserSet do
|
11
|
+
name "Dogs and cats"
|
12
|
+
description "Ugly dogs and cats"
|
13
|
+
user
|
14
|
+
factory :user_set_with_set_item do
|
15
|
+
after(:create) do |user_set|
|
16
|
+
user_set.set_items.build(attributes_for(:set_item))
|
17
|
+
user_set.save
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
factory :set_item, class: SupplejackApi::SetItem do
|
23
|
+
record_id 12345
|
24
|
+
position 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
module SupplejackApi
|
9
|
+
FactoryGirl.define do
|
10
|
+
factory :user, class: SupplejackApi::User do
|
11
|
+
authentication_token '12345'
|
12
|
+
daily_requests 0
|
13
|
+
max_requests 1000
|
14
|
+
role 'developer'
|
15
|
+
|
16
|
+
factory :admin_user do
|
17
|
+
role 'admin'
|
18
|
+
email 'admin@example.com'
|
19
|
+
password 'p@ssw0rd'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module SupplejackApi
|
4
|
+
describe ApplicationHelper do
|
5
|
+
|
6
|
+
def label(string)
|
7
|
+
safe_join([string, content_tag(:span)])
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#extract_sort_info' do
|
11
|
+
it 'returns the column and direction from the order param' do
|
12
|
+
allow(helper).to receive(:params) { {order: 'name_asc'} }
|
13
|
+
expect(helper.extract_sort_info).to eq ['name', 'asc']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#sortable' do
|
18
|
+
pending
|
19
|
+
# it 'returns a link to sort by name' do
|
20
|
+
# expect(helper.sortable('user', 'name')).to eq(link_to(label('Name'), admin_users_path(order: 'name_asc')))
|
21
|
+
# end
|
22
|
+
|
23
|
+
# context 'already ordered by name' do
|
24
|
+
# before { helper.stub(:params) { {order: 'name_asc'} }}
|
25
|
+
# it 'sorts by name in descending order' do
|
26
|
+
# expect(helper.sortable('user', 'name')).to eq(link_to(label('Name'), admin_users_path(order: 'name_desc'), class: 'current asc'))
|
27
|
+
# end
|
28
|
+
|
29
|
+
# it 'sorts by email in ascending order' do
|
30
|
+
# expect(elper.sortable('user', 'email')).to eq(link_to(label('Email'), admin_users_path(order: 'email_asc')))
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# The majority of the Supplejack API code is Crown copyright (C) 2014, New Zealand Government,
|
2
|
+
# and is licensed under the GNU General Public License, version 3.
|
3
|
+
# One component is a third party component. See https://github.com/DigitalNZ/supplejack_api for details.
|
4
|
+
#
|
5
|
+
# Supplejack was created by DigitalNZ at the National Library of NZ and
|
6
|
+
# the Department of Internal Affairs. http://digitalnz.org/supplejack
|
7
|
+
|
8
|
+
require 'spec_helper'
|
9
|
+
|
10
|
+
module SupplejackApi
|
11
|
+
describe Concept do
|
12
|
+
let(:concept) { create(:concept) }
|
13
|
+
let(:record) { create(:record) }
|
14
|
+
|
15
|
+
subject { concept }
|
16
|
+
|
17
|
+
it { should be_stored_in :concepts }
|
18
|
+
it { should be_timestamped_document }
|
19
|
+
it { should be_timestamped_document.with(:created) }
|
20
|
+
it { should be_timestamped_document.with(:updated) }
|
21
|
+
|
22
|
+
it { should have_many(:source_authorities) }
|
23
|
+
|
24
|
+
describe 'fields' do
|
25
|
+
context '.model fields' do
|
26
|
+
%w(concept_type concept_id).each do |field|
|
27
|
+
it "responds to #{field} field" do
|
28
|
+
expect(concept.respond_to?(field)).to be_truthy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context '.schema fields' do
|
34
|
+
ConceptSchema.model_fields.each do |name, field|
|
35
|
+
it "sets the #{name} field from the schema" do
|
36
|
+
expect(concept.respond_to?(name)).to be_truthy unless field.try(:store) == false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#custom_find' do
|
43
|
+
before(:each) do
|
44
|
+
@concept = FactoryGirl.create(:concept, concept_id: 54321)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should search for a concept via its concept_id' do
|
48
|
+
expect(Concept.custom_find(54321)).to eq(@concept)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should search for a concept via its ObjectId (MongoDB auto assigned id)' do
|
52
|
+
expect(Concept.custom_find(@concept.id)).to eq(@concept)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should raise a error when a concept is not found' do
|
56
|
+
expect { Concept.custom_find(111) }.to raise_error(Mongoid::Errors::DocumentNotFound)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#build_context' do
|
61
|
+
let(:fields) { [:name, :prefLabel, :dateOfBirth] }
|
62
|
+
|
63
|
+
it 'builds inline context' do
|
64
|
+
context = {
|
65
|
+
:skos => "http://www.w3.org/2004/02/skos/core#",
|
66
|
+
:foaf => "http://xmlns.com/foaf/0.1/",
|
67
|
+
:rdaGr2 => "http://rdvocab.info/ElementsGr2/",
|
68
|
+
:dcterms => "http://purl.org/dc/terms/",
|
69
|
+
:concept_id => {
|
70
|
+
"@id" => "dcterms:identifier"
|
71
|
+
},
|
72
|
+
:name => {
|
73
|
+
"@id" => "foaf:name"
|
74
|
+
},
|
75
|
+
:prefLabel => {
|
76
|
+
"@id" => "skos:prefLabel"
|
77
|
+
},
|
78
|
+
:dateOfBirth => {
|
79
|
+
"@id" => "rdaGr2:dateOfBirth"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
expect(Concept.build_context(fields)).to eq context
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#records' do
|
87
|
+
it 'returns the records' do
|
88
|
+
record.concepts << concept
|
89
|
+
expect(concept.records).to eq [record]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#edm_type' do
|
94
|
+
it 'returns the type of the concept' do
|
95
|
+
expect(concept.edm_type).to eq 'agents'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#site_id' do
|
100
|
+
it 'returns the site_id of the concept' do
|
101
|
+
expect(concept.site_id).to eq "#{ENV['CONCEPT_HTTP_HOST']}/concepts/1"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#context' do
|
106
|
+
it 'returns the context of the concept' do
|
107
|
+
expect(concept.context).to eq "#{ENV['HTTP_HOST']}/schema"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# it "shouldn't call find when the mongo id is invalid" do
|
112
|
+
# expect(Concept).to_not receive(:find)
|
113
|
+
# expect { Concept.custom_find('1234567abc') }.to raise_error(Mongoid::Errors::DocumentNotFound)
|
114
|
+
# end
|
115
|
+
|
116
|
+
# context 'restricting inactive concepts' do
|
117
|
+
# it 'finds only active concepts' do
|
118
|
+
# @concept.update_attribute(:status, 'deleted')
|
119
|
+
# @concept.reload
|
120
|
+
# expect { Concept.custom_find(54321) }.to raise_error(Mongoid::Errors::DocumentNotFound)
|
121
|
+
# end
|
122
|
+
|
123
|
+
# it 'finds also inactive records when :status => :all' do
|
124
|
+
# @concept.update_attribute(:status, 'deleted')
|
125
|
+
# @concept.reload
|
126
|
+
# expect(Concept.custom_find(54321, nil, {status: :all})).to eq @concept
|
127
|
+
# end
|
128
|
+
|
129
|
+
# it "doesn't break with nil options" do
|
130
|
+
# expect(Concept.custom_find(54321, nil, nil)).to eq @concept
|
131
|
+
# end
|
132
|
+
# end
|
133
|
+
# end
|
134
|
+
|
135
|
+
# describe '#active?' do
|
136
|
+
# before { @record = build(:record) }
|
137
|
+
|
138
|
+
# it 'returns true when state is active' do
|
139
|
+
# @record.status = 'active'
|
140
|
+
# expect(@record.active?).to be_truthy
|
141
|
+
# end
|
142
|
+
|
143
|
+
# it 'returns false when state is deleted' do
|
144
|
+
# @record.status = 'deleted'
|
145
|
+
# expect(@record.active?).to be_falsey
|
146
|
+
# end
|
147
|
+
# end
|
148
|
+
|
149
|
+
# describe '#should_index?' do
|
150
|
+
# before { @record = build(:record) }
|
151
|
+
|
152
|
+
# it 'returns false when active? is false' do
|
153
|
+
# allow(@record).to receive(:active?) { false }
|
154
|
+
# expect(@record.should_index?).to be_falsey
|
155
|
+
# end
|
156
|
+
|
157
|
+
# it 'returns true when active? is true' do
|
158
|
+
# allow(@record).to receive(:active?) { true }
|
159
|
+
# expect(@record.should_index?).to be_truthy
|
160
|
+
# end
|
161
|
+
# end
|
162
|
+
end
|
163
|
+
end
|