Initial commit
This commit is contained in:
48
spec/controllers/api/notes_controller_spec.rb
Normal file
48
spec/controllers/api/notes_controller_spec.rb
Normal file
@@ -0,0 +1,48 @@
|
||||
# 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
|
||||
}
|
||||
]
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user