Sha256: 8fa6ff782b4a524cc558901d52c2f0a710b43a04380a71ba18005c0494a1d0c7

Contents?: true

Size: 978 Bytes

Versions: 5

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Mutations::Admin::<%= class_name %>s::Update<%= class_name %>, type: :request do
  let(:admin_user) { create :admin_user }
  let(:<%= class_name.underscore %>) { create :<%= class_name.underscore %> }

  describe '.resolve' do
    it 'should update' do
      sign_in admin_user

      variables = <<~GQL
        {
          "id":    "#{<%= class_name.underscore %>.id}"
        }
      GQL

      post '/api/admin/graphql', headers: admin_user.create_new_auth_token, params: { query: query, variables: variables }
      expect(response).to have_http_status(:success)
      json = JSON.parse(response.body)

      data = json['data']['update<%= class_name %>']
      expect(data['id']).to eq <%= class_name.underscore %>.id.to_s
    end
  end

  def query
    <<~GQL
      mutation update<%= class_name %>($id: ID!) {
        update<%= class_name %>(id: $id){
          id
        }
      }
    GQL
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
graphql_scaffold_fan-0.2.7 lib/generators/templates/mutation_update_test.haml
graphql_scaffold_fan-0.2.6 lib/generators/templates/mutation_update_test.haml
graphql_scaffold_fan-0.2.5 lib/generators/templates/mutation_update_test.haml
graphql_scaffold_fan-0.2.4 lib/generators/templates/mutation_update_test.haml
graphql_scaffold_fan-0.2.3 lib/generators/templates/mutation_update_test.haml