<commit_before>require 'spec_helper'


feature "As a consumer I want to check out my cart", js: true do
  include AuthenticationWorkflow
  include ShopWorkflow
  include WebHelper
  include UIComponentHelper

  let(:distributor) { create(:distributor_enterprise) }
  let(:supplier) { create(:supplier_enterprise) }
  let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
  let(:product) { create(:simple_product, supplier: supplier) }
  let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }

  before do
    set_order order
    add_product_to_cart
  end

  it "shows the current distributor oncheckout" do
    visit checkout_path 
    page.should have_content distributor.name
  end

  describe "with shipping methods" do
    let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") }
    let(:sm2) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue") }
    before do
      distributor.shipping_methods << sm1 
      distributor.shipping_methods << sm2 
    end

    context "on the checkout page" do
      before do
        visit checkout_path
      end

      it "shows all shipping methods, but doesn't show ship address when not needed" do
        toggle_accordion "Shipping"
        page.should have_content "Frogs"
        page.should have_content "Donkeys"
      end

      context "When shipping method requires an address" do
        before do
          toggle_accordion "Shipping"
          choose(sm1.name)<commit_msg>Patching a spec issue with occlusion<commit_after>require 'spec_helper'


feature "As a consumer I want to check out my cart", js: true do
  include AuthenticationWorkflow
  include ShopWorkflow
  include WebHelper
  include UIComponentHelper

  let(:distributor) { create(:distributor_enterprise) }
  let(:supplier) { create(:supplier_enterprise) }
  let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
  let(:product) { create(:simple_product, supplier: supplier) }
  let(:order) { create(:order, order_cycle: order_cycle, distributor: distributor) }

  before do
    set_order order
    add_product_to_cart
  end

  it "shows the current distributor oncheckout" do
    visit checkout_path 
    page.should have_content distributor.name
  end

  describe "with shipping methods" do
    let(:sm1) { create(:shipping_method, require_ship_address: true, name: "Frogs", description: "yellow") }
    let(:sm2) { create(:shipping_method, require_ship_address: false, name: "Donkeys", description: "blue") }
    before do
      distributor.shipping_methods << sm1 
      distributor.shipping_methods << sm2 
    end

    context "on the checkout page" do
      before do
        visit checkout_path
      end

      it "shows all shipping methods, but doesn't show ship address when not needed" do
        toggle_accordion "Shipping"
        page.should have_content "Frogs"
        page.should have_content "Donkeys"
      end

      context "When shipping method requires an address" do
        before do
          toggle_accordion "Shipping"
          find(:radio_button, sm1.name, {}).trigger "click"
{'fraction_non_alphanumeric': 0.08389057750759879, 'fraction_numerical': 0.00303951367781155, 'mean_word_length': 3.7973760932944605, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883558', 'n_tokens_mistral': 978, 'n_tokens_neox': 923, 'n_words': 283}