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