Files
old-holivud2/spec/controllers/api/notes_controller_spec.rb
2020-07-09 11:06:17 +02:00

57 lines
1.6 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
releases = [
{
type: :appearance_release,
obligatory_attribute: :person_name
},
{
type: :talent_release,
obligatory_attribute: :person_name
},
{
type: :location_release,
obligatory_attribute: :name
},
{
type: :material_release,
obligatory_attribute: :name
},
{
type: :medical_release,
obligatory_attribute: :person_name
},
{
type: :misc_release,
obligatory_attribute: :person_name
}
]
releases.each do |release|
RSpec.describe Api::NotesController, type: :controller do
let(:current_user) { create(:user, :admin) }
describe '#create' do
it 'creates a note and returns a created response' do
project = create(:project, name: 'first', account_id: current_user.primary_account.id)
tested_release = create(release[:type], release[:obligatory_attribute] => 'contract template 1', :project_id => project.id)
sign_in_to_api(current_user)
post :create, params: { "#{release[:type]}_id": tested_release.id, note: { content: 'blah blah' } }
expect(response.status).to eq 201
end
end
describe '#index' do
it 'returns all notes for the release' do
project = create(:project, name: 'first', account_id: current_user.primary_account.id)
tested_release = create(release[:type], release[:obligatory_attribute] => 'contract template 1', :project_id => project.id)
sign_in_to_api(current_user)
get :index, params: { "#{release[:type]}_id": tested_release.id }
expect(response).to be_successful
end
end
end
end