Sha256: 56747d6ba256a03364d5bbe3e7286a9b033183ab3f9c0c09bcd93c7cdbbbe101

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

require "test_helper"
require "govuk_content_models/test_helpers/local_services"

class LocalTransactionEditionTest < ActiveSupport::TestCase
  include LocalServicesHelper
  BINS = 1
  HOUSING_BENEFIT = 2
  NONEXISTENT = 999

  def setup
    @artefact = FactoryGirl.create(:artefact)
  end

  test "should report that an authority provides a service" do
    bins_transaction = LocalTransactionEdition.new(
      lgsl_code:     BINS,
      title:         "Transaction",
      slug:          "slug",
      panopticon_id: @artefact.id
    )
    county_council = make_authority_providing(BINS)
    assert bins_transaction.service_provided_by?(county_council.snac)
  end

  test "should report that an authority does not provide a service" do
    bins_transaction = LocalTransactionEdition.new(
      lgsl_code:     BINS,
      title:         "Transaction",
      slug:          "slug",
      panopticon_id: @artefact.id
    )
    county_council = make_authority_providing(HOUSING_BENEFIT)
    refute bins_transaction.service_provided_by?(county_council.snac)
  end

  test "should be a transaction search format" do
    bins_transaction = LocalTransactionEdition.new(
      lgsl_code:     BINS,
      title:         "Transaction",
      slug:          "slug",
      panopticon_id: @artefact.id
    )
    assert_equal "transaction", bins_transaction.search_format
  end


  test "should validate on save that a LocalService exists for that lgsl_code" do
    s = LocalService.create!(lgsl_code: BINS, providing_tier: %w{county unitary})

    lt = LocalTransactionEdition.new(lgsl_code: NONEXISTENT, title: "Foo", slug: "foo", panopticon_id: @artefact.id)
    lt.save
    assert !lt.valid?

    lt = LocalTransactionEdition.new(lgsl_code: s.lgsl_code, title: "Bar", slug: "bar", panopticon_id: @artefact.id)
    lt.save
    assert lt.valid?
    assert lt.persisted?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
govuk_content_models-37.0.0 test/models/local_transaction_edition_test.rb
govuk_content_models-36.0.0 test/models/local_transaction_edition_test.rb
govuk_content_models-35.0.1 test/models/local_transaction_edition_test.rb
govuk_content_models-35.0.0 test/models/local_transaction_edition_test.rb