require 'spec_helper'

describe 'edit availability exceptions' do

  it 'should create availability_exceptions', js: true  do
    fixxpert = create :fixxpert, availability_defaults: "{\"0\":[\"25200\"],\"1\":[],\"2\":[],\"3\":[],\"4\":[],\"5\":[],\"6\":[]}"
    exception = create :availability_exception, fixxpert: fixxpert, date: '2020-07-05', data: "[\"25200\"]"

    login_as_user fixxpert
    click_link 'availability_settings_link'
    within '#availability_exceptions_list' do
      click_link 'Edit'
    end

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

    click_button 'Update'

    wait_for_content 'Availability exception updated'

    fixxpert.reload
    fixxpert.availability_exceptions.last.data.should eq "[\"26100\"]"
  end
end
