Sha256: 48f5832daa3c23204d0eba13831044f209b48810710b8ec5e288f8b4384e552a

Contents?: true

Size: 789 Bytes

Versions: 4

Compression:

Stored size: 789 Bytes

Contents

require 'spec_helper'

describe FamilyGallery::UserRolesController do
  let(:admin) { create :admin }
  let(:user) { create :user }
  let(:user_role) { create :user_role, user: user }
  let(:valid_params) do
    {
      role: 'administrator'
    }
  end

  routes { FamilyGallery::Engine.routes }

  render_views

  before do
    sign_in admin
  end

  it '#new' do
    get :new, user_id: user.id
    expect(response).to be_success
  end

  it '#create' do
    post :create, user_id: user.id, user_role: valid_params
    expect(response).to redirect_to user_url(user)
  end

  it '#destroy' do
    delete :destroy, user_id: user.id, id: user_role.id

    expect { user_role.reload }.to raise_error(ActiveRecord::RecordNotFound)
    expect(response).to redirect_to user_url(user)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
family_gallery-0.0.8 spec/controllers/family_gallery/user_roles_controller_spec.rb
family_gallery-0.0.7 spec/controllers/family_gallery/user_roles_controller_spec.rb
family_gallery-0.0.6 spec/controllers/family_gallery/user_roles_controller_spec.rb
family_gallery-0.0.5 spec/controllers/family_gallery/user_roles_controller_spec.rb