Added validation on subject. Fixed failed save. #1135
This commit is contained in:
@@ -40,7 +40,7 @@ class DeliverablesController < ApplicationController
|
||||
format.html { redirect_to :action => 'index' }
|
||||
format.js { render :action => 'create.js.rjs'}
|
||||
else
|
||||
# TODO: Failed save
|
||||
format.js { render :action => 'create_error.js.rjs'}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Deliverable < ActiveRecord::Base
|
||||
unloadable
|
||||
|
||||
validates_presence_of :subject
|
||||
|
||||
belongs_to :project
|
||||
|
||||
attr_accessor :overhead
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="box">
|
||||
<div class="splitcontentleft">
|
||||
<p><%= f.text_field :subject, :size => 65, :required => true %></p>
|
||||
<p><%= f.text_area :description, :required => true,
|
||||
<p><%= f.text_area :description,
|
||||
:cols => 60,
|
||||
:rows => (@deliverable.description.blank? ? 10 : [[10, @deliverable.description.length / 50].max, 100].min),
|
||||
:accesskey => accesskey(:edit),
|
||||
|
||||
@@ -10,6 +10,7 @@ page.select('#errorExplanation').each do |value|
|
||||
end
|
||||
|
||||
page << "Form.reset($('deliverable-form'))"
|
||||
page << "Budget.updateAmounts()"
|
||||
|
||||
# Add a fading out flash
|
||||
page.insert_html :before, 'new-deliverable', content_tag(:div, @flash, :class => "flash notice", :id => 'rjs-flash')
|
||||
|
||||
2
app/views/deliverables/create_error.js.rjs
Normal file
2
app/views/deliverables/create_error.js.rjs
Normal file
@@ -0,0 +1,2 @@
|
||||
page.replace_html 'new-deliverable', :partial => 'form'
|
||||
page << "Budget.updateAmounts()"
|
||||
@@ -1,8 +1,12 @@
|
||||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe Deliverable do
|
||||
it "should not be valid without subject" do
|
||||
Deliverable.new.should_not be_valid
|
||||
end
|
||||
|
||||
it "should be valid" do
|
||||
Deliverable.new.should be_valid
|
||||
Deliverable.new({ :subject => 'test' }).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user