Commit a57f2f48bab2e4a71214dec27b71b59afd047626

make project description obligatory

Commit diff

app/models/project.rb

 
2727
2828
2929 URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze
30 validates_presence_of :title, :user_id, :slug
30 validates_presence_of :title, :user_id, :slug, :description
3131 validates_uniqueness_of :slug, :case_sensitive => false
3232 validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i,
3333 :message => "must match something in the range of [a-z0-9_\-]+"
toggle raw diff

app/views/projects/_form.html.erb

 
3232 <%= form.text_field :bugtracker_url, :class => "text" -%>
3333</p>
3434<p>
35 <%= form.label :description -%><br />
35 <%= form.label :description, "Description (obligatory)" -%><br />
3636 <small class="hint">
3737 <a href="http://daringfireball.net/projects/markdown/">Markdown</a> and
3838 basic html is allowed
toggle raw diff

spec/controllers/projects_controller_spec.rb

 
3939
4040 it "POST projects/create with valid data should create project" do
4141 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"}
4343 response.should be_redirect
4444 response.should redirect_to(projects_path)
4545
6565
6666 it "PUT projects/update can only be done by project owner" do
6767 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"}
6969 flash[:error].should match(/you're not the owner of this project/i)
7070 response.should redirect_to(project_path(projects(:johans)))
7171 end
7373 it "PUT projects/update with valid data should update record" do
7474 login_as :johan
7575 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"}
7777 assigns(:project).should == project
7878 response.should be_redirect
7979 response.should redirect_to(project_path(project.reload))
toggle raw diff