From a69b55502d945730ba20b7c7855c0aae838429bc Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 21 Oct 2011 19:41:03 +0400 Subject: [PATCH] Added specs form merged branches --- spec/routing/permissions_routing_spec.rb | 35 +++++++++++++++++++ spec/routing/rights_routing_spec.rb | 35 +++++++++++++++++++ spec/routing/roles_routing_spec.rb | 35 +++++++++++++++++++ spec/views/permissions/edit.html.haml_spec.rb | 22 ++++++++++++ .../views/permissions/index.html.haml_spec.rb | 28 +++++++++++++++ spec/views/permissions/new.html.haml_spec.rb | 22 ++++++++++++ spec/views/permissions/show.html.haml_spec.rb | 21 +++++++++++ spec/views/rights/edit.html.haml_spec.rb | 22 ++++++++++++ spec/views/rights/index.html.haml_spec.rb | 28 +++++++++++++++ spec/views/rights/new.html.haml_spec.rb | 22 ++++++++++++ spec/views/rights/show.html.haml_spec.rb | 21 +++++++++++ spec/views/roles/edit.html.haml_spec.rb | 18 ++++++++++ spec/views/roles/index.html.haml_spec.rb | 20 +++++++++++ spec/views/roles/new.html.haml_spec.rb | 18 ++++++++++ spec/views/roles/show.html.haml_spec.rb | 15 ++++++++ test/integration/permission_test.rb | 10 ++++++ test/integration/right_test.rb | 10 ++++++ test/integration/role_test.rb | 10 ++++++ 18 files changed, 392 insertions(+) create mode 100644 spec/routing/permissions_routing_spec.rb create mode 100644 spec/routing/rights_routing_spec.rb create mode 100644 spec/routing/roles_routing_spec.rb create mode 100644 spec/views/permissions/edit.html.haml_spec.rb create mode 100644 spec/views/permissions/index.html.haml_spec.rb create mode 100644 spec/views/permissions/new.html.haml_spec.rb create mode 100644 spec/views/permissions/show.html.haml_spec.rb create mode 100644 spec/views/rights/edit.html.haml_spec.rb create mode 100644 spec/views/rights/index.html.haml_spec.rb create mode 100644 spec/views/rights/new.html.haml_spec.rb create mode 100644 spec/views/rights/show.html.haml_spec.rb create mode 100644 spec/views/roles/edit.html.haml_spec.rb create mode 100644 spec/views/roles/index.html.haml_spec.rb create mode 100644 spec/views/roles/new.html.haml_spec.rb create mode 100644 spec/views/roles/show.html.haml_spec.rb create mode 100644 test/integration/permission_test.rb create mode 100644 test/integration/right_test.rb create mode 100644 test/integration/role_test.rb diff --git a/spec/routing/permissions_routing_spec.rb b/spec/routing/permissions_routing_spec.rb new file mode 100644 index 000000000..287f50156 --- /dev/null +++ b/spec/routing/permissions_routing_spec.rb @@ -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 diff --git a/spec/routing/rights_routing_spec.rb b/spec/routing/rights_routing_spec.rb new file mode 100644 index 000000000..5ae75a976 --- /dev/null +++ b/spec/routing/rights_routing_spec.rb @@ -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 diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb new file mode 100644 index 000000000..4084a6e7e --- /dev/null +++ b/spec/routing/roles_routing_spec.rb @@ -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 diff --git a/spec/views/permissions/edit.html.haml_spec.rb b/spec/views/permissions/edit.html.haml_spec.rb new file mode 100644 index 000000000..05715ddbd --- /dev/null +++ b/spec/views/permissions/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/permissions/index.html.haml_spec.rb b/spec/views/permissions/index.html.haml_spec.rb new file mode 100644 index 000000000..67d29ede2 --- /dev/null +++ b/spec/views/permissions/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/permissions/new.html.haml_spec.rb b/spec/views/permissions/new.html.haml_spec.rb new file mode 100644 index 000000000..151976539 --- /dev/null +++ b/spec/views/permissions/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/permissions/show.html.haml_spec.rb b/spec/views/permissions/show.html.haml_spec.rb new file mode 100644 index 000000000..0460962bf --- /dev/null +++ b/spec/views/permissions/show.html.haml_spec.rb @@ -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

" 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 diff --git a/spec/views/rights/edit.html.haml_spec.rb b/spec/views/rights/edit.html.haml_spec.rb new file mode 100644 index 000000000..a1a9c538b --- /dev/null +++ b/spec/views/rights/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/rights/index.html.haml_spec.rb b/spec/views/rights/index.html.haml_spec.rb new file mode 100644 index 000000000..2a7129898 --- /dev/null +++ b/spec/views/rights/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/rights/new.html.haml_spec.rb b/spec/views/rights/new.html.haml_spec.rb new file mode 100644 index 000000000..063a74cd5 --- /dev/null +++ b/spec/views/rights/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/rights/show.html.haml_spec.rb b/spec/views/rights/show.html.haml_spec.rb new file mode 100644 index 000000000..81a8a36fa --- /dev/null +++ b/spec/views/rights/show.html.haml_spec.rb @@ -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

" 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 diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb new file mode 100644 index 000000000..9560395a1 --- /dev/null +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb new file mode 100644 index 000000000..d0ba6c026 --- /dev/null +++ b/spec/views/roles/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb new file mode 100644 index 000000000..dba3ada41 --- /dev/null +++ b/spec/views/roles/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb new file mode 100644 index 000000000..f49a5a36d --- /dev/null +++ b/spec/views/roles/show.html.haml_spec.rb @@ -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

" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + rendered.should match(/Name/) + end +end diff --git a/test/integration/permission_test.rb b/test/integration/permission_test.rb new file mode 100644 index 000000000..41f04d956 --- /dev/null +++ b/test/integration/permission_test.rb @@ -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 diff --git a/test/integration/right_test.rb b/test/integration/right_test.rb new file mode 100644 index 000000000..1f13dc615 --- /dev/null +++ b/test/integration/right_test.rb @@ -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 diff --git a/test/integration/role_test.rb b/test/integration/role_test.rb new file mode 100644 index 000000000..8bc8544bd --- /dev/null +++ b/test/integration/role_test.rb @@ -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