Skip to content

Commit

Permalink
wow..mais da metade...
Browse files Browse the repository at this point in the history
  • Loading branch information
nofxx committed Apr 14, 2009
1 parent 9b98875 commit 46a8ab3
Show file tree
Hide file tree
Showing 34 changed files with 283 additions and 335 deletions.
2 changes: 2 additions & 0 deletions app/models/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
class Family < ActiveRecord::Base


has_money :revenue

def self.search(filter, page)
paginate :per_page => 10, :page => page,
:conditions => ['families.name like ?', "%#{filter}%"],
Expand Down
2 changes: 1 addition & 1 deletion app/views/families/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.block
.content
.inner
= show @family, :name, :people_count, :revenue, sex_text, :state_text
= show @family, :name, :people_count, :revenue, :state_text
= link_to 'Editar', edit_family_path(@family)
|
= link_to 'Voltar', families_path
22 changes: 22 additions & 0 deletions app/views/heritages/_heritage.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- form_for(@heritage) do |f|
= f.error_messages
%p
= f.label :name
%br
= f.text_field :name
%p
= f.label :code
%br
= f.text_field :code
%p
= f.label :bought_at
%br
= f.date_select :bought_at
%p
= f.label :value_cents
%br
= f.text_field :value_cents
%p
= f.submit 'Create'

= link_to 'Back', heritages_path
30 changes: 3 additions & 27 deletions app/views/heritages/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
<h1>Editing heritage</h1>
%h1
New heritage

<% form_for(@heritage) do |f| %>
<%= f.error_messages %>

<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :code %><br />
<%= f.text_field :code %>
</p>
<p>
<%= f.label :bought_at %><br />
<%= f.date_select :bought_at %>
</p>
<p>
<%= f.label :value_cents %><br />
<%= f.text_field :value_cents %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>

<%= link_to 'Show', @heritage %> |
<%= link_to 'Back', heritages_path %>
= render @heritage
55 changes: 30 additions & 25 deletions app/views/heritages/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<h1>Listing heritages</h1>
%h1
Listing heritages
%table
%tr
%th
Name
%th
Code
%th
Bought at
%th
Value cents
- @heritages.each do |heritage|
%tr
%td
= h heritage.name
%td
= h heritage.code
%td
= h heritage.bought_at
%td
= h heritage.value_cents
%td
= link_to 'Show', heritage
%td
= link_to 'Edit', edit_heritage_path(heritage)
%td
= link_to 'Destroy', heritage, :confirm => 'Are you sure?', :method => :delete

<table>
<tr>
<th>Name</th>
<th>Code</th>
<th>Bought at</th>
<th>Value cents</th>
</tr>

<% @heritages.each do |heritage| %>
<tr>
<td><%=h heritage.name %></td>
<td><%=h heritage.code %></td>
<td><%=h heritage.bought_at %></td>
<td><%=h heritage.value_cents %></td>
<td><%= link_to 'Show', heritage %></td>
<td><%= link_to 'Edit', edit_heritage_path(heritage) %></td>
<td><%= link_to 'Destroy', heritage, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New heritage', new_heritage_path %>
%br
= link_to 'New heritage', new_heritage_path
29 changes: 3 additions & 26 deletions app/views/heritages/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
<h1>New heritage</h1>
%h1
New heritage

<% form_for(@heritage) do |f| %>
<%= f.error_messages %>

<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :code %><br />
<%= f.text_field :code %>
</p>
<p>
<%= f.label :bought_at %><br />
<%= f.date_select :bought_at %>
</p>
<p>
<%= f.label :value_cents %><br />
<%= f.text_field :value_cents %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>

<%= link_to 'Back', heritages_path %>
= render @heritage
42 changes: 19 additions & 23 deletions app/views/heritages/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<p>
<b>Name:</b>
<%=h @heritage.name %>
</p>

<p>
<b>Code:</b>
<%=h @heritage.code %>
</p>

<p>
<b>Bought at:</b>
<%=h @heritage.bought_at %>
</p>

<p>
<b>Value cents:</b>
<%=h @heritage.value_cents %>
</p>


