Sha256: d0f8b1ec6db38ea92cfd5db4d916198451ba9a79ac6231b8225e9eb3d858c730

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

require 'rails_helper'

RSpec.describe TbCommerce::Option, type: :model do

  describe '#label' do
    it 'should return the option set name' do
      set = FactoryGirl.create(:tb_commerce_option_set)
      option = FactoryGirl.create(:tb_commerce_option, :option_set => set)
      expect(option.label).to eq(set.name)
    end
  end

  describe '#set_sort_order' do
    it 'should set the sort_order to n+1' do
      set = FactoryGirl.create(:tb_commerce_option_set)
      option_a = FactoryGirl.create(:tb_commerce_option, :option_set => set)
      option_b = FactoryGirl.create(:tb_commerce_option, :option_set => set)
      expect(option_b.sort_order).to eq(option_a.sort_order+1)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tb_commerce-0.0.4 spec/models/tb_commerce/option_spec.rb
tb_commerce-0.0.3 spec/models/tb_commerce/option_spec.rb
tb_commerce-0.0.2 spec/models/tb_commerce/option_spec.rb