Sha256: b63058ad616ba3feadf8ce4fbe2656b5c382e1c02c22fe41277440c1bb32e339

Contents?: true

Size: 1.51 KB

Versions: 13

Compression:

Stored size: 1.51 KB

Contents

describe TrophyHelper, type: :helper do
  describe "#display_trophy_link" do
    let(:user) { FactoryGirl.create(:user) }
    let(:id) { '9999' }

    let(:text_attributes) { '[data-add-text="Highlight Work on Profile"][data-remove-text="Unhighlight Work"]' }
    let(:url_attribute) { "[data-url=\"/works/#{id}/trophy\"]" }

    context "when there is no trophy" do
      it "has a link for highlighting" do
        out = helper.display_trophy_link(user, id) { |text| "foo #{text} bar" }
        node = Capybara::Node::Simple.new(out)
        expect(node).to have_selector("a.trophy-class.trophy-off#{text_attributes}#{url_attribute}")
        expect(node).to have_link 'foo Highlight Work on Profile bar', href: '#'
      end
    end

    context "when there is a trophy" do
      before do
        user.trophies.create(work_id: id)
      end

      it "has a link for highlighting" do
        out = helper.display_trophy_link(user, id) { |text| "foo #{text} bar" }
        node = Capybara::Node::Simple.new(out)
        expect(node).to have_selector("a.trophy-class.trophy-on#{text_attributes}#{url_attribute}")
        expect(node).to have_link 'foo Unhighlight Work bar', href: '#'
      end

      it "allows removerow to be passed" do
        out = helper.display_trophy_link(user, id, data: { removerow: true }) { |text| "foo #{text} bar" }
        node = Capybara::Node::Simple.new(out)
        expect(node).to have_selector("a.trophy-class.trophy-on[data-removerow=\"true\"]#{text_attributes}#{url_attribute}")
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sufia-7.4.1 spec/helpers/trophy_helper_spec.rb
sufia-7.4.0 spec/helpers/trophy_helper_spec.rb
sufia-7.3.1 spec/helpers/trophy_helper_spec.rb
sufia-7.3.0 spec/helpers/trophy_helper_spec.rb
sufia-7.3.0.rc3 spec/helpers/trophy_helper_spec.rb
sufia-7.3.0.rc2 spec/helpers/trophy_helper_spec.rb
sufia-7.3.0.rc1 spec/helpers/trophy_helper_spec.rb
sufia-7.2.0 spec/helpers/trophy_helper_spec.rb
sufia-7.1.0 spec/helpers/trophy_helper_spec.rb
sufia-7.0.0 spec/helpers/trophy_helper_spec.rb
sufia-7.0.0.rc2 spec/helpers/trophy_helper_spec.rb
sufia-7.0.0.rc1 spec/helpers/trophy_helper_spec.rb
sufia-7.0.0.beta4 spec/helpers/trophy_helper_spec.rb