Sha256: 5fbdc6f9acc6f68ab0c63b7c20f0e2618be879fb61d5a7134da0b3b994fc0c6d

Contents?: true

Size: 936 Bytes

Versions: 6

Compression:

Stored size: 936 Bytes

Contents

require 'spec_helper'

describe AuthoritiesController do
  describe "#query" do
    it "should return an array of hashes" do
      mock_hits = [{label: "English", uri: "http://example.org/eng"},
                   {label: "Environment", uri: "http://example.org/env"},
                   {label: "Edge", uri: "http://example.org/edge"},
                   {label: "Edgar", uri: "http://example.org/edga"},
                   {label: "Eddie", uri: "http://example.org/edd"},
                   {label: "Economics", uri: "http://example.org/eco"}]
      LocalAuthority.should_receive(:entries_by_term).and_return(mock_hits)
      xhr :get, :query, model: "generic_files", term: "subject", q: "E"
      response.should be_success
      JSON.parse(response.body).count.should == 6
      JSON.parse(response.body)[0]["label"].should == "English"
      JSON.parse(response.body)[0]["uri"].should == "http://example.org/eng"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sufia-4.0.1 spec/controllers/authorities_controller_spec.rb
sufia-4.0.0 spec/controllers/authorities_controller_spec.rb
sufia-4.0.0.rc2 spec/controllers/authorities_controller_spec.rb
sufia-4.0.0.rc1 spec/controllers/authorities_controller_spec.rb
sufia-4.0.0.beta4 spec/controllers/authorities_controller_spec.rb
sufia-4.0.0.beta3 spec/controllers/authorities_controller_spec.rb