require 'spec_helper'

describe 'KeypayIntegration::Sync::LeaveCategory', configure: true do
  describe 'pull_all' do
    let(:object_type) { 'leave_category' }
    let(:klass) { 'LeaveCategory' }
    let(:vcr_file_name) { 'sync_leave_category' }
    let(:eh_context) { {organisation_id: 5841, member_id: nil, id: nil} }
    let(:kp_context) { {payroll_organisation_id: 12803, payroll_member_id: nil, payroll_id: nil} }
    let(:leave_category_exist_on_payroll) { { "id" => 1, "name" => "Annual Leave", "external_id" => "61245"} }
    let(:leave_category_not_exist_on_payroll) { { "id" => 2, "name" => "Testing", "external_id" => nil} }

    let(:eh_models) { [leave_category_exist_on_payroll, leave_category_not_exist_on_payroll] }


    let(:created_leave_cat) { { external_id: 61246,
                                hide_from_payslip: false,
                                entitlement_period: nil,
                                balance_untracked: false,
                                name: "Sick Leave",
                                hide_balance: false,
                                unit_type: "HoursPerHourWorked",
                                units: 0.07692,
                                enable: true
    } }

    let(:updated_leave_cat) { { external_id: 61245,
                                hide_from_payslip: false,
                                entitlement_period: nil,
                                balance_untracked: false,
                                name: "Annual Leave",
                                hide_balance: false,
                                unit_type: "HoursPerHourWorked",
                                units: 0.07692,
                                id: 1,
                                enable: true
    } }
    let(:disabled_leave_cat) { { id: 2, enable: false } }

    let(:expected_params) { {leave_categories: [updated_leave_cat, created_leave_cat, disabled_leave_cat]} }

    it_behaves_like 'update pay items from keypay'
  end
end
