From 9057a9be54f97ff69c157006d19cc2d96b99c607 Mon Sep 17 00:00:00 2001 From: Michael Noack Date: Mon, 9 Nov 2015 10:45:48 +1030 Subject: [PATCH] Move setup to spec_helper --- spec/action_controller_extensions_spec.rb | 18 ------------------ spec/right_on_spec.rb | 18 ------------------ spec/spec_helper.rb | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/spec/action_controller_extensions_spec.rb b/spec/action_controller_extensions_spec.rb index 9d3a55e..2e97013 100644 --- a/spec/action_controller_extensions_spec.rb +++ b/spec/action_controller_extensions_spec.rb @@ -1,23 +1,5 @@ require 'spec_helper' -DB_FILE = 'tmp/test_db' -FileUtils.mkdir_p File.dirname(DB_FILE) -FileUtils.rm_f DB_FILE - -ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE - -load('spec/schema.rb') - -Right.rights_yaml 'db/rights_roles.yml' - -class Model < ActiveRecord::Base - restricted_by_right -end - -class User < ActiveRecord::Base - include RightOn::RoleModel -end - require 'action_controller' class AdminController < ActionController::Base include RightOn::ActionControllerExtensions diff --git a/spec/right_on_spec.rb b/spec/right_on_spec.rb index 4b886ac..b162409 100644 --- a/spec/right_on_spec.rb +++ b/spec/right_on_spec.rb @@ -1,23 +1,5 @@ require 'spec_helper' -DB_FILE = 'tmp/test_db' -FileUtils.mkdir_p File.dirname(DB_FILE) -FileUtils.rm_f DB_FILE - -ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE - -load('spec/schema.rb') - -Right.rights_yaml 'db/rights_roles.yml' - -class Model < ActiveRecord::Base - restricted_by_right -end - -class User < ActiveRecord::Base - include RightOn::RoleModel -end - describe User do let(:basic_user) { User.where(name: 'basic').first } let(:admin_user) { User.where(name: 'admin').first } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b79476d..221f0c2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -21,3 +21,21 @@ Right.cache = ActiveSupport::Cache::MemoryStore.new end end + +DB_FILE = 'tmp/test_db' +FileUtils.mkdir_p File.dirname(DB_FILE) +FileUtils.rm_f DB_FILE + +ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE + +load('spec/schema.rb') + +Right.rights_yaml 'db/rights_roles.yml' + +class Model < ActiveRecord::Base + restricted_by_right +end + +class User < ActiveRecord::Base + include RightOn::RoleModel +end