Sha256: eb086fadf8284c64baa1cef4e77508fd673d7a2871b69907dbb057cb599b6ff5

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe "/de/backend/juristisches/privacy_policies", type: :feature do
  # let(:resource_class) { EuGdpr::PrivacyPolicy }
  let(:resource_class) { Cmor::Legal::PrivacyPolicy }
  let(:resource) { create(:cmor_legal_privacy_policy) }
  let(:resources) { I18n.available_locales.map { |l| create(:cmor_legal_privacy_policy, locale: l) } }

  # List
  it { resources; expect(subject).to implement_index_action(self) }

  # Create
  it {
    expect(subject).to implement_create_action(self)
      .for(resource_class)
      .within_form("#new_privacy_policy") {
        # fill the needed form inputs via capybara here
        #
        # Example:
        #
        #     select 'de', from: 'slider[locale]'
        #     fill_in 'slider[name]', with: 'My first slider'
        #     check 'slider[auto_start]'
        #     fill_in 'slider[interval]', with: '3'
        select "en", from: "privacy_policy[locale]"
        fill_in "privacy_policy[title]", with: "Privacy Policy"
        fill_in "privacy_policy[body]", with: "<h1>Privacy Policy</h1>"
      }
      .increasing { Cmor::Legal::PrivacyPolicy.count }.by(1)
  }

  # Read
  it { expect(subject).to implement_show_action(self).for(resource) }

  # Update
  it {
    expect(subject).to implement_update_action(self)
      .for(resource)
      .within_form(".edit_privacy_policy") {
        # fill the needed form inputs via capybara here
        #
        # Example:
        #
        #     fill_in 'slider[name]', with: 'New name'
        fill_in "privacy_policy[body]", with: "<h1>Privacy Policy (v2.0)</h1>"
      }
      .updating
      .from(resource.attributes)
      .to("body" => "<h1>Privacy Policy (v2.0)</h1>") # Example: .to({ 'name' => 'New name' })
  }

  # Delete
  it {
    expect(subject).to implement_delete_action(self)
      .for(resource)
      .reducing { resource_class.count }.by(1)
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cmor_legal-0.0.45.pre spec/features/de/backend/juristisches/privacy_policies_feature_spec.rb