Commit 6787d6ea31318c45e14a1160e692e1768c631be5
1 parent
51453c89
Exists in
master
and in
29 other branches
metadata: Add test for new product crash (Closes #81)
Showing
2 changed files
with
28 additions
and
1 deletions
Show diff stats
plugins/metadata/test/functional/home_controller_test.rb
| @@ -12,7 +12,7 @@ class HomeControllerTest < ActionController::TestCase | @@ -12,7 +12,7 @@ class HomeControllerTest < ActionController::TestCase | ||
| 12 | @response = ActionController::TestResponse.new | 12 | @response = ActionController::TestResponse.new |
| 13 | 13 | ||
| 14 | Noosfero::Plugin.stubs(:all).returns([MetadataPlugin.name]) | 14 | Noosfero::Plugin.stubs(:all).returns([MetadataPlugin.name]) |
| 15 | - Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([MetadataPlugin.new]) | 15 | + Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([MetadataPlugin.new(@controller)]) |
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | should 'display meta tags for social media' do | 18 | should 'display meta tags for social media' do |
plugins/metadata/test/functional/manage_products_controller_test.rb
0 → 100644
| @@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
| 1 | +require 'test_helper' | ||
| 2 | +require 'home_controller' | ||
| 3 | + | ||
| 4 | +# Re-raise errors caught by the controller. | ||
| 5 | +class ManageProductsController; def rescue_action(e) raise e end; end | ||
| 6 | + | ||
| 7 | +class ManageProductsControllerTest < ActionController::TestCase | ||
| 8 | + | ||
| 9 | + def setup | ||
| 10 | + @controller = ManageProductsController.new | ||
| 11 | + @request = ActionController::TestRequest.new | ||
| 12 | + @response = ActionController::TestResponse.new | ||
| 13 | + @enterprise = fast_create(Enterprise, name: 'test', identifier: 'test_ent') | ||
| 14 | + @user = create_user_with_permission('test_user', 'manage_products', @enterprise) | ||
| 15 | + @environment = @enterprise.environment | ||
| 16 | + @environment.enable('products_for_enterprises') | ||
| 17 | + login_as :test_user | ||
| 18 | + | ||
| 19 | + Noosfero::Plugin.stubs(:all).returns([MetadataPlugin.name]) | ||
| 20 | + Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([MetadataPlugin.new(@controller)]) | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | + should "not crash on new products" do | ||
| 24 | + get :new, profile: @enterprise.identifier | ||
| 25 | + end | ||
| 26 | + | ||
| 27 | +end |