Adjusting the Sinatra extension so it is namespaced under the PaperTrail module instead of under the Sinatra module. close #277

This commit is contained in:
Ben Atkins 2013-09-26 10:29:53 -04:00
parent 8440ae778b
commit 9d4437bf00
4 changed files with 7 additions and 7 deletions

View File

@ -92,7 +92,7 @@ If you're using the modular [Sinatra::Base](http://www.sinatrarb.com/intro.html#
require 'sinatra/base'
class BlehApp < Sinatra::Base
register Sinatra::PaperTrail
register PaperTrail::Sinatra
end
```

View File

@ -1,9 +1,9 @@
module Sinatra
module PaperTrail
module PaperTrail
module Sinatra
# Register this module inside your Sinatra application to gain access to controller-level methods used by PaperTrail
def self.registered(app)
app.helpers Sinatra::PaperTrail
app.helpers self
app.before { set_paper_trail_whodunnit }
end
@ -27,5 +27,5 @@ module Sinatra
end
register Sinatra::PaperTrail if defined?(register)
::Sinatra.register PaperTrail::Sinatra if defined?(::Sinatra)
end

View File

@ -4,7 +4,7 @@ require 'sinatra/base'
# --- Tests for modular `Sinatra::Base` style ----
class BaseApp < Sinatra::Base
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => File.expand_path('../../dummy/db/test.sqlite3', __FILE__))
register Sinatra::PaperTrail
register PaperTrail::Sinatra
get '/test' do
Widget.create!(:name => 'foo')

View File

@ -4,7 +4,7 @@ require 'test_helper'
# --- Tests for non-modular `Sinatra::Application` style ----
class Sinatra::Application
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => File.expand_path('../../dummy/db/test.sqlite3', __FILE__))
register Sinatra::PaperTrail # we shouldn't actually need this line if I'm not mistaken but the tests seem to fail without it ATM
register PaperTrail::Sinatra # we shouldn't actually need this line if I'm not mistaken but the tests seem to fail without it ATM
get '/test' do
Widget.create!(:name => 'bar')