Skip to content

Commit

Permalink
remove hourly delivery schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Jan 24, 2024
1 parent 01c3cfc commit 907fe79
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 49 deletions.
26 changes: 12 additions & 14 deletions app/models/statement_of_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
#
# Table name: statement_of_works
#
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# hour_delivery_schedule :string
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
#
# Indexes
#
Expand All @@ -40,7 +39,6 @@ class StatementOfWork < ApplicationRecord
validates :end_date, presence: true
validates :model, presence: true, inclusion: { in: %w[maintenance time_and_materials fixed_bid] }
validates :total_revenue, numericality: { greater_than: 0 }
validates :hour_delivery_schedule, presence: true, inclusion: { in: %w[contract_period weekly monthly] }

# custom validation for date range
validate :validate_date_range
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true

json.extract! statement_of_work, :id, :model, :total_revenue, :total_hours, :hour_delivery_schedule,
json.extract! statement_of_work, :id, :model, :total_revenue, :total_hours,
:start_date, :end_date, :project_id, :created_at, :updated_at, :name
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class RemoveHourlyDeliveryScheduleFromStatementOfWork < ActiveRecord::Migration[7.0]
def change
remove_column :statement_of_works, :hour_delivery_schedule, :string
end
end
3 changes: 1 addition & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spec/controllers/statement_of_works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
context 'with valid params' do
let(:new_attributes) do
{
hour_delivery_schedule: 'weekly'
end_date: Time.zone.today + 2.days
}
end

Expand All @@ -70,7 +70,7 @@
put :update,
params: { id: statement_of_work.to_param, statement_of_work: new_attributes, project_id: project.id }
statement_of_work.reload
expect(statement_of_work.hour_delivery_schedule).to eql('weekly')
expect(statement_of_work.end_date.to_date).to eql(Time.zone.today + 2.days)
end

it 'renders a JSON response with the statement_of_work' do
Expand Down
29 changes: 12 additions & 17 deletions spec/factories/statement_of_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
#
# Table name: statement_of_works
#
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# hour_delivery_schedule :string
# hourly_revenue :float
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
#
# Indexes
#
Expand All @@ -39,21 +37,18 @@
model { 'maintenance' }
total_hours { 120 }
total_revenue { 12_000 }
hour_delivery_schedule { 'monthly' }
end

trait :with_time_and_materials do
model { 'time_and_materials' }
total_hours { 120 }
total_revenue { 12_000 }
hour_delivery_schedule { 'contract_period' }
end

trait :with_fixed_bid do
model { 'time_and_materials' }
total_hours { nil }
total_revenue { 12_000 }
hour_delivery_schedule { 'contract_period' }
end
end
end
25 changes: 12 additions & 13 deletions spec/models/statement_of_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
#
# Table name: statement_of_works
#
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# hour_delivery_schedule :string
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
# id :bigint not null, primary key
# contract_model_type :string
# end_date :datetime
# model :string
# name :string
# start_date :datetime
# total_hours :float
# total_revenue :float
# created_at :datetime not null
# updated_at :datetime not null
# contract_model_id :integer
# project_id :bigint not null
#
# Indexes
#
Expand Down

0 comments on commit 907fe79

Please sign in to comment.