summaryrefslogtreecommitdiff
path: root/modules/gallery/tests/Item_Model_Test.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-06-08 20:59:24 -0700
committerBharat Mediratta <bharat@menalto.com>2010-06-08 20:59:24 -0700
commitb40057283e1dfbb3bbb41a6dfc8ccc8e2111d810 (patch)
tree7874b8363f0992ecc8f1b294b06474b7a50d1927 /modules/gallery/tests/Item_Model_Test.php
parent9ec600fd459ab16008f6ced11e55778505b2a099 (diff)
Add a "can_edit" field to the Item_Model's REST output. It's
applicable to the current user.
Diffstat (limited to 'modules/gallery/tests/Item_Model_Test.php')
-rw-r--r--modules/gallery/tests/Item_Model_Test.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 6c5882c4..3df6197d 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Item_Model_Test extends Gallery_Unit_Test_Case {
+ public function teardown() {
+ identity::set_active_user(identity::admin_user());
+ }
+
public function saving_sets_created_and_updated_dates_test() {
$item = test::random_photo();
$this->assert_true(!empty($item->created));
@@ -376,6 +380,15 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(!array_key_exists("album_cover_item", $result));
}
+ public function as_restful_array_with_edit_bit_test() {
+ $response = item::root()->as_restful_array(true);
+ $this->assert_true($response["can_edit"]);
+
+ identity::set_active_user(identity::guest());
+ $response = item::root()->as_restful_array(true);
+ $this->assert_false($response["can_edit"]);
+ }
+
public function first_photo_becomes_album_cover() {
$album = test::random_album();
$photo = test::random_photo($album);