Skip to content

Commit c42b71c

Browse files
committed
We now use Admin controller for mutations
1 parent 8e6e904 commit c42b71c

3 files changed

Lines changed: 5 additions & 28 deletions

File tree

api/app/controllers/refinery/api/graphql_controller.rb renamed to api/app/controllers/refinery/admin/graphql_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Refinery
2-
module Api
3-
class GraphqlController < ::ApplicationController
2+
module Admin
3+
class GraphqlController < Refinery::AdminController
44

55
def execute
66
query = params[:query]

api/config/routes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Refinery::Core::Engine.routes.draw do
2-
namespace :api do
2+
namespace :admin, path: Refinery::Core.backend_route do
33
post 'graphql' => 'graphql#execute'
44

55
if Rails.env.development?
6-
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/api/graphql"
6+
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/#{Refinery::Core.backend_route}/graphql"
77
end
88
end
99
end

api/spec/graph/refinery/api/mutations/pages/page_mutations_spec.rb

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,13 @@ module Pages
3636
subject { result }
3737

3838
context 'Correct page id' do
39-
let(:variables) { {'page': { 'id': page.id }} }
39+
let(:variables) { {'page' => { 'id' => page.id }} }
4040

4141
it 'deletes the page' do
4242
subject
4343
expect(Refinery::Page.find_by_id(page.id)).to be(nil)
4444
end
4545
end
46-
47-
context 'Incorrect page id' do
48-
let(:variables) { {'page': { 'id': 1000 }} }
49-
50-
it 'does not delete the page' do
51-
subject
52-
expect(Refinery::Page.find_by_id(page.id)).to_not be(nil)
53-
end
54-
end
55-
56-
context 'Current user does not exist' do
57-
let(:variables) { {'page': { 'id': page.id }} }
58-
let(:context) { {current_user: nil} }
59-
60-
it 'returns an error' do
61-
expect(subject['errors']).
62-
to include(include('message' => "You're not authorized to do this"))
63-
end
64-
65-
it 'returns no data' do
66-
expect(subject['data']['delete_page']).to be(nil)
67-
end
68-
end
6946
end
7047
end
7148
end

0 commit comments

Comments
 (0)