Skip to content

Commit

Permalink
disallow create empty plan; ui tidy up for safari
Browse files Browse the repository at this point in the history
  • Loading branch information
gigix committed Mar 12, 2011
1 parent 1a7441e commit db00636
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion rails_root/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def name
end

def create_plan!(from_date, habit_names)
habit_names.reject!(&:blank?)
raise if habit_names.blank?

from_date = Date.parse(from_date) if(from_date.is_a?(String))
Expand All @@ -25,7 +26,7 @@ def create_plan!(from_date, habit_names)
plan.status = Plan::Status::ACTIVE
plan.save!

habit_names.reject(&:blank?).each do |name|
habit_names.each do |name|
habit = plan.habits.create!(:title => name)
end

Expand Down
4 changes: 2 additions & 2 deletions rails_root/app/views/plans/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</div>
<h3>in a month starts from ...</h3>
<div class='row'>
<div class='column_left fyi'>YYYY-mm-dd</div>
<div class='column_right'><%= text_field_tag 'start_from' %></div>
<div class='column_left fyi'>&nbsp;</div>
<div class='column_right'><%= text_field_tag 'start_from', Date.today.to_s %></div>
</div>
<div class='row'>
<div class='column_left'>&nbsp;</div>
Expand Down
6 changes: 6 additions & 0 deletions rails_root/public/stylesheets/ohfy.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ a:hover {
margin-bottom: 5px;
}

.sticker h3 {
margin-top: 20px;
margin-bottom: 5px;
font-size: 20px;
}

.sticker a {
color: #000000;
}
Expand Down
2 changes: 1 addition & 1 deletion rails_root/spec/controllers/plans_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
it 'redirects back with error message if no habit inputted' do
sign_in @user
lambda do
post :create, :habits => [], :start_from => Date.yesterday.to_s(:db)
post :create, :habits => ['', '', ''], :start_from => Date.yesterday.to_s(:db)
response.should redirect_to(root_path)
flash[:alert].should_not be_blank
end.should_not change(Plan, :count)
Expand Down

0 comments on commit db00636

Please sign in to comment.