./test/functional/resolve_controller_test.rb in umlaut-3.1.1 vs ./test/functional/resolve_controller_test.rb in umlaut-3.2.0

- old
+ new

@@ -5,23 +5,32 @@ require 'rack/utils' class ResolveControllerTest < ActionController::TestCase extend TestWithCassette fixtures :requests, :referents, :referent_values, :dispatched_services, :service_responses - + setup do @controller = ResolveController.new end - + test_with_cassette("nytimes by issn", :resolve, :match_requests_on => [:method, :uri_without_ctx_tim]) do umlaut_request = requests(:nytimes) get :index, "umlaut.request_id" => umlaut_request.id assert_response :success assert_select "title", "Find It | The New York times" assert_select "h1", "Find It" + # Resource title assertion assert_select "h2.title", "The New York times" - + # Background updater assertions + assert_select ".umlaut-resolve-container > script" do |scripts| + assert_equal 1, scripts.size + # Make sure we have an HtmlUpdater in our script + scripts.each do |script| + assert_match /var updater = new Umlaut.HtmlUpdater\("http:\/\/test\.host\/", "umlaut\.request_id=#{umlaut_request.id}"\);/, script.to_s + end + end + # Citation section assertions assert_select ".umlaut-main .umlaut-resource-info dl.citation-info" do |dls| assert_equal 1, dls.size dls.each do |dl| assert_select dl, "dt", 1 assert_select dl, "dt" do |dts| @@ -31,20 +40,22 @@ assert_select dl, "dd" do |dds| assert dds.last, "0362-4331" end end end - # puts @response.body + # Fulltext section assertions assert_select ".umlaut-main .umlaut-section.fulltext" do |sections| assert_equal 1, sections.size sections.each do |section| assert_select section, ".response_list", 1 assert_select section, ".response_list" do |response_lists| + assert_select section, ".section_heading h3", { :count => 1, :text => "Online Access" } assert_select section, "li.response_item", 4 end end end + # Holding section assertions assert_select ".umlaut-main .umlaut-section.holding" do |sections| assert_equal 1, sections.size sections.each do |section| assert_select section, ".umlaut-holdings", 1 assert_select section, ".umlaut-holdings .umlaut-holding" do |holdings| @@ -60,22 +71,43 @@ assert_select holding, ".umlaut-holding-notes", 1 end end end end + # Export citation section assertions assert_select ".umlaut-sidebar .umlaut-section.export_citation" do |sections| assert_equal 1, sections.size sections.each do |section| + assert_select section, ".section_heading h3", { :count => 1, :text => "Export tool" } assert_select section, ".response_list", 1 end end + # Highlighted link section assertions assert_select ".umlaut-sidebar .umlaut-section.highlighted_link" do |sections| assert_equal 1, sections.size sections.each do |section| + assert_select section, ".section_heading h3", { :count => 1, :text => "See also" } assert_select section, ".response_list", 1 end end + # Help section assertions + assert_select ".umlaut-sidebar .umlaut-section.help" do |sections| + assert_equal 1, sections.size + sections.each do |section| + assert_select section, ".section_heading h3", { :count => 1, :text => "Question? Problem? Contact:" } + assert_select section, ".response_list", 1 + end + end + # Modal assertions + assert_select ".modal" do |modals| + assert_equal 1, modals.size + modals.each do |modal| + assert_select modal, ".modal-header", { :count => 1 } + assert_select modal, ".modal-body", { :count => 1 } + assert_select modal, ".modal-footer", { :count => 1 } + end + end end test_with_cassette("POSTed OpenURL redirects to GET", :resolve, :match_requests_on => [:method, :uri_without_ctx_tim]) do # an actual post request Gale GREENr was sending us pparams = {"genre"=>"article", "sid"=>"gale:GRNR", "__char_set"=>"utf8", "spage"=>"138", "issn"=>"0016-7398", "issue"=>"2", "pid"=>"info:sid/gale:ugnid:balt85423", "date"=>"2010", "aulast"=>"Hedley, Peter J.", "au"=>"Hedley, Peter J.", "atitle"=>"Evolution of the Irrawaddy delta region since 1850.(Report)", "title"=>"The Geographical Journal", "aufirst"=>"Hedley, Peter J.", "volume"=>"176"} @@ -83,14 +115,14 @@ assert_response :redirect redirect_uri = URI.parse(@response.redirect_url) - assert_equal "/resolve", redirect_uri.path + assert_equal "/resolve", redirect_uri.path # Redirected params is a subset of pparams, pparams can have extra - # stuff maybe, we don't care. + # stuff maybe, we don't care. redirected_params = Rack::Utils.parse_nested_query redirect_uri.query assert (redirected_params.to_a - pparams.to_a).empty?, "Redirected params include all of original POSTed params" end test_with_cassette("fulltext with edition warning", :resolve, :match_requests_on => [:method, :uri_without_ctx_tim]) do @@ -107,11 +139,11 @@ end end test_with_cassette("no holdings", :resolve, :match_requests_on => [:method, :uri_without_ctx_tim]) do umlaut_request = requests(:advocate) - get(:index, {'umlaut.request_id' => umlaut_request.id, "umlaut.institution" => "NYU"}) + get(:index, {'umlaut.request_id' => umlaut_request.id}) assert_response :success assert_select 'div#fulltext ul.response_list li.response_item' do |elements| assert_equal(1, elements.size) elements.each do |element| assert_select element, "a", {:count => 1, :href => "", :text => "Gale Cengage Newsstand"} @@ -119,6 +151,19 @@ end end # Assert no holdings assert_select 'div#holding div.umlaut-holdings', :count => 0 end -end \ No newline at end of file + + test_with_cassette("manually entered", :resolve, :match_requests_on => [:method, :uri_without_ctx_tim]) do + umlaut_request = requests(:manually_entered) + get(:index, {'umlaut.request_id' => umlaut_request.id}) + assert_response :success + assert_select('.resource_info_sections > div.alert.alert-error', + {:text => "Warning: Find It does not know about a journal with this name. Please check your entry."}) do |error_divs| + assert_equal 1, error_divs.size, "More than one error div" + error_divs.each do |error_div| + assert_select error_div, 'i.umlaut_icons-famfamfam-error', 1 + end + end + end +end