bento_search 1.7.0 → 2.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/README.md +2 -6
 - data/app/assets/javascripts/bento_search/ajax_load.js +17 -1
 - data/app/controllers/bento_search/search_controller.rb +2 -2
 - data/app/models/bento_search/concurrent_searcher.rb +2 -2
 - data/app/models/bento_search/result_item.rb +5 -2
 - data/app/views/bento_search/_item_title.html.erb +2 -4
 - data/lib/bento_search/version.rb +1 -1
 - data/lib/generators/bento_search/install/ajax_load_js_generator.rb +15 -0
 - data/test/decorator/standard_decorator_test.rb +30 -30
 - data/test/dummy/app/assets/config/manifest.js +4 -0
 - data/test/dummy/config/application.rb +7 -0
 - data/test/dummy/config/environments/development.rb +2 -0
 - data/test/dummy/config/environments/production.rb +7 -1
 - data/test/dummy/config/environments/test.rb +10 -3
 - data/test/functional/bento_search/search_controller_test.rb +5 -1
 - data/test/search_engines/google_site_search_test.rb +48 -48
 - data/test/search_engines/scopus_engine_test.rb +51 -51
 - data/test/support/atom.xsd.xml +3 -3
 - data/test/support/xml.xsd +117 -0
 - data/test/view/atom_results_test.rb +94 -94
 - metadata +27 -49
 - data/app/assets/javascripts/bento_search.js +0 -3
 - data/app/item_decorators/bento_search/ebscohost/conditional_openurl_main_link.rb +0 -36
 - data/app/item_decorators/bento_search/only_premade_openurl.rb +0 -20
 - data/app/item_decorators/bento_search/openurl_add_other_link.rb +0 -39
 - data/app/item_decorators/bento_search/openurl_main_link.rb +0 -34
 - data/app/models/bento_search/multi_searcher.rb +0 -132
 - data/test/dummy/config/initializers/secret_token.rb +0 -8
 - data/test/dummy/db/schema.rb +0 -15
 - data/test/unit/multi_searcher_test.rb +0 -46
 
| 
         @@ -4,32 +4,32 @@ require 'cgi' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            require 'uri'
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            # Set shell env SCOPUS_KEY to your api key to test fresh http
         
     | 
| 
       7 
     | 
    
         
            -
            # connections, if you can't use the ones cached by VCR. 
     | 
| 
      
 7 
     | 
    
         
            +
            # connections, if you can't use the ones cached by VCR.
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            class ScopusEngineTest < ActiveSupport::TestCase
         
     | 
| 
       10 
10 
     | 
    
         
             
              extend TestWithCassette
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       12 
12 
     | 
    
         
             
              # Filter API key out of VCR cache for tag :scopus, which we'll use
         
     | 
| 
       13 
     | 
    
         
            -
              # in this test. 
     | 
| 
      
 13 
     | 
    
         
            +
              # in this test.
         
     | 
| 
       14 
14 
     | 
    
         
             
              @@api_key = (ENV["SCOPUS_KEY"] || "DUMMY_API_KEY")
         
     | 
| 
       15 
15 
     | 
    
         
             
              VCR.configure do |c|
         
     | 
| 
       16 
16 
     | 
    
         
             
                c.filter_sensitive_data("DUMMY_API_KEY", :scopus) { @@api_key }
         
     | 
| 
       17 
17 
     | 
    
         
             
              end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       19 
19 
     | 
    
         
             
              def setup
         
     | 
| 
       20 
20 
     | 
    
         
             
                @engine = BentoSearch::ScopusEngine.new(:api_key => @@api_key)
         
     | 
| 
       21 
21 
     | 
    
         
             
              end
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
              def test_construct_search_url
         
     | 
| 
       25 
25 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two")
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       27 
27 
     | 
    
         
             
                assert_equal "http://api.elsevier.com/content/search/index:SCOPUS?query=one+two&sort=refeid", url
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       30 
30 
     | 
    
         
             
              def test_construct_fielded_search_url
         
     | 
| 
       31 
31 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two", :search_field => "AUTH")
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
       33 
33 
     | 
    
         
             
                assert_equal "http://api.elsevier.com/content/search/index:SCOPUS?query=AUTH%28one+two%29&sort=refeid", url
         
     | 
| 
       34 
34 
     | 
    
         
             
              end
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
         @@ -46,66 +46,66 @@ class ScopusEngineTest < ActiveSupport::TestCase 
     | 
|
| 
       46 
46 
     | 
    
         
             
                assert_includes query_components, "AUTH(John Smith)"
         
     | 
| 
       47 
47 
     | 
    
         
             
                assert_includes query_components, "TITLE(Terrible Diseases)"
         
     | 
| 
       48 
48 
     | 
    
         
             
              end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       50 
50 
     | 
    
         
             
              def test_construct_search_with_per_page
         
     | 
| 
       51 
51 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two", :per_page => 30)
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
       53 
53 
     | 
    
         
             
                assert_equal "http://api.elsevier.com/content/search/index:SCOPUS?query=one+two&count=30&sort=refeid", url
         
     | 
| 
       54 
54 
     | 
    
         
             
              end
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
       56 
56 
     | 
    
         
             
              def test_construct_search_with_sort
         
     | 
| 
       57 
57 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two", :sort => "date_desc")
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       59 
59 
     | 
    
         
             
                assert_equal "http://api.elsevier.com/content/search/index:SCOPUS?query=one+two&sort=-datesort%2C%2Bauth", url
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
       61 
61 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two", :sort => "relevance")
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
       63 
63 
     | 
    
         
             
                assert_equal "http://api.elsevier.com/content/search/index:SCOPUS?query=one+two&sort=refeid", url
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
       65 
65 
     | 
    
         
             
              end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
       67 
