Skip to content

Commit

Permalink
Implement proper Travis testing of different Rails versions per Ruby …
Browse files Browse the repository at this point in the history
…version.
  • Loading branch information
cedric committed Apr 10, 2014
1 parent 5d47c6e commit 98ecb5d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 18 deletions.
23 changes: 20 additions & 3 deletions .travis.yml
@@ -1,14 +1,31 @@
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.0
- ree
- jruby-18mode
- 2.1.1
- jruby-19mode
- jruby-20mode
- jruby-21mode
gemfile:
- test/gemfiles/rails-3.1
- test/gemfiles/rails-3.2
- test/gemfiles/rails-4.0
matrix:
exclude:
- { rvm: 1.9.2, gemfile: test/gemfiles/rails-4.0 }
- { rvm: 2.0.0, gemfile: test/gemfiles/rails-3.1 }
- { rvm: 2.0.0, gemfile: test/gemfiles/rails-3.2 }
- { rvm: 2.1.0, gemfile: test/gemfiles/rails-3.1 }
- { rvm: 2.1.0, gemfile: test/gemfiles/rails-3.2 }
- { rvm: 2.1.1, gemfile: test/gemfiles/rails-3.1 }
- { rvm: 2.1.1, gemfile: test/gemfiles/rails-3.2 }
- { rvm: jruby-19mode, gemfile: test/gemfiles/rails-4.0 }
- { rvm: jruby-20mode, gemfile: test/gemfiles/rails-3.1 }
- { rvm: jruby-20mode, gemfile: test/gemfiles/rails-3.2 }
- { rvm: jruby-21mode, gemfile: test/gemfiles/rails-3.1 }
- { rvm: jruby-21mode, gemfile: test/gemfiles/rails-3.2 }
notifications:
recipients:
email:
Expand Down
16 changes: 6 additions & 10 deletions lib/spamtrap/controller.rb
@@ -1,17 +1,13 @@
module Spamtrap::Controller

def self.included(base)
base.extend ActsAsMethods
end

module ActsAsMethods
def spamtrap(actions, honeypot='spamtrap', &block)
actions = [actions] unless actions.is_a?(Array)
raise 'Spamtrap must have actions defined.' if actions.empty?
before_filter(:only => actions) do |controller|
if block_given?
controller.instance_eval(&block)
end
def spamtrap(honeypot = 'spamtrap', options = {}, &block)
before_filter(options) do |controller|
controller.instance_eval(&block) if block_given?
controller.instance_eval do
if params[honeypot].present?
Rails.logger.warn "Spamtrap triggered by #{request.remote_ip}."
Expand All @@ -21,7 +17,7 @@ def spamtrap(actions, honeypot='spamtrap', &block)
end
end
end

end

ActionController::Base.send :include, Spamtrap::Controller
11 changes: 11 additions & 0 deletions lib/spamtrap/helper.rb
Expand Up @@ -3,4 +3,15 @@ def spamtrap(parameter='spamtrap', options={})
options.reverse_merge!({:class => 'spamtrap'})
@template.text_area_tag(parameter, nil, options)
end

# # def nonce(method, tag_value, options = {})
# def cryptographic_nonce(options = {})
# # @template.hidden_field(@object_name, method, tag_value, objectify_options(options))
# now, random = Time.now.to_i, SecureRandom.hex
# # OpenSSL::HMAC.hexdigest()
# cryptographic_nonce = Digest::MD5.hexdigest([timestamp, Rails.application.config.secret_key_base].join(':'))
# @template.hidden_field(@object_name, :timestamp, now, objectify_options(options)) +
# @template.hidden_field(@object_name, :random, random, objectify_options(options)) +
# @template.hidden_field(@object_name, :spinner, cryptographic_nonce(now), objectify_options(options))
# end
end
8 changes: 4 additions & 4 deletions lib/spamtrap/version.rb
@@ -1,5 +1,5 @@
module Spamtrap
VERSION = '0.0.5'
end

VERSION = '0.1.0'

end
2 changes: 1 addition & 1 deletion spamtrap.gemspec
Expand Up @@ -16,5 +16,5 @@ spec = Gem::Specification.new do |s|
s.files = Dir['lib/**/*.rb']
s.test_files = Dir['test/**/*.rb']
s.required_rubygems_version = '>= 1.3.6'
s.add_dependency('rails', RUBY_VERSION < '1.9.3' ? '~> 3.1' : '>= 3.1')
s.add_dependency('rails')
end
5 changes: 5 additions & 0 deletions test/gemfiles/rails-3.1
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec :path => "./../.."

gem 'rails', '~> 3.1.0'
5 changes: 5 additions & 0 deletions test/gemfiles/rails-3.2
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec :path => "./../.."

gem 'rails', '~> 3.2.0'
5 changes: 5 additions & 0 deletions test/gemfiles/rails-4.0
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec :path => "./../.."

gem 'rails', '~> 4.0.0'

0 comments on commit 98ecb5d

Please sign in to comment.