Skip to content

Commit cdf7f62

Browse files
author
Ryan Bigg
committed
Section 4.1.2: Add the ability to view a list of all projects
1 parent cb1984e commit cdf7f62

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

ticketee/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ end
4747

4848
group :test do
4949
gem 'capybara', '~> 2.4'
50+
gem 'factory_girl_rails', '~> 4.5'
5051
end
5152

ticketee/Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ GEM
6363
diff-lcs (1.2.5)
6464
erubis (2.7.0)
6565
execjs (2.2.2)
66+
factory_girl (4.5.0)
67+
activesupport (>= 3.0.0)
68+
factory_girl_rails (4.5.0)
69+
factory_girl (~> 4.5.0)
70+
railties (>= 3.0.0)
6671
globalid (0.3.0)
6772
activesupport (>= 4.1.0)
6873
hike (1.2.3)
@@ -177,6 +182,7 @@ DEPENDENCIES
177182
byebug
178183
capybara (~> 2.4)
179184
coffee-rails (~> 4.1.0)
185+
factory_girl_rails (~> 4.5)
180186
jbuilder (~> 2.0)
181187
jquery-rails (~> 4.0.0.beta2)
182188
rails (= 4.2.0.beta4)

ticketee/app/controllers/projects_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class ProjectsController < ApplicationController
22
def index
3+
@projects = Project.all
34
end
45

56
def new
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
<%= link_to "New Project", new_project_path %>
2+
3+
<h2>Projects</h2>
4+
<ul>
5+
<% @projects.each do |project| %>
6+
<li><%= link_to project.name, project %></li>
7+
<% end %>
8+
</ul>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FactoryGirl.define do
2+
factory :project do
3+
name "Example project"
4+
end
5+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'rails_helper'
2+
3+
feature 'Viewing projects' do
4+
scenario 'Listing all projects' do
5+
project = FactoryGirl.create(:project, name: 'Sublime Text 3')
6+
visit '/'
7+
click_link 'Sublime Text 3'
8+
expect(page.current_url).to eql(project_url(project))
9+
end
10+
end

0 commit comments

Comments
 (0)