67 
     | 
    
         
             
              def test_construct_default_relevance_sort
         
     | 
| 
       68 
68 
     | 
    
         
             
                url_implicit = @engine.send(:scopus_url, :query => "one two")
         
     | 
| 
       69 
69 
     | 
    
         
             
                url_explicit = @engine.send(:scopus_url, :query => "one two", :sort => "relevance")
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       71 
71 
     | 
    
         
             
                assert_equal url_explicit, url_implicit
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       75 
75 
     | 
    
         
             
              def test_construct_with_pagination
         
     | 
| 
       76 
76 
     | 
    
         
             
                url = @engine.send(:scopus_url, :query => "one two", :start => 20, :per_page => 10)
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
       78 
78 
     | 
    
         
             
                query_hash = CGI.parse(URI.parse(url).query)
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
       80 
80 
     | 
    
         
             
                assert_equal ["20"], query_hash["start"]
         
     | 
| 
       81 
     | 
    
         
            -
                assert_equal ["10"], query_hash["count"] 
     | 
| 
      
 81 
     | 
    
         
            +
                assert_equal ["10"], query_hash["count"]
         
     | 
| 
       82 
82 
     | 
    
         
             
              end
         
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       85 
85 
     | 
    
         
             
              test_with_cassette("bad api key should return error response", :scopus) do
         
     | 
| 
       86 
86 
     | 
    
         
             
                @engine = BentoSearch::ScopusEngine.new(:api_key => "BAD_KEY_ERROR")
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       88 
88 
     | 
    
         
             
                results = @engine.search(:query => "cancer")
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                assert results.failed?, "response.failed? should be" 
     | 
| 
      
 90 
     | 
    
         
            +
                assert results.failed?, "response.failed? should be"
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
                assert_present results.error[:error_info]
         
     | 
| 
       93 
93 
     | 
    
         
             
                assert_includes results.error[:error_info], "AUTHORIZATION_ERROR"
         
     | 
| 
       94 
94 
     | 
    
         
             
              end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
       96 
96 
     | 
    
         
             
              test_with_cassette("simple search", :scopus) do
         
     | 
| 
       97 
97 
     | 
    
         
             
                results = @engine.search(:query => "cancer")
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       99 
99 
     | 
    
         
             
                assert_not_nil results.total_items, "total_items not nil"
         
     | 
| 
       100 
     | 
    
         
            -
                assert_kind_of  
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
                assert_kind_of 1.class, results.total_items
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
       102 
102 
     | 
    
         
             
                assert_not_nil results.start, "start not nil"
         
     | 
| 
       103 
103 
     | 
    
         
             
                assert_not_nil results.per_page, "per_page not nil"
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
       105 
105 
     | 
    
         
             
                assert_equal 10, results.length
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
       107 
107 
     | 
    
         
             
                sample_result = results.first
         
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       109 
109 
     | 
    
         
             
                assert_present sample_result.title
         
     | 
| 
       110 
110 
     | 
    
         
             
                assert_present sample_result.link
         
     | 
| 
       111 
111 
     | 
    
         
             
                assert_present sample_result.journal_title
         
     | 
| 
         @@ -114,37 +114,37 @@ class ScopusEngineTest < ActiveSupport::TestCase 
     | 
|
| 
       114 
114 
     | 
    
         
             
                assert_present sample_result.volume
         
     | 
| 
       115 
115 
     | 
    
         
             
                assert_present sample_result.issue
         
     | 
| 
       116 
116 
     | 
    
         
             
                assert_present sample_result.start_page
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                assert_present sample_result.authors 
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                assert_present sample_result.authors
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
       120 
120 
     | 
    
         
             
                assert_present sample_result.format
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
       122 
122 
     | 
    
         
             
                assert_present sample_result.unique_id
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
       124 
124 
     | 
    
         
             
              end
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
       126 
126 
     | 
    
         
             
              test_with_cassette("zero results search", :scopus) do
         
     | 
| 
       127 
127 
     | 
    
         
             
                results = @engine.search(:query => "aldfjkadf lakdj zdfzzzz")
         
     | 
| 
       128 
128 
     | 
    
         
             
                assert ! results.failed?, "results not marked failed"
         
     | 
| 
       129 
129 
     | 
    
         
             
                assert_equal 0, results.size
         
     | 
| 
       130 
130 
     | 
    
         
             
              end
         
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
       132 
132 
     | 
    
         
             
              test_with_cassette("escaped chars", :scopus) do
         
     | 
| 
       133 
133 
     | 
    
         
             
                results = @engine.search(:query => "monkey:(brain)")
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
       135 
135 
     | 
    
         
             
                assert ! results.failed?, "results not marked failed"
         
     | 
| 
       136 
136 
     | 
    
         
             
              end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
       140 
140 
     | 
    
         
             
              test_with_cassette("fielded search", :scopus) do
         
     | 
| 
       141 
141 
     | 
    
         
             
                results = @engine.search(:query => "cancer", :semantic_search_field => :title)
         
     | 
| 
       142 
142 
     | 
    
         | 
| 
       143 
     | 
    
         
            -
                assert results.first.title.downcase.include?("cancer"), "Title includes query term" 
     | 
| 
      
 143 
     | 
    
         
            +
                assert results.first.title.downcase.include?("cancer"), "Title includes query term"
         
     | 
| 
       144 
144 
     | 
    
         
             
              end
         
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
       146 
146 
     | 
    
         
             
              test_with_cassette("multi-field search", :scopus) do
         
     | 
