Added specs form merged branches

This commit is contained in:
George Vinogradov 2011-10-21 19:41:03 +04:00
parent 600a897490
commit a69b55502d
18 changed files with 392 additions and 0 deletions

View File

@ -0,0 +1,35 @@
require "spec_helper"
describe PermissionsController do
describe "routing" do
it "routes to #index" do
get("/permissions").should route_to("permissions#index")
end
it "routes to #new" do
get("/permissions/new").should route_to("permissions#new")
end
it "routes to #show" do
get("/permissions/1").should route_to("permissions#show", :id => "1")
end
it "routes to #edit" do
get("/permissions/1/edit").should route_to("permissions#edit", :id => "1")
end
it "routes to #create" do
post("/permissions").should route_to("permissions#create")
end
it "routes to #update" do
put("/permissions/1").should route_to("permissions#update", :id => "1")
end
it "routes to #destroy" do
delete("/permissions/1").should route_to("permissions#destroy", :id => "1")
end
end
end

View File

@ -0,0 +1,35 @@
require "spec_helper"
describe RightsController do
describe "routing" do
it "routes to #index" do
get("/rights").should route_to("rights#index")
end
it "routes to #new" do
get("/rights/new").should route_to("rights#new")
end
it "routes to #show" do
get("/rights/1").should route_to("rights#show", :id => "1")
end
it "routes to #edit" do
get("/rights/1/edit").should route_to("rights#edit", :id => "1")
end
it "routes to #create" do
post("/rights").should route_to("rights#create")
end
it "routes to #update" do
put("/rights/1").should route_to("rights#update", :id => "1")
end
it "routes to #destroy" do
delete("/rights/1").should route_to("rights#destroy", :id => "1")
end
end
end

View File

@ -0,0 +1,35 @@
require "spec_helper"
describe RolesController do
describe "routing" do
it "routes to #index" do
get("/roles").should route_to("roles#index")
end
it "routes to #new" do
get("/roles/new").should route_to("roles#new")
end
it "routes to #show" do
get("/roles/1").should route_to("roles#show", :id => "1")
end
it "routes to #edit" do
get("/roles/1/edit").should route_to("roles#edit", :id => "1")
end
it "routes to #create" do
post("/roles").should route_to("roles#create")
end
it "routes to #update" do
put("/roles/1").should route_to("roles#update", :id => "1")
end
it "routes to #destroy" do
delete("/roles/1").should route_to("roles#destroy", :id => "1")
end
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe "permissions/edit.html.haml" do
before(:each) do
@permission = assign(:permission, stub_model(Permission,
:role_id => 1,
:right_id => 1,
:access_obj_id => 1
))
end
it "renders the edit permission form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => permissions_path(@permission), :method => "post" do
assert_select "input#permission_role_id", :name => "permission[role_id]"
assert_select "input#permission_right_id", :name => "permission[right_id]"
assert_select "input#permission_access_obj_id", :name => "permission[access_obj_id]"
end
end
end

View File

@ -0,0 +1,28 @@
require 'spec_helper'
describe "permissions/index.html.haml" do
before(:each) do
assign(:permissions, [
stub_model(Permission,
:role_id => 1,
:right_id => 1,
:access_obj_id => 1
),
stub_model(Permission,
:role_id => 1,
:right_id => 1,
:access_obj_id => 1
)
])
end
it "renders a list of permissions" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => 1.to_s, :count => 2
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => 1.to_s, :count => 2
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => 1.to_s, :count => 2
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe "permissions/new.html.haml" do
before(:each) do
assign(:permission, stub_model(Permission,
:role_id => 1,
:right_id => 1,
:access_obj_id => 1
).as_new_record)
end
it "renders new permission form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => permissions_path, :method => "post" do
assert_select "input#permission_role_id", :name => "permission[role_id]"
assert_select "input#permission_right_id", :name => "permission[right_id]"
assert_select "input#permission_access_obj_id", :name => "permission[access_obj_id]"
end
end
end

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe "permissions/show.html.haml" do
before(:each) do
@permission = assign(:permission, stub_model(Permission,
:role_id => 1,
:right_id => 1,
:access_obj_id => 1
))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe "rights/edit.html.haml" do
before(:each) do
@right = assign(:right, stub_model(Right,
:controller_name => "MyString",
:method_name => "MyString",
:name => "MyString"
))
end
it "renders the edit right form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => rights_path(@right), :method => "post" do
assert_select "input#right_controller_name", :name => "right[controller_name]"
assert_select "input#right_method_name", :name => "right[method_name]"
assert_select "input#right_name", :name => "right[name]"
end
end
end

View File

@ -0,0 +1,28 @@
require 'spec_helper'
describe "rights/index.html.haml" do
before(:each) do
assign(:rights, [
stub_model(Right,
:controller_name => "Controller Name",
:method_name => "Method Name",
:name => "Name"
),
stub_model(Right,
:controller_name => "Controller Name",
:method_name => "Method Name",
:name => "Name"
)
])
end
it "renders a list of rights" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => "Controller Name".to_s, :count => 2
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => "Method Name".to_s, :count => 2
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => "Name".to_s, :count => 2
end
end

View File

@ -0,0 +1,22 @@
require 'spec_helper'
describe "rights/new.html.haml" do
before(:each) do
assign(:right, stub_model(Right,
:controller_name => "MyString",
:method_name => "MyString",
:name => "MyString"
).as_new_record)
end
it "renders new right form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => rights_path, :method => "post" do
assert_select "input#right_controller_name", :name => "right[controller_name]"
assert_select "input#right_method_name", :name => "right[method_name]"
assert_select "input#right_name", :name => "right[name]"
end
end
end

View File

@ -0,0 +1,21 @@
require 'spec_helper'
describe "rights/show.html.haml" do
before(:each) do
@right = assign(:right, stub_model(Right,
:controller_name => "Controller Name",
:method_name => "Method Name",
:name => "Name"
))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Controller Name/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Method Name/)
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Name/)
end
end

View File

@ -0,0 +1,18 @@
require 'spec_helper'
describe "roles/edit.html.haml" do
before(:each) do
@role = assign(:role, stub_model(Role,
:name => "MyString"
))
end
it "renders the edit role form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => roles_path(@role), :method => "post" do
assert_select "input#role_name", :name => "role[name]"
end
end
end

View File

@ -0,0 +1,20 @@
require 'spec_helper'
describe "roles/index.html.haml" do
before(:each) do
assign(:roles, [
stub_model(Role,
:name => "Name"
),
stub_model(Role,
:name => "Name"
)
])
end
it "renders a list of roles" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => "Name".to_s, :count => 2
end
end

View File

@ -0,0 +1,18 @@
require 'spec_helper'
describe "roles/new.html.haml" do
before(:each) do
assign(:role, stub_model(Role,
:name => "MyString"
).as_new_record)
end
it "renders new role form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => roles_path, :method => "post" do
assert_select "input#role_name", :name => "role[name]"
end
end
end

View File

@ -0,0 +1,15 @@
require 'spec_helper'
describe "roles/show.html.haml" do
before(:each) do
@role = assign(:role, stub_model(Role,
:name => "Name"
))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Name/)
end
end

View File

@ -0,0 +1,10 @@
require 'test_helper'
class PermissionTest < ActionDispatch::IntegrationTest
fixtures :all
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,10 @@
require 'test_helper'
class RightTest < ActionDispatch::IntegrationTest
fixtures :all
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,10 @@
require 'test_helper'
class RoleTest < ActionDispatch::IntegrationTest
fixtures :all
# Replace this with your real tests.
test "the truth" do
assert true
end
end