-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
122 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
58 changes: 58 additions & 0 deletions
58
api/spec/graph/refinery/api/mutations/pages/create_page_mutation_spec.rb
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,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
module Refinery | ||
module Api | ||
module Mutations | ||
module Pages | ||
describe 'CreatePageMutation' do | ||
let(:logged_in_user) { Refinery::Core::NilUser.new } | ||
|
||
let(:context) { {current_user: logged_in_user} } | ||
|
||
let(:result) do | ||
GraphqlSchema.execute( | ||
query_string, | ||
context: context, | ||
variables: variables | ||
) | ||
end | ||
|
||
let(:query_string) do | ||
<<-QUERY | ||
mutation($page: CreatePageInput!) { | ||
create_page(input: $page) { | ||
page { | ||
title | ||
} | ||
} | ||
} | ||
QUERY | ||
end | ||
|
||
subject { result } | ||
|
||
context 'as an admin' do | ||
context 'create a page' do | ||
let(:variables) do | ||
{ | ||
'page' => { | ||
'page' => { | ||
'title' => 'Test page' | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'returns the page title of the newly created page' do | ||
subject | ||
expect(result['data']['create_page']['page']['title']).to eq('Test page') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
63 changes: 63 additions & 0 deletions
63
api/spec/graph/refinery/api/mutations/pages/update_page_mutation_spec.rb
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,63 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
module Refinery | ||
module Api | ||
module Mutations | ||
module Pages | ||
describe 'UpdatePageMutation' do | ||
let(:logged_in_user) { Refinery::Core::NilUser.new } | ||
|
||
let!(:page) { FactoryBot.create(:page) } | ||
|
||
let(:context) { {current_user: logged_in_user} } | ||
|
||
let(:result) do | ||
GraphqlSchema.execute( | ||
query_string, | ||
context: context, | ||
variables: variables | ||
) | ||
end | ||
|
||
let(:query_string) do | ||
<<-QUERY | ||
mutation($page: UpdatePageInput!) { | ||
update_page(input: $page) { | ||
page { | ||
id | ||
title | ||
} | ||
} | ||
} | ||
QUERY | ||
end | ||
|
||
subject { result } | ||
|
||
context 'as an admin' do | ||
context 'update a page' do | ||
let(:variables) do | ||
{ | ||
'page' => { | ||
'id' => page.id, | ||
'page' => { | ||
'title' => 'Updated Test page' | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'returns the page id and title of the newly created page' do | ||
subject | ||
expect(result['data']['update_page']['page']['id']).to eq(page.id.to_s) | ||
expect(result['data']['update_page']['page']['title']).to eq('Updated Test page') | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |