On 05/23/2011 12:38 PM, Adam Young wrote:
On 05/23/2011 12:06 PM, Endi Sukma Dewata wrote:
On 5/23/2011 9:42 AM, Adam Young wrote:
Patch 227 is the automount patch that I still am not ready to submit.
This patch stands alone.
A few issues in IPA.get_entity():
1. It executes that.entities.get() twice. The result of the first
invocation can be stored in a variable and reused later. The result
of the factory() invocation can be assigned to the same variable.
2. It executes factory = that.entity_factories[name] twice. The second
one can be removed.
Other than that it's ACKed and can be pushed after fixing the above
issues.
Now with fixed unit tests
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
Better navigation test
From 3ad21ca10461d0b2f8d34ab1e658799bab0c72b7 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Mon, 23 May 2011 10:39:09 -0400
Subject: [PATCH] create entities on demand. fixed changes from code review
Fixed unit tests for entity on demand changes.
---
install/ui/ipa.js | 31 ++++++++++++++-----------------
install/ui/test/details_tests.js | 1 -
install/ui/test/navigation_tests.js | 9 ++++-----
install/ui/webui.js | 2 --
4 files changed, 18 insertions(+), 25 deletions(-)
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 8f11b92df2e86adc61758da1790e900e562f2510..13c894fa6b614eb982e22f9dc01784c130092e70 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -131,31 +131,28 @@ var IPA = ( function () {
};
that.get_entity = function(name) {
- return that.entities.get(name);
- };
-
- that.add_entity = function(entity) {
- that.entities.put(entity.name, entity);
- };
-
- that.remove_entity = function(name) {
- that.entities.remove(name);
- };
-
- that.start_entities = function() {
- var factory;
- var name;
- for (name in that.entity_factories) {
- factory = that.entity_factories[name];
+ var entity = that.entities.get(name);
+ if (!entity){
+ var factory = that.entity_factories[name];
try {
- var entity = factory();
+ entity = factory();
that.add_entity(entity);
entity.init();
} catch (e) {
/*exceptions thrown by builder just mean that entities
are not to be registered. */
+ return null;
}
}
+ return entity;
+ };
+
+ that.add_entity = function(entity) {
+ that.entities.put(entity.name, entity);
+ };
+
+ that.remove_entity = function(name) {
+ that.entities.remove(name);
};
that.test_dirty = function(){
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 8f98f1fef33e19ba8400266ee7faf632da40764c..ca4658f8712f7925001c8a59d4de3bb6ae5aeb3a 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -43,7 +43,6 @@ module('details', {
return IPA.entity({name:obj_name,
metadata:IPA.metadata.objects.user});
};
- IPA.start_entities();
},
teardown: function() {
details_container.remove();
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index 0f8f1be4a886074ca6946316f356dc9b0c6aadd4..d9bcc8eb6dd0feadc518d840d03649f4b10b0ef5 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -20,6 +20,7 @@
module('navigation', {
+
setup: function() {
IPA.ajax_options.async = false;
IPA.init(
@@ -32,11 +33,14 @@ module('navigation', {
}
);
}
+
});
test("Testing IPA.navigation.create().", function() {
var entity;
+ var user_mock_called = false;
+ var group_mock_called = false;
IPA.entity_factories.user = function() {
var that = IPA.entity({name: 'user',
@@ -59,13 +63,8 @@ test("Testing IPA.navigation.create().", function() {
return that;
};
- IPA.start_entities();
-
- IPA.metadata = {};
var navigation_container = $('<div id="navigation"/>').appendTo(document.body);
var entity_container = $('<div id="content"/>').appendTo(document.body);
- var user_mock_called = false;
- var group_mock_called = false;
var navigation = IPA.navigation({
container: navigation_container,
diff --git a/install/ui/webui.js b/install/ui/webui.js
index b9d050c29a0c93d96d242c16b873e3825ed82a95..00c35b459d0f649b773e308916fdc1a845c6ec4e 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -143,8 +143,6 @@ $(function() {
$('#loggedinas a').fragment(
{'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
- IPA.start_entities();
-
IPA.nav = create_navigation();
IPA.nav.create();
IPA.nav.update();
--
1.7.5.1
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel