Sha256: c37542247078c9e5ffcda7018bb3532e41aeb5ef7efeba7290d95660e6ab2aa1

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

# -*- coding: utf-8 -*-
require 'test_helper'

Webrat.configure do |config|
  config.mode = :rails
end

class TrolliedTest < ActionController::IntegrationTest
  context "A gets_trollied object" do
    include Webrat::HaveTagMatcher
    setup do
      @item = Factory.create(:item)
      @user = Factory.create(:user)
    end

    should "have an add to cart link on its show page" do
      visit "/items/#{@item.id}"
      assert_have_tag "input", :type => "submit", :value => I18n.t('gets_trollied_helper.add_to_trolley')
    end

    should "be able to submit add to trolley request and be added to trolley" do
      visit "/items/#{@item.id}"
      click_button "add to cart"
      assert_have_tag "title", :content => I18n.t('trolleys.show.your_title')
      assert_have_tag "a", :href => "/items/#{@item.id}", :content => @item.description_for_purchasing
    end

    # if an item has been placed in trolley previously, the add to trolley is replaced with link to trolley, and status of item shown
    should "after being added to a trolley, the object on its show page report that it is in the trolley, rather than providing the button to add to trolley" do
      @trolley = @user.trolley
      @trolley.add(@item)

      visit "/items/#{@item.id}"
      assert_have_tag "div", :content => I18n.t('gets_trollied_helper.in_trolley')
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trollied-0.1.4 test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb
trollied-0.1.3 test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb
trollied-0.1.2 test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb
trollied-0.1.1 test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb
trollied-0.1.0 test/full_2_3_5_app_with_tests/test/integration/gets_trollied_test.rb