Sha256: 23abf2e1a1912a2634b0f3208fd6f02cc26939e9d54aecf31b5b547832b787c7

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Iugu::AccountRolesController do

  context "edit" do
    login_as_user

    context "when current_user owns the account" do

      before(:each) do
        @current_account_user = @user.account_users.first
        @current_account_user.set_roles(["owner"])
        get :edit, :id => @current_account_user.account_id, :user_id => @current_account_user.user_id
      end

      it { response.should render_template "iugu/account_roles/edit" }
      it { response.should be_success }

    end

    context "when current_user do not owns the account" do

      before(:each) do
        @current_account_user = @user.account_users.first
        @account = @current_account_user.account
        @account.account_users << Fabricate(:account_user) { user Fabricate(:user) { email "notowner@account.test" } }
        @current_account_user.set_roles(["user"])
        get :edit, :id => @current_account_user.account_id, :user_id => @current_account_user.user_id
      end

      it { response.should_not render_template "iugu/account_roles/edit" }
      it { response.should_not be_success }
    end
  
  end

  context "update" do
    login_as_user
    before(:each) do
      @account_id = @user.account_users.first.account_id
      post :update, :id => @account_id, :user_id => @user.id, :roles => []
    end
  
    it { response.should redirect_to account_users_index_path(@account_id)}
  
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.1 spec/controllers/account_roles_controller_spec.rb
iugusdk-1.0.0.alpha.0 spec/controllers/account_roles_controller_spec.rb