Permalink
Browse files

Added the ability to view a list of projects

  • Loading branch information...
1 parent be728be commit a904cd4a89c4d6661bc3a01e75e59b85360baaec @spartan-developer committed Jan 19, 2012
View
@@ -13,6 +13,7 @@ gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
+ gem 'dynamic_form', '1.1.4'
gem 'uglifier', '>= 1.0.3'
end
@@ -38,4 +39,5 @@ group :test do
gem 'cucumber-rails', '1.0.6'
gem 'capybara', '1.1.2'
gem 'database_cleaner', '0.7.1'
+ gem 'factory_girl', '2.2.0'
end
View
@@ -59,9 +59,12 @@ GEM
nokogiri (>= 1.5.0)
database_cleaner (0.7.1)
diff-lcs (1.1.3)
+ dynamic_form (1.1.4)
erubis (2.7.0)
execjs (1.2.13)
multi_json (~> 1.0)
+ factory_girl (2.2.0)
+ activesupport
ffi (1.0.11)
gherkin (2.7.3)
json (>= 1.4.6)
@@ -157,6 +160,8 @@ DEPENDENCIES
coffee-rails (~> 3.1.1)
cucumber-rails (= 1.0.6)
database_cleaner (= 0.7.1)
+ dynamic_form (= 1.1.4)
+ factory_girl (= 2.2.0)
jquery-rails
rails (= 3.1.1)
rspec-rails (= 2.7.0)
Binary file not shown.
@@ -1,16 +1,19 @@
class ProjectsController < ApplicationController
def index
-
+ @projects = Project.all
end
def new
@project = Project.new
end
def create
@project = Project.new(params[:project])
- @project.save
- flash[:notice] = "Project has been created!"
- redirect_to @project # :notice => 'message'
+ if @project.save
+ redirect_to @project, :notice => 'Project has been created'
+ else
+ flash.alert = 'Project has not been created.'
+ render :action => 'new'
+ end
end
def show
View
@@ -1,2 +1,3 @@
class Project < ActiveRecord::Base
+ validates_presence_of :name
end
@@ -1 +1,7 @@
<%= link_to "New Project", new_project_path %>
+<h2>Projects</h2>
+<ul>
+ <% @projects.each do |p| %>
+ <li><%= link_to p.name, p %></li>
+ <% end %>
+</ul>
@@ -1,4 +1,5 @@
<%= form_for @project do |f| %>
+ <%= f.error_messages %>
<p>
<%= f.label :name %>
<%= f.text_field :name %>
@@ -0,0 +1,3 @@
+Factory.define :project do |p|
+ p.name "Ticketee"
+end
@@ -3,11 +3,18 @@ Feature: Creating projects
As a user
I want to create them easily
- Scenario: Creating a project
+ Background:
Given I am on the homepage
When I follow "New Project"
+
+ Scenario: Creating a project
And I fill in "Name" with "TextMate 2"
And I press "Create Project"
Then I should see "Project has been created"
And I should be on the project page for "TextMate 2"
And I should see "TextMate 2 - Projects - Ticketee"
+
+ Scenario: Creating a project without a name
+ And I press "Create Project"
+ Then I should see "Project has not been created."
+ And I should see "Name can't be blank"
@@ -0,0 +1,4 @@
+Given /^there is a project called "([^"]*)"$/ do |arg1|
+ Factory(:project, :name => arg1)
+end
+
@@ -0,0 +1,4 @@
+Dir[Rails.root + "factories/*.rb"].each do |file|
+ require file
+end
+
@@ -0,0 +1,10 @@
+Feature: Viewing Projects
+ In order to go find a project to work with
+ As a user
+ I want to see a list of projects
+
+ Scenario: Listing all projects
+ Given there is a project called "TextMate 2"
+ And I am on the homepage
+ When I follow "TextMate 2"
+ Then I should be on the project page for "TextMate 2"

0 comments on commit a904cd4

Please sign in to comment.