Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw committed Jun 26, 2012
1 parent be977ce commit 5c9810a
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 119 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,11 @@
# master

### Added

### Changed

### Fixed

# Versions <= 0.0.5

Long-long history here undocumented...
15 changes: 3 additions & 12 deletions Rakefile
Expand Up @@ -22,6 +22,7 @@ Jeweler::Tasks.new do |gem|
gem.description = %Q{Simple Role System for Rails Apps}
gem.email = "s.pankevich@gmail.com"
gem.authors = ["stanislaw"]
gem.version = SimpleRoles::VERSION
# dependencies defined in Gemfile
end
Jeweler::RubygemsDotOrgTasks.new
Expand All @@ -35,19 +36,9 @@ RDoc::Task.new(:rdoc) do |rdoc|
end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'

load 'rails/tasks/engine.rake'

Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task :default => :test
# task :default => :test
13 changes: 9 additions & 4 deletions lib/simple_roles.rb
@@ -1,5 +1,6 @@
require "sweetloader"
require "require_all"

require "sugar-high/array"
require "sugar-high/dsl"

Expand All @@ -11,9 +12,13 @@
module SimpleRoles
autoload_modules :Base, :Configuration, :RolesArray

class << self
def configure &block
yield SimpleRoles::Configuration
end
extend self

def configure &block
yield config
end

def config
SimpleRoles::Configuration
end
end
11 changes: 1 addition & 10 deletions lib/simple_roles/base.rb
Expand Up @@ -9,6 +9,7 @@ def included base
}

base.send :include, SimpleRoles::Base::InstanceMethods

SimpleRoles::Configuration.user_models << base
base.register_roles_methods
end
Expand Down Expand Up @@ -90,22 +91,12 @@ def roles= *rolez
roles_array.roles = *rolez
end

# TODO: implement
#
def role_groups_list
[]
end

private

def roles_array
@roles_array ||= SimpleRoles::RolesArray.new self
end

end

end
end



1 change: 1 addition & 0 deletions lib/simple_roles/configuration.rb
Expand Up @@ -13,6 +13,7 @@ def user_models
def valid_roles= vr
raise "There should be an array of valid roles" if !vr.kind_of?(Array)
@valid_roles = vr

distribute_methods
end

Expand Down
5 changes: 1 addition & 4 deletions lib/simple_roles/macros.rb
@@ -1,10 +1,7 @@
module SimpleRoles
module Macros
def self.included(base)
end

def simple_roles &block
yield SimpleRoles::Configuration if block
yield SimpleRoles.config if block
include SimpleRoles::Base
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/simple_roles/version.rb
@@ -1,3 +1,3 @@
module SimpleRoles
VERSION = "0.0.1"
VERSION = "0.0.5"
end
4 changes: 2 additions & 2 deletions spec/integration/main_spec.rb
@@ -1,7 +1,7 @@
require 'dummy_spec_helper'
require 'spec_helper'

describe "" do
it "truth" do
pending "truth" do
Rails.application.should be_kind_of(Dummy::Application)
end
end
62 changes: 0 additions & 62 deletions spec/integration/messages_spec.rb

This file was deleted.

7 changes: 3 additions & 4 deletions spec/integration/requests/main_spec.rb
@@ -1,11 +1,11 @@
require 'dummy_spec_helper'
require 'spec_helper'

describe "Requests" do
it "truth" do
pending "truth" do
Rails.application.should be_kind_of(Dummy::Application)
end

describe "Basic pages" do
pending "Basic pages" do
before do
login_as(User.first)
end
Expand All @@ -16,6 +16,5 @@
get '/'
response.status.should be(200)
end

end
end
2 changes: 1 addition & 1 deletion spec/simple_roles/base_spec.rb
Expand Up @@ -33,7 +33,7 @@
its(:"#{meth}") { should be_empty }
end

[:roles, :roles_list, :role_groups_list].each do |meth|
[:roles, :roles_list].each do |meth|
specify { should respond_to(meth) }
its(:"#{meth}") { should be_empty }
end
Expand Down
39 changes: 21 additions & 18 deletions spec/spec_helper.rb
Expand Up @@ -5,48 +5,51 @@

#require File.expand_path("../dummy/config/environment", __FILE__)
require 'require_all'
require 'cutter'
require 'sugar-high/dsl'

#require 'rails'
require 'active_record'
require 'active_model'

require 'simple_roles'

require 'cutter'
require 'sugar-high/dsl'

require 'rspec/core'
#require 'shoulda'
require 'factory_girl'

require_all File.expand_path('../support', __FILE__)

path = File.dirname(__FILE__) + '/support/database.yml'

dbfile = File.open(path)
dbconfig = YAML::load(dbfile)
ActiveRecord::Base.establish_connection(dbconfig)

class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil

def self.connection
@@shared_connection || retrieve_connection
end
end

ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

#ActiveRecord::Base.logger = Logger.new(STDERR)

RSpec.configure do |config|
config.mock_with :rspec

config.include Factory::Syntax::Methods
config.include FactoryGirl::Syntax::Methods

config.before(:suite) do
with ActiveRecord::Base.connection do

tables.map do |table|
drop_table table
end
with ActiveRecord::Migrator do
# SimpleRoles's own migrations
migrate File.expand_path('../../db/migrate', __FILE__)
# Helper migration - users table
migrate File.expand_path('../support/migrations', __FILE__)
end if tables.empty?
end

with ActiveRecord::Migrator do
# SimpleRoles's own migrations
ActiveRecord::Migrator.migrate File.expand_path('../../db/migrate', __FILE__)
# Helper migration - users table
ActiveRecord::Migrator.migrate File.expand_path('../support/migrations', __FILE__)
end

end
end
2 changes: 1 addition & 1 deletion spec/support/database.yml
Expand Up @@ -2,5 +2,5 @@ adapter: mysql2
host: localhost
database: simple_roles_test
username: root
password: root
password:
encoding: utf8

0 comments on commit 5c9810a

Please sign in to comment.