-
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
Bas Wenneker
committed
May 6, 2010
1 parent
7ff5698
commit fc918d6
Showing
14 changed files
with
244 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,85 @@ | ||
class CitationsController < ApplicationController | ||
# GET /citations | ||
# GET /citations.xml | ||
def index | ||
@citations = Citation.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @citations } | ||
end | ||
end | ||
|
||
# GET /citations/1 | ||
# GET /citations/1.xml | ||
def show | ||
@citation = Citation.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @citation } | ||
end | ||
end | ||
|
||
# GET /citations/new | ||
# GET /citations/new.xml | ||
def new | ||
@citation = Citation.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @citation } | ||
end | ||
end | ||
|
||
# GET /citations/1/edit | ||
def edit | ||
@citation = Citation.find(params[:id]) | ||
end | ||
|
||
# POST /citations | ||
# POST /citations.xml | ||
def create | ||
@citation = Citation.new(params[:citation]) | ||
|
||
respond_to do |format| | ||
if @citation.save | ||
flash[:notice] = 'Citation was successfully created.' | ||
format.html { redirect_to(@citation) } | ||
format.xml { render :xml => @citation, :status => :created, :location => @citation } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @citation.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /citations/1 | ||
# PUT /citations/1.xml | ||
def update | ||
@citation = Citation.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @citation.update_attributes(params[:citation]) | ||
flash[:notice] = 'Citation was successfully updated.' | ||
format.html { redirect_to(@citation) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @citation.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /citations/1 | ||
# DELETE /citations/1.xml | ||
def destroy | ||
@citation = Citation.find(params[:id]) | ||
@citation.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(citations_url) } | ||
format.xml { head :ok } | ||
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,2 @@ | ||
module CitationsHelper | ||
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 Citation < 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h1>Editing citation</h1> | ||
|
||
<% form_for(@citation) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :citation %><br /> | ||
<%= f.text_area :citation %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Update' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Show', @citation %> | | ||
<%= link_to 'Back', citations_path %> |
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,20 @@ | ||
<h1>Listing citations</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Citation</th> | ||
</tr> | ||
|
||
<% @citations.each do |citation| %> | ||
<tr> | ||
<td><%=h citation.citation %></td> | ||
<td><%= link_to 'Show', citation %></td> | ||
<td><%= link_to 'Edit', edit_citation_path(citation) %></td> | ||
<td><%= link_to 'Destroy', citation, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New citation', new_citation_path %> |
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,15 @@ | ||
<h1>New citation</h1> | ||
|
||
<% form_for(@citation) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :citation %><br /> | ||
<%= f.text_area :citation %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Create' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Back', citations_path %> |
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 @@ | ||
<p> | ||
<b>Citation:</b> | ||
<%=h @citation.citation %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_citation_path(@citation) %> | | ||
<%= link_to 'Back', citations_path %> |
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 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" /> | ||
<title>Citations: <%= controller.action_name %></title> | ||
<%= stylesheet_link_tag 'scaffold' %> | ||
</head> | ||
<body> | ||
|
||
<p style="color: green"><%= flash[:notice] %></p> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
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,13 @@ | ||
class CreateCitations < ActiveRecord::Migration | ||
def self.up | ||
create_table :citations do |t| | ||
t.text :citation | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :citations | ||
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,7 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
citation: MyText | ||
|
||
two: | ||
citation: MyText |
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,45 @@ | ||
require 'test_helper' | ||
|
||
class CitationsControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:citations) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create citation" do | ||
assert_difference('Citation.count') do | ||
post :create, :citation => { } | ||
end | ||
|
||
assert_redirected_to citation_path(assigns(:citation)) | ||
end | ||
|
||
test "should show citation" do | ||
get :show, :id => citations(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => citations(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should update citation" do | ||
put :update, :id => citations(:one).to_param, :citation => { } | ||
assert_redirected_to citation_path(assigns(:citation)) | ||
end | ||
|
||
test "should destroy citation" do | ||
assert_difference('Citation.count', -1) do | ||
delete :destroy, :id => citations(:one).to_param | ||
end | ||
|
||
assert_redirected_to citations_path | ||
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,8 @@ | ||
require 'test_helper' | ||
|
||
class CitationTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
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,4 @@ | ||
require 'test_helper' | ||
|
||
class CitationsHelperTest < ActionView::TestCase | ||
end |