This repository has been archived by the owner on Feb 8, 2019. It is now read-only.
-
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
1 parent
4db7be5
commit 15b9ba3
Showing
18 changed files
with
316 additions
and
4 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.swp | ||
*log/* | ||
*tmp/* | ||
*log | ||
*tmp |
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
85 changes: 85 additions & 0 deletions
85
april_09/eugene_bolshakov/integration_testing/app/controllers/posts_controller.rb
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 PostsController < ApplicationController | ||
# GET /posts | ||
# GET /posts.xml | ||
def index | ||
@posts = Post.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @posts } | ||
end | ||
end | ||
|
||
# GET /posts/1 | ||
# GET /posts/1.xml | ||
def show | ||
@post = Post.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @post } | ||
end | ||
end | ||
|
||
# GET /posts/new | ||
# GET /posts/new.xml | ||
def new | ||
@post = Post.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @post } | ||
end | ||
end | ||
|
||
# GET /posts/1/edit | ||
def edit | ||
@post = Post.find(params[:id]) | ||
end | ||
|
||
# POST /posts | ||
# POST /posts.xml | ||
def create | ||
@post = Post.new(params[:post]) | ||
|
||
respond_to do |format| | ||
if @post.save | ||
flash[:notice] = 'Post was successfully created.' | ||
format.html { redirect_to(@post) } | ||
format.xml { render :xml => @post, :status => :created, :location => @post } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @post.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /posts/1 | ||
# PUT /posts/1.xml | ||
def update | ||
@post = Post.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @post.update_attributes(params[:post]) | ||
flash[:notice] = 'Post was successfully updated.' | ||
format.html { redirect_to(@post) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @post.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /posts/1 | ||
# DELETE /posts/1.xml | ||
def destroy | ||
@post = Post.find(params[:id]) | ||
@post.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(posts_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
april_09/eugene_bolshakov/integration_testing/app/helpers/posts_helper.rb
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 PostsHelper | ||
end |
2 changes: 2 additions & 0 deletions
2
april_09/eugene_bolshakov/integration_testing/app/models/post.rb
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 Post < ActiveRecord::Base | ||
end |
17 changes: 17 additions & 0 deletions
17
april_09/eugene_bolshakov/integration_testing/app/views/layouts/posts.html.erb
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>Posts: <%= controller.action_name %></title> | ||
<%= stylesheet_link_tag 'scaffold' %> | ||
</head> | ||
<body> | ||
|
||
<p style="color: green"><%= flash[:notice] %></p> | ||
|
||
<%= yield %> | ||
|
||
</body> | ||
</html> |
20 changes: 20 additions & 0 deletions
20
april_09/eugene_bolshakov/integration_testing/app/views/posts/edit.html.erb
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>Editing post</h1> | ||
|
||
<% form_for(@post) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :title %><br /> | ||
<%= f.text_field :title %> | ||
</p> | ||
<p> | ||
<%= f.label :body %><br /> | ||
<%= f.text_area :body %> | ||
</p> | ||
<p> | ||
<%= f.submit "Update" %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Show', @post %> | | ||
<%= link_to 'Back', posts_path %> |
22 changes: 22 additions & 0 deletions
22
april_09/eugene_bolshakov/integration_testing/app/views/posts/index.html.erb
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,22 @@ | ||
<h1>Listing posts</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Title</th> | ||
<th>Body</th> | ||
</tr> | ||
|
||
<% for post in @posts %> | ||
<tr> | ||
<td><%=h post.title %></td> | ||
<td><%=h post.body %></td> | ||
<td><%= link_to 'Show', post %></td> | ||
<td><%= link_to 'Edit', edit_post_path(post) %></td> | ||
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New post', new_post_path %> |
19 changes: 19 additions & 0 deletions
19
april_09/eugene_bolshakov/integration_testing/app/views/posts/new.html.erb
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,19 @@ | ||
<h1>New post</h1> | ||
|
||
<% form_for(@post) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :title %><br /> | ||
<%= f.text_field :title %> | ||
</p> | ||
<p> | ||
<%= f.label :body %><br /> | ||
<%= f.text_area :body %> | ||
</p> | ||
<p> | ||
<%= f.submit "Create" %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Back', posts_path %> |
13 changes: 13 additions & 0 deletions
13
april_09/eugene_bolshakov/integration_testing/app/views/posts/show.html.erb
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 @@ | ||
<p> | ||
<b>Title:</b> | ||
<%=h @post.title %> | ||
</p> | ||
|
||
<p> | ||
<b>Body:</b> | ||
<%=h @post.body %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_post_path(@post) %> | | ||
<%= link_to 'Back', posts_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
2 changes: 2 additions & 0 deletions
2
april_09/eugene_bolshakov/integration_testing/config/routes.rb
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
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
april_09/eugene_bolshakov/integration_testing/db/migrate/20090420152549_create_posts.rb
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,14 @@ | ||
class CreatePosts < ActiveRecord::Migration | ||
def self.up | ||
create_table :posts do |t| | ||
t.string :title | ||
t.text :body | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :posts | ||
end | ||
end |
54 changes: 54 additions & 0 deletions
54
april_09/eugene_bolshakov/integration_testing/public/stylesheets/scaffold.css
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,54 @@ | ||
body { background-color: #fff; color: #333; } | ||
|
||
body, p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { color: #000; } | ||
a:visited { color: #666; } | ||
a:hover { color: #fff; background-color:#000; } | ||
|
||
.fieldWithErrors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#errorExplanation { | ||
width: 400px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 12px; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
#errorExplanation h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
#errorExplanation p { | ||
color: #333; | ||
margin-bottom: 0; | ||
padding: 5px; | ||
} | ||
|
||
#errorExplanation ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
april_09/eugene_bolshakov/integration_testing/test/fixtures/posts.yml
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,9 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
title: MyString | ||
body: MyText | ||
|
||
two: | ||
title: MyString | ||
body: MyText |
45 changes: 45 additions & 0 deletions
45
april_09/eugene_bolshakov/integration_testing/test/functional/posts_controller_test.rb
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 PostsControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:posts) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create post" do | ||
assert_difference('Post.count') do | ||
post :create, :post => { } | ||
end | ||
|
||
assert_redirected_to post_path(assigns(:post)) | ||
end | ||
|
||
test "should show post" do | ||
get :show, :id => posts(:one).id | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => posts(:one).id | ||
assert_response :success | ||
end | ||
|
||
test "should update post" do | ||
put :update, :id => posts(:one).id, :post => { } | ||
assert_redirected_to post_path(assigns(:post)) | ||
end | ||
|
||
test "should destroy post" do | ||
assert_difference('Post.count', -1) do | ||
delete :destroy, :id => posts(:one).id | ||
end | ||
|
||
assert_redirected_to posts_path | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
april_09/eugene_bolshakov/integration_testing/test/unit/post_test.rb
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 PostTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |