Sha256: 5310e188afb2a525121b64d0cc92d18d5797962dffea300edcc8e5119fe44279

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

RSpec.describe Preserve, type: :request do
  it 'persists a parameter value' do
    get parameters_path, per_page: '20'
    get parameters_path

    expect(json_response[:per_page]).to eq('20')
  end

  it 'updates a parameter value' do
    get parameters_path, per_page: '20'
    get parameters_path, per_page: '10'

    expect(json_response[:per_page]).to eq('10')
  end

  it 'handles multiple parameters' do
    get parameters_path, page: '5', per_page: '20'
    get parameters_path

    expect(json_response[:page]).to eq('5')
    expect(json_response[:per_page]).to eq('20')
  end

  it 'handles action restrictions' do
    post parameters_path, per_page: '20'
    post parameters_path

    expect(json_response[:per_page]).to be_nil
  end

  it 'handles a blank parameter value' do
    get parameters_path, status: 'active'
    get parameters_path, status: ''

    expect(json_response[:status]).to eq('')
  end

  it 'handles a session key prefix' do
    get parameters_path, order: 'created_at'

    key = :preserved_parameters_order
    expect(session[key]).to eq('created_at')
  end

  it 'supports controller inheritance' do
    get parameters_path, locale: 'en'
    get parameters_path

    expect(json_response[:locale]).to eq('en')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
preserve-1.0.0 spec/preserve_spec.rb