[noosfero/noosfero][master] 3 commits: Fix 'I edit my profile' step definition
Victor Costa
gitlab at gitlab.com
Tue Mar 24 18:00:17 BRT 2015
Victor Costa pushed to master at Noosfero / noosfero
Commits:
84904a0e by Victor Costa at 2015-03-24T15:38:47Z
Fix 'I edit my profile' step definition
Store current user to use it later in 'I edit my profile'
- - - - -
156ae506 by Victor Costa at 2015-03-24T16:33:24Z
require_auth_to_comment: fix tests
- - - - -
793f7219 by Victor Costa at 2015-03-24T17:28:07Z
display_content: fix tests
- - - - -
6 changed files:
- features/step_definitions/noosfero_steps.rb
- plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
- plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
- plugins/display_content/test/test_helper.rb
- plugins/require_auth_to_comment/features/require_auth_to_comment.feature
- plugins/require_auth_to_comment/lib/ext/profile.rb
Changes:
=====================================
features/step_definitions/noosfero_steps.rb
=====================================
--- a/features/step_definitions/noosfero_steps.rb
+++ b/features/step_definitions/noosfero_steps.rb
@@ -293,6 +293,7 @@ Given /^I am logged in as "(.+)"$/ do |username|
When %{I press "Log in"}
And %{I go to #{username}'s control panel}
Then %{I should be on #{username}'s control panel}
+ @current_user = username
end
Given /^"([^"]*)" is environment admin$/ do |person|
=====================================
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
=====================================
--- a/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
+++ b/plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -40,7 +40,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
Article.delete_all
get :index, :block_id => block.id
json_response = ActiveSupport::JSON.decode(@response.body)
- assert_equivalent [], json_response
+ assert_equal [], json_response
end
should 'index action returns an json with node content' do
@@ -52,7 +52,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
expected_json = {'data' => article.title}
expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with node checked if the node is in the nodes list' do
@@ -67,7 +67,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
expected_json['attr'].merge!({'class' => 'jstree-checked'})
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
@@ -95,7 +95,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
expected_json['state'] = 'closed'
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with all the children nodes if some parent is in the parents list' do
@@ -118,7 +118,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
expected_json['children'] = children
expected_json['state'] = 'closed'
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
@@ -148,7 +148,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id, "class" => "jstree-checked"}
expected_json.push(value)
- assert_equivalent expected_json, json_response
+ assert_hash_equivalent expected_json, json_response
end
should 'index action returns an json without children nodes if the parent is not in the parents list' do
@@ -170,7 +170,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase
value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
expected_json.push(value)
- assert_equivalent expected_json, json_response
+ assert_hash_equivalent expected_json, json_response
end
end
=====================================
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
=====================================
--- a/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
+++ b/plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
Article.delete_all
get :index, :block_id => block.id, :profile => profile.identifier
json_response = ActiveSupport::JSON.decode(@response.body)
- assert_equivalent [], json_response
+ assert_equal [], json_response
end
should 'index action returns an json with node content' do
@@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
expected_json = {'data' => article.title}
expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with node checked if the node is in the nodes list' do
@@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
expected_json['attr'].merge!({'class' => 'jstree-checked'})
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
@@ -97,7 +97,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
expected_json['state'] = 'closed'
- assert_equivalent [expected_json], json_response
+ assert_hash_equivalent [expected_json], json_response
end
should 'index action returns an json with all the children nodes if some parent is in the parents list' do
@@ -120,26 +120,26 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
expected_json['children'] = children
expected_json['state'] = 'closed'
- assert_equivalent [expected_json], json_response
- end
-
- should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
- Article.delete_all
- f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id)
- a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id)
- a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id)
- a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id)
- block.checked_nodes = {a1.id => true}
- block.save!
-
- get :index, :block_id => block.id, :profile => profile.identifier
- json_response = ActiveSupport::JSON.decode(@response.body)
- expected_json = []
- value = {'data' => f.title}
- value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
- children = [
- {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id, "class" => "jstree-checked"}},
- {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}}
+ assert_hash_equivalent [expected_json], json_response
+ end
+
+ should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
+ Article.delete_all
+ f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id)
+ a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id)
+ a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id)
+ a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id)
+ block.checked_nodes = {a1.id => true}
+ block.save!
+
+ get :index, :block_id => block.id, :profile => profile.identifier
+ json_response = ActiveSupport::JSON.decode(@response.body)
+ expected_json = []
+ value = {'data' => f.title}
+ value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
+ children = [
+ {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id, "class" => "jstree-checked"}},
+ {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}}
]
value['attr'].merge!({'class' => 'jstree-undetermined'})
value['children'] = children
@@ -150,7 +150,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
expected_json.push(value)
- assert_equivalent expected_json, json_response
+ assert_hash_equivalent expected_json, json_response
end
should 'index action returns an json without children nodes if the parent is not in the parents list' do
@@ -172,7 +172,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase
value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
expected_json.push(value)
- assert_equivalent expected_json, json_response
+ assert_hash_equivalent expected_json, json_response
end
end
=====================================
plugins/display_content/test/test_helper.rb
=====================================
--- a/plugins/display_content/test/test_helper.rb
+++ b/plugins/display_content/test/test_helper.rb
@@ -1 +1,11 @@
-require File.dirname(__FILE__) + '/../../../test/test_helper'
+require_relative "../../../test/test_helper"
+
+def sort_by_data(array)
+ return if array.blank?
+ array.each {|el| el['children'] = sort_by_data(el['children']) }
+ array.sort_by {|el| el['data']}
+end
+
+def assert_hash_equivalent(expected, response)
+ assert_equal sort_by_data(expected), sort_by_data(response)
+end
=====================================
plugins/require_auth_to_comment/features/require_auth_to_comment.feature
=====================================
--- a/plugins/require_auth_to_comment/features/require_auth_to_comment.feature
+++ b/plugins/require_auth_to_comment/features/require_auth_to_comment.feature
@@ -1,7 +1,7 @@
Feature: require authentication to comment
Background:
- Given plugin RequireAuthToCommentPlugin is enabled on environment
+ Given plugin RequireAuthToComment is enabled on environment
And the following users
| login |
| bozo |
=====================================
plugins/require_auth_to_comment/lib/ext/profile.rb
=====================================
--- a/plugins/require_auth_to_comment/lib/ext/profile.rb
+++ b/plugins/require_auth_to_comment/lib/ext/profile.rb
@@ -3,4 +3,8 @@ require_dependency 'profile'
class Profile
settings_items :allow_unauthenticated_comments, :type => :boolean
attr_accessible :allow_unauthenticated_comments
+
+ descendants.each do |descendant|
+ descendant.attr_accessible :allow_unauthenticated_comments
+ end
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/365042dabe707ea1c2758b7369851e4ae41a998c...793f7219d5a529771720214beb33d225779891e2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150324/3f7a03a3/attachment-0001.html>
More information about the Noosfero-dev
mailing list