-
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.
Ran 'script/generate scaffold share link_id:integer recipient_id:integer viewed:boolean read:boolean'
1 parent
0e8f6ab
commit 58a654b
Showing
14 changed files
with
298 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 SharesController < ApplicationController | ||
# GET /shares | ||
# GET /shares.xml | ||
def index | ||
@shares = Share.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @shares } | ||
end | ||
end | ||
|
||
# GET /shares/1 | ||
# GET /shares/1.xml | ||
def show | ||
@share = Share.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @share } | ||
end | ||
end | ||
|
||
# GET /shares/new | ||
# GET /shares/new.xml | ||
def new | ||
@share = Share.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @share } | ||
end | ||
end | ||
|
||
# GET /shares/1/edit | ||
def edit | ||
@share = Share.find(params[:id]) | ||
end | ||
|
||
# POST /shares | ||
# POST /shares.xml | ||
def create | ||
@share = Share.new(params[:share]) | ||
|
||
respond_to do |format| | ||
if @share.save | ||
flash[:notice] = 'Share was successfully created.' | ||
format.html { redirect_to(@share) } | ||
format.xml { render :xml => @share, :status => :created, :location => @share } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @share.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /shares/1 | ||
# PUT /shares/1.xml | ||
def update | ||
@share = Share.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @share.update_attributes(params[:share]) | ||
flash[:notice] = 'Share was successfully updated.' | ||
format.html { redirect_to(@share) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @share.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /shares/1 | ||
# DELETE /shares/1.xml | ||
def destroy | ||
@share = Share.find(params[:id]) | ||
@share.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(shares_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 SharesHelper | ||
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 Share < 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,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>Shares: <%= 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<h1>Editing share</h1> | ||
|
||
<% form_for(@share) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :link_id %><br /> | ||
<%= f.text_field :link_id %> | ||
</p> | ||
<p> | ||
<%= f.label :recipient_id %><br /> | ||
<%= f.text_field :recipient_id %> | ||
</p> | ||
<p> | ||
<%= f.label :viewed %><br /> | ||
<%= f.check_box :viewed %> | ||
</p> | ||
<p> | ||
<%= f.label :read %><br /> | ||
<%= f.check_box :read %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Update' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Show', @share %> | | ||
<%= link_to 'Back', shares_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,26 @@ | ||
<h1>Listing shares</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Link</th> | ||
<th>Recipient</th> | ||
<th>Viewed</th> | ||
<th>Read</th> | ||
</tr> | ||
|
||
<% @shares.each do |share| %> | ||
<tr> | ||
<td><%=h share.link_id %></td> | ||
<td><%=h share.recipient_id %></td> | ||
<td><%=h share.viewed %></td> | ||
<td><%=h share.read %></td> | ||
<td><%= link_to 'Show', share %></td> | ||
<td><%= link_to 'Edit', edit_share_path(share) %></td> | ||
<td><%= link_to 'Destroy', share, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New share', new_share_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,27 @@ | ||
<h1>New share</h1> | ||
|
||
<% form_for(@share) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :link_id %><br /> | ||
<%= f.text_field :link_id %> | ||
</p> | ||
<p> | ||
<%= f.label :recipient_id %><br /> | ||
<%= f.text_field :recipient_id %> | ||
</p> | ||
<p> | ||
<%= f.label :viewed %><br /> | ||
<%= f.check_box :viewed %> | ||
</p> | ||
<p> | ||
<%= f.label :read %><br /> | ||
<%= f.check_box :read %> | ||
</p> | ||
<p> | ||
<%= f.submit 'Create' %> | ||
</p> | ||
<% end %> | ||
|
||
<%= link_to 'Back', shares_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,23 @@ | ||
<p> | ||
<b>Link:</b> | ||
<%=h @share.link_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Recipient:</b> | ||
<%=h @share.recipient_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Viewed:</b> | ||
<%=h @share.viewed %> | ||
</p> | ||
|
||
<p> | ||
<b>Read:</b> | ||
<%=h @share.read %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_share_path(@share) %> | | ||
<%= link_to 'Back', shares_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
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 @@ | ||
class CreateShares < ActiveRecord::Migration | ||
def self.up | ||
create_table :shares do |t| | ||
t.integer :link_id | ||
t.integer :recipient_id | ||
t.boolean :viewed | ||
t.boolean :read | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :shares | ||
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,13 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
link_id: 1 | ||
recipient_id: 1 | ||
viewed: false | ||
read: false | ||
|
||
two: | ||
link_id: 1 | ||
recipient_id: 1 | ||
viewed: false | ||
read: false |
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 SharesControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:shares) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create share" do | ||
assert_difference('Share.count') do | ||
post :create, :share => { } | ||
end | ||
|
||
assert_redirected_to share_path(assigns(:share)) | ||
end | ||
|
||
test "should show share" do | ||
get :show, :id => shares(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => shares(:one).to_param | ||
assert_response :success | ||
end | ||
|
||
test "should update share" do | ||
put :update, :id => shares(:one).to_param, :share => { } | ||
assert_redirected_to share_path(assigns(:share)) | ||
end | ||
|
||
test "should destroy share" do | ||
assert_difference('Share.count', -1) do | ||
delete :destroy, :id => shares(:one).to_param | ||
end | ||
|
||
assert_redirected_to shares_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,4 @@ | ||
require 'test_helper' | ||
|
||
class SharesHelperTest < ActionView::TestCase | ||
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 ShareTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |