# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Api::ProjectsController, type: :controller do
  let(:current_user) { create(:user, :admin) }

  describe '#index' do
    it 'returns a succesful response with and without updated_since param' do
      create(:project, name: 'first', account_id: current_user.primary_account.id, updated_at: 10.days.ago)
      create(:project, name: 'second', account_id: current_user.primary_account.id, updated_at: 10.days.ago)

      sign_in_to_api(current_user)
      get :index

      expect(response).to be_successful

      expect(response.body).to have_content('first')
      expect(response.body).to have_content('second')
    end
  end
end
