Sha256: 94a12c31e6c69d8c8940db420330143e3b016b306a1c75929b41486abe7054e3

Contents?: true

Size: 1.44 KB

Versions: 10

Compression:

Stored size: 1.44 KB

Contents

require 'rails_helper'

describe SpudRole, :type => :model do

	before :each do
		@role = FactoryGirl.build(:spud_role)
		@full_access = SpudPermission.new('Test Full Access', 'admin.test.full_access')
		@partial_access = SpudPermission.new('Test Partial Access', 'admin.test.partial_access')
		Spud::Core.permissions += [@full_access, @partial_access]
		@role.permissions = [@partial_access]
		@role.save()
	end

	describe "permissions" do
		it "should return an array of SpudPermission objects" do
			expect(@role.permissions).to be_an_instance_of(Array)
			expect(@role.permissions.first).to be_an_instance_of(SpudPermission)
		end
	end

	describe "permissions=" do
		it "should update the SpudRolePermissions on the role" do
			original_count = @role.spud_role_permissions.length
			@role.permissions = [@full_access, @partial_access]
			@role.save
			expect(@role.spud_role_permissions.length).to be > original_count
		end
	end

	describe "permission_tags" do
		it "should return an array of Strings" do
			expect(@role.permission_tags).to be_an_instance_of(Array)
			expect(@role.permission_tags.first).to be_an_instance_of(String)
		end
	end

	describe "permission_tags=" do
		it "should update the SpudRolePermissions on the role" do
			original_count = @role.spud_role_permissions.length
			@role.permission_tags = ['admin.test.full_access', 'admin.test.partial_access']
			@role.save
			expect(@role.spud_role_permissions.length).to be > original_count
		end
	end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tb_core-1.3.10 spec/models/spud_role_spec.rb
tb_core-1.3.9 spec/models/spud_role_spec.rb
tb_core-1.3.7 spec/models/spud_role_spec.rb
tb_core-1.3.6 spec/models/spud_role_spec.rb
tb_core-1.3.5 spec/models/spud_role_spec.rb
tb_core-1.3.4 spec/models/spud_role_spec.rb
tb_core-1.3.3 spec/models/spud_role_spec.rb
tb_core-1.3.2 spec/models/spud_role_spec.rb
tb_core-1.3.1 spec/models/spud_role_spec.rb
tb_core-1.3.0 spec/models/spud_role_spec.rb