ur-product 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,4 +24,8 @@ Feature: UR Product
24
24
  Scenario: Check if a product has an image
25
25
  Given I want the product 100001
26
26
  When I get the product
27
- Then it should have image
27
+ Then it should have image
28
+
29
+ # Scenario: Boolean search for sab:H* should return 3 or more hits
30
+ # Given I search for "sab:H*"
31
+ # Then I should get 3 or more hits
@@ -22,6 +22,22 @@ Given /^I want the products (.+)$/ do |ids|
22
22
  @ids = ids.split(' and ')
23
23
  end
24
24
 
25
+ Given /^I search for "([^\"]*)"$/ do |query|
26
+ @search = UR::Product.search({
27
+ :per_page => 10,
28
+ :qt => 'internalfacets',
29
+ :defType => 'lucene',
30
+ :q => query
31
+ })
32
+
33
+ puts @search.inspect
34
+
35
+ end
36
+
37
+ Then /^I should get (\d+) or more hits$/ do |num_hits|
38
+ @search.num_hits.should >= num_hits
39
+ end
40
+
25
41
  # When
26
42
 
27
43
  When /^I get the product$/ do
@@ -8,7 +8,8 @@ FakeWeb.allow_net_connect = false
8
8
  faked_urls = [
9
9
  'http://metadata.ur.se/products/100001.json',
10
10
  'http://metadata.ur.se/products.json?ur_product_ids=100001,150423',
11
- 'http://assets.ur.se/id/100001/images/1.jpg'
11
+ 'http://assets.ur.se/id/100001/images/1.jpg',
12
+ 'http://services.ur.se/search/select?qt=internalfacets&wt=ruby&defType=lucene&q=sab%3AH%2A&rows=10'
12
13
  ]
13
14
 
14
15
  faked_urls.each do |url|
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'yajl/json_gem'
2
2
  require 'restclient'
3
3
 
4
4
  # Module for Utbildningsradion AB (http://ur.se/)
data/lib/ur/product.rb CHANGED
@@ -235,5 +235,13 @@ module UR
235
235
  def has_url?
236
236
  (url)
237
237
  end
238
+
239
+ def short_title
240
+ if !remainder_of_title.nil?
241
+ remainder_of_title
242
+ else
243
+ title
244
+ end
245
+ end
238
246
  end
239
247
  end
data/lib/ur/search.rb CHANGED
@@ -33,7 +33,7 @@ module UR
33
33
  end
34
34
 
35
35
  def ok?
36
- !@solr.nil? && @solr.ok?
36
+ (!@solr.nil? && @solr && @solr.ok?)
37
37
  end
38
38
 
39
39
  def num_found
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 8
8
- version: "0.8"
7
+ - 9
8
+ version: "0.9"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Peter Hellberg
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-05-21 00:00:00 +02:00
16
+ date: 2010-05-25 00:00:00 +02:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency