Sha256: e615e046387d5cd5e3e89a4ce92ef35de2a3fbe9f3c701efacc5e1cef3e51c2b

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe 'profiles/edit' do
  fixtures :all

  before(:each) do
    @profile = assign(:profile, profiles(:admin))
    assign(:user_groups, UserGroup.all)
    assign(:libraries, Library.all)
    assign(:roles, Role.all)
    assign(:available_languages, Language.available_languages)
    view.stub(:current_user).and_return(User.friendly.find('enjuadmin'))
  end

  describe 'when logged in as librarian' do
    before(:each) do
      @profile = assign(:profile, profiles(:librarian2))
      user = users(:librarian1)
      view.stub(:current_user).and_return(user)
    end

    it 'renders the edit user form' do
      allow(view).to receive(:policy).and_return double(destroy?: true)
      render
      assert_select 'form', action: profiles_path(@profile), method: 'post' do
        assert_select 'input#profile_user_number', name: 'profile[user_number]'
      end
    end

    it "should not display 'delete' link" do
      allow(view).to receive(:policy).and_return double(destroy?: false)
      render
      expect(rendered).not_to have_selector("a[href='#{profile_path(@profile.id)}'][data-method='delete']")
    end

    it 'should disable role selection' do
      allow(view).to receive(:policy).and_return double(destroy?: true)
      render
      expect(rendered).to have_selector("select#profile_user_attributes_user_has_role_attributes_role_id[disabled='disabled']")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
enju_seed-0.4.0.beta.1 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.4 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.3 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.2 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.1 spec/views/profiles/edit.html.erb_spec.rb