<%= link_to 'Edit', edit_heritage_path(@heritage) %> |
<%= link_to 'Back', heritages_path %>
%p
%b
Name:
= h @heritage.name
%p
%b
Code:
= h @heritage.code
%p
%b
Bought at:
= h @heritage.bought_at
%p
%b
Value cents:
= h @heritage.value_cents
= link_to 'Edit', edit_heritage_path(@heritage)
|
= link_to 'Back', heritages_path
2 changes: 1 addition & 1 deletion app/views/zones/_zone.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- form_for(@zone) do |f|
= f.error_messages
= f.error_messages
%p
= f.label :name
= f.text_field :name
Expand Down
40 changes: 24 additions & 16 deletions spec/controllers/groups_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@
def mock_group(stubs={})
@mock_group ||= mock_model(Group, stubs)
end


describe "When Logged In" do

before(:each) do
@login_warning= nil #{}"You need to be logged in to do that"
autho_login_as :admin
end

describe "GET index" do

it "exposes all groups as @groups" do
Group.should_receive(:find).with(:all).and_return([mock_group])
Group.should_receive(:search).with(nil, nil).and_return([mock_group])
get :index
assigns[:groups].should == [mock_group]
end

describe "with mime type of xml" do

it "renders all groups as xml" do
Group.should_receive(:find).with(:all).and_return(groups = mock("Array of Groups"))
Group.should_receive(:search).with(nil, nil).and_return(groups = mock("Array of Groups"))
groups.should_receive(:to_xml).and_return("generated XML")
get :index, :format => 'xml'
response.body.should == "generated XML"
end

end

end
Expand All @@ -34,7 +41,7 @@ def mock_group(stubs={})
get :show, :id => "37"
assigns[:group].should equal(mock_group)
end

describe "with mime type of xml" do

it "renders the requested group as xml" do
Expand All @@ -45,11 +52,11 @@ def mock_group(stubs={})
end

end

end

describe "GET new" do

it "exposes a new group as @group" do
Group.should_receive(:new).and_return(mock_group)
get :new
Expand All @@ -59,7 +66,7 @@ def mock_group(stubs={})
end

describe "GET edit" do

it "exposes the requested group as @group" do
Group.should_receive(:find).with("37").and_return(mock_group)
get :edit, :id => "37"
Expand All @@ -71,7 +78,7 @@ def mock_group(stubs={})
describe "POST create" do

describe "with valid params" do

it "exposes a newly created group as @group" do
Group.should_receive(:new).with({'these' => 'params'}).and_return(mock_group(:save => true))
post :create, :group => {:these => 'params'}
Expand All @@ -83,9 +90,9 @@ def mock_group(stubs={})
post :create, :group => {}
response.should redirect_to(group_url(mock_group))
end

end

describe "with invalid params" do

it "exposes a newly created but unsaved group as @group" do
Expand All @@ -99,9 +106,9 @@ def mock_group(stubs={})
post :create, :group => {}
response.should render_template('new')
end

end

end

describe "PUT udpate" do
Expand All @@ -127,7 +134,7 @@ def mock_group(stubs={})
end

end

describe "with invalid params" do

it "updates the requested group" do
Expand Down Expand Up @@ -159,7 +166,7 @@ def mock_group(stubs={})
mock_group.should_receive(:destroy)
delete :destroy, :id => "37"
end

it "redirects to the groups list" do
Group.stub!(:find).and_return(mock_group(:destroy => true))
delete :destroy, :id => "1"
Expand All @@ -169,3 +176,4 @@ def mock_group(stubs={})
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@ def mock_person(stubs={})
@mock_person ||= mock_model(Person, stubs)
end

describe "When Logged In" do

before(:each) do
@login_warning= nil #{}"You need to be logged in to do that"
autho_login_as :admin
end

describe "GET index" do

it "exposes all people as @people" do
Person.should_receive(:find).with(:all).and_return([mock_person])
Person.should_receive(:search).with(nil, nil).and_return([mock_person])
get :index
assigns[:people].should == [mock_person]
end

describe "with mime type of xml" do

it "renders all people as xml" do
Person.should_receive(:find).with(:all).and_return(people = mock("Array of People"))
Person.should_receive(:search).with(nil, nil).and_return(people = mock("Array of People"))
people.should_receive(:to_xml).and_return("generated XML")
get :index, :format => 'xml'
response.body.should == "generated XML"
Expand Down Expand Up @@ -169,3 +176,4 @@ def mock_person(stubs={})
end

end
end
Loading

0 comments on commit 46a8ab3

Please sign in to comment.