Sha256: 344a84db3e5f9f6e2c5db663f5081b813d45fc5b6532ed1528eba79c665affae

Contents?: true

Size: 1.39 KB

Versions: 28

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

28 entries across 27 versions & 2 rubygems

Version Path
enju_seed-0.3.6 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.5 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.4.0.rc.2 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.4 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.4.0.rc.1 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.4.0.beta.3 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.5.0.beta.1 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.4.0.beta.2 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.3 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.2 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.1 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.rc.1 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.7 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.3.0.beta.6 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.2.3 spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.2.2 spec/views/profiles/edit.html.erb_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_seed-0.2.0/spec/views/profiles/edit.html.erb_spec.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/enju_seed-0.2.1/spec/views/profiles/edit.html.erb_spec.rb
enju_seed-0.2.1 spec/views/profiles/edit.html.erb_spec.rb