Sha256: 9a75e2eccd490f740820ac9fdd9c1af7e76a61ba1149baee3a3b99b9a94bad0d

Contents?: true

Size: 1.81 KB

Versions: 13

Compression:

Stored size: 1.81 KB

Contents

require 'spec_helper'

describe SufiaHelper do
  describe "link_to_profile" do
    it "should use User#to_params" do
      u = User.new
      u.stub(:user_key).and_return('justin@example.com')
      User.should_receive(:find_by_user_key).with('justin@example.com').and_return(u)
      helper.link_to_profile('justin@example.com').should == "<a href=\"/users/justin@example-dot-com\">justin@example.com</a>"
    end
  end

  describe "selected facet" do
    let(:blacklight_config) { Blacklight::Configuration.new }

    before(:each) do
      helper.stub(:blacklight_config).and_return blacklight_config
      helper.stub(:url_for).and_return('http://example.com')
    end


    describe "render_selected_facet_value" do
      it "be html_safe and not have the remove link" do
        item = double("item", :value=>'two', :hits=>9)
        ret_val = helper.render_facet_value("one", item)
        doc = Nokogiri::HTML(ret_val)
        filter = doc.xpath("//a[@class='facet_select']")
        filter.text.should == item.value
        ret_val.should be_html_safe
      end
      it "use facet_display_value" do
        item = double("item", :value=>'two', :hits=>9)
        helper.stub(:facet_display_value).and_return('four')
        ret_val = helper.render_facet_value("one", item)
        doc = Nokogiri::HTML(ret_val)
        filter = doc.xpath("//a[@class='facet_select']")
        filter.text.should == 'four'
      end
      it "use facet_display_value for dashboard" do
        params[:controller] = "dashboard"
        item = double("item", :value=>'two', :hits=>9)
        helper.stub(:facet_display_value).and_return('four')
        ret_val = helper.render_facet_value("one", item)
        doc = Nokogiri::HTML(ret_val)
        filter = doc.xpath("//a[@class='facet_select']")
        filter.text.should == 'four'
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sufia-3.5.0 spec/helpers/sufia_helper_spec.rb
sufia-3.4.0 spec/helpers/sufia_helper_spec.rb
sufia-3.4.0.rc4 spec/helpers/sufia_helper_spec.rb
sufia-3.4.0.rc3 spec/helpers/sufia_helper_spec.rb
sufia-3.3.1 spec/helpers/sufia_helper_spec.rb
sufia-3.4.0.rc2 spec/helpers/sufia_helper_spec.rb
sufia-3.4.0.rc1 spec/helpers/sufia_helper_spec.rb
sufia-3.3.0 spec/helpers/sufia_helper_spec.rb
sufia-3.2.1 spec/helpers/sufia_helper_spec.rb
sufia-3.1.3 spec/helpers/sufia_helper_spec.rb
sufia-3.1.2 spec/helpers/sufia_helper_spec.rb
sufia-3.1.1 spec/helpers/sufia_helper_spec.rb
sufia-3.1.0 spec/helpers/sufia_helper_spec.rb