Skip to content
Browse files

initial checkin of restful_roles plugin

  • Loading branch information...
0 parents commit 5cfa69f0ab9696872d02091e00079f28b98feb76 @jamesgolick committed
Showing with 90 additions and 0 deletions.
  1. +20 −0 MIT-LICENSE
  2. +13 −0 README
  3. +22 −0 Rakefile
  4. +1 −0 init.rb
  5. +1 −0 install.rb
  6. +1 −0 lib/restful_roles.rb
  7. +4 −0 tasks/restful_roles_tasks.rake
  8. +7 −0 test/restful_roles_test.rb
  9. +20 −0 test/test_helper.rb
  10. +1 −0 uninstall.rb
20 MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 [name of plugin creator]
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13 README
@@ -0,0 +1,13 @@
+RestfulRoles
+============
+
+Introduction goes here.
+
+
+Example
+=======
+
+Example goes here.
+
+
+Copyright (c) 2008 [name of plugin creator], released under the MIT license
22 Rakefile
@@ -0,0 +1,22 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the restful_roles plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the restful_roles plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'RestfulRoles'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
1 init.rb
@@ -0,0 +1 @@
+# Include hook code here
1 install.rb
@@ -0,0 +1 @@
+# Install hook code here
1 lib/restful_roles.rb
@@ -0,0 +1 @@
+# RestfulRoles
4 tasks/restful_roles_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :restful_roles do
+# # Task goes here
+# end
7 test/restful_roles_test.rb
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/test_helper'
+
+Expectations do
+ expect Post.to.be.permits?(:create, stub(:let_me_create? => true))
+ expect Post.not.to.be.permits?(:create, stub(:let_me_create? => false))
+end
+
20 test/test_helper.rb
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/../init.rb'
+require 'rubygems'
+require 'activerecord'
+require 'expectations'
+
+ActiveRecord::Base.configurations = {'sqlite3' => {:adapter => 'sqlite3', :database => ':memory:'}}
+ActiveRecord::Base.establish_connection('sqlite3')
+
+ActiveRecord::Base.logger = Logger.new(STDERR)
+ActiveRecord::Base.logger.level = Logger::WARN
+
+ActiveRecord::Schema.define(:version => 0) do
+ create_table :post do |t|
+ end
+end
+
+class Post < ActiveRecord::Base
+ permits :create, :if => lambda { |person| person.let_me_create? }
+end
+
1 uninstall.rb
@@ -0,0 +1 @@
+# Uninstall hook code here

0 comments on commit 5cfa69f

Please sign in to comment.
Something went wrong with that request. Please try again.