Initial commit
This commit is contained in:
44
spec/controllers/api/contract_templates_controller_spec.rb
Normal file
44
spec/controllers/api/contract_templates_controller_spec.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::ContractTemplatesController, type: :controller do
|
||||
let(:current_user) { create(:user) }
|
||||
let(:project) { create(:project, name: 'first', account: current_user.primary_account) }
|
||||
|
||||
describe '#index' do
|
||||
it 'returns a succesful response' do
|
||||
create(:contract_template, name: 'ct1', project_id: project.id)
|
||||
|
||||
sign_in_to_api(current_user)
|
||||
get :index, params: { project_id: project.id }
|
||||
|
||||
expect(response).to be_successful
|
||||
old_body = response.body
|
||||
|
||||
get :index, params: { project_id: project.id, updated_since: (DateTime.current + 10.days).to_date.to_s }
|
||||
expect(response.body).not_to eq(old_body)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
it 'returns a succesful response' do
|
||||
tested_release = create(:contract_template, name: 'ct1', project_id: project.id)
|
||||
|
||||
sign_in_to_api(current_user)
|
||||
get :show, params: { id: tested_release.id }
|
||||
|
||||
expect(response).to be_successful
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def response_body_data_attributes
|
||||
JSON.parse(response.body).dig('data', 'attributes')
|
||||
end
|
||||
|
||||
def response_body_included_attributes
|
||||
JSON.parse(response.body).dig('included')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user