diff --git a/app/models/statement_of_work.rb b/app/models/statement_of_work.rb index 0836e2e..a113b24 100644 --- a/app/models/statement_of_work.rb +++ b/app/models/statement_of_work.rb @@ -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 # @@ -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 diff --git a/app/views/statement_of_works/_statement_of_work.json.jbuilder b/app/views/statement_of_works/_statement_of_work.json.jbuilder index 3d8c973..6ac8e17 100644 --- a/app/views/statement_of_works/_statement_of_work.json.jbuilder +++ b/app/views/statement_of_works/_statement_of_work.json.jbuilder @@ -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 diff --git a/db/migrate/20240124223542_remove_hourly_delivery_schedule_from_statement_of_work.rb b/db/migrate/20240124223542_remove_hourly_delivery_schedule_from_statement_of_work.rb new file mode 100644 index 0000000..42e3a51 --- /dev/null +++ b/db/migrate/20240124223542_remove_hourly_delivery_schedule_from_statement_of_work.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 2679d4c..bdfcda0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_01_24_222718) do +ActiveRecord::Schema[7.0].define(version: 2024_01_24_223542) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -178,7 +178,6 @@ t.string "model" t.float "total_revenue" t.float "total_hours" - t.string "hour_delivery_schedule" t.datetime "start_date" t.datetime "end_date" t.bigint "project_id", null: false diff --git a/spec/controllers/statement_of_works_controller_spec.rb b/spec/controllers/statement_of_works_controller_spec.rb index 188951c..6e5fdc4 100644 --- a/spec/controllers/statement_of_works_controller_spec.rb +++ b/spec/controllers/statement_of_works_controller_spec.rb @@ -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 @@ -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 diff --git a/spec/factories/statement_of_works.rb b/spec/factories/statement_of_works.rb index d70255b..ab23bea 100644 --- a/spec/factories/statement_of_works.rb +++ b/spec/factories/statement_of_works.rb @@ -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 # @@ -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 diff --git a/spec/models/statement_of_work_spec.rb b/spec/models/statement_of_work_spec.rb index e935a36..dacf705 100644 --- a/spec/models/statement_of_work_spec.rb +++ b/spec/models/statement_of_work_spec.rb @@ -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 #