| |   |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze |
| 30 | | validates_presence_of :title, :user_id, :slug |
| 30 | validates_presence_of :title, :user_id, :slug, :description |
| 31 | 31 | validates_uniqueness_of :slug, :case_sensitive => false |
| 32 | 32 | validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i, |
| 33 | 33 | :message => "must match something in the range of [a-z0-9_\-]+" |
| toggle raw diff |
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -27,7 +27,7 @@ class Project < ActiveRecord::Base
URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze
- validates_presence_of :title, :user_id, :slug
+ validates_presence_of :title, :user_id, :slug, :description
validates_uniqueness_of :slug, :case_sensitive => false
validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i,
:message => "must match something in the range of [a-z0-9_\-]+" |
| |   |
| 32 | 32 | <%= form.text_field :bugtracker_url, :class => "text" -%> |
| 33 | 33 | </p> |
| 34 | 34 | <p> |
| 35 | | <%= form.label :description -%><br /> |
| 35 | <%= form.label :description, "Description (obligatory)" -%><br /> |
| 36 | 36 | <small class="hint"> |
| 37 | 37 | <a href="http://daringfireball.net/projects/markdown/">Markdown</a> and |
| 38 | 38 | basic html is allowed |
| toggle raw diff |
--- a/app/views/projects/_form.html.erb
+++ b/app/views/projects/_form.html.erb
@@ -32,7 +32,7 @@
<%= form.text_field :bugtracker_url, :class => "text" -%>
</p>
<p>
- <%= form.label :description -%><br />
+ <%= form.label :description, "Description (obligatory)" -%><br />
<small class="hint">
<a href="http://daringfireball.net/projects/markdown/">Markdown</a> and
basic html is allowed |
| |   |
| 39 | 39 | |
| 40 | 40 | it "POST projects/create with valid data should create project" do |
| 41 | 41 | login_as :johan |
| 42 | | post :create, :project => {:title => "project x", :slug => "projectx"} |
| 42 | post :create, :project => {:title => "project x", :slug => "projectx", :description => "projectx's description"} |
| 43 | 43 | response.should be_redirect |
| 44 | 44 | response.should redirect_to(projects_path) |
| 45 | 45 | |
| … | … | |
| 65 | 65 | |
| 66 | 66 | it "PUT projects/update can only be done by project owner" do |
| 67 | 67 | login_as :moe |
| 68 | | put :update, :id => projects(:johans).slug, :project => {:title => "new name", :slug => "foo"} |
| 68 | put :update, :id => projects(:johans).slug, :project => {:title => "new name", :slug => "foo", :description => "bar"} |
| 69 | 69 | flash[:error].should match(/you're not the owner of this project/i) |
| 70 | 70 | response.should redirect_to(project_path(projects(:johans))) |
| 71 | 71 | end |
| … | … | |
| 73 | 73 | it "PUT projects/update with valid data should update record" do |
| 74 | 74 | login_as :johan |
| 75 | 75 | project = projects(:johans) |
| 76 | | put :update, :id => project.slug, :project => {:title => "new name", :slug => "foo"} |
| 76 | put :update, :id => project.slug, :project => {:title => "new name", :slug => "foo", :description => "bar"} |
| 77 | 77 | assigns(:project).should == project |
| 78 | 78 | response.should be_redirect |
| 79 | 79 | response.should redirect_to(project_path(project.reload)) |
| toggle raw diff |
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -39,7 +39,7 @@ describe ProjectsController do
it "POST projects/create with valid data should create project" do
login_as :johan
- post :create, :project => {:title => "project x", :slug => "projectx"}
+ post :create, :project => {:title => "project x", :slug => "projectx", :description => "projectx's description"}
response.should be_redirect
response.should redirect_to(projects_path)
@@ -65,7 +65,7 @@ describe ProjectsController do
it "PUT projects/update can only be done by project owner" do
login_as :moe
- put :update, :id => projects(:johans).slug, :project => {:title => "new name", :slug => "foo"}
+ put :update, :id => projects(:johans).slug, :project => {:title => "new name", :slug => "foo", :description => "bar"}
flash[:error].should match(/you're not the owner of this project/i)
response.should redirect_to(project_path(projects(:johans)))
end
@@ -73,7 +73,7 @@ describe ProjectsController do
it "PUT projects/update with valid data should update record" do
login_as :johan
project = projects(:johans)
- put :update, :id => project.slug, :project => {:title => "new name", :slug => "foo"}
+ put :update, :id => project.slug, :project => {:title => "new name", :slug => "foo", :description => "bar"}
assigns(:project).should == project
response.should be_redirect
response.should redirect_to(project_path(project.reload)) |