permissionable 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c683e2b6a92a99c88d7c8914797d2e03345ec9
4
- data.tar.gz: 97735819e09708dfdcb62c2fc62a35528194b733
3
+ metadata.gz: 2b3291aed21cc9e20392419b0ee512fa578fd335
4
+ data.tar.gz: ca2dfd9bad69191f9ad342b01c721f4dbf23b42f
5
5
  SHA512:
6
- metadata.gz: dea2db4e91d2654cf48e6f7f5eb28e184e75554b4cc1c2b0ff39426bb9e9254b38206d628b96994c8d139e585e44f9feba05ea3419fc6ed74fc83511d5a63d18
7
- data.tar.gz: 30cf805a817a8ef758588554f0eeb12c26b2dd0618ee8c5ef5bd522fadf997f07f47fba8f8810f65a7975ce55f51f72861e46c68026a73f139067de72f94285d
6
+ metadata.gz: c6fd05d537db592239652ed21919ca18f93c2ccfd918cfe6b789c012b5c521643d539b3c262b54bbdbedd7f1f4adc593018914cefd2221a5e2dfd48d9dbcac1d
7
+ data.tar.gz: e819ee8e617b32b194036c8f9fd4c1acd79ec5e93450e050ebce154f859048f5cb946ec898997ec1bcc0d04261022486200a729430603df35efe5ad33964b5a7
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.1.5"
4
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
+ [![Build Status](https://travis-ci.org/robertfalken/permissionable.svg?branch=master)](https://travis-ci.org/robertfalken/permissionable)
2
+
1
3
  # permissionable
2
4
  ## Installation
3
5
 
4
6
  Permissionable is distributed as a gem. To install, just add this line to your Gemfile:
5
- `gem 'permissionable', '~> 0.1.1'`
7
+ `gem 'permissionable', '~> 0.1.2'`
6
8
 
7
9
 
8
10
  ## Usage
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task default: :spec
7
+ rescue
8
+ puts "No rspec available"
9
+ end
10
+
@@ -69,7 +69,7 @@ module Permissionable
69
69
 
70
70
  def sync_with_owner
71
71
  if @owner.respond_to?(:update_column)
72
- @owner.update_column(:permission, @permission_integer)
72
+ @owner.update_column(:permissions, @permission_integer)
73
73
  end
74
74
  end
75
75
 
@@ -1,3 +1,3 @@
1
1
  module Permissionable
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,4 +1,3 @@
1
- require 'pry'
2
1
  require 'permissionable'
3
2
  require 'dummy'
4
3
 
@@ -7,6 +6,7 @@ class FlakyDummy
7
6
  include Permissionable
8
7
  end
9
8
 
9
+
10
10
  describe Permissionable do
11
11
  context 'permission definitions' do
12
12
  subject(:permissions) { Dummy.instance_variable_get(:@permissions) }
@@ -1,7 +1,15 @@
1
- require 'pry'
2
1
  require 'permissionable'
3
2
  require 'dummy'
4
3
 
4
+ class DummyWithPermissions
5
+ include Permissionable
6
+ permissions walk: 1
7
+
8
+ def read_attribute(attribute)
9
+ 1 if attribute == :permissions
10
+ end
11
+ end
12
+
5
13
  describe Permissionable::Permissions do
6
14
  before(:each) { @permissions = Permissionable::Permissions.new(Dummy.new) }
7
15
 
@@ -59,18 +67,24 @@ describe Permissionable::Permissions do
59
67
  expect(@permissions[:play]).to eq(false)
60
68
  end
61
69
 
62
- it 'writes attribute when adding permission' do
70
+ it 'updates column when adding permission' do
63
71
  @owner = Dummy.new
64
72
  @permissions = Permissionable::Permissions.new(@owner)
65
- expect(@owner).to receive(:write_attribute).with(:permission, 2)
73
+ expect(@owner).to receive(:update_column).with(:permissions, 2)
66
74
  @permissions << :walk
67
75
  end
68
76
 
69
- it 'writes attribute when removing permission' do
77
+ it 'updates column when removing permission' do
70
78
  @owner = Dummy.new
71
79
  @permissions = Permissionable::Permissions.new(@owner)
72
80
  @permissions << :run
73
- expect(@owner).to receive(:write_attribute).with(:permission, 0)
81
+ expect(@owner).to receive(:update_column).with(:permissions, 0)
74
82
  @permissions.remove :run
75
83
  end
84
+
85
+ it 'can read permissions from owner' do
86
+ owner = DummyWithPermissions.new
87
+ permissions = Permissionable::Permissions.new(owner)
88
+ expect(permissions[:walk]).to be true
89
+ end
76
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permissionable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Falkén
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".travis.yml"
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md