qa 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -23
  3. data/Rakefile +9 -6
  4. data/lib/generators/qa/install/USAGE +5 -0
  5. data/lib/generators/qa/install/install_generator.rb +13 -0
  6. data/lib/generators/qa/install/templates/config/oclcts-authorities.yml +24 -0
  7. data/lib/qa/authorities/loc.rb +35 -18
  8. data/lib/qa/version.rb +1 -1
  9. data/spec/controllers/terms_controller_spec.rb +10 -10
  10. data/spec/fixtures/loc-response.txt +85 -2
  11. data/spec/internal/Gemfile +4 -6
  12. data/spec/internal/Gemfile.lock +42 -65
  13. data/spec/internal/config/application.rb +1 -1
  14. data/spec/internal/config/boot.rb +1 -1
  15. data/spec/internal/config/initializers/secret_token.rb +1 -1
  16. data/spec/internal/config/oclcts-authorities.yml +24 -0
  17. data/spec/internal/config/routes.rb +2 -0
  18. data/spec/internal/db/development.sqlite3 +0 -0
  19. data/spec/internal/db/migrate/20140611161143_create_qa_subject_mesh_terms.qa.rb +12 -0
  20. data/spec/internal/db/migrate/20140611161144_create_qa_mesh_tree.qa.rb +11 -0
  21. data/spec/internal/db/migrate/20140611161145_add_term_lower_to_qa_subject_mesh_terms.qa.rb +8 -0
  22. data/spec/internal/db/schema.rb +34 -0
  23. data/spec/internal/db/test.sqlite3 +0 -0
  24. data/spec/internal/lib/generators/test_app_generator.rb +13 -11
  25. data/spec/internal/log/development.log +212 -0
  26. data/spec/internal/public/robots.txt +1 -1
  27. data/spec/lib/authorities_loc_spec.rb +21 -0
  28. data/spec/spec_helper.rb +5 -1
  29. data/spec/test_app_templates/lib/generators/test_app_generator.rb +22 -0
  30. metadata +57 -24
  31. data/spec/support/lib/generators/test_app_generator.rb +0 -20
@@ -4,7 +4,7 @@ require 'rails/all'
4
4
 
5
5
  # Require the gems listed in Gemfile, including any gems
6
6
  # you've limited to :test, :development, or :production.
7
- Bundler.require(:default, Rails.env)
7
+ Bundler.require(*Rails.groups)
8
8
 
9
9
  module Internal
10
10
  class Application < Rails::Application
@@ -1,4 +1,4 @@
1
1
  # Set up gems listed in the Gemfile.
2
2
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
3
 
4
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -9,4 +9,4 @@
9
9
 
10
10
  # Make sure your secret_key_base is kept private
11
11
  # if you're sharing your code publicly.
12
- Internal::Application.config.secret_key_base = '66c858b75897c8982958abbc82b7b9446578fb1d4dcb090a59e4a1ecfb22fb175acbc4730ad88eeccbb9ef523d558f0a8b5041a5851ca5f5b25c8b6cd0662927'
12
+ Internal::Application.config.secret_key_base = 'ac3130ff074153869235aade642f0cab7fb3aa43cae4e302b75cb577542e2b5f74f6e5ff105065d1a1f3692ec8307ac0242f11e60c91b8749fe2262ed7460fae'
@@ -0,0 +1,24 @@
1
+ url-pattern:
2
+ prefix-query: http://tspilot.oclc.org/{authority-id}/?query=oclcts.rootHeading+exact+%22{query}*%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys=
3
+ id-lookup: http://tspilot.oclc.org/{authority-id}/?query=dc.identifier+exact+%22{id}%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys=
4
+ authorities:
5
+ lcgft:
6
+ name: Library of Congress Genre/Form Terms for Library and Archival Materials (LCGFT)
7
+ bisacsh:
8
+ name: Book Industry Study Group Subject Headings (BISAC®). Used with permission.
9
+ fast:
10
+ name: Faceted Application of Subject Terminology (FAST subject headings)
11
+ gsafd:
12
+ name: Form and genre headings for fiction and drama
13
+ lcshac:
14
+ name: Library of Congress AC Subject Headings
15
+ lcsh:
16
+ name: Library of Congress Subject Headings
17
+ mesh:
18
+ name: Medical Subject Headings (MeSH®)
19
+ lctgm:
20
+ name: "Thesaurus for graphic materials: TGM I, Subject terms"
21
+ gmgpc:
22
+ name: "Thesaurus for graphic materials: TGM II, Genre terms"
23
+ meta:
24
+ name: Controlled Vocabulary Metadata
@@ -1,4 +1,6 @@
1
1
  Internal::Application.routes.draw do
2
+ mount Qa::Engine => '/qa'
3
+
2
4
  # The priority is based upon order of creation: first created -> highest priority.
3
5
  # See how all your routes lay out with "rake routes".
4
6
 
@@ -0,0 +1,12 @@
1
+ # This migration comes from qa (originally 20130917200611)
2
+ class CreateQaSubjectMeshTerms < ActiveRecord::Migration
3
+ def change
4
+ create_table :qa_subject_mesh_terms do |t|
5
+ t.string :term_id
6
+ t.string :term
7
+ t.text :synonyms
8
+ end
9
+ add_index :qa_subject_mesh_terms, :term_id
10
+ add_index :qa_subject_mesh_terms, :term
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # This migration comes from qa (originally 20130917201026)
2
+ class CreateQaMeshTree < ActiveRecord::Migration
3
+ def change
4
+ create_table :qa_mesh_trees do |t|
5
+ t.string :term_id
6
+ t.string :tree_number
7
+ end
8
+ add_index :qa_mesh_trees, :term_id
9
+ add_index :qa_mesh_trees, :tree_number
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # This migration comes from qa (originally 20130918141523)
2
+ class AddTermLowerToQaSubjectMeshTerms < ActiveRecord::Migration
3
+ def change
4
+ add_column :qa_subject_mesh_terms, :term_lower, :string
5
+ add_index :qa_subject_mesh_terms, :term_lower
6
+ remove_index :qa_subject_mesh_terms, :term
7
+ end
8
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20140611161145) do
15
+
16
+ create_table "qa_mesh_trees", force: true do |t|
17
+ t.string "term_id"
18
+ t.string "tree_number"
19
+ end
20
+
21
+ add_index "qa_mesh_trees", ["term_id"], name: "index_qa_mesh_trees_on_term_id"
22
+ add_index "qa_mesh_trees", ["tree_number"], name: "index_qa_mesh_trees_on_tree_number"
23
+
24
+ create_table "qa_subject_mesh_terms", force: true do |t|
25
+ t.string "term_id"
26
+ t.string "term"
27
+ t.text "synonyms"
28
+ t.string "term_lower"
29
+ end
30
+
31
+ add_index "qa_subject_mesh_terms", ["term_id"], name: "index_qa_subject_mesh_terms_on_term_id"
32
+ add_index "qa_subject_mesh_terms", ["term_lower"], name: "index_qa_subject_mesh_terms_on_term_lower"
33
+
34
+ end
Binary file
@@ -1,20 +1,22 @@
1
1
  require 'rails/generators'
2
2
 
3
3
  class TestAppGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../../../../support", __FILE__)
4
+ source_root "./spec/test_app_templates"
5
5
 
6
- def inject_routes
7
- insert_into_file "config/routes.rb", :after => ".draw do" do
8
- %{
9
-
10
- mount Qa::Engine => '/qa'
11
-
12
- }
6
+ def update_app
7
+ Bundler.with_clean_env do
8
+ run "bundle install"
13
9
  end
14
10
  end
15
11
 
16
- def copy_configs
17
- copy_file "../../config/oclcts-authorities.yml", "config/oclcts-authorities.yml"
12
+ def run_qa_installer
13
+ generate "qa:install"
14
+ end
15
+
16
+ def run_migrations
17
+ rake "qa:install:migrations"
18
+ rake "db:migrate"
19
+ rake "db:test:prepare"
18
20
  end
19
21
 
20
- end
22
+ end
@@ -0,0 +1,212 @@
1
+  (8.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
+ Migrating to CreateQaSubjectMeshTerms (20140611161143)
5
+  (0.1ms) begin transaction
6
+  (0.3ms) CREATE TABLE "qa_subject_mesh_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "term" varchar(255), "synonyms" text) 
7
+  (0.1ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_id" ON "qa_subject_mesh_terms" ("term_id")
8
+  (0.1ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term" ON "qa_subject_mesh_terms" ("term")
9
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140611161143"]]
10
+  (0.7ms) commit transaction
11
+ Migrating to CreateQaMeshTree (20140611161144)
12
+  (0.0ms) begin transaction
13
+  (0.2ms) CREATE TABLE "qa_mesh_trees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "tree_number" varchar(255)) 
14
+  (0.1ms) CREATE INDEX "index_qa_mesh_trees_on_term_id" ON "qa_mesh_trees" ("term_id")
15
+  (0.1ms) CREATE INDEX "index_qa_mesh_trees_on_tree_number" ON "qa_mesh_trees" ("tree_number")
16
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140611161144"]]
17
+  (0.6ms) commit transaction
18
+ Migrating to AddTermLowerToQaSubjectMeshTerms (20140611161145)
19
+  (0.0ms) begin transaction
20
+  (0.3ms) ALTER TABLE "qa_subject_mesh_terms" ADD "term_lower" varchar(255)
21
+  (0.1ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_lower" ON "qa_subject_mesh_terms" ("term_lower")
22
+  (0.7ms) DROP INDEX "index_qa_subject_mesh_terms_on_term"
23
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140611161145"]]
24
+  (0.6ms) commit transaction
25
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
26
+  (9.1ms) CREATE TABLE "qa_mesh_trees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "tree_number" varchar(255)) 
27
+  (0.8ms) CREATE INDEX "index_qa_mesh_trees_on_term_id" ON "qa_mesh_trees" ("term_id")
28
+  (0.7ms) CREATE INDEX "index_qa_mesh_trees_on_tree_number" ON "qa_mesh_trees" ("tree_number")
29
+  (0.8ms) CREATE TABLE "qa_subject_mesh_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "term" varchar(255), "synonyms" text, "term_lower" varchar(255))
30
+  (0.7ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_id" ON "qa_subject_mesh_terms" ("term_id")
31
+  (0.8ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_lower" ON "qa_subject_mesh_terms" ("term_lower")
32
+  (0.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
33
+  (0.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
34
+  (0.1ms) SELECT version FROM "schema_migrations"
35
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161145')
36
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161143')
37
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161144')
38
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
39
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
40
+  (0.7ms) CREATE TABLE "qa_mesh_trees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "tree_number" varchar(255)) 
41
+  (0.6ms) CREATE INDEX "index_qa_mesh_trees_on_term_id" ON "qa_mesh_trees" ("term_id")
42
+  (0.6ms) CREATE INDEX "index_qa_mesh_trees_on_tree_number" ON "qa_mesh_trees" ("tree_number")
43
+  (0.6ms) CREATE TABLE "qa_subject_mesh_terms" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "term_id" varchar(255), "term" varchar(255), "synonyms" text, "term_lower" varchar(255))
44
+  (0.7ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_id" ON "qa_subject_mesh_terms" ("term_id")
45
+  (1.3ms) CREATE INDEX "index_qa_subject_mesh_terms_on_term_lower" ON "qa_subject_mesh_terms" ("term_lower")
46
+  (0.7ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
47
+  (0.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
48
+  (0.1ms) SELECT version FROM "schema_migrations"
49
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161145')
50
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161143')
51
+  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20140611161144')
52
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
53
+  (0.1ms) begin transaction
54
+ Processing by Qa::TermsController#index as HTML
55
+ Parameters: {"q"=>"foo", "vocab"=>"loc", "sub_authority"=>"foo"}
56
+ Filter chain halted as :check_sub_authority rendered or redirected
57
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
58
+  (0.1ms) rollback transaction
59
+  (0.0ms) begin transaction
60
+ Processing by Qa::TermsController#index as HTML
61
+ Parameters: {"vocab"=>nil}
62
+ Filter chain halted as :check_vocab_param rendered or redirected
63
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
64
+  (0.0ms) rollback transaction
65
+  (0.0ms) begin transaction
66
+ Processing by Qa::TermsController#index as HTML
67
+ Parameters: {"q"=>"foo", "vocab"=>"bar"}
68
+ Filter chain halted as :check_authority rendered or redirected
69
+ Completed 400 Bad Request in 1ms (ActiveRecord: 0.0ms)
70
+  (0.0ms) rollback transaction
71
+  (0.1ms) begin transaction
72
+ Processing by Qa::TermsController#index as HTML
73
+ Parameters: {"q"=>nil}
74
+ Filter chain halted as :check_vocab_param rendered or redirected
75
+ Completed 400 Bad Request in 0ms (ActiveRecord: 0.0ms)
76
+  (0.1ms) rollback transaction
77
+  (0.0ms) begin transaction
78
+ Processing by Qa::TermsController#index as HTML
79
+ Parameters: {"q"=>"foo", "vocab"=>"loc", "sub_authority"=>"relators"}
80
+ Completed 200 OK in 5ms (Views: 0.3ms | ActiveRecord: 0.0ms)
81
+  (0.1ms) rollback transaction
82
+  (0.1ms) begin transaction
83
+ Processing by Qa::TermsController#index as HTML
84
+ Parameters: {"q"=>"Tibetan", "vocab"=>"tgnlang"}
85
+ Completed 200 OK in 9ms (Views: 0.2ms | ActiveRecord: 0.0ms)
86
+  (0.1ms) rollback transaction
87
+  (0.1ms) begin transaction
88
+ Processing by Qa::TermsController#index as HTML
89
+ Parameters: {"q"=>"foo", "vocab"=>"loc"}
90
+ Completed 200 OK in 5ms (Views: 0.2ms | ActiveRecord: 0.0ms)
91
+  (0.1ms) rollback transaction
92
+  (0.0ms) begin transaction
93
+  (0.1ms) select sqlite_version(*)
94
+ Class Create Many Without Validations Or Callbacks (0.5ms) INSERT INTO "qa_subject_mesh_terms" ("term_id","term","term_lower","synonyms") VALUES ('D008288','Malaria','malaria','Marsh Fever|Plasmodium Infections|Remittent Fever|Infections, Plasmodium|Paludism|Fever, Marsh|Fever, Remittent|Infection, Plasmodium|Plasmodium Infection'),('D000001','Calcimycin','calcimycin','A-23187|A23187|Antibiotic A23187|A 23187|A23187, Antibiotic'),('D005260','Female','female','Females'),('D005261','Female Urogenital Diseases and Pregnancy Complications','female urogenital diseases and pregnancy complications',''),('D010272','Parasitic Diseases','parasitic diseases','Disease, Parasitic|Diseases, Parasitic|Parasitic Disease'),('D011528','Protozoan Infections','protozoan infections','Histomoniasis|Infections, Protozoan|Histomoniases|Infection, Protozoan|Protozoan Infection'),('D062310','Tropical Diseases','tropical diseases','Disease, Tropical|Diseases, Tropical|Tropical Disease'),('D013568','Pathological Conditions, Signs and Symptoms','pathological conditions, signs and symptoms','Symptoms and General Pathology'),('D001583','Benzoxazoles','benzoxazoles',''),('D006574','Heterocyclic Compounds, 2-Ring','heterocyclic compounds, 2-ring','2-Ring Heterocyclic Compounds|Compounds, 2-Ring Heterocyclic|Heterocyclic Compounds, 2 Ring'),('D006571','Heterocyclic Compounds','heterocyclic compounds','Compounds, Heterocyclic')
95
+ Class Create Many Without Validations Or Callbacks (0.3ms) INSERT INTO "qa_mesh_trees" ("term_id","tree_number") VALUES ('D008288','C03.752.530'),('D008288','C23.996.660'),('D000001','D03.438.221.173'),('D005261','C13'),('D010272','C03'),('D011528','C03.752'),('D062310','C03.883'),('D062310','C23.996'),('D013568','C23'),('D001583','D03.438.221'),('D006574','D03.438'),('D006571','D03')
96
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_lower" = 'malaria'
97
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term" = 'Malaria'
98
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_id" = 'D008288'
99
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms"
100
+  (0.4ms) rollback transaction
101
+  (0.1ms) begin transaction
102
+ SQL (0.4ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mr Plow"], ["term_id", "1"], ["term_lower", "mr plow"]]
103
+  (0.7ms) commit transaction
104
+  (0.1ms) begin transaction
105
+ SQL (0.2ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mr Snow"], ["term_id", "2"], ["term_lower", "mr snow"]]
106
+  (0.5ms) commit transaction
107
+  (0.0ms) begin transaction
108
+ SQL (0.2ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id", "term_lower") VALUES (?, ?, ?) [["term", "Mrs Fields"], ["term_id", "3"], ["term_lower", "mrs fields"]]
109
+  (0.5ms) commit transaction
110
+  (0.0ms) begin transaction
111
+ Qa::SubjectMeshTerm Load (0.2ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE (term_lower LIKE 'mr%') LIMIT 10
112
+  (0.1ms) rollback transaction
113
+  (0.1ms) begin transaction
114
+ Qa::SubjectMeshTerm Load (0.2ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_id" = '2' ORDER BY "qa_subject_mesh_terms"."id" ASC LIMIT 1
115
+  (0.1ms) rollback transaction
116
+ SQL (0.7ms) DELETE FROM "qa_subject_mesh_terms"
117
+  (0.1ms) begin transaction
118
+  (0.0ms) rollback transaction
119
+  (0.1ms) begin transaction
120
+  (0.0ms) rollback transaction
121
+  (0.0ms) begin transaction
122
+  (0.0ms) rollback transaction
123
+  (0.1ms) begin transaction
124
+  (0.0ms) rollback transaction
125
+  (0.1ms) begin transaction
126
+  (0.0ms) rollback transaction
127
+  (0.1ms) begin transaction
128
+  (0.0ms) rollback transaction
129
+  (0.1ms) begin transaction
130
+  (0.0ms) rollback transaction
131
+  (0.1ms) begin transaction
132
+  (0.1ms) rollback transaction
133
+  (0.1ms) begin transaction
134
+  (0.0ms) rollback transaction
135
+  (0.0ms) begin transaction
136
+  (0.1ms) rollback transaction
137
+  (0.1ms) begin transaction
138
+  (0.1ms) rollback transaction
139
+  (0.1ms) begin transaction
140
+  (0.1ms) rollback transaction
141
+  (0.1ms) begin transaction
142
+  (0.1ms) rollback transaction
143
+  (0.1ms) begin transaction
144
+  (0.1ms) rollback transaction
145
+  (0.1ms) begin transaction
146
+  (0.1ms) rollback transaction
147
+  (0.1ms) begin transaction
148
+  (0.1ms) rollback transaction
149
+  (0.0ms) begin transaction
150
+ SQL (0.3ms) INSERT INTO "qa_subject_mesh_terms" ("term", "term_id") VALUES (?, ?) [["term", "Glyphon"], ["term_id", "ABCDEFG"]]
151
+  (0.8ms) commit transaction
152
+  (0.0ms) begin transaction
153
+  (0.0ms) SAVEPOINT active_record_1
154
+ SQL (0.2ms) INSERT INTO "qa_mesh_trees" ("term_id", "tree_number") VALUES (?, ?) [["term_id", "ABCDEFG"], ["tree_number", "D1.2.3.4"]]
155
+  (0.0ms) RELEASE SAVEPOINT active_record_1
156
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" INNER JOIN qa_mesh_trees ON qa_subject_mesh_terms.term_id = qa_mesh_trees.term_id WHERE (qa_mesh_trees.tree_number = 'D1.2.3.4')
157
+  (0.3ms) rollback transaction
158
+  (0.1ms) begin transaction
159
+  (0.0ms) rollback transaction
160
+  (0.0ms) begin transaction
161
+ Qa::MeshTree Load (0.1ms) SELECT "qa_mesh_trees".* FROM "qa_mesh_trees" WHERE "qa_mesh_trees"."term_id" = 'ABCDEFG'
162
+  (0.0ms) rollback transaction
163
+  (0.0ms) begin transaction
164
+  (0.0ms) SAVEPOINT active_record_1
165
+ SQL (0.2ms) INSERT INTO "qa_subject_mesh_terms" ("synonyms", "term_id") VALUES (?, ?) [["synonyms", "b|c"], ["term_id", "a"]]
166
+  (0.0ms) RELEASE SAVEPOINT active_record_1
167
+  (0.4ms) rollback transaction
168
+  (0.1ms) begin transaction
169
+ SQL (2.7ms) DELETE FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."id" = ? [["id", 4]]
170
+  (0.6ms) commit transaction
171
+  (0.0ms) begin transaction
172
+ Class Create Many Without Validations Or Callbacks (0.3ms) INSERT INTO "qa_subject_mesh_terms" ("term_id","term","term_lower","synonyms") VALUES ('5','test','test','')
173
+ Qa::SubjectMeshTerm Load (0.1ms) SELECT "qa_subject_mesh_terms".* FROM "qa_subject_mesh_terms" WHERE "qa_subject_mesh_terms"."term_id" = 5 LIMIT 1
174
+  (0.4ms) rollback transaction
175
+  (0.1ms) begin transaction
176
+  (0.0ms) rollback transaction
177
+  (0.0ms) begin transaction
178
+  (0.0ms) rollback transaction
179
+  (0.0ms) begin transaction
180
+  (0.0ms) rollback transaction
181
+  (0.1ms) begin transaction
182
+  (0.1ms) rollback transaction
183
+  (0.0ms) begin transaction
184
+  (0.1ms) rollback transaction
185
+  (0.0ms) begin transaction
186
+  (0.0ms) rollback transaction
187
+  (0.1ms) begin transaction
188
+  (0.0ms) rollback transaction
189
+  (0.1ms) begin transaction
190
+  (0.1ms) rollback transaction
191
+  (0.3ms) begin transaction
192
+  (0.1ms) rollback transaction
193
+  (0.0ms) begin transaction
194
+  (0.1ms) rollback transaction
195
+  (0.0ms) begin transaction
196
+  (0.0ms) rollback transaction
197
+  (0.0ms) begin transaction
198
+  (0.0ms) rollback transaction
199
+  (0.0ms) begin transaction
200
+  (0.0ms) rollback transaction
201
+  (0.0ms) begin transaction
202
+  (0.0ms) rollback transaction
203
+  (0.0ms) begin transaction
204
+  (0.1ms) rollback transaction
205
+  (0.0ms) begin transaction
206
+  (0.0ms) rollback transaction
207
+  (0.0ms) begin transaction
208
+  (0.0ms) rollback transaction
209
+  (0.0ms) begin transaction
210
+  (0.0ms) rollback transaction
211
+  (0.0ms) begin transaction
212
+  (0.0ms) rollback transaction
@@ -1,4 +1,4 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
2
  #
3
3
  # To ban all spiders from the entire site uncomment the next two lines:
4
4
  # User-agent: *
@@ -67,4 +67,25 @@ describe Qa::Authorities::Loc do
67
67
 
68
68
  end
69
69
 
70
+ describe "#parse_authority_response" do
71
+ before :all do
72
+ stub_request(:get, "http://id.loc.gov/search/?format=json&q=h&q=cs:http://id.loc.gov/authorities/subjects").
73
+ with(:headers => {'Accept'=>'application/json'}).
74
+ to_return(:body => webmock_fixture("loc-response.txt"), :status => 200)
75
+ @authority.search("h", "subjects")
76
+ end
77
+
78
+ let(:parsed_response) { @authority.parse_authority_response(@authority.raw_response) }
79
+
80
+ it "should return an array of entries returned in the JSON" do
81
+ expect(parsed_response.length).to eq(2)
82
+ end
83
+
84
+ it "should have a URI for the id and a string label" do
85
+ expect(parsed_response[0]["id"]).to eq("info:lc/authorities/names/n2008008718")
86
+ expect(parsed_response[0]["label"]).to eq("Haw, Lily, 1890?-1915")
87
+ expect(parsed_response[1]["id"]).to eq("info:lc/vocabulary/geographicAreas/n-us-hi")
88
+ expect(parsed_response[1]["label"]).to eq("Hawaii")
89
+ end
90
+ end
70
91
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require File.expand_path("../internal/config/environment.rb", __FILE__)
2
2
  require 'rspec/rails'
3
- require 'rspec/autorun'
4
3
  require 'webmock/rspec'
4
+ require 'engine_cart'
5
5
 
6
6
  ENV["RAILS_ENV"] ||= 'test'
7
7
 
@@ -11,6 +11,8 @@ if ENV['COVERAGE']
11
11
  SimpleCov.command_name "spec"
12
12
  end
13
13
 
14
+ EngineCart.load_application!
15
+
14
16
  # Requires supporting ruby files with custom matchers and macros, etc,
15
17
  # in spec/support/ and its subdirectories.
16
18
  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
@@ -49,6 +51,8 @@ RSpec.configure do |config|
49
51
 
50
52
  # Disable Webmock if we choose so we can test against the authorities, instead of their mocks
51
53
  WebMock.disable! if ENV["WEBMOCK"] == "disabled"
54
+
55
+ config.infer_spec_type_from_file_location!
52
56
  end
53
57
 
54
58
  def webmock_fixture fixture
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+
3
+ class TestAppGenerator < Rails::Generators::Base
4
+ source_root "./spec/test_app_templates"
5
+
6
+ def update_app
7
+ Bundler.with_clean_env do
8
+ run "bundle install"
9
+ end
10
+ end
11
+
12
+ def run_qa_installer
13
+ generate "qa:install"
14
+ end
15
+
16
+ def run_migrations
17
+ rake "qa:install:migrations"
18
+ rake "db:migrate"
19
+ rake "db:test:prepare"
20
+ end
21
+
22
+ end