RSpec.describe LineReferentialsController, :type => :controller do
  login_user

  let(:context) do
    Chouette.create do
      workgroup owner: Organisation.find_by_code('first') do
        workbench organisation: Organisation.find_by_code('first')
      end
    end
  end
  let(:workbench) { context.workbench }

  describe 'PUT sync' do
    let(:request){ put :sync, params: { workbench_id: workbench.id }}

    it 'should respond with 403' do
      expect(request).to have_http_status 403
    end

    with_permission "line_referentials.synchronize" do
      it 'returns HTTP success' do
        expect(request).to redirect_to [ workbench, :line_referential ]
      end
    end
  end
end
