Add Organization to API
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
class Organization < ActiveRecord::Base
|
class Organization < ActiveRecord::Base
|
||||||
|
|
||||||
|
include Graphqlable
|
||||||
|
|
||||||
belongs_to :user, touch: true
|
belongs_to :user, touch: true
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
User:
|
User:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
username: string
|
username: string
|
||||||
debates: [Debate]
|
debates: [Debate]
|
||||||
proposals: [Proposal]
|
proposals: [Proposal]
|
||||||
comments: [Comment]
|
comments: [Comment]
|
||||||
|
organization: Organization
|
||||||
Debate:
|
Debate:
|
||||||
fields:
|
fields:
|
||||||
id: integer
|
id: integer
|
||||||
@@ -82,3 +83,8 @@ Vote:
|
|||||||
votable_id: integer
|
votable_id: integer
|
||||||
votable_type: string
|
votable_type: string
|
||||||
public_timestamp: string
|
public_timestamp: string
|
||||||
|
Organization:
|
||||||
|
fields:
|
||||||
|
id: integer
|
||||||
|
user_id: integer
|
||||||
|
name: string
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ describe 'ConsulSchema' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns has_one associations" do
|
it "returns has_one associations" do
|
||||||
skip "Organizations are not being exposed yet"
|
|
||||||
organization = create(:organization)
|
organization = create(:organization)
|
||||||
response = execute("{ user(id: #{organization.user_id}) { organization { name } } }")
|
response = execute("{ user(id: #{organization.user_id}) { organization { name } } }")
|
||||||
expect(dig(response, 'data.user.organization.name')).to eq(organization.name)
|
expect(dig(response, 'data.user.organization.name')).to eq(organization.name)
|
||||||
@@ -61,7 +60,6 @@ describe 'ConsulSchema' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "executes deeply nested queries" do
|
it "executes deeply nested queries" do
|
||||||
skip "Organizations are not being exposed yet"
|
|
||||||
org_user = create(:user)
|
org_user = create(:user)
|
||||||
organization = create(:organization, user: org_user)
|
organization = create(:organization, user: org_user)
|
||||||
org_proposal = create(:proposal, author: org_user)
|
org_proposal = create(:proposal, author: org_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user