# Copyright 2015 CareerBuilder, LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
require 'spec_helper'
module Cb
  describe Responses::AnonymousSavedSearch::Create do
    let(:json_hash) do
      {
        'Errors' => [],
        'Status' => 'Success',
        'ExternalID' => 'testID',
        'AnonymousSavedSearch' => {
          'SearchName' => 'search name',
          'IsDailyEmail' => 'true',
          'DailyValue' => '',
          'EmailAddress' => 'email@example.com',
          'CobrandCode' => '',
          'SiteID' => '',
          'HostSite' => 'host site',
          'SearchParameters' => {
            'BooleanOperator' => 'boolean operator',
            'Category' => '',
            'EducationCode' => 'education code',
            'EmpType' => 'emp type',
            'ExcludeCompanyNames' => 'exclude company names',
            'ExcludeJobTitles' => 'exclude job titles',
            'ExcludeKeywords' => 'exclude keywords',
            'ExcludeNational' => false,
            'IndustryCodes' => 'industry codes',
            'JobTitle' => 'job title',
            'Keywords' => 'jobs',
            'Location' => 'atlanta',
            'OrderBy' => 'order by',
            'OrderDirection' => 'order direction',
            'PayHigh' => 100,
            'PayInfoOnly' => false,
            'PayLow' => 10,
            'PostedWithin' => 3,
            'Radius' => 50,
            'SpecificEducation' => false,
            'JCPositionLevel' => '',
            'JCLocation' => '',
            'JCAdvertiserflags' => '',
            'JCJobNature' => '',
            'JCSchools' => '',
            'JobCategory' => 'job category',
            'Company' => '',
            'City' => '',
            'State' => '',
            'Country' => nil
          }
        }
      }
    end

    context '#new' do
      it 'returns a response object with a filled in model' do
        expect(Responses::AnonymousSavedSearch::Create.new(json_hash).class).to eq Responses::AnonymousSavedSearch::Create
      end

      it 'instantiates new model objects' do
        response = Responses::AnonymousSavedSearch::Create.new(json_hash)

        expect(response.model.class).to eq(Cb::Models::SavedSearch)
      end
    end
  end
end
