Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSGN-191: Set created by from offer params #645

Merged
merged 16 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ DEPENDENCIES
yarjuf

RUBY VERSION
ruby 2.7.0p0
ruby 2.7.1p83

BUNDLED WITH
2.1.4
3 changes: 2 additions & 1 deletion app/graphql/resolvers/create_offer_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def submission_id

def partner_id
gravity_partner_id = @arguments[:gravity_partner_id]
Partner.find_by(gravity_partner_id: gravity_partner_id).id
partner = Partner.find_by(gravity_partner_id: gravity_partner_id)
partner.id
end

def offer_attributes
Expand Down
10 changes: 9 additions & 1 deletion app/models/offer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ class Offer < ApplicationRecord
].freeze

# FIXME: deprecate 'accepted' state
STATES = %w[draft sent accepted rejected lapsed review consigned].freeze
STATES = [
DRAFT = 'draft',
SENT = 'sent',
ACCEPTED = 'accepted',
REJECTED = 'rejected',
LAPSED = 'lapsed',
REVIEW = 'review',
CONSIGNED = 'consigned'
].freeze

REJECTION_REASONS = [
'Low estimate',
Expand Down
8 changes: 4 additions & 4 deletions app/services/offer_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def create_offer(
if partner_submission.notified_at.blank?
partner_submission.update!(notified_at: Time.now.utc)
end
offer =
partner_submission.offers.new(
offer_params.merge(state: 'draft', created_by_id: current_user)
)

default_offer_attrs = { state: 'draft', created_by_id: current_user }
offer_attrs = default_offer_attrs.merge(offer_params)
offer = partner_submission.offers.new(offer_attrs)
offer.save!
offer
rescue ActiveRecord::RecordNotFound => e
Expand Down
Loading