require 'spec_helper'

describe 'create availability exceptions' do

  it 'should create availability_exceptions', js: true do
    fixxpert = create :fixxpert, availability_defaults: "{\"0\":[\"25200\"],\"1\":[],\"2\":[],\"3\":[],\"4\":[],\"5\":[],\"6\":[]}"
    login_as_user fixxpert
    click_link 'availability_settings_link'
    click_link 'create_exception_link'

    fill_in 'availability_exception_date', with: '2020-07-05'
    find(:xpath, "//div[@data-block='25200']").click
    find(:xpath, "//div[@data-block='26100']").click

    click_button 'Create'

    wait_for_content 'Availability exception created'

    fixxpert.reload
    fixxpert.availability_exceptions.last.data.should eq "[\"26100\"]"
    fixxpert.availability_exceptions.last.date.to_s.should eq '2020-07-05'
  end
end
