summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Lee2015-07-08 17:29:12 (GMT)
committerDamian Lee2015-07-08 17:29:12 (GMT)
commit44098bb9da5447765da02bd7b3bc974661acc5e4 (patch)
tree0863353fd04b2370c6130a443bc8dd8347d618e2
parent01d61ad155999e995821a139a75e75630993cf76 (diff)
Always use display configured path in access handler7.x-1.5
-rw-r--r--plugins/views_plugin_access_menu.inc11
-rw-r--r--tests/admin_views.test36
2 files changed, 43 insertions, 4 deletions
diff --git a/plugins/views_plugin_access_menu.inc b/plugins/views_plugin_access_menu.inc
index 1d76324..82c9cea 100644
--- a/plugins/views_plugin_access_menu.inc
+++ b/plugins/views_plugin_access_menu.inc
@@ -19,14 +19,17 @@ class views_plugin_access_menu extends views_plugin_access {
* In that case, we need to check access to the router path manually.
*/
function access($account) {
+ // Retrieve the original router path for this view, and check access to it.
+ // Get this based on the display property of this access plugin, not the
+ // view itself. The 'current display' could be set to something else, like
+ // default.
+ $path = $this->display->handler->get_option('path');
+ $item = menu_get_item($path);
+
// If we are on the original router path, the menu system has checked access already.
- $item = menu_get_item();
if ($item['href'] == $_GET['q']) {
return TRUE;
}
- // Retrieve the original router path for this view, and check access to it.
- $path = $this->view->display_handler->get_option('path');
- $item = menu_get_item($path);
return $item['access'];
}
diff --git a/tests/admin_views.test b/tests/admin_views.test
index 7ffa639..727bded 100644
--- a/tests/admin_views.test
+++ b/tests/admin_views.test
@@ -249,3 +249,39 @@ class AdminViewsPageDisplayTestCase extends AdminViewsWebTestCase {
return $view;
}
}
+
+/**
+ * Tests default views.
+ */
+class AdminViewsAccessHandlerTestCase extends AdminViewsWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'Access handler',
+ 'description' => 'Tests views_plugin_access_menu handler.',
+ 'group' => 'Administration views',
+ );
+ }
+
+ function setUp() {
+ parent::setUp(array('node'));
+ }
+
+ /**
+ * Tests access handler via views/ajax.
+ */
+ function testAjaxAccess() {
+ $params = array(
+ 'view_name' => 'admin_views_user',
+ 'view_display_id' => 'system_1',
+ );
+ $response_data = $this->drupalGetAJAX('views/ajax', array('query' => $params));
+
+ $this->assertResponse(200);
+ // Check no views settings are returned.
+ $this->assertTrue(empty($response_data[0]['settings']['views']));
+ // The next item in the AJAX data will be the insert command containing the
+ // rendered view.
+ $this->assertTrue(empty($response_data[1]));
+ }
+}