diff --git a/app/graphql/mutations/upsert_project.rb b/app/graphql/mutations/upsert_project.rb index 368e026f..44feb57e 100644 --- a/app/graphql/mutations/upsert_project.rb +++ b/app/graphql/mutations/upsert_project.rb @@ -13,7 +13,7 @@ class UpsertProject < BaseMutation argument :ends_on, GraphQL::Types::ISO8601Date, required: false, description: "The date this assignment ends." # return type from the mutation - type Types::StaffPlan::ProjectType + type Types::StaffPlan::ProjectType, null: true def resolve(id: nil, client_id: nil, name: nil, status: nil, cost: nil, payment_frequency: nil, starts_on: nil, ends_on: nil) current_company = context[:current_company] @@ -32,7 +32,7 @@ def resolve(id: nil, client_id: nil, name: nil, status: nil, cost: nil, payment_ GraphQL::ExecutionError.new("Client not found", extensions: { attribute: "client_id" }) ) - return + return {} end project = client.projects.new diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 0c7b3756..a9aabba3 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -113,7 +113,7 @@ type Mutation { """ The ID of the client for this project. """ - clientId: ID! + clientId: ID """ The cost of the project. @@ -133,7 +133,7 @@ type Mutation { """ The name of the project. """ - name: String! + name: String """ The frequency of payment for the project. @@ -148,8 +148,8 @@ type Mutation { """ The status of the assignment. """ - status: String! - ): Project! + status: String + ): Project """ Create or update a work week record for a StaffPlan user. diff --git a/app/models/project.rb b/app/models/project.rb index 71f58c72..d1f8d8b7 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -24,7 +24,7 @@ class Project < ApplicationRecord VALID_PAYMENT_FREQUENCIES = [WEEKLY, MONTHLY, FORTNIGHTLY, QUARTERLY, ANNUALLY].freeze validates :client_id, presence: true - validates :name, presence: true, uniqueness: { case_sensitive: false } + validates :name, presence: true, uniqueness: { scope: :client_id, case_sensitive: false } validates :status, inclusion: { in: VALID_STATUSES }, allow_blank: true validates :cost, numericality: { greater_than_or_equal_to: 0.0 }, allow_blank: true validates :payment_frequency, inclusion: { in: VALID_PAYMENT_FREQUENCIES }, allow_blank: true diff --git a/spec/sidekiq/sync_customer_subscription_job_spec.rb b/spec/sidekiq/sync_customer_subscription_job_spec.rb index 441a658e..20cebfb5 100644 --- a/spec/sidekiq/sync_customer_subscription_job_spec.rb +++ b/spec/sidekiq/sync_customer_subscription_job_spec.rb @@ -26,8 +26,7 @@ company.subscription.stripe_id, { items: [ {id: company.subscription.item_id, quantity: 2 } - ]}, - {proration_date: Date.today.iso8601} + ]} ) SyncCustomerSubscriptionJob.perform_inline(company.id)