-
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.
- Loading branch information
James Deville
committed
Oct 20, 2008
1 parent
0a4b491
commit 2d89e4a
Showing
9 changed files
with
137 additions
and
0 deletions.
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,57 @@ | ||
class Hellos < Application | ||
# provides :xml, :yaml, :js | ||
|
||
def index | ||
@hellos = Hello.all | ||
display @hellos | ||
end | ||
|
||
def show(id) | ||
@hello = Hello.get(id) | ||
raise NotFound unless @hello | ||
display @hello | ||
end | ||
|
||
def new | ||
only_provides :html | ||
@hello = Hello.new | ||
display Hello | ||
end | ||
|
||
def edit(id) | ||
only_provides :html | ||
@hello = Hello.get(id) | ||
raise NotFound unless @hello | ||
display @hello | ||
end | ||
|
||
def create(hello) | ||
@hello = Hello.new(params[:hello]) | ||
if @hello.save | ||
redirect resource(@hello), :message => {:notice => "Hello was successfully created"} | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update(hello) | ||
@hello = Hello.get(hello[:id] ) | ||
raise NotFound unless @hello | ||
if @hello.update_attributes(hello) | ||
redirect resource(@hello) | ||
else | ||
display @hello, :edit | ||
end | ||
end | ||
|
||
def destroy(id) | ||
@hello = Hello.get(id) | ||
raise NotFound unless @hello | ||
if @hello.destroy | ||
redirect resource(@hellos) | ||
else | ||
raise InternalServerError | ||
end | ||
end | ||
|
||
end # Hellos |
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 @@ | ||
module Merb | ||
module HellosHelper | ||
|
||
end | ||
end # Merb |
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 @@ | ||
class Hello | ||
include DataMapper::Resource | ||
|
||
property :id, Serial | ||
|
||
|
||
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,3 @@ | ||
<h1>Hellos controller, edit action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/hellos/edit.html.erb</tt></p> |
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 @@ | ||
<h1>Hellos controller, index action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/hellos/index.html.erb</tt></p> |
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 @@ | ||
<h1>Hellos controller, new action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/hellos/new.html.erb</tt></p> |
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 @@ | ||
<h1>Hellos controller, show action</h1> | ||
|
||
<p>Edit this file in <tt>app/views/hellos/show.html.erb</tt></p> |
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 @@ | ||
require File.join( File.dirname(__FILE__), '..', "spec_helper" ) | ||
|
||
describe Hello do | ||
|
||
it "should have specs" | ||
|
||
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,49 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
given "a hello exists" do | ||
request(resource(:hellos), :method => "POST", | ||
:params => { :hello => { }}) | ||
end | ||
|
||
describe "resource(:hellos)" do | ||
describe "GET" do | ||
|
||
before(:each) do | ||
@response = request(resource(:hellos)) | ||
end | ||
|
||
it "responds successfully" do | ||
@response.should be_successful | ||
end | ||
|
||
it "contains a list of speakers" do | ||
pending | ||
@response.should have_xpath("//ul") | ||
end | ||
|
||
end | ||
|
||
describe "GET", :given => "a hello exists" do | ||
before(:each) do | ||
@response = request(resource(:hellos)) | ||
end | ||
|
||
it "has a list of hellos" do | ||
pending | ||
@response.should have_xpath("//ul/li") | ||
end | ||
end | ||
|
||
describe "a successful POST" do | ||
before(:each) do | ||
@response = request(resource(:hellos), :method => "POST", | ||
:params => { :hello => { }}) | ||
end | ||
|
||
it "redirects to resource(:hellos)" do | ||
@response.should redirect_to(resource(Hello.first), :message => {:notice => "hello was successfully created"}) | ||
end | ||
|
||
end | ||
end | ||
|