Sha256: f98454a2d042cbc3eb9b2b161753f9b011d86de4a19ca2b2851539870b317e1e

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

RSpec.describe 'Delete<%= @camelize_name %>', type: :request do
  include_context 'authenticated user'

  def query()
  <%= "  <<~GQL" %>
    mutation Delete<%= @camelize_name %>($id: ID!) {
      delete<%= @camelize_name %>(input: {id: $id}) {
          id
          <%= 
            @parsed_fields.filter{|f| !f[:reference].present? }.map{|field| 
              var = field[:name].camelize
              var[0] = var[0].downcase
              if field[:reference].present? then var += ' { id } ' end
              var
            }.join("\n          ")
          %>
        }
      }
    GQL
  end

  it 'delete_<%= @snake_case_name %> success' do
    <%= @snake_case_name%> = create(:<%= @snake_case_name %>)
    variables = { id: <%= @snake_case_name%>.id }

    json = graphql(query, variables: variables)
    data = json['delete<%= @camelize_name %>']

    expect(data).to include('id' => <%= @snake_case_name%>.id)
    <%= 
      @parsed_fields.filter{|f| !f[:reference].present? }.map{|field| 
        var = field[:name].camelize
        var[0] = var[0].downcase
        "expect(data).to include('#{var}' => updated_#{@snake_case_name}.#{field[:name]})"
      }.join("\n    ")
    %>

    expect(<%= @camelize_name %>.count).to eq(0)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
graphql_helper_generator-0.0.26 lib/graphql_helper_generator/graphql_model/templates/tests/delete_test_template.erb
graphql_helper_generator-0.0.25 lib/graphql_helper_generator/graphql_model/templates/tests/delete_test_template.erb
graphql_helper_generator-0.0.24 lib/graphql_helper_generator/graphql_model/templates/tests/delete_test_template.erb
graphql_helper_generator-0.0.23 lib/graphql_helper_generator/graphql_model/templates/tests/delete_test_template.erb
graphql_helper_generator-0.0.22 lib/graphql_helper_generator/graphql_model/templates/tests/delete_test_template.erb