diff --git a/config/optional/views.view.content_revisions.yml b/config/optional/views.view.content_revisions.yml
new file mode 100644
index 0000000..b00f997
--- /dev/null
+++ b/config/optional/views.view.content_revisions.yml
@@ -0,0 +1,699 @@
+langcode: en
+status: true
+dependencies:
+  module:
+    - moderation_state
+    - node
+    - user
+id: content_revisions
+label: 'Content Revisions'
+module: views
+description: 'View the revisions of a node.'
+tag: ''
+base_table: node_field_revision
+base_field: vid
+core: 8.x
+display:
+  default:
+    display_plugin: default
+    id: default
+    display_title: Master
+    position: 0
+    display_options:
+      access:
+        type: perm
+        options:
+          perm: 'view all revisions'
+      cache:
+        type: tag
+        options: {  }
+      query:
+        type: views_query
+        options:
+          disable_sql_rewrite: false
+          distinct: false
+          replica: false
+          query_comment: ''
+          query_tags: {  }
+      exposed_form:
+        type: basic
+        options:
+          submit_button: Apply
+          reset_button: false
+          reset_button_label: Reset
+          exposed_sorts_label: 'Sort by'
+          expose_sort_order: true
+          sort_asc_label: Asc
+          sort_desc_label: Desc
+      pager:
+        type: full
+        options:
+          items_per_page: 10
+          offset: 0
+          id: 0
+          total_pages: null
+          expose:
+            items_per_page: false
+            items_per_page_label: 'Items per page'
+            items_per_page_options: '5, 10, 25, 50'
+            items_per_page_options_all: false
+            items_per_page_options_all_label: '- All -'
+            offset: false
+            offset_label: Offset
+          tags:
+            previous: '‹ Previous'
+            next: 'Next ›'
+            first: '« First'
+            last: 'Last »'
+          quantity: 9
+      style:
+        type: table
+        options:
+          grouping: {  }
+          row_class: ''
+          default_row_class: true
+          override: true
+          sticky: false
+          caption: ''
+          summary: ''
+          description: ''
+          columns:
+            changed: changed
+            uid: changed
+            link_to_revision: link_to_revision
+            revert_revision: revert_revision
+            delete_revision: delete_revision
+            dropbutton: dropbutton
+          info:
+            changed:
+              sortable: false
+              default_sort_order: asc
+              align: ''
+              separator: ' by '
+              empty_column: false
+              responsive: ''
+            uid:
+              sortable: false
+              default_sort_order: asc
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: ''
+            link_to_revision:
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: ''
+            revert_revision:
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: ''
+            delete_revision:
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: ''
+            dropbutton:
+              sortable: false
+              default_sort_order: asc
+              align: ''
+              separator: ''
+              empty_column: false
+              responsive: ''
+          default: '-1'
+          empty_table: false
+      row:
+        type: fields
+      fields:
+        title:
+          id: title
+          table: node_field_revision
+          field: title
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: Title
+          exclude: true
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          click_sort_column: value
+          type: string
+          settings:
+            link_to_entity: false
+          group_column: value
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+          entity_type: node
+          entity_field: title
+          plugin_id: field
+        changed:
+          id: changed
+          table: node_field_revision
+          field: changed
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: Revision
+          exclude: false
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: '{{ link_to_revision }}'
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: '{{ changed }}'
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: false
+            ellipsis: false
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          click_sort_column: value
+          type: timestamp
+          settings:
+            date_format: short
+            custom_date_format: ''
+            timezone: ''
+          group_column: value
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+          entity_type: node
+          entity_field: changed
+          plugin_id: field
+        uid:
+          id: uid
+          table: node_field_revision
+          field: uid
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: 'Authored by'
+          exclude: false
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          click_sort_column: target_id
+          type: entity_reference_label
+          settings:
+            link: true
+          group_column: target_id
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+          entity_type: node
+          entity_field: uid
+          plugin_id: field
+        moderation_state:
+          id: moderation_state
+          table: node_field_revision
+          field: moderation_state
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: State
+          exclude: false
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          click_sort_column: target_id
+          type: entity_reference_label
+          settings:
+            link: false
+          group_column: target_id
+          group_columns: {  }
+          group_rows: true
+          delta_limit: 0
+          delta_offset: 0
+          delta_reversed: false
+          delta_first_last: false
+          multi_type: separator
+          separator: ', '
+          field_api_classes: false
+          entity_type: node
+          entity_field: moderation_state
+          plugin_id: field
+        set_current_revision:
+          id: set_current_revision
+          table: node_field_revision
+          field: set_current_revision
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: 'Link to set the current revision'
+          exclude: true
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          text: 'Set current'
+          entity_type: node
+          plugin_id: node_revision_link_set_current
+        link_to_revision:
+          id: link_to_revision
+          table: node_field_revision
+          field: link_to_revision
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: ''
+          exclude: true
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: true
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: false
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: false
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          text: ''
+          entity_type: node
+          plugin_id: node_revision_link
+        delete_revision:
+          id: delete_revision
+          table: node_field_revision
+          field: delete_revision
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: 'Link to delete revision'
+          exclude: true
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          text: Delete
+          entity_type: node
+          plugin_id: node_revision_link_delete
+        dropbutton:
+          id: dropbutton
+          table: views
+          field: dropbutton
+          relationship: none
+          group_type: group
+          admin_label: ''
+          label: Operations
+          exclude: false
+          alter:
+            alter_text: false
+            text: ''
+            make_link: false
+            path: ''
+            absolute: false
+            external: false
+            replace_spaces: false
+            path_case: none
+            trim_whitespace: false
+            alt: ''
+            rel: ''
+            link_class: ''
+            prefix: ''
+            suffix: ''
+            target: ''
+            nl2br: false
+            max_length: 0
+            word_boundary: true
+            ellipsis: true
+            more_link: false
+            more_link_text: ''
+            more_link_path: ''
+            strip_tags: false
+            trim: false
+            preserve_tags: ''
+            html: false
+          element_type: ''
+          element_class: ''
+          element_label_type: ''
+          element_label_class: ''
+          element_label_colon: true
+          element_wrapper_type: ''
+          element_wrapper_class: ''
+          element_default_classes: true
+          empty: ''
+          hide_empty: false
+          empty_zero: false
+          hide_alter_empty: true
+          fields:
+            set_current_revision: set_current_revision
+            link_to_revision: link_to_revision
+            delete_revision: delete_revision
+            changed: '0'
+            uid: '0'
+            moderation_state: '0'
+          destination: true
+          plugin_id: dropbutton
+      filters: {  }
+      sorts:
+        changed:
+          id: changed
+          table: node_field_revision
+          field: changed
+          relationship: none
+          group_type: group
+          admin_label: ''
+          order: DESC
+          exposed: false
+          expose:
+            label: ''
+          granularity: second
+          entity_type: node
+          entity_field: changed
+          plugin_id: date
+      title: 'Revisions for {{ title }}'
+      header: {  }
+      footer: {  }
+      empty: {  }
+      relationships: {  }
+      arguments:
+        nid:
+          id: nid
+          table: node_field_revision
+          field: nid
+          relationship: none
+          group_type: group
+          admin_label: ''
+          default_action: empty
+          exception:
+            value: all
+            title_enable: false
+            title: All
+          title_enable: true
+          title: 'Revisions for <em>{{ arguments.nid }}</em>'
+          default_argument_type: fixed
+          default_argument_options:
+            argument: ''
+          default_argument_skip_url: false
+          summary_options:
+            base_path: ''
+            count: true
+            items_per_page: 25
+            override: false
+          summary:
+            sort_order: asc
+            number_of_records: 0
+            format: default_summary
+          specify_validation: false
+          validate:
+            type: none
+            fail: 'not found'
+          validate_options: {  }
+          break_phrase: false
+          not: false
+          entity_type: node
+          entity_field: nid
+          plugin_id: node_nid
+      display_extenders: {  }
+    cache_metadata:
+      max-age: 0
+      contexts:
+        - 'languages:language_content'
+        - 'languages:language_interface'
+        - url
+        - url.query_args
+        - 'user.node_grants:view'
+        - user.permissions
+      tags: {  }
+  page_1:
+    display_plugin: page
+    id: page_1
+    display_title: Page
+    position: 1
+    display_options:
+      display_extenders: {  }
+      path: node/%/revisions
+      menu:
+        type: tab
+        title: Revisions
+        description: ''
+        expanded: false
+        parent: ''
+        weight: 0
+        context: '0'
+        menu_name: main
+      enabled: true
+    cache_metadata:
+      max-age: 0
+      contexts:
+        - 'languages:language_content'
+        - 'languages:language_interface'
+        - url
+        - url.query_args
+        - 'user.node_grants:view'
+        - user.permissions
+      tags: {  }
diff --git a/config/schema/moderation_state.views.schema.yml b/config/schema/moderation_state.views.schema.yml
new file mode 100644
index 0000000..60f4db3
--- /dev/null
+++ b/config/schema/moderation_state.views.schema.yml
@@ -0,0 +1,9 @@
+# Schema for the views plugins of the moderation state module.
+
+views.field.node_revision_link_set_current:
+  type: views_field
+  label: 'Link to set the current revision'
+  mapping:
+    text:
+      type: label
+      label: 'Text to display'
diff --git a/moderation_state.views.inc b/moderation_state.views.inc
new file mode 100644
index 0000000..5a9b2de
--- /dev/null
+++ b/moderation_state.views.inc
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @file
+ * Contains Views hook implementations.
+ */
+
+/**
+ * Implements hook_view_data_alter().
+ */
+function moderation_state_views_data_alter(array &$data) {
+  $data['node_field_revision']['set_current_revision'] = array(
+    'field' => array(
+      'title' => t('Link to set the current revision'),
+      'help' => t('Provide a simple link to set the revision as current.'),
+      'id' => 'node_revision_link_set_current',
+      'click sortable' => FALSE,
+    ),
+  );
+}
diff --git a/src/Plugin/views/field/RevisionLinkSetCurrent.php b/src/Plugin/views/field/RevisionLinkSetCurrent.php
new file mode 100644
index 0000000..7e906a8
--- /dev/null
+++ b/src/Plugin/views/field/RevisionLinkSetCurrent.php
@@ -0,0 +1,96 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\moderation_state\Plugin\views\field\RevisionLinkSetCurrent
+ */
+
+namespace Drupal\moderation_state\Plugin\views\field;
+
+use Drupal\Core\Access\AccessManagerInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\node\Plugin\views\field\RevisionLinkRevert;
+use Drupal\views\ResultRow;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Provides a field handler so set a revision as current.
+ *
+ * @ingroup views_field_handlers
+ *
+ * @ViewsField("node_revision_link_set_current")
+ */
+class RevisionLinkSetCurrent extends RevisionLinkRevert {
+
+  /**
+   * The access manager service.
+   *
+   * @var \Drupal\Core\Access\AccessManagerInterface
+   */
+  protected $accessManager;
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * Constructs a RevisionLinkSetCurrent object.
+   *
+   * @param array $configuration
+   *   A configuration array containing information about the plugin instance.
+   * @param string $plugin_id
+   *   The plugin_id for the plugin instance.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Access\AccessManagerInterface $access_manager
+   *   The access manager.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, AccessManagerInterface $access_manager, EntityTypeManagerInterface $entity_type_manager) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition, $access_manager);
+    $this->entityTypeManager = $entity_type_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('access_manager'),
+      $container->get('entity_type.manager')
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function getDefaultLabel() {
+    return $this->t('Set current');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function renderLink(ResultRow $row) {
+    $text = parent::renderLink($row);
+    /* @var \Drupal\node\NodeInterface $node */
+    $node = $this->getEntity($row);
+    /* @var \Drupal\node\NodeTypeInterface $node_type */
+    $node_type = $this->entityTypeManager->getStorage('node_type')->load($node->bundle());
+    if (!$node_type->getThirdPartySetting('moderation_state', 'enabled', FALSE)) {
+      // @todo write a test for this.
+      return $text;
+    }
+    if ($node->isDefaultRevision()) {
+      return '';
+    }
+    return $text;
+  }
+}
diff --git a/src/Tests/ModerationRevisionsViewTest.php b/src/Tests/ModerationRevisionsViewTest.php
new file mode 100644
index 0000000..a00c119
--- /dev/null
+++ b/src/Tests/ModerationRevisionsViewTest.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\moderation_state\Tests\ModerationRevisionsViewTest
+ */
+
+namespace Drupal\moderation_state\Tests;
+
+/**
+ * Tests moderation state integration with the content revisions View.
+ *
+ * @group moderation_state
+ */
+class ModerationRevisionsViewTest extends ModerationStateTestBase {
+
+  use ModerationStateTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $type = $this->drupalCreateContentType([
+      'type' => 'moderated_content',
+      'name' => 'Moderated Content'
+    ]);
+    $type->setThirdPartySetting('moderation_state', 'enabled', TRUE);
+    $type->setThirdPartySetting('moderation_state', 'allowed_moderation_states', [
+      'draft',
+      'needs_review',
+      'published'
+    ]);
+    $type->setThirdPartySetting('moderation_state', 'default_moderation_state', 'draft');
+    $type->save();
+    $this->grantUserPermissionToCreateContentOfType($this->adminUser, 'moderated_content');
+  }
+
+  /**
+   * Tests the content revisions view.
+   */
+  public function testRevisionsView() {
+    $this->drupalLogin($this->adminUser);
+    $node = $this->drupalCreateNode(['type' => 'moderated_content', 'moderation_state' => 'draft']);
+    $node->setNewRevision(TRUE);
+    $node->moderation_state = 'needs_review';
+    $node->save();
+    $node->setNewRevision(TRUE);
+    $node->moderation_state = 'published';
+    $node->save();
+    $this->drupalGet('node/' . $node->id() . '/revisions');
+    $this->assertResponse(200);
+
+
+  }
+
+}
diff --git a/src/Tests/ModerationStateNodeTypeTest.php b/src/Tests/ModerationStateNodeTypeTest.php
index bb34971..82c3e98 100644
--- a/src/Tests/ModerationStateNodeTypeTest.php
+++ b/src/Tests/ModerationStateNodeTypeTest.php
@@ -14,6 +14,8 @@ use Drupal\user\Entity\Role;
  */
 class ModerationStateNodeTypeTest extends ModerationStateTestBase {
 
+  use ModerationStateTestTrait;
+
   /**
    * A node type without moderation state disabled.
    */
@@ -104,22 +106,4 @@ class ModerationStateNodeTypeTest extends ModerationStateTestBase {
     $this->drupalPostForm(NULL, $edit, t('Save content type'));
   }
 
-  /**
-   * Grants given user permission to create content of given type.
-   *
-   * @param \Drupal\Core\Session\AccountInterface $account
-   *   User to grant permission to.
-   * @param string $content_type_id
-   *   Content type ID.
-   */
-  protected function grantUserPermissionToCreateContentOfType(AccountInterface $account, $content_type_id) {
-    $role_ids = $account->getRoles(TRUE);
-    /* @var \Drupal\user\RoleInterface $role */
-    $role_id = reset($role_ids);
-    $role = Role::load($role_id);
-    $role->grantPermission(sprintf('create %s content', $content_type_id));
-    $role->grantPermission(sprintf('edit any %s content', $content_type_id));
-    $role->save();
-  }
-
 }
diff --git a/src/Tests/ModerationStateTestTrait.php b/src/Tests/ModerationStateTestTrait.php
new file mode 100644
index 0000000..b7f1dfa
--- /dev/null
+++ b/src/Tests/ModerationStateTestTrait.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * @file
+ * Contains Drupal\moderation_state\Tests\ModerationStateTestTrait
+ */
+
+namespace Drupal\moderation_state\Tests;
+
+use Drupal\Core\Session\AccountInterface;
+use Drupal\user\Entity\Role;
+
+/**
+ * Provides a trait for moderation state tests.
+ */
+trait ModerationStateTestTrait {
+
+  /**
+   * Grants given user permission to create content of given type.
+   *
+   * @param \Drupal\Core\Session\AccountInterface $account
+   *   User to grant permission to.
+   * @param string $content_type_id
+   *   Content type ID.
+   */
+  protected function grantUserPermissionToCreateContentOfType(AccountInterface $account, $content_type_id) {
+    $role_ids = $account->getRoles(TRUE);
+    /* @var \Drupal\user\RoleInterface $role */
+    $role_id = reset($role_ids);
+    $role = Role::load($role_id);
+    $role->grantPermission(sprintf('create %s content', $content_type_id));
+    $role->grantPermission(sprintf('edit any %s content', $content_type_id));
+    $role->grantPermission('view all revisions');
+    $role->grantPermission('revert all revisions');
+    $role->grantPermission('delete all revisions');
+    $role->save();
+  }
+
+}
