-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As as User I want to call /projects to get all the projects for account
- Loading branch information
1 parent
c3aa5fd
commit 76e7c2e
Showing
12 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Place all the styles related to the projects controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ | ||
|
||
body.projects { | ||
// Place scoped styles here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class ProjectsController < ApplicationController | ||
respond_to :json | ||
|
||
def index | ||
@projects = Project.all | ||
respond_with(@projects) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ProjectsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Project < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateProjects < ActiveRecord::Migration | ||
def change | ||
create_table :projects do |t| | ||
t.integer :id | ||
t.string :name | ||
t.text :description | ||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Feature: Projects API | ||
|
||
As as User | ||
I want to call /projects | ||
to get all the projects for account | ||
|
||
Scenario: Listing projects | ||
Given I have the projects: | ||
| id | name | description | | ||
| 1 | Blazing Saddles | To ruin a western town, a corrupt political boss appoints a black sheriff, who promptly becomes his most formidable adversary.| | ||
| 2 | Spaceballs | Planet Spaceball's President Skroob sends Lord Dark Helmet to steal Planet Druidia's abundant supply of air to replenish their own, and only Lone Starr can stop them.| | ||
| 3 | Young Frankenstein| Dr. Frankenstein's grandson, after years of living down the family reputation, inherits granddad's castle and repeats the experiments.| | ||
When I call API "/projects" | ||
Then the JSON response should have 3 projects | ||
And the JSON should have the following: | ||
| 0 | {"id": 1, "name": "Blazing Saddles", "description": "To ruin a western town, a corrupt political boss appoints a black sheriff, who promptly becomes his most formidable adversary."} | | ||
| 1 | {"id": 2, "name": "Spaceballs", "description": "Planet Spaceball's President Skroob sends Lord Dark Helmet to steal Planet Druidia's abundant supply of air to replenish their own, and only Lone Starr can stop them."} | | ||
| 2 | {"id": 3, "name": "Young Frankenstein", "description": "Dr. Frankenstein's grandson, after years of living down the family reputation, inherits granddad's castle and repeats the experiments."} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Given /^I have the projects:$/ do |table| | ||
table.hashes.each { |project| Project.create project } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe ProjectsController do | ||
|
||
before(:each) do | ||
@projects = (1..10).collect {|i| stub_model(Project, :id => i, :name => "project_#{i}", :description => "description_#{i}") } | ||
end | ||
|
||
describe 'GET on index via JSON' do | ||
it 'renders the projects page' do | ||
Project.stub(:all).and_return(@projects) | ||
get :index, :format => :json | ||
response.body.should eq(@projects.to_json) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe Project do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |