Sha256: 6141e60ddc6fbc4bedb836af973d6eb4eb13cf9d53b2a0ad65192475c0bf3974

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Applicants::ApplicantPanelParameterSet do
  it { should belong_to :applicant }
  it { should belong_to :panel }
  it { should have_db_column :parameters }

  describe "ApplicantPanelParameterSet" do
    context "with paramters" do
      before :each do
        @parameters = '{"panel":"1","rid":"mypoints","visit_id":"abcd","another":"12341324"}'
        @applicant_panel_parameter_set = Applicants::ApplicantPanelParameterSet.new(applicant_id: 1, panel_id: 1, parameters: @parameters)
      end

      it "parsed_parameters is set" do
        @applicant_panel_parameter_set.parameters.should eq @parameters
      end

      it "referral id set" do
        @applicant_panel_parameter_set.rid.should eq "mypoints"
      end

      it "MyPoints visit id set" do
        @applicant_panel_parameter_set.visit_id.should eq "abcd"
      end
    end

    context "without parameters" do
      before :each do
        @parameters = "{}"
        @applicant_panel_parameter_set = Applicants::ApplicantPanelParameterSet.new(applicant_id: 1, panel_id: 1, parameters: @parameters)
      end

      it "parsed_parameters is empty" do
        @applicant_panel_parameter_set.parsed_parameters.should be_empty
      end

      it "referral id is nil" do
        @applicant_panel_parameter_set.rid.should be_nil
      end

      it "MyPoints visit id set" do
        @applicant_panel_parameter_set.visit_id.should be_nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
applicants-0.11.0 spec/models/applicants/applicant_panel_parameter_set_spec.rb