diff --git a/modules/contextual/contextual.test b/modules/contextual/contextual.test
index 79eedb8..46bad38 100644
--- a/modules/contextual/contextual.test
+++ b/modules/contextual/contextual.test
@@ -47,3 +47,46 @@ class ContextualDynamicContextTestCase extends DrupalWebTestCase {
     $this->assertRaw('node/' . $node3->nid . '/edit', 'Edit link for most recent article node showing.');
   }
 }
+
+/**
+ * Tests to ensure that contextual links in blocks are cached properly.
+ */
+class ContextualBlockCacheTestCase extends DrupalWebTestCase {
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Contextual link block caching',
+      'description' => 'Tests if contextual links in blocks are cached properly and not shown to users without the correct permissions.',
+      'group' => 'Contextual',
+    );
+  }
+
+  function setUp() {
+    parent::setUp(array('contextual', 'block', 'forum'));
+    $web_user = $this->drupalCreateUser(array('access content', 'access contextual links', 'administer blocks'));
+    $this->drupalLogin($web_user);
+  }
+
+  /**
+   * Tests contextual links on Active forum topics block with different users.
+   */
+  function testForumBlock() {
+    // Set the forum_active block to the content region.
+    $edit = array();
+    $edit['blocks[forum_active][region]'] = 'content';
+    $edit['blocks[system_main][region]'] = 'content';
+    $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
+    $this->assertText(t('The block settings have been updated.'), 'Active forum topics block successfully moved to content region.');
+
+    // Make sure the block is visible on the front page to the logged in user.
+    $this->drupalGet('node');
+    $this->assertLinkByHref('admin/structure/block/manage/forum/active/configure', 0, 'Configure block link for Active forum topics block is displayed.');
+
+    // Log out and make sure the "Configure block" link is not visible to
+    // anonymous users.
+    $this->drupalLogout();
+    $this->drupalGet('node');
+    $this->assertNoLinkByHref('admin/structure/block/manage/forum/active/configure', 'Configure block link for Active forum topics block is not displayed for logged out user.');
+  }
+}
