Sha256: ced34e7392013497f55963f1b20b03638264fbc2ab37f3a4b1cd45ac70dc297c
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
require 'spec_helper' describe CatalogController do describe "when logged in" do before :all do ActiveFedora::Base.destroy_all end let(:user) { FactoryGirl.create(:user) } let!(:work1) { FactoryGirl.create(:generic_work, user: user) } let!(:work2) { FactoryGirl.create(:generic_work) } before do sign_in user end after do work1.destroy work2.destroy end context "Searching all works" do it "should return all the works" do get 'index', 'f' => {'generic_type_sim' => 'Work'} response.should be_successful assigns(:document_list).map(&:id).should == [work1.id, work2.id] end end context "searching just my works" do it "should return just my works" do get 'index', works: 'mine' response.should be_successful assigns(:document_list).map(&:id).should == [work1.id] end end context "index page" do let!(:collection) { FactoryGirl.create(:collection, user: user) } after do collection.destroy end it "assigns options for adding items to collection" do get 'index' assigns(:collection_options).should == [collection] assigns(:profile_collection_options).should == [] end end context "when json is requested for autosuggest of related works" do let!(:work) { FactoryGirl.create(:generic_work, user: user, title:"All my #{srand}") } after do work.destroy end it "should return json" do xhr :get, :index, format: :json, q: work.title json = JSON.parse(response.body) # Grab the doc corresponding to work and inspect the json work_json = json["docs"].first work_json.should == {"pid"=>work.pid, "title"=> "#{work.title} (#{work.human_readable_type})"} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
curate-0.5.4 | spec/controllers/catalog_controller_spec.rb |
curate-0.5.2 | spec/controllers/catalog_controller_spec.rb |