Sha256: 3a25fa8a02befe8b1d112753434eda632e5e9029ed542087aa37ed1b64ac86bf

Contents?: true

Size: 1.67 KB

Versions: 19

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

class ProductTest < ActiveSupport::TestCase

  test 'validate status' do
    assert_equal 'active', Product.new.status
    assert_equal 'hidden', Product.new(status: 'hidden').status
  end

  test 'should create a default picture record' do
    assert_equal 1, create(:product).pictures.size
  end

  test '#to_param' do
    assert_equal 'test', Product.new(permalink: 'test').to_param
  end

end

class ProductStatusTest < ActiveSupport::TestCase

  setup do
    #Product.delete_all
    @product1 = create :product, status: 'active', name: 'product1'
    @product2 = create :product, status: 'hidden', name: 'product2'
    @product3 = create :product, status: 'hidden', name: 'product3'
    @product4 = create :product, name: 'product4'
    @product5 = create :product, status: 'sold_out', name: 'product5'
  end

  test 'various status' do
    assert_equal 5, Product.count
    assert_must_have_same_records [ @product2, @product3 ], Product.hidden
    assert_must_have_same_records  [ @product5 ], Product.sold_out
  end

  test 'active status' do
    assert_must_have_same_records [ @product1, @product4 ], Product.active
  end

end

class ProductFindOrBuildForField < ActiveSupport::TestCase
  setup do
    @product = create(:product)
    @field1  = create(:text_custom_field)
    @field2  = create(:number_custom_field)
    @answer  = @product.custom_field_answers.create(custom_field: @field1, value: 23)
  end

  test 'needs to build new answer' do
    @answer = @product.find_or_build_answer_for_field(@field2)
    assert_equal nil, @answer.id
  end

  test 'needs to return exisitng answer' do
    assert_equal @answer, @product.find_or_build_answer_for_field(@field1)
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.12 test/unit/product_test.rb
nimbleshop_core-0.0.11 test/unit/product_test.rb
nimbleshop_core-0.0.10 test/unit/product_test.rb
nimbleshop_core-0.0.9 test/unit/product_test.rb
nimbleshop_core-0.0.8 test/unit/product_test.rb
nimbleshop_core-0.0.7 test/unit/product_test.rb
nimbleshop_core-0.0.5 test/unit/product_test.rb
nimbleshop_core-0.0.4.beta1 test/unit/product_test.rb
nimbleshop_core-0.0.4 test/unit/product_test.rb
nimbleshop_core-0.0.3 test/unit/product_test.rb
nimbleshop_core-0.0.2 test/unit/product_test.rb
nimbleshop_core-0.0.2.beta1 test/unit/product_test.rb
nimbleshop_core-0.0.1 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc6 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc5 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc4 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc3 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc2 test/unit/product_test.rb
nimbleshop_core-0.0.1.rc1 test/unit/product_test.rb