private_person 0.1.0 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/private_person/models/permissible.rb +5 -1
- data/lib/private_person/models/permission.rb +1 -1
- data/lib/private_person/models/permissor.rb +20 -2
- data/lib/private_person/models/permitted.rb +9 -2
- data/private_person.gemspec +3 -2
- data/spec/dummy/config/application.rb +56 -56
- data/spec/dummy/config/environments/development.rb +27 -27
- data/spec/dummy/config/environments/production.rb +58 -58
- data/spec/dummy/config/environments/test.rb +25 -25
- data/spec/dummy/config/routes.rb +59 -59
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/models/page_spec.rb +1 -1
- data/spec/models/user_spec.rb +41 -3
- data/spec/support/permissor_support.rb +12 -0
- data/spec/support/users_support.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjkzZWFiNmMyYzRmZTZlNDEzMjQ3ODk4MGE2YjIxZGU3N2U5NDQ3Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTRhZTJjYzBjOTdjMDkyNWU5N2Y0ZTdhNzRjYTAyZGRiODFiZTMzNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTU5MzkyM2JkMTUzNTVhYmNkNjFlYzUwYTE2MGYwNTg3NjIxZTMxNTQ2MmJj
|
10
|
+
ZjM0ZmQ0NTYwYzNjMmYyMDk5NGVjMDBmN2RmZDkyMjY1ZGE0MTMwYzdkNDlk
|
11
|
+
NmU3NDYzMTI5MTBjOWVkMjNhNzUxZjA1ZmJmODRkY2I4MjBmMzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTVkZGYyZjVjOWZkYWYxMGUwY2RkMzEzNDk1NzA4NTMyODhkNGU3MmY5M2Zh
|
14
|
+
ZDVhNTRiNjkxZmQ1MmYyMGQ1Y2VhZTcwZDg0NTg4MTEwYzQzOTkxOGNlOGYy
|
15
|
+
MmZlZWUzZTgxMzM0ZDQxYzA5MzQxNjkyZjk5NzI2YTFmODdkMzE=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.4
|
@@ -9,7 +9,11 @@ module PrivatePerson
|
|
9
9
|
|
10
10
|
class_eval do
|
11
11
|
has_many :permissions, :as => :permissible
|
12
|
-
|
12
|
+
has_one :permissor, :through => :permissions, :as => :permissor
|
13
|
+
|
14
|
+
def is_public?
|
15
|
+
!permissions.find_all_by_relationship_type(nil).empty?
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -18,7 +18,7 @@ class Permission < ActiveRecord::Base
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.find_all_by_relationship_type(relationship_type)
|
21
|
-
if relationship_type == 'public'
|
21
|
+
if relationship_type == 'public' or relationship_type.nil?
|
22
22
|
return where("relationship_type = 'public'")
|
23
23
|
end
|
24
24
|
if(self.permissible_types.include? relationship_type)
|
@@ -9,8 +9,26 @@ module PrivatePerson
|
|
9
9
|
class_name = params[:class_name] || params[:of].to_s.classify
|
10
10
|
class_name.constantize.acts_as_permitted
|
11
11
|
class_eval do
|
12
|
-
has_many :
|
13
|
-
has_many :permissibles, :through => :permissions, :as => :
|
12
|
+
has_many :permissions_as_permissor, :as => :permissor, :class_name => 'Permission'
|
13
|
+
has_many :permissibles, :through => :permissions, :as => :permissor
|
14
|
+
|
15
|
+
def permit!(whom, what)
|
16
|
+
existing = self.permissions_as_permissor.find_all_by_relationship_type(whom).find_all_by_permissible(what)
|
17
|
+
|
18
|
+
if existing.empty?
|
19
|
+
self.permissions_as_permissor.create!({:relationship_type => whom, :permissible => what})
|
20
|
+
end
|
21
|
+
self.permissions_as_permissor.reload
|
22
|
+
end
|
23
|
+
|
24
|
+
def wildcard_permit!(whom, what)
|
25
|
+
existing = self.permissions_as_permissor.find_all_by_relationship_type(whom).find_all_by_permissible_type(what)
|
26
|
+
|
27
|
+
if existing.empty?
|
28
|
+
self.permissions_as_permissor.create!({:relationship_type => whom, :permissible_type => what})
|
29
|
+
end
|
30
|
+
self.permissions_as_permissor.reload
|
31
|
+
end
|
14
32
|
end
|
15
33
|
end
|
16
34
|
end
|
@@ -3,6 +3,9 @@ module PrivatePerson
|
|
3
3
|
def acts_as_permitted
|
4
4
|
class_eval do
|
5
5
|
def is_permitted?(permissor, permissible)
|
6
|
+
if permissible.nil?
|
7
|
+
raise 'Called is_permitted? on nil. Does not compute. Preparing to self destruct.'
|
8
|
+
end
|
6
9
|
if Permission.find_all_by_permissible(permissible).blocked.exists?
|
7
10
|
return false
|
8
11
|
end
|
@@ -22,7 +25,11 @@ module PrivatePerson
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def relationship_to(permissor)
|
25
|
-
# First
|
28
|
+
# First make sure we're not a new user
|
29
|
+
if self.new_record?
|
30
|
+
return 'public'
|
31
|
+
end
|
32
|
+
# Next check for an efficient method
|
26
33
|
for relationship_method in permissor.class.of
|
27
34
|
is_method = ('is_' + relationship_method.to_s.singularize + '_of?').to_sym
|
28
35
|
if respond_to?(is_method) and self.send(is_method, permissor)
|
@@ -36,7 +43,7 @@ module PrivatePerson
|
|
36
43
|
return relationship_method.to_s
|
37
44
|
end
|
38
45
|
end
|
39
|
-
return
|
46
|
+
return 'public'
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
data/private_person.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "private_person"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Karen Lundgren"]
|
12
|
-
s.date = "2013-09-
|
12
|
+
s.date = "2013-09-13"
|
13
13
|
s.description = "Private person is an active record extension gem that allows a model to be given privacy settings over arbitrary models and polymorphic relations, putting users' accounts in control of their own privacy policies."
|
14
14
|
s.email = "webmaster@sourcherryweb.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -74,6 +74,7 @@ Gem::Specification.new do |s|
|
|
74
74
|
"spec/private_person_spec.rb",
|
75
75
|
"spec/spec_helper.rb",
|
76
76
|
"spec/support/permissions_support.rb",
|
77
|
+
"spec/support/permissor_support.rb",
|
77
78
|
"spec/support/users_support.rb"
|
78
79
|
]
|
79
80
|
s.homepage = "http://github.com/nerakdon/private_person"
|
@@ -1,56 +1,56 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
# Pick the frameworks you want:
|
4
|
-
require "active_record/railtie"
|
5
|
-
# require "rails/test_unit/railtie"
|
6
|
-
|
7
|
-
Bundler.require
|
8
|
-
require "private_person"
|
9
|
-
require 'acts_as_follower'
|
10
|
-
|
11
|
-
module Dummy
|
12
|
-
class Application < Rails::Application
|
13
|
-
# Settings in config/environments/* take precedence over those specified here.
|
14
|
-
# Application configuration should go into files in config/initializers
|
15
|
-
# -- all .rb files in that directory are automatically loaded.
|
16
|
-
|
17
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
18
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
19
|
-
|
20
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
21
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
22
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
23
|
-
|
24
|
-
# Activate observers that should always be running.
|
25
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
26
|
-
|
27
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
28
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
29
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
30
|
-
|
31
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
32
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
33
|
-
# config.i18n.default_locale = :de
|
34
|
-
|
35
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
36
|
-
config.encoding = "utf-8"
|
37
|
-
|
38
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
39
|
-
config.filter_parameters += [:password]
|
40
|
-
|
41
|
-
# Enable escaping HTML in JSON.
|
42
|
-
config.active_support.escape_html_entities_in_json = true
|
43
|
-
|
44
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
45
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
46
|
-
# like if you have constraints or database-specific column types
|
47
|
-
# config.active_record.schema_format = :sql
|
48
|
-
|
49
|
-
# Enforce whitelist mode for mass assignment.
|
50
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
51
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
52
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
53
|
-
config.active_record.whitelist_attributes = true
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
# require "rails/test_unit/railtie"
|
6
|
+
|
7
|
+
Bundler.require
|
8
|
+
require "private_person"
|
9
|
+
require 'acts_as_follower'
|
10
|
+
|
11
|
+
module Dummy
|
12
|
+
class Application < Rails::Application
|
13
|
+
# Settings in config/environments/* take precedence over those specified here.
|
14
|
+
# Application configuration should go into files in config/initializers
|
15
|
+
# -- all .rb files in that directory are automatically loaded.
|
16
|
+
|
17
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
18
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
19
|
+
|
20
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
21
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
22
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
23
|
+
|
24
|
+
# Activate observers that should always be running.
|
25
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
26
|
+
|
27
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
28
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
29
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
30
|
+
|
31
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
32
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
33
|
+
# config.i18n.default_locale = :de
|
34
|
+
|
35
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
36
|
+
config.encoding = "utf-8"
|
37
|
+
|
38
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
39
|
+
config.filter_parameters += [:password]
|
40
|
+
|
41
|
+
# Enable escaping HTML in JSON.
|
42
|
+
config.active_support.escape_html_entities_in_json = true
|
43
|
+
|
44
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
45
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
46
|
+
# like if you have constraints or database-specific column types
|
47
|
+
# config.active_record.schema_format = :sql
|
48
|
+
|
49
|
+
# Enforce whitelist mode for mass assignment.
|
50
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
51
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
52
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
53
|
+
config.active_record.whitelist_attributes = true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -1,27 +1,27 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
|
-
# Show full error reports and disable caching
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
|
15
|
-
# Print deprecation notices to the Rails logger
|
16
|
-
config.active_support.deprecation = :log
|
17
|
-
|
18
|
-
# Only use best-standards-support built into browsers
|
19
|
-
config.action_dispatch.best_standards_support = :builtin
|
20
|
-
|
21
|
-
# Raise exception on mass assignment protection for Active Record models
|
22
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
23
|
-
|
24
|
-
# Log the query plan for queries taking more than this (works
|
25
|
-
# with SQLite, MySQL, and PostgreSQL)
|
26
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
27
|
-
end
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Print deprecation notices to the Rails logger
|
16
|
+
config.active_support.deprecation = :log
|
17
|
+
|
18
|
+
# Only use best-standards-support built into browsers
|
19
|
+
config.action_dispatch.best_standards_support = :builtin
|
20
|
+
|
21
|
+
# Raise exception on mass assignment protection for Active Record models
|
22
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
23
|
+
|
24
|
+
# Log the query plan for queries taking more than this (works
|
25
|
+
# with SQLite, MySQL, and PostgreSQL)
|
26
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
27
|
+
end
|
@@ -1,58 +1,58 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# Code is not reloaded between requests
|
5
|
-
config.cache_classes = true
|
6
|
-
|
7
|
-
# Full error reports are disabled and caching is turned on
|
8
|
-
config.consider_all_requests_local = false
|
9
|
-
config.action_controller.perform_caching = true
|
10
|
-
|
11
|
-
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
-
config.serve_static_assets = false
|
13
|
-
|
14
|
-
# Defaults to nil and saved in location specified by config.assets.prefix
|
15
|
-
# config.assets.manifest = YOUR_PATH
|
16
|
-
|
17
|
-
# Specifies the header that your server uses for sending files
|
18
|
-
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
19
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
20
|
-
|
21
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
22
|
-
# config.force_ssl = true
|
23
|
-
|
24
|
-
# See everything in the log (default is :info)
|
25
|
-
# config.log_level = :debug
|
26
|
-
|
27
|
-
# Prepend all log lines with the following tags
|
28
|
-
# config.log_tags = [ :subdomain, :uuid ]
|
29
|
-
|
30
|
-
# Use a different logger for distributed setups
|
31
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
32
|
-
|
33
|
-
# Use a different cache store in production
|
34
|
-
# config.cache_store = :mem_cache_store
|
35
|
-
|
36
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
37
|
-
# config.action_controller.asset_host = "http://assets.example.com"
|
38
|
-
|
39
|
-
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
40
|
-
# config.assets.precompile += %w( search.js )
|
41
|
-
|
42
|
-
# Disable delivery errors, bad email addresses will be ignored
|
43
|
-
# config.action_mailer.raise_delivery_errors = false
|
44
|
-
|
45
|
-
# Enable threaded mode
|
46
|
-
# config.threadsafe!
|
47
|
-
|
48
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
49
|
-
# the I18n.default_locale when a translation can not be found)
|
50
|
-
config.i18n.fallbacks = true
|
51
|
-
|
52
|
-
# Send deprecation notices to registered listeners
|
53
|
-
config.active_support.deprecation = :notify
|
54
|
-
|
55
|
-
# Log the query plan for queries taking more than this (works
|
56
|
-
# with SQLite, MySQL, and PostgreSQL)
|
57
|
-
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
58
|
-
end
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
15
|
+
# config.assets.manifest = YOUR_PATH
|
16
|
+
|
17
|
+
# Specifies the header that your server uses for sending files
|
18
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
19
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
20
|
+
|
21
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
22
|
+
# config.force_ssl = true
|
23
|
+
|
24
|
+
# See everything in the log (default is :info)
|
25
|
+
# config.log_level = :debug
|
26
|
+
|
27
|
+
# Prepend all log lines with the following tags
|
28
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
29
|
+
|
30
|
+
# Use a different logger for distributed setups
|
31
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
32
|
+
|
33
|
+
# Use a different cache store in production
|
34
|
+
# config.cache_store = :mem_cache_store
|
35
|
+
|
36
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
37
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
38
|
+
|
39
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
40
|
+
# config.assets.precompile += %w( search.js )
|
41
|
+
|
42
|
+
# Disable delivery errors, bad email addresses will be ignored
|
43
|
+
# config.action_mailer.raise_delivery_errors = false
|
44
|
+
|
45
|
+
# Enable threaded mode
|
46
|
+
# config.threadsafe!
|
47
|
+
|
48
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
49
|
+
# the I18n.default_locale when a translation can not be found)
|
50
|
+
config.i18n.fallbacks = true
|
51
|
+
|
52
|
+
# Send deprecation notices to registered listeners
|
53
|
+
config.active_support.deprecation = :notify
|
54
|
+
|
55
|
+
# Log the query plan for queries taking more than this (works
|
56
|
+
# with SQLite, MySQL, and PostgreSQL)
|
57
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
58
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite. You never need to work with it otherwise. Remember that
|
6
|
-
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
config.cache_classes = true
|
9
|
-
|
10
|
-
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.serve_static_assets = true
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
13
|
-
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
15
|
-
config.whiny_nils = true
|
16
|
-
|
17
|
-
# Show full error reports and disable caching
|
18
|
-
config.consider_all_requests_local = true
|
19
|
-
|
20
|
-
# Raise exception on mass assignment protection for Active Record models
|
21
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
22
|
-
|
23
|
-
# Print deprecation notices to the stderr
|
24
|
-
config.active_support.deprecation = :stderr
|
25
|
-
end
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
|
20
|
+
# Raise exception on mass assignment protection for Active Record models
|
21
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
22
|
+
|
23
|
+
# Print deprecation notices to the stderr
|
24
|
+
config.active_support.deprecation = :stderr
|
25
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
Dummy::Application.routes.draw do
|
2
|
-
|
3
|
-
# The priority is based upon order of creation:
|
4
|
-
# first created -> highest priority.
|
5
|
-
|
6
|
-
# Sample of regular route:
|
7
|
-
# match 'products/:id' => 'catalog#view'
|
8
|
-
# Keep in mind you can assign values other than :controller and :action
|
9
|
-
|
10
|
-
# Sample of named route:
|
11
|
-
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
12
|
-
# This route can be invoked with purchase_url(:id => product.id)
|
13
|
-
|
14
|
-
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
15
|
-
# resources :products
|
16
|
-
|
17
|
-
# Sample resource route with options:
|
18
|
-
# resources :products do
|
19
|
-
# member do
|
20
|
-
# get 'short'
|
21
|
-
# post 'toggle'
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# collection do
|
25
|
-
# get 'sold'
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
|
-
# Sample resource route with sub-resources:
|
30
|
-
# resources :products do
|
31
|
-
# resources :comments, :sales
|
32
|
-
# resource :seller
|
33
|
-
# end
|
34
|
-
|
35
|
-
# Sample resource route with more complex sub-resources
|
36
|
-
# resources :products do
|
37
|
-
# resources :comments
|
38
|
-
# resources :sales do
|
39
|
-
# get 'recent', :on => :collection
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# Sample resource route within a namespace:
|
44
|
-
# namespace :admin do
|
45
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
46
|
-
# # (app/controllers/admin/products_controller.rb)
|
47
|
-
# resources :products
|
48
|
-
# end
|
49
|
-
|
50
|
-
# You can have the root of your site routed with "root"
|
51
|
-
# just remember to delete public/index.html.
|
52
|
-
# root :to => 'welcome#index'
|
53
|
-
|
54
|
-
# See how all your routes lay out with "rake routes"
|
55
|
-
|
56
|
-
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
57
|
-
# Note: This route will make all actions in every controller accessible via GET requests.
|
58
|
-
# match ':controller(/:action(/:id))(.:format)'
|
59
|
-
end
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
|
3
|
+
# The priority is based upon order of creation:
|
4
|
+
# first created -> highest priority.
|
5
|
+
|
6
|
+
# Sample of regular route:
|
7
|
+
# match 'products/:id' => 'catalog#view'
|
8
|
+
# Keep in mind you can assign values other than :controller and :action
|
9
|
+
|
10
|
+
# Sample of named route:
|
11
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
12
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
13
|
+
|
14
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# resources :products
|
16
|
+
|
17
|
+
# Sample resource route with options:
|
18
|
+
# resources :products do
|
19
|
+
# member do
|
20
|
+
# get 'short'
|
21
|
+
# post 'toggle'
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# collection do
|
25
|
+
# get 'sold'
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Sample resource route with sub-resources:
|
30
|
+
# resources :products do
|
31
|
+
# resources :comments, :sales
|
32
|
+
# resource :seller
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Sample resource route with more complex sub-resources
|
36
|
+
# resources :products do
|
37
|
+
# resources :comments
|
38
|
+
# resources :sales do
|
39
|
+
# get 'recent', :on => :collection
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Sample resource route within a namespace:
|
44
|
+
# namespace :admin do
|
45
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
46
|
+
# # (app/controllers/admin/products_controller.rb)
|
47
|
+
# resources :products
|
48
|
+
# end
|
49
|
+
|
50
|
+
# You can have the root of your site routed with "root"
|
51
|
+
# just remember to delete public/index.html.
|
52
|
+
# root :to => 'welcome#index'
|
53
|
+
|
54
|
+
# See how all your routes lay out with "rake routes"
|
55
|
+
|
56
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
57
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
58
|
+
# match ':controller(/:action(/:id))(.:format)'
|
59
|
+
end
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/models/page_spec.rb
CHANGED
data/spec/models/user_spec.rb
CHANGED
@@ -3,11 +3,9 @@ require 'spec_helper'
|
|
3
3
|
describe User do
|
4
4
|
|
5
5
|
describe PrivatePerson::Permitted do
|
6
|
-
it { should have_many(:
|
6
|
+
it { should have_many(:permissions_as_permissor) }
|
7
7
|
it { should have_many(:permissibles) }
|
8
|
-
end
|
9
8
|
|
10
|
-
describe PrivatePerson::Permitted do
|
11
9
|
context 'Instance Methods' do
|
12
10
|
|
13
11
|
describe '#relationship_to' do
|
@@ -32,6 +30,10 @@ describe User do
|
|
32
30
|
subject { follower_of_follower_user.relationship_to(followed_user) }
|
33
31
|
it { should eq 'follower_of_followers' }
|
34
32
|
end
|
33
|
+
context 'when stranger' do
|
34
|
+
subject { stranger.relationship_to(followed_user) }
|
35
|
+
it { should eq 'public' }
|
36
|
+
end
|
35
37
|
end
|
36
38
|
describe '#permissions_by' do
|
37
39
|
include_context 'permissions support'
|
@@ -98,4 +100,40 @@ describe User do
|
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
103
|
+
|
104
|
+
describe PrivatePerson::Permissor do
|
105
|
+
include_context 'users support'
|
106
|
+
include_context 'permissor support'
|
107
|
+
context 'Instance Methods' do
|
108
|
+
|
109
|
+
describe '#permits' do
|
110
|
+
context 'when overriding public' do
|
111
|
+
before do
|
112
|
+
public_user.permit! 'none', public_user_page
|
113
|
+
end
|
114
|
+
subject { stranger.is_permitted? public_user, public_user_page }
|
115
|
+
it { should be false }
|
116
|
+
end
|
117
|
+
context 'when overriding none' do
|
118
|
+
before do
|
119
|
+
private_user.permit! 'public', private_user_page
|
120
|
+
end
|
121
|
+
subject { stranger.is_permitted? private_user, private_user_page }
|
122
|
+
it { should be true }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
describe '#wildcard_permits' do
|
126
|
+
# the support files already ran the heavy lifting,
|
127
|
+
# so if they worked we're golden
|
128
|
+
context 'with none' do
|
129
|
+
subject { stranger.is_permitted? private_user, private_user_page }
|
130
|
+
it { should be false }
|
131
|
+
end
|
132
|
+
context 'with public' do
|
133
|
+
subject { stranger.is_permitted? public_user, public_user_page }
|
134
|
+
it { should be true }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
101
139
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
shared_context 'permissor support' do
|
2
|
+
let!(:public_user) { FactoryGirl.create(:user) }
|
3
|
+
let!(:private_user) { FactoryGirl.create(:user) }
|
4
|
+
|
5
|
+
let!(:public_user_page) { FactoryGirl.create(:page, :user => public_user)}
|
6
|
+
let!(:private_user_page) { FactoryGirl.create(:page, :user => private_user)}
|
7
|
+
|
8
|
+
before do
|
9
|
+
public_user.wildcard_permit! 'public', 'Page'
|
10
|
+
private_user.wildcard_permit! 'none', 'Page'
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: private_person
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karen Lundgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- spec/private_person_spec.rb
|
232
232
|
- spec/spec_helper.rb
|
233
233
|
- spec/support/permissions_support.rb
|
234
|
+
- spec/support/permissor_support.rb
|
234
235
|
- spec/support/users_support.rb
|
235
236
|
homepage: http://github.com/nerakdon/private_person
|
236
237
|
licenses:
|