-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to test issue with optional dependencies
- Loading branch information
1 parent
4a2a7ed
commit 91838e4
Showing
7 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'GET /notes', type: :request do | ||
subject { response } | ||
|
||
let(:project) do | ||
current_user.projects.create! name: 'Foo' | ||
end | ||
|
||
let(:list) do | ||
project.lists.create! name: 'Foo' | ||
end | ||
|
||
let(:task) do | ||
list.tasks.create! name: 'Foo' | ||
end | ||
|
||
let(:assignment) do | ||
task.assignments.create! user: current_user | ||
end | ||
|
||
let(:note) do | ||
list.notes.create!(text: 'foo', assignment: assignment) | ||
end | ||
|
||
let(:notes) do | ||
list.notes.order(:created_at) | ||
end | ||
|
||
context 'with valid request' do | ||
before do | ||
note.update!(assignment: nil) | ||
|
||
get "/notes?list_id=#{list.id}" | ||
end | ||
|
||
it { is_expected.to have_http_status(:ok) } | ||
it { expect(response.body).to eq_json(notes) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Note, type: :model do | ||
it { is_expected.to belong_to(:assignment).optional } | ||
it { is_expected.to belong_to(:list) } | ||
it { is_expected.to validate_presence_of(:text) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Notes | ||
module Model | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
belongs_to :assignments, optional: true | ||
|
||
schema_validations auto_create: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Notes | ||
class Resource < ApplicationResource | ||
filter_by :list | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
:lists, | ||
:tasks, | ||
:assignments, | ||
:notes, | ||
multi_tenancy_by: :organization | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateNotes < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :notes do |t| | ||
t.references :assignment | ||
t.references :list, null: false | ||
t.text :text, null: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters