radiant-users-extension 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/README.md +31 -0
- data/Rakefile +136 -0
- data/VERSION +1 -0
- data/config/routes.rb +8 -0
- data/cucumber.yml +1 -0
- data/db/migrate/20100311014641_add_api_key_to_users.rb +14 -0
- data/db/migrate/20100311021835_add_access_to_user.rb +9 -0
- data/features/support/env.rb +16 -0
- data/features/support/paths.rb +14 -0
- data/lib/tasks/users_extension_tasks.rake +54 -0
- data/lib/users/lib/login_system.rb +40 -0
- data/lib/users/models/user/scoped.rb +15 -0
- data/lib/users/models/user.rb +22 -0
- data/radiant-users-extension.gemspec +63 -0
- data/spec/datasets/scoped_users_dataset.rb +20 -0
- data/spec/models/user_spec.rb +24 -0
- data/spec/models/visitor_spec.rb +40 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +18 -0
- data/users_extension.rb +13 -0
- metadata +91 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Radiant Users Extension
|
2
|
+
|
3
|
+
Hook standard Radiant users to provide front end user creation and login.
|
4
|
+
|
5
|
+
A good example comes from [radiant-shop-extension](http://github.com/dirkkelly/radiant-shop-extension) in the use of customers
|
6
|
+
|
7
|
+
## Create a Model
|
8
|
+
|
9
|
+
class ShopCustomer < User
|
10
|
+
include Users::Models::User::Scoped
|
11
|
+
end
|
12
|
+
|
13
|
+
When a customer is created the access attributes present status will prevent them from accessing the administration system.
|
14
|
+
|
15
|
+
## Define Their Welcome Page
|
16
|
+
|
17
|
+
Radiant::Config['users.shop_customer.redirect'] = '/cart'
|
18
|
+
|
19
|
+
## API Access
|
20
|
+
|
21
|
+
Login Candy provided us with authentication hooks allowing for API login, there is currently no login mechanism. Contributions are welcome
|
22
|
+
|
23
|
+
# Installation
|
24
|
+
|
25
|
+
Gemfile
|
26
|
+
|
27
|
+
gem 'radiant-users-extension', :require => nil
|
28
|
+
|
29
|
+
config/environment.rb
|
30
|
+
|
31
|
+
config.gem 'radiant-users-extension', :lib => false
|
data/Rakefile
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "radiant-users-extension"
|
5
|
+
gem.summary = %Q{Users Extension for Radiant CMS}
|
6
|
+
gem.description = %Q{Users creates support for non-admin users with API access}
|
7
|
+
gem.email = "dk@squaretalent.com"
|
8
|
+
gem.homepage = "http://github.com/dirkkelly/radiant-users-extension"
|
9
|
+
gem.authors = ["Christopher Rankin", "Dirk Kelly"]
|
10
|
+
end
|
11
|
+
Jeweler::GemcutterTasks.new
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler (or a dependency) not available. This is only required if you plan to package users as a gem."
|
14
|
+
end
|
15
|
+
|
16
|
+
# In rails 1.2, plugins aren't available in the path until they're loaded.
|
17
|
+
# Check to see if the rspec plugin is installed first and require
|
18
|
+
# it if it is. If not, use the gem version.
|
19
|
+
|
20
|
+
# Determine where the RSpec plugin is by loading the boot
|
21
|
+
unless defined? RADIANT_ROOT
|
22
|
+
ENV["RAILS_ENV"] = "test"
|
23
|
+
case
|
24
|
+
when ENV["RADIANT_ENV_FILE"]
|
25
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
26
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
27
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
28
|
+
else
|
29
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'rake'
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
require 'rake/testtask'
|
36
|
+
|
37
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
38
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
39
|
+
require 'spec/rake/spectask'
|
40
|
+
require 'cucumber'
|
41
|
+
require 'cucumber/rake/task'
|
42
|
+
|
43
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
44
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
45
|
+
|
46
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
47
|
+
|
48
|
+
task :default => :spec
|
49
|
+
task :stats => "spec:statsetup"
|
50
|
+
|
51
|
+
desc "Run all specs in spec directory"
|
52
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
53
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
54
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
55
|
+
end
|
56
|
+
|
57
|
+
task :features => 'spec:integration'
|
58
|
+
|
59
|
+
namespace :spec do
|
60
|
+
desc "Run all specs in spec directory with RCov"
|
61
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
62
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
63
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
64
|
+
t.rcov = true
|
65
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Print Specdoc for all specs"
|
69
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
70
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
71
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
72
|
+
end
|
73
|
+
|
74
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
75
|
+
desc "Run the specs under spec/#{sub}"
|
76
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
77
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
78
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Run the Cucumber features"
|
83
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
84
|
+
t.fork = true
|
85
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
86
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
87
|
+
t.profile = "default"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Setup specs for stats
|
91
|
+
task :statsetup do
|
92
|
+
require 'code_statistics'
|
93
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
94
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
95
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
96
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
97
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
98
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
99
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
100
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
101
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
102
|
+
end
|
103
|
+
|
104
|
+
namespace :db do
|
105
|
+
namespace :fixtures do
|
106
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
107
|
+
task :load => :environment do
|
108
|
+
require 'active_record/fixtures'
|
109
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
110
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
111
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'Generate documentation for the users extension.'
|
119
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
120
|
+
rdoc.rdoc_dir = 'rdoc'
|
121
|
+
rdoc.title = 'UsersExtension'
|
122
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
123
|
+
rdoc.rdoc_files.include('README')
|
124
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
125
|
+
end
|
126
|
+
|
127
|
+
# For extensions that are in transition
|
128
|
+
desc 'Test the users extension.'
|
129
|
+
Rake::TestTask.new(:test) do |t|
|
130
|
+
t.libs << 'lib'
|
131
|
+
t.pattern = 'test/**/*_test.rb'
|
132
|
+
t.verbose = true
|
133
|
+
end
|
134
|
+
|
135
|
+
# Load any custom rakefiles for extension
|
136
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/config/routes.rb
ADDED
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features --tags ~@proposed,~@in_progress
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddApiKeyToUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :users, :api_key, :string, :limit => 40, :default => ''
|
4
|
+
|
5
|
+
User.all.each do |u|
|
6
|
+
u.generate_api_key
|
7
|
+
u.save
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
remove_column :users, :api_key
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
# Extension root
|
4
|
+
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
5
|
+
require extension_env+'.rb'
|
6
|
+
|
7
|
+
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
|
8
|
+
|
9
|
+
Cucumber::Rails::World.class_eval do
|
10
|
+
include Dataset
|
11
|
+
datasets_directory "#{RADIANT_ROOT}/spec/datasets"
|
12
|
+
Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
|
13
|
+
self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
|
14
|
+
|
15
|
+
# dataset :login_candy
|
16
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :users do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Users extension"
|
6
|
+
task :migrate => [ :environment, 'radiant:extensions:forms:migrate' ] do
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
UsersExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
else
|
11
|
+
UsersExtension.migrator.migrate
|
12
|
+
end
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copies public assets of the Users to the instance public/ directory."
|
17
|
+
task :update => :environment do
|
18
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
19
|
+
puts "Copying assets from UsersExtension"
|
20
|
+
Dir[UsersExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
21
|
+
path = file.sub(UsersExtension.root, '')
|
22
|
+
directory = File.dirname(path)
|
23
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
24
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
25
|
+
end
|
26
|
+
unless UsersExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
27
|
+
puts "Copying rake tasks from UsersExtension"
|
28
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
29
|
+
mkdir_p local_tasks_path, :verbose => false
|
30
|
+
Dir[File.join UsersExtension.root, %w(lib tasks *.rake)].each do |file|
|
31
|
+
cp file, local_tasks_path, :verbose => false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
37
|
+
task :sync => :environment do
|
38
|
+
# The main translation root, basically where English is kept
|
39
|
+
language_root = UsersExtension.root + "/config/locales"
|
40
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
41
|
+
|
42
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
43
|
+
next if filename.match('_available_tags')
|
44
|
+
basename = File.basename(filename, '.yml')
|
45
|
+
puts "Syncing #{basename}"
|
46
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
47
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
48
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
49
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Users
|
2
|
+
module Lib
|
3
|
+
module LoginSystem
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
protected
|
8
|
+
alias_method :authorize_radiant, :authorize
|
9
|
+
alias_method :current_user_radiant, :current_user
|
10
|
+
|
11
|
+
def authorize
|
12
|
+
if user_has_backend_access?
|
13
|
+
authorize_radiant
|
14
|
+
else
|
15
|
+
path = Radiant::Config["scoped.#{current_user.access}.welcome"]
|
16
|
+
path = "/#{path}".gsub('//','/')
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.any(:html, :xml, :json) { redirect_to(path) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def user_has_backend_access?
|
25
|
+
current_user.access.blank?
|
26
|
+
end
|
27
|
+
|
28
|
+
def current_user
|
29
|
+
@current_user ||= (current_user_radiant || login_from_api_key)
|
30
|
+
end
|
31
|
+
|
32
|
+
def login_from_api_key
|
33
|
+
self.current_user = User.find_by_api_key(params[:api_key]) if params[:api_key].present?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Users
|
2
|
+
module Models
|
3
|
+
module User
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
attr_protected :access
|
8
|
+
after_initialize :generate_api_key
|
9
|
+
|
10
|
+
def generate_api_key
|
11
|
+
begin
|
12
|
+
self.api_key = self.sha1(Time.now + Radiant::Config['session_timeout'].to_i)
|
13
|
+
rescue
|
14
|
+
logger.error "attempt to create api key failed - please migrate radiant-scoped-extension"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{radiant-users-extension}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Christopher Rankin", "Dirk Kelly"]
|
12
|
+
s.date = %q{2010-11-10}
|
13
|
+
s.description = %q{Users creates support for non-admin users with API access}
|
14
|
+
s.email = %q{dk@squaretalent.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"config/routes.rb",
|
24
|
+
"cucumber.yml",
|
25
|
+
"db/migrate/20100311014641_add_api_key_to_users.rb",
|
26
|
+
"db/migrate/20100311021835_add_access_to_user.rb",
|
27
|
+
"features/support/env.rb",
|
28
|
+
"features/support/paths.rb",
|
29
|
+
"lib/tasks/users_extension_tasks.rake",
|
30
|
+
"lib/users/lib/login_system.rb",
|
31
|
+
"lib/users/models/user.rb",
|
32
|
+
"lib/users/models/user/scoped.rb",
|
33
|
+
"radiant-users-extension.gemspec",
|
34
|
+
"spec/datasets/scoped_users_dataset.rb",
|
35
|
+
"spec/models/user_spec.rb",
|
36
|
+
"spec/models/visitor_spec.rb",
|
37
|
+
"spec/spec.opts",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"users_extension.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/dirkkelly/radiant-users-extension}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
45
|
+
s.summary = %q{Users Extension for Radiant CMS}
|
46
|
+
s.test_files = [
|
47
|
+
"spec/datasets/scoped_users_dataset.rb",
|
48
|
+
"spec/models/user_spec.rb",
|
49
|
+
"spec/models/visitor_spec.rb",
|
50
|
+
"spec/spec_helper.rb"
|
51
|
+
]
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
+
else
|
59
|
+
end
|
60
|
+
else
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ScopedUsersDataset < Dataset::Base
|
2
|
+
|
3
|
+
def load
|
4
|
+
create_model :user, :admin,
|
5
|
+
:name => 'Admin',
|
6
|
+
:email => 'admin@example.com',
|
7
|
+
:login => 'admin',
|
8
|
+
:password => 'radiant',
|
9
|
+
:password_confirmation => 'radiant'
|
10
|
+
|
11
|
+
create_model :user, :visitor,
|
12
|
+
:name => 'Visitor',
|
13
|
+
:email => 'visitor@example.com',
|
14
|
+
:login => 'visitor',
|
15
|
+
:access => 'some_visitor',
|
16
|
+
:password => 'radiant',
|
17
|
+
:password_confirmation => 'radiant'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe User do
|
4
|
+
|
5
|
+
dataset :users
|
6
|
+
|
7
|
+
describe '#access attribute' do
|
8
|
+
it 'should be protected' do
|
9
|
+
@user = User.new({
|
10
|
+
:access => 'everything'
|
11
|
+
})
|
12
|
+
|
13
|
+
@user.access.should === ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#generate_api_key' do
|
18
|
+
it 'should generate an api key on initialize' do
|
19
|
+
@user = User.new
|
20
|
+
@user.api_key.should_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
class SomeVisitor < User
|
4
|
+
include Users::Models::User::Scoped
|
5
|
+
end
|
6
|
+
|
7
|
+
describe SomeVisitor do
|
8
|
+
|
9
|
+
dataset :scoped_users
|
10
|
+
|
11
|
+
describe 'scope' do
|
12
|
+
it 'should return only users with scoped access' do
|
13
|
+
SomeVisitor.count.should === User.all({:conditions => { :access => 'some_visitor' } }).count
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'before_save set_access filter' do
|
18
|
+
before :each do
|
19
|
+
mock.instance_of(SomeVisitor).save { true }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'a new object with no access set' do
|
23
|
+
it 'should set access to visitor' do
|
24
|
+
@visitor = SomeVisitor.new
|
25
|
+
@visitor.access.should === 'some_visitor'
|
26
|
+
@visitor.save
|
27
|
+
@visitor.access.should === 'some_visitor'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'an existing object with access set' do
|
32
|
+
@visitor = SomeVisitor.new
|
33
|
+
@visitor.access = 'not visitor'
|
34
|
+
@visitor.access.should === 'not visitor'
|
35
|
+
@visitor.save
|
36
|
+
@visitor.access.should === 'not visitor'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
|
16
|
+
Spec::Runner.configure do |config|
|
17
|
+
config.mock_with :rr
|
18
|
+
end
|
data/users_extension.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class UsersExtension < Radiant::Extension
|
2
|
+
version "0.0.1"
|
3
|
+
description "Users allows you to create non-admin users with API access"
|
4
|
+
url "http://github.com/dirkkelly/radiant-users-extension"
|
5
|
+
|
6
|
+
def activate
|
7
|
+
# Models
|
8
|
+
User.send :include, Users::Models::User
|
9
|
+
|
10
|
+
# Controllers
|
11
|
+
ApplicationController.send :include, Users::Lib::LoginSystem
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-users-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Christopher Rankin
|
14
|
+
- Dirk Kelly
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-11-10 00:00:00 +08:00
|
20
|
+
default_executable:
|
21
|
+
dependencies: []
|
22
|
+
|
23
|
+
description: Users creates support for non-admin users with API access
|
24
|
+
email: dk@squaretalent.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files:
|
30
|
+
- README.md
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- config/routes.rb
|
37
|
+
- cucumber.yml
|
38
|
+
- db/migrate/20100311014641_add_api_key_to_users.rb
|
39
|
+
- db/migrate/20100311021835_add_access_to_user.rb
|
40
|
+
- features/support/env.rb
|
41
|
+
- features/support/paths.rb
|
42
|
+
- lib/tasks/users_extension_tasks.rake
|
43
|
+
- lib/users/lib/login_system.rb
|
44
|
+
- lib/users/models/user.rb
|
45
|
+
- lib/users/models/user/scoped.rb
|
46
|
+
- radiant-users-extension.gemspec
|
47
|
+
- spec/datasets/scoped_users_dataset.rb
|
48
|
+
- spec/models/user_spec.rb
|
49
|
+
- spec/models/visitor_spec.rb
|
50
|
+
- spec/spec.opts
|
51
|
+
- spec/spec_helper.rb
|
52
|
+
- users_extension.rb
|
53
|
+
has_rdoc: true
|
54
|
+
homepage: http://github.com/dirkkelly/radiant-users-extension
|
55
|
+
licenses: []
|
56
|
+
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.7
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Users Extension for Radiant CMS
|
87
|
+
test_files:
|
88
|
+
- spec/datasets/scoped_users_dataset.rb
|
89
|
+
- spec/models/user_spec.rb
|
90
|
+
- spec/models/visitor_spec.rb
|
91
|
+
- spec/spec_helper.rb
|