diff --git a/app/models/workout.rb b/app/models/workout.rb
index 645e141..59243a7 100644
--- a/app/models/workout.rb
+++ b/app/models/workout.rb
@@ -1,3 +1,5 @@
class Workout < ActiveRecord::Base
+ DAY_TYPES = %w(heavy medium light)
validates_date :date
+ validates_inclusion_of :day_type, :in => Workout::DAY_TYPES
end
diff --git a/app/views/workouts/_form.html.erb b/app/views/workouts/_form.html.erb
index 7aef6e5..fa54b78 100644
--- a/app/views/workouts/_form.html.erb
+++ b/app/views/workouts/_form.html.erb
@@ -6,7 +6,21 @@
<% end %>
<% end %>
- <%= f.label :date %>
- <%= f.text_field :date %>
- <%= f.submit nil %>
+
+
+ <%= f.label :date %>
+ <%= f.text_field :date %>
+
+
+ <%= f.label :day_type %>
+ <%= f.select :day_type, [["Heavy", 'heavy'], ["Medium", 'medium'],
+ ["Light", 'light']] %>
+
+
+ <%= f.label :comment %>
+ <%= f.text_area :comment, rows: 7, cols: 60 %>
+
+
+ <%= f.submit nil %>
+
<% end %>
diff --git a/app/views/workouts/show.html.erb b/app/views/workouts/show.html.erb
index 07eed19..9c28fb5 100644
--- a/app/views/workouts/show.html.erb
+++ b/app/views/workouts/show.html.erb
@@ -1 +1,3 @@
-<%= @workout.date %>
+<%= @workout.date %>
+<%= @workout.day_type %>
+<%= @workout.comment %>
diff --git a/db/migrate/20130810191419_add_fields_to_workout.rb b/db/migrate/20130810191419_add_fields_to_workout.rb
new file mode 100644
index 0000000..42d065f
--- /dev/null
+++ b/db/migrate/20130810191419_add_fields_to_workout.rb
@@ -0,0 +1,11 @@
+class AddFieldsToWorkout < ActiveRecord::Migration
+ def self.up
+ add_column :workouts, :comment, :text, :null => false, :default => ''
+ add_column :workouts, :type, :string, :null => false, :default => 'Heavy'
+ end
+
+ def self.down
+ remove_column :workouts, :comment
+ remove_column :workouts, :type
+ end
+end
diff --git a/db/migrate/20130810192652_change_col_type_in_workouts.rb b/db/migrate/20130810192652_change_col_type_in_workouts.rb
new file mode 100644
index 0000000..7d7ed51
--- /dev/null
+++ b/db/migrate/20130810192652_change_col_type_in_workouts.rb
@@ -0,0 +1,9 @@
+class ChangeColTypeInWorkouts < ActiveRecord::Migration
+ def self.up
+ rename_column :workouts, :type, :day_type
+ end
+
+ def self.down
+ rename_column :workouts, :day_type, :type
+ end
+end
diff --git a/db/migrate/20130811021123_change_day_type_in_workotus.rb b/db/migrate/20130811021123_change_day_type_in_workotus.rb
new file mode 100644
index 0000000..e4005de
--- /dev/null
+++ b/db/migrate/20130811021123_change_day_type_in_workotus.rb
@@ -0,0 +1,9 @@
+class ChangeDayTypeInWorkotus < ActiveRecord::Migration
+ def self.up
+ change_column_default :workouts, :day_type, 'heavy'
+ end
+
+ def self.down
+ change_column_default :workouts, :day_type, 'Heavy'
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 663d234..2a1942f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,12 +11,14 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20130810061810) do
+ActiveRecord::Schema.define(version: 20130811021123) do
create_table "workouts", force: true do |t|
t.date "date"
t.datetime "created_at"
t.datetime "updated_at"
+ t.text "comment", default: "", null: false
+ t.string "day_type", default: "heavy", null: false
end
end
diff --git a/spec/factories/workouts.rb b/spec/factories/workouts.rb
index 654d45d..a624435 100644
--- a/spec/factories/workouts.rb
+++ b/spec/factories/workouts.rb
@@ -3,5 +3,6 @@
FactoryGirl.define do
factory :workout do
date Time.now
+ day_type { %w(heavy medium light).sample }
end
end
diff --git a/spec/features/workouts_spec.rb b/spec/features/workouts_spec.rb
index e57e327..0f3ffc3 100644
--- a/spec/features/workouts_spec.rb
+++ b/spec/features/workouts_spec.rb
@@ -63,6 +63,7 @@ describe "Workouts" do
click_link 'Create'
fill_in 'Date', :with => Date.today
+ select 'Heavy', :from => 'Day type'
click_button 'Create Workout'
page.should have_content 'Workout created'
@@ -83,6 +84,7 @@ describe "Workouts" do
visit workouts_path
click_link 'Create'
fill_in 'Date', :with => '2013-13-13'
+ select 'Heavy', :from => 'Day type'
click_button 'Create Workout'
page.should have_content "Date is not a valid date"