| 
       147 
     | 
    
         
            -
                results = @engine.search(:query => 
     | 
| 
      
 147 
     | 
    
         
            +
                results = @engine.search(:query =>
         
     | 
| 
       148 
148 
     | 
    
         
             
                  { :title => "Protein measurement with the folin phenol reagent",
         
     | 
| 
       149 
149 
     | 
    
         
             
                    :author => "Lowry",
         
     | 
| 
       150 
150 
     | 
    
         
             
                    :issn => "0021-9258"
         
     | 
| 
         @@ -168,12 +168,12 @@ class ScopusEngineTest < ActiveSupport::TestCase 
     | 
|
| 
       168 
168 
     | 
    
         
             
                })
         
     | 
| 
       169 
169 
     | 
    
         | 
| 
       170 
170 
     | 
    
         
             
                assert ! results.failed?
         
     | 
| 
       171 
     | 
    
         
            -
                assert_equal 1, results.total_items 
     | 
| 
      
 171 
     | 
    
         
            +
                assert_equal 1, results.total_items
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
                item = results.first
         
     | 
| 
       174 
174 
     | 
    
         | 
| 
       175 
175 
     | 
    
         
             
                assert item.title.start_with?("Architects and planners in the middle of a road war")
         
     | 
| 
       176 
176 
     | 
    
         
             
              end
         
     | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
       179 
179 
     | 
    
         
             
            end
         
     | 
    
        data/test/support/atom.xsd.xml
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            <?xml version="1.0" encoding="utf-8" ?>
         
     | 
| 
       2 
     | 
    
         
            -
            <xs:schema targetNamespace="http://www.w3.org/2005/Atom" elementFormDefault="qualified" 
     | 
| 
      
 2 
     | 
    
         
            +
            <xs:schema targetNamespace="http://www.w3.org/2005/Atom" elementFormDefault="qualified"
         
     | 
| 
       3 
3 
     | 
    
         
             
            	attributeFormDefault="unqualified"
         
     | 
| 
       4 
4 
     | 
    
         
             
            	xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema">
         
     | 
| 
       5 
5 
     | 
    
         
             
            	<xs:annotation>
         
     | 
| 
         @@ -8,7 +8,7 @@ 
     | 
|
| 
       8 
8 
     | 
    
         
             
            				found here http://www.atomenabled.org/developers/syndication/atom-format-spec.php.
         
     | 
| 
       9 
9 
     | 
    
         
             
            			</xs:documentation>
         
     | 
| 
       10 
10 
     | 
    
         
             
            	</xs:annotation>
         
     | 
| 
       11 
     | 
    
         
            -
            	<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation=" 
     | 
| 
      
 11 
     | 
    
         
            +
            	<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="./xml.xsd" />
         
     | 
| 
       12 
12 
     | 
    
         
             
            	<xs:annotation>
         
     | 
| 
       13 
13 
     | 
    
         
             
            		<xs:documentation>
         
     | 
| 
       14 
14 
     | 
    
         
             
            			An Atom document may have two root elements, feed and entry, as defined in section 2.
         
     | 
| 
         @@ -237,4 +237,4 @@ 
     | 
|
| 
       237 
237 
     | 
    
         
             
            		<xs:attribute ref="xml:lang" />
         
     | 
| 
       238 
238 
     | 
    
         
             
            		<xs:anyAttribute namespace="##other"/>
         
     | 
| 
       239 
239 
     | 
    
         
             
            	</xs:attributeGroup>
         
     | 
| 
       240 
     | 
    
         
            -
            </xs:schema>
         
     | 
| 
      
 240 
     | 
    
         
            +
            </xs:schema>
         
     | 
| 
         @@ -0,0 +1,117 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <?xml version='1.0'?>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
         
     | 
| 
      
 3 
     | 
    
         
            +
            <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             <xs:annotation>
         
     | 
| 
      
 6 
     | 
    
         
            +
              <xs:documentation>
         
     | 
| 
      
 7 
     | 
    
         
            +
               See http://www.w3.org/XML/1998/namespace.html and
         
     | 
| 
      
 8 
     | 
    
         
            +
               http://www.w3.org/TR/REC-xml for information about this namespace.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                This schema document describes the XML namespace, in a form
         
     | 
| 
      
 11 
     | 
    
         
            +
                suitable for import by other schema documents.  
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                Note that local names in this namespace are intended to be defined
         
     | 
| 
      
 14 
     | 
    
         
            +
                only by the World Wide Web Consortium or its subgroups.  The
         
     | 
| 
      
 15 
     | 
    
         
            +
                following names are currently defined in this namespace and should
         
     | 
| 
      
 16 
     | 
    
         
            +
                not be used with conflicting semantics by any Working Group,
         
     | 
| 
      
 17 
     | 
    
         
            +
                specification, or document instance:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                base (as an attribute name): denotes an attribute whose value
         
     | 
| 
      
 20 
     | 
    
         
            +
                     provides a URI to be used as the base for interpreting any
         
     | 
| 
      
 21 
     | 
    
         
            +
                     relative URIs in the scope of the element on which it
         
     | 
| 
      
 22 
     | 
    
         
            +
                     appears; its value is inherited.  This name is reserved
         
     | 
| 
      
 23 
     | 
    
         
            +
                     by virtue of its definition in the XML Base specification.
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                lang (as an attribute name): denotes an attribute whose value
         
     | 
| 
      
 26 
     | 
    
         
            +
                     is a language code for the natural language of the content of
         
     | 
| 
      
 27 
     | 
    
         
            +
                     any element; its value is inherited.  This name is reserved
         
     | 
| 
      
 28 
     | 
    
         
            +
                     by virtue of its definition in the XML specification.
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
                space (as an attribute name): denotes an attribute whose
         
     | 
| 
      
 31 
     | 
    
         
            +
                     value is a keyword indicating what whitespace processing
         
     | 
| 
      
 32 
     | 
    
         
            +
                     discipline is intended for the content of the element; its
         
     | 
| 
      
 33 
     | 
    
         
            +
                     value is inherited.  This name is reserved by virtue of its
         
     | 
| 
      
 34 
     | 
    
         
            +
                     definition in the XML specification.
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                Father (in any context at all): denotes Jon Bosak, the chair of 
         
     | 
| 
      
 37 
     | 
    
         
            +
                     the original XML Working Group.  This name is reserved by 
         
     | 
| 
      
 38 
     | 
    
         
            +
                     the following decision of the W3C XML Plenary and 
         
     | 
| 
      
 39 
     | 
    
         
            +
                     XML Coordination groups:
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                         In appreciation for his vision, leadership and dedication
         
     | 
| 
      
 42 
     | 
    
         
            +
                         the W3C XML Plenary on this 10th day of February, 2000
         
     | 
| 
      
 43 
     | 
    
         
            +
                         reserves for Jon Bosak in perpetuity the XML name
         
     | 
| 
      
 44 
     | 
    
         
            +
                         xml:Father
         
     | 
| 
      
 45 
     | 
    
         
            +
              </xs:documentation>
         
     | 
| 
      
 46 
     | 
    
         
            +
             </xs:annotation>
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
             <xs:annotation>
         
     | 
| 
      
 49 
     | 
    
         
            +
              <xs:documentation>This schema defines attributes and an attribute group
         
     | 
| 
      
 50 
     | 
    
         
            +
                    suitable for use by
         
     | 
| 
      
 51 
     | 
    
         
            +
                    schemas wishing to allow xml:base, xml:lang or xml:space attributes
         
     | 
| 
      
 52 
     | 
    
         
            +
                    on elements they define.
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    To enable this, such a schema must import this schema
         
     | 
| 
      
 55 
     | 
    
         
            +
                    for the XML namespace, e.g. as follows:
         
     | 
| 
      
 56 
     | 
    
         
            +
                    <schema . . .>
         
     | 
| 
      
 57 
     | 
    
         
            +
                     . . .
         
     | 
| 
      
 58 
     | 
    
         
            +
                     <import namespace="http://www.w3.org/XML/1998/namespace"
         
     | 
| 
      
 59 
     | 
    
         
            +
                                schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    Subsequently, qualified reference to any of the attributes
         
     | 
| 
      
 62 
     | 
    
         
            +
                    or the group defined below will have the desired effect, e.g.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                    <type . . .>
         
     | 
| 
      
 65 
     | 
    
         
            +
                     . . .
         
     | 
| 
      
 66 
     | 
    
         
            +
                     <attributeGroup ref="xml:specialAttrs"/>
         
     | 
| 
      
 67 
     | 
    
         
            +
             
         
     | 
| 
      
 68 
     | 
    
         
            +
                     will define a type which will schema-validate an instance
         
     | 
| 
      
 69 
     | 
    
         
            +
                     element with any of those attributes</xs:documentation>
         
     | 
| 
      
 70 
     | 
    
         
            +
             </xs:annotation>
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
             <xs:annotation>
         
     | 
| 
      
 73 
     | 
    
         
            +
              <xs:documentation>In keeping with the XML Schema WG's standard versioning
         
     | 
| 
      
 74 
     | 
    
         
            +
               policy, this schema document will persist at
         
     | 
| 
      
 75 
     | 
    
         
            +
               http://www.w3.org/2001/03/xml.xsd.
         
     | 
| 
      
 76 
     | 
    
         
            +
               At the date of issue it can also be found at
         
     | 
| 
      
 77 
     | 
    
         
            +
               http://www.w3.org/2001/xml.xsd.
         
     | 
| 
      
 78 
     | 
    
         
            +
               The schema document at that URI may however change in the future,
         
     | 
| 
      
 79 
     | 
    
         
            +
               in order to remain compatible with the latest version of XML Schema
         
     | 
| 
      
 80 
     | 
    
         
            +
               itself.  In other words, if the XML Schema namespace changes, the version
         
     | 
| 
      
 81 
     | 
    
         
            +
               of this document at
         
     | 
| 
      
 82 
     | 
    
         
            +
               http://www.w3.org/2001/xml.xsd will change
         
     | 
| 
      
 83 
     | 
    
         
            +
               accordingly; the version at
         
     | 
| 
      
 84 
     | 
    
         
            +
               http://www.w3.org/2001/03/xml.xsd will not change.
         
     | 
| 
      
 85 
     | 
    
         
            +
              </xs:documentation>
         
     | 
| 
      
 86 
     | 
    
         
            +
             </xs:annotation>
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
             <xs:attribute name="lang" type="xs:language">
         
     | 
| 
      
 89 
     | 
    
         
            +
              <xs:annotation>
         
     | 
| 
      
 90 
     | 
    
         
            +
               <xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
         
     | 
| 
      
 91 
     | 
    
         
            +
                     codes as the enumerated possible values . . .</xs:documentation>
         
     | 
| 
      
 92 
     | 
    
         
            +
              </xs:annotation>
         
     | 
| 
      
 93 
     | 
    
         
            +
             </xs:attribute>
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
             <xs:attribute name="space" default="preserve">
         
     | 
| 
      
 96 
     | 
    
         
            +
              <xs:simpleType>
         
     | 
| 
      
 97 
     | 
    
         
            +
               <xs:restriction base="xs:NCName">
         
     | 
| 
      
 98 
     | 
    
         
            +
                <xs:enumeration value="default"/>
         
     | 
| 
      
 99 
     | 
    
         
            +
                <xs:enumeration value="preserve"/>
         
     | 
| 
      
 100 
     | 
    
         
            +
               </xs:restriction>
         
     | 
| 
      
 101 
     | 
    
         
            +
              </xs:simpleType>
         
     | 
| 
      
 102 
     | 
    
         
            +
             </xs:attribute>
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
             <xs:attribute name="base" type="xs:anyURI">
         
     | 
| 
      
 105 
     | 
    
         
            +
              <xs:annotation>
         
     | 
| 
      
 106 
     | 
    
         
            +
               <xs:documentation>See http://www.w3.org/TR/xmlbase/ for
         
     | 
| 
      
 107 
     | 
    
         
            +
                                 information about this attribute.</xs:documentation>
         
     | 
| 
      
 108 
     | 
    
         
            +
              </xs:annotation>
         
     | 
| 
      
 109 
     | 
    
         
            +
             </xs:attribute>
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
             <xs:attributeGroup name="specialAttrs">
         
     | 
| 
      
 112 
     | 
    
         
            +
              <xs:attribute ref="xml:base"/>
         
     | 
| 
      
 113 
     | 
    
         
            +
              <xs:attribute ref="xml:lang"/>
         
     | 
| 
      
 114 
     | 
    
         
            +
              <xs:attribute ref="xml:space"/>
         
     | 
| 
      
 115 
     | 
    
         
            +
             </xs:attributeGroup>
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            </xs:schema>
         
     | 
| 
         @@ -4,7 +4,7 @@ require 'nokogiri' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class AtomResultsTest < ActionView::TestCase
         
     | 
| 
       6 
6 
     | 
    
         
             
              include ActionView::Helpers::UrlHelper
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       8 
8 
     | 
    
         
             
              @@namespaces = {
         
     | 
| 
       9 
9 
     | 
    
         
             
                "atom"        => "http://www.w3.org/2005/Atom",
         
     | 
| 
       10 
10 
     | 
    
         
             
                "opensearch"  => "http://a9.com/-/spec/opensearch/1.1/",
         
     | 
| 
         @@ -12,7 +12,7 @@ class AtomResultsTest < ActionView::TestCase 
     | 
|
| 
       12 
12 
     | 
    
         
             
                "dcterms"     => "http://purl.org/dc/terms/",
         
     | 
| 
       13 
13 
     | 
    
         
             
                "bibo"        => "http://purl.org/ontology/bibo/"
         
     | 
| 
       14 
14 
     | 
    
         
             
              }
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       16 
16 
     | 
    
         
             
              # Instead of using assert_select, we do it ourselves with nokogiri
         
     | 
| 
       17 
17 
     | 
    
         
             
              # for better namespace control.
         
     | 
| 
       18 
18 
     | 
    
         
             
              #
         
     | 
| 
         @@ -21,26 +21,26 @@ class AtomResultsTest < ActionView::TestCase 
     | 
|
| 
       21 
21 
     | 
    
         
             
              #   assert matched_node.first["attribute"] == "foo"
         
     | 
| 
       22 
22 
     | 
    
         
             
              # end
         
     | 
| 
       23 
23 
     | 
    
         
             
              def assert_node(xml, xpath, options = {})
         
     | 
| 
       24 
     | 
    
         
            -
                result = xml.xpath(xpath, @@namespaces) 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                result = xml.xpath(xpath, @@namespaces)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       26 
26 
     | 
    
         
             
                assert result.length > 0, "Expected xpath '#{xpath}' to match in #{xml.to_s[0..200]}..."
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
       28 
28 
     | 
    
         
             
                if options[:text]
         
     | 
| 
       29 
29 
     | 
    
         
             
                  assert_equal options[:text], result.text.strip, "Expected #{options[:text]} as content of #{result.to_s[0..200]}"
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       32 
32 
     | 
    
         
             
                yield result if block_given?
         
     | 
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       35 
35 
     | 
    
         
             
              def setup
         
     | 
| 
       36 
36 
     | 
    
         
             
                @total_items = 1000
         
     | 
| 
       37 
37 
     | 
    
         
             
                @start       = 6
         
     | 
| 
       38 
38 
     | 
    
         
             
                @per_page    = 15
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                @engine = BentoSearch::MockEngine.new(:total_items => @total_items) 
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                @engine = BentoSearch::MockEngine.new(:total_items => @total_items)
         
     | 
| 
       42 
42 
     | 
    
         
             
                @results = @engine.search("some query", :start => @start, :per_page => @per_page)
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       44 
44 
     | 
    
         
             
                # but fill the first result elements with some non-blank data to test
         
     | 
| 
       45 
45 
     | 
    
         
             
                @article = BentoSearch::ResultItem.new(
         
     | 
| 
       46 
46 
     | 
    
         
             
                  :title      => "An Article", #
         
     | 
| 
         @@ -66,7 +66,7 @@ class AtomResultsTest < ActionView::TestCase 
     | 
|
| 
       66 
66 
     | 
    
         
             
                    BentoSearch::Link.new(:url => "http://example.org/bare_link"),
         
     | 
| 
       67 
67 
     | 
    
         
             
                    BentoSearch::Link.new(
         
     | 
| 
       68 
68 
     | 
    
         
             
                      :url    => "http://example.org/label_and_type",
         
     | 
| 
       69 
     | 
    
         
            -
                      :label  => "A link somewhere", 
     | 
| 
      
 69 
     | 
    
         
            +
                      :label  => "A link somewhere",
         
     | 
| 
       70 
70 
     | 
    
         
             
                      :type   => "application/pdf"
         
     | 
| 
       71 
71 
     | 
    
         
             
                    ),
         
     | 
| 
       72 
72 
     | 
    
         
             
                    BentoSearch::Link.new(
         
     | 
| 
         @@ -93,189 +93,189 @@ class AtomResultsTest < ActionView::TestCase 
     | 
|
| 
       93 
93 
     | 
    
         
             
                  :oclcnum   => "12124345",
         
     | 
| 
       94 
94 
     | 
    
         
             
                  :year      => "2004"
         
     | 
| 
       95 
95 
     | 
    
         
             
                )
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
       99 
99 
     | 
    
         
             
                @results[0] = @article
         
     | 
| 
       100 
100 
     | 
    
         
             
                @results[1] = @article_with_html_abstract
         
     | 
| 
       101 
101 
     | 
    
         
             
                @results[3] = @article_with_full_date
         
     | 
| 
       102 
     | 
    
         
            -
                @results[4] = @book 
     | 
| 
      
 102 
     | 
    
         
            +
                @results[4] = @book
         
     | 
| 
       103 
103 
     | 
    
         
             
              end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
       105 
105 
     | 
    
         
             
              def test_smoke_atom_validate
         
     | 
| 
       106 
106 
     | 
    
         
             
                # Validate under Atom schema. Should we validate under prism and dc schemas
         
     | 
| 
       107 
107 
     | 
    
         
             
                # too? Not sure if it makes sense, or if there's even a relevant schema
         
     | 
| 
       108 
     | 
    
         
            -
                # for how we're using em. So of just basic 'smoke' value. 
     | 
| 
      
 108 
     | 
    
         
            +
                # for how we're using em. So of just basic 'smoke' value.
         
     | 
| 
       109 
109 
     | 
    
         
             
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
       110 
110 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered ) { |config| config.strict }
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
       112 
112 
     | 
    
         
             
                atom_xsd_filepath = File.expand_path("../../support/atom.xsd.xml",  __FILE__)
         
     | 
| 
       113 
     | 
    
         
            -
                schema_xml        = Nokogiri::XML(File. 
     | 
| 
      
 113 
     | 
    
         
            +
                schema_xml        = Nokogiri::XML(File.open(atom_xsd_filepath))
         
     | 
| 
       114 
114 
     | 
    
         
             
                # modify to add processContents lax so it'll let us include elements from
         
     | 
| 
       115 
     | 
    
         
            -
                # external namespaces. 
     | 
| 
      
 115 
     | 
    
         
            +
                # external namespaces.
         
     | 
| 
       116 
116 
     | 
    
         
             
                schema_xml.xpath("//xs:any[@namespace='##other']", {"xs" => "http://www.w3.org/2001/XMLSchema"}).each do |node|
         
     | 
| 
       117 
117 
     | 
    
         
             
                  node["processContents"] = "lax"
         
     | 
| 
       118 
     | 
    
         
            -
                end 
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
      
 118 
     | 
    
         
            +
                end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
       120 
120 
     | 
    
         
             
                schema = Nokogiri::XML::Schema.from_document( schema_xml )
         
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
                assert_empty schema.validate(xml_response), "Validates with atom XSD schema" 
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                assert_empty schema.validate(xml_response), "Validates with atom XSD schema"
         
     | 
| 
       123 
123 
     | 
    
         
             
              end
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
       126 
126 
     | 
    
         
             
              def test_feed_metadata
         
     | 
| 
       127 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
       128 
     | 
    
         
            -
                xml_response = Nokogiri::XML( rendered ) 
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                assert_node(xml_response, "atom:feed") do |feed| 
     | 
| 
      
 127 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
      
 128 
     | 
    
         
            +
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                assert_node(xml_response, "atom:feed") do |feed|
         
     | 
| 
       131 
131 
     | 
    
         
             
                  assert_node(feed, "atom:title")
         
     | 
| 
       132 
132 
     | 
    
         
             
                  assert_node(feed, "atom:author")
         
     | 
| 
       133 
133 
     | 
    
         
             
                  assert_node(feed, "atom:updated")
         
     | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
       135 
135 
     | 
    
         
             
                  assert_node(feed, "opensearch:totalResults", :text => @total_items.to_s)
         
     | 
| 
       136 
136 
     | 
    
         
             
                  assert_node(feed, "opensearch:startIndex",   :text => @start.to_s)
         
     | 
| 
       137 
137 
     | 
    
         
             
                  assert_node(feed, "opensearch:itemsPerPage", :text => @per_page.to_s)
         
     | 
| 
       138 
138 
     | 
    
         
             
                end
         
     | 
| 
       139 
     | 
    
         
            -
             
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
       140 
140 
     | 
    
         
             
              end
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
       142 
142 
     | 
    
         
             
              def test_article_entry_example
         
     | 
| 
       143 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
       144 
     | 
    
         
            -
                xml_response = Nokogiri::XML( rendered ) 
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 143 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
      
 144 
     | 
    
         
            +
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
       146 
146 
     | 
    
         
             
                assert_node(xml_response, "./atom:feed/atom:entry[1]") do |article|
         
     | 
| 
       147 
     | 
    
         
            -
                  assert_node(article, "atom:title", :text => @article.title) 
     | 
| 
      
 147 
     | 
    
         
            +
                  assert_node(article, "atom:title", :text => @article.title)
         
     | 
| 
       148 
148 
     | 
    
         
             
                  assert_node(article, "prism:coverDate", :text => @article.year)
         
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
       150 
150 
     | 
    
         
             
                  assert_node(article, "prism:issn", :text => @article.issn)
         
     | 
| 
       151 
151 
     | 
    
         
             
                  assert_node(article, "prism:doi", :text => @article.doi)
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
       153 
153 
     | 
    
         
             
                  assert_node(article, "prism:volume", :text => @article.volume)
         
     | 
| 
       154 
154 
     | 
    
         
             
                  assert_node(article, "prism:number",  :text => @article.issue)
         
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
       156 
156 
     | 
    
         
             
                  assert_node(article, "prism:startingPage", :text => @article.start_page)
         
     | 
| 
       157 
157 
     | 
    
         
             
                  assert_node(article, "prism:endingPage",   :text => @article.end_page)
         
     | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
       159 
159 
     | 
    
         
             
                  assert_node(article, "prism:publicationName", :text => @article.source_title)
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
       161 
161 
     | 
    
         
             
                  abstract = article.at_xpath("atom:summary", @@namespaces)
         
     | 
| 
       162 
162 
     | 
    
         
             
                  assert_present abstract, "Has an abstract"
         
     | 
| 
       163 
163 
     | 
    
         
             
                  assert_equal "text", abstract["type"], "Abstract type text"
         
     | 
| 
       164 
164 
     | 
    
         
             
                  assert_equal @article.abstract, abstract.text
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
       166 
166 
     | 
    
         
             
                  assert_node(article, "dcterms:language[@vocabulary='http://dbpedia.org/resource/ISO_639-1']", :text => @article.language_iso_639_1)
         
     | 
| 
       167 
167 
     | 
    
         
             
                  assert_node(article, "dcterms:language[@vocabulary='http://dbpedia.org/resource/ISO_639-3']", :text => @article.language_iso_639_3)
         
     | 
| 
       168 
     | 
    
         
            -
                  assert_node(article, "dcterms:language[not(@vocabulary)]", :text => @article.language_str) 
     | 
| 
       169 
     | 
    
         
            -
             
     | 
| 
      
 168 
     | 
    
         
            +
                  assert_node(article, "dcterms:language[not(@vocabulary)]", :text => @article.language_str)
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
       170 
170 
     | 
    
         
             
                  assert_node(article, "dcterms:type[not(@vocabulary)]", :text => @article.format_str)
         
     | 
| 
       171 
     | 
    
         
            -
             
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
       172 
172 
     | 
    
         
             
                  assert_node(article, "dcterms:type[@vocabulary='http://schema.org/']", :text => @article.schema_org_type_url)
         
     | 
| 
       173 
173 
     | 
    
         
             
                  assert_node(article, "dcterms:type[@vocabulary='http://purl.org/NET/bento_search/ontology']", :text => @article.format)
         
     | 
| 
       174 
     | 
    
         
            -
             
     | 
| 
       175 
     | 
    
         
            -
                  # Just make sure right number of author elements, with right structure. 
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                  # Just make sure right number of author elements, with right structure.
         
     | 
| 
       176 
176 
     | 
    
         
             
                  assert_node(article, "atom:author/atom:name") do |authors|
         
     | 
| 
       177 
177 
     | 
    
         
             
                    assert_equal @article.authors.length, authors.length, "right number of author elements"
         
     | 
| 
       178 
178 
     | 
    
         
             
                  end
         
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
       180 
180 
     | 
    
         
             
                  # Links. Main link is just rel=alternate
         
     | 
| 
       181 
     | 
    
         
            -
                  assert_node(article, 
     | 
| 
      
 181 
     | 
    
         
            +
                  assert_node(article,
         
     | 
| 
       182 
182 
     | 
    
         
             
                    "atom:link[@rel='alternate'][@href='#{@article.link}']")
         
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
       184 
184 
     | 
    
         
             
                  # other links also there, default rel=related
         
     | 
| 
       185 
     | 
    
         
            -
                  assert_node(article, 
     | 
| 
      
 185 
     | 
    
         
            +
                  assert_node(article,
         
     | 
| 
       186 
186 
     | 
    
         
             
                    "atom:link[@rel='related'][@type='application/pdf'][@title='A link somewhere'][@href='http://example.org/label_and_type']")
         
     | 
| 
       187 
187 
     | 
    
         
             
                  assert_node(article,
         
     | 
| 
       188 
     | 
    
         
            -
                    "atom:link[@rel='something'][@href='http://example.org/rel']") 
     | 
| 
       189 
     | 
    
         
            -
                end 
     | 
| 
       190 
     | 
    
         
            -
             
     | 
| 
      
 188 
     | 
    
         
            +
                    "atom:link[@rel='something'][@href='http://example.org/rel']")
         
     | 
| 
      
 189 
     | 
    
         
            +
                end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       191 
191 
     | 
    
         
             
              end
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
             
     | 
| 
       194 
194 
     | 
    
         
             
              def test_with_unique_id
         
     | 
| 
       195 
     | 
    
         
            -
                @results  = @engine.search("find") 
     | 
| 
      
 195 
     | 
    
         
            +
                @results  = @engine.search("find")
         
     | 
| 
       196 
196 
     | 
    
         
             
                @results[0] = BentoSearch::ResultItem.new(
         
     | 
| 
       197 
     | 
    
         
            -
                  :title => "Something", 
     | 
| 
      
 197 
     | 
    
         
            +
                  :title => "Something",
         
     | 
| 
       198 
198 
     | 
    
         
             
                  :unique_id => "a000:/01",
         
     | 
| 
       199 
199 
     | 
    
         
             
                  :engine_id => "some_engine"
         
     | 
| 
       200 
200 
     | 
    
         
             
                )
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
       203 
203 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
       205 
205 
     | 
    
         
             
                with_unique_id = xml_response.xpath("./atom:feed/atom:entry", @@namespaces)[0]
         
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
       207 
207 
     | 
    
         
             
                assert_node(with_unique_id, "atom:id") do |id|
         
     | 
| 
       208 
208 
     | 
    
         
             
                  # based off of engine_id and unique_id
         
     | 
| 
       209 
209 
     | 
    
         
             
                  assert_includes id.text, "some_engine"
         
     | 
| 
       210 
210 
     | 
    
         
             
                  assert_includes id.text, "a000%3A%2F01"
         
     | 
| 
       211 
     | 
    
         
            -
                end 
     | 
| 
      
 211 
     | 
    
         
            +
                end
         
     | 
| 
       212 
212 
     | 
    
         
             
              end
         
     | 
| 
       213 
     | 
    
         
            -
             
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
       214 
214 
     | 
    
         
             
              def test_with_html_abstract
         
     | 
| 
       215 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
      
 215 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
       216 
216 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
       218 
218 
     | 
    
         
             
                with_html_abstract = xml_response.xpath("./atom:feed/atom:entry", @@namespaces)[1]
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
       220 
     | 
    
         
            -
                assert_node(with_html_abstract, "atom:summary[@type='html']", :text => @article_with_html_abstract.abstract.to_s) 
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                assert_node(with_html_abstract, "atom:summary[@type='html']", :text => @article_with_html_abstract.abstract.to_s)
         
     | 
| 
       221 
221 
     | 
    
         
             
              end
         
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
       223 
223 
     | 
    
         
             
              def test_book
         
     | 
| 
       224 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
      
 224 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
       225 
225 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
       227 
227 
     | 
    
         
             
                book = xml_response.xpath("./atom:feed/atom:entry", @@namespaces)[4]
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
       229 
229 
     | 
    
         
             
                assert_node(book, "dcterms:type[@vocabulary='http://purl.org/NET/bento_search/ontology']", :text => "Book")
         
     | 
| 
       230 
230 
     | 
    
         
             
                assert_node(book, "dcterms:type[@vocabulary='http://schema.org/']", :text => "http://schema.org/Book")
         
     | 
| 
       231 
     | 
    
         
            -
             
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
       232 
232 
     | 
    
         
             
                assert_node(book, "dcterms:publisher", :text => @book.publisher)
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
       234 
234 
     | 
    
         
             
                assert_node(book, "prism:isbn", :text => @book.isbn)
         
     | 
| 
       235 
     | 
    
         
            -
             
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
       236 
236 
     | 
    
         
             
                assert_node(book, "bibo:oclcnum", :text => @book.oclcnum)
         
     | 
| 
       237 
237 
     | 
    
         
             
              end
         
     | 
| 
       238 
     | 
    
         
            -
             
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
       239 
239 
     | 
    
         
             
              def test_with_full_date
         
     | 
| 
       240 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results} 
     | 
| 
      
 240 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => @results}
         
     | 
| 
       241 
241 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
      
 242 
     | 
    
         
            +
             
     | 
| 
       243 
243 
     | 
    
         
             
                with_full_date = xml_response.at_xpath("./atom:feed/atom:entry[4]", @@namespaces)
         
     | 
| 
       244 
     | 
    
         
            -
             
     | 
| 
       245 
     | 
    
         
            -
                assert_node(with_full_date, "prism:coverDate", :text => "2011-05-06") 
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                assert_node(with_full_date, "prism:coverDate", :text => "2011-05-06")
         
     | 
| 
       246 
246 
     | 
    
         
             
              end
         
     | 
| 
       247 
247 
     | 
    
         | 
| 
       248 
248 
     | 
    
         
             
              def test_nil_results
         
     | 
| 
       249 
249 
     | 
    
         
             
                # should render a more or less empty atom response for
         
     | 
| 
       250 
250 
     | 
    
         
             
                # nil results, convenient to not raise on nil
         
     | 
| 
       251 
     | 
    
         
            -
                render :template => "bento_search/atom_results", :locals => {:atom_results => nil} 
     | 
| 
      
 251 
     | 
    
         
            +
                render :template => "bento_search/atom_results", :locals => {:atom_results => nil}
         
     | 
| 
       252 
252 
     | 
    
         
             
              end
         
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
       254 
254 
     | 
    
         
             
              def test_locals_for_feed_name_and_author
         
     | 
| 
       255 
     | 
    
         
            -
                render( :template => "bento_search/atom_results", 
     | 
| 
       256 
     | 
    
         
            -
                  :locals => {:atom_results => @results, 
     | 
| 
      
 255 
     | 
    
         
            +
                render( :template => "bento_search/atom_results",
         
     | 
| 
      
 256 
     | 
    
         
            +
                  :locals => {:atom_results => @results,
         
     | 
| 
       257 
257 
     | 
    
         
             
                              :feed_name => "My Feed",
         
     | 
| 
       258 
258 
     | 
    
         
             
                              :feed_author_name => "ACME Seed And Feed Products"}
         
     | 
| 
       259 
259 
     | 
    
         
             
                )
         
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
       261 
261 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
       263 
263 
     | 
    
         
             
                assert_node(xml_response, "./atom:feed/atom:title", :text => "My Feed")
         
     | 
| 
       264 
264 
     | 
    
         
             
                assert_node(xml_response, "./atom:feed/atom:author/atom:name", :text => "ACME Seed And Feed Products")
         
     | 
| 
       265 
265 
     | 
    
         
             
              end
         
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
      
 266 
     | 
    
         
            +
             
     | 
| 
       267 
267 
     | 
    
         
             
              def test_html_in_title_stripped
         
     | 
| 
       268 
268 
     | 
    
         
             
                results = BentoSearch::Results.new
         
     | 
| 
       269 
269 
     | 
    
         
             
                results << BentoSearch::ResultItem.new(
         
     | 
| 
       270 
270 
     | 
    
         
             
                  :title => "html <b>title</b>".html_safe
         
     | 
| 
       271 
271 
     | 
    
         
             
                )
         
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
       273 
273 
     | 
    
         
             
                render(:template => "bento_search/atom_results", :locals => {:atom_results => results})
         
     | 
| 
       274 
274 
     | 
    
         
             
                xml_response = Nokogiri::XML( rendered )
         
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
       276 
276 
     | 
    
         
             
                assert_node(xml_response, "./atom:feed/atom:entry[1]/atom:title", :text => "html title")
         
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
       278 
278 
     | 
    
         
             
              end
         
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
       281 
281 
     | 
    
         
             
            end
         
     |