diff --git a/.travis.yml b/.travis.yml index e2f0ec2..e370057 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ language: ruby rvm: - - 1.9.3 - - 2.0.0 - - 2.1.0 + - 2.5.0 diff --git a/Gemfile b/Gemfile index 331e337..83437d1 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,8 @@ source "https://rubygems.org" gemspec -gem "rdoc" +gem 'rdoc', '~> 5.1' group :test do - gem 'sqlite3' -end \ No newline at end of file + gem 'sqlite3', '1.3.13' +end diff --git a/Gemfile.lock b/Gemfile.lock index 3c5ad8f..6bd1c03 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,101 +1,128 @@ PATH remote: . specs: - survey (0.1) - rails (>= 3.2.6, < 5) - railties (>= 3.2.6, < 5) + survey (1.0.0) + rails (~> 5.0.7) + railties (~> 5.0.7) GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.2) - actionpack (= 4.0.2) - mail (~> 2.5.4) - actionpack (4.0.2) - activesupport (= 4.0.2) - builder (~> 3.1.0) + actioncable (5.0.7.2) + actionpack (= 5.0.7.2) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.7.2) + actionview (= 5.0.7.2) + activesupport (= 5.0.7.2) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.7.2) + activesupport (= 5.0.7.2) + builder (~> 3.1) erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.2) - activesupport (= 4.0.2) - builder (~> 3.1.0) - activerecord (4.0.2) - activemodel (= 4.0.2) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.2) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.2) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.1) - atomic (1.1.14) - builder (3.1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.7.2) + activesupport (= 5.0.7.2) + globalid (>= 0.3.6) + activemodel (5.0.7.2) + activesupport (= 5.0.7.2) + activerecord (5.0.7.2) + activemodel (= 5.0.7.2) + activesupport (= 5.0.7.2) + arel (~> 7.0) + activesupport (5.0.7.2) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (7.1.4) + builder (3.2.4) + concurrent-ruby (1.1.6) + crass (1.0.6) erubis (2.7.0) - faker (1.1.2) - i18n (~> 0.5) - hike (1.2.3) - i18n (0.6.9) - json (1.7.6) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - metaclass (0.0.1) - mime-types (1.25.1) - minitest (4.7.5) - mocha (0.13.2) - metaclass (~> 0.0.1) - multi_json (1.8.2) - polyglot (0.3.3) - rack (1.5.2) - rack-test (0.6.2) + faker (1.9.6) + i18n (>= 0.7) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + method_source (1.0.0) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.0) + mocha (1.11.2) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + rack (2.2.2) + rack-test (0.6.3) rack (>= 1.0) - rails (4.0.2) - actionmailer (= 4.0.2) - actionpack (= 4.0.2) - activerecord (= 4.0.2) - activesupport (= 4.0.2) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.2) - sprockets-rails (~> 2.0.0) - railties (4.0.2) - actionpack (= 4.0.2) - activesupport (= 4.0.2) + rails (5.0.7.2) + actioncable (= 5.0.7.2) + actionmailer (= 5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + activemodel (= 5.0.7.2) + activerecord (= 5.0.7.2) + activesupport (= 5.0.7.2) + bundler (>= 1.3.0) + railties (= 5.0.7.2) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.0.7.2) + actionpack (= 5.0.7.2) + activesupport (= 5.0.7.2) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.0.3) - rdoc (3.12) - json (~> 1.4) - sprockets (2.10.1) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - sqlite3 (1.3.7) - thor (0.18.1) - thread_safe (0.1.3) - atomic - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.38) + rake (13.0.1) + rdoc (5.1.0) + sprockets (4.0.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + thor (1.0.1) + thread_safe (0.3.6) + tzinfo (1.2.6) + thread_safe (~> 0.1) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) PLATFORMS ruby DEPENDENCIES - faker - mocha - rake - rdoc - sqlite3 + faker (~> 1.8, >= 1.8.7) + mocha (~> 1.11) + rake (~> 13.0, >= 13.0.1) + rdoc (~> 5.1) + sqlite3 (= 1.3.13) survey! + +BUNDLED WITH + 2.1.4 diff --git a/lib/generators/templates/attempts_plain.rb b/lib/generators/templates/attempts_plain.rb index 76ada4f..4709aaf 100644 --- a/lib/generators/templates/attempts_plain.rb +++ b/lib/generators/templates/attempts_plain.rb @@ -60,7 +60,7 @@ def normalize_data!(hash) end def attempt_params - rails4? ? params_whitelist : params[:survey_attempt] + params_whitelist end def params_whitelist diff --git a/lib/generators/templates/survey_plain.rb b/lib/generators/templates/survey_plain.rb index 46a3102..85c5b37 100644 --- a/lib/generators/templates/survey_plain.rb +++ b/lib/generators/templates/survey_plain.rb @@ -44,11 +44,10 @@ def load_survey end def survey_params - rails4? ? params_whitelist : params[:survey_survey] + params_whitelist end def params_whitelist params.require(:survey_survey).permit(Survey::Survey::AccessibleAttributes) end - end diff --git a/lib/survey.rb b/lib/survey.rb index be0e532..51ead54 100644 --- a/lib/survey.rb +++ b/lib/survey.rb @@ -1,15 +1,5 @@ -module ::Kernel - def rails4? - return defined?(Rails) && Rails::VERSION::MAJOR == 4 - end - - def in_rails_3(&block) - yield if block_given? unless rails4? - end -end - require 'survey/engine' require 'survey/version' require 'survey/active_record' -ActiveRecord::Base.send(:include, Survey::ActiveRecord) \ No newline at end of file +ActiveRecord::Base.send(:include, Survey::ActiveRecord) diff --git a/lib/survey/active_record.rb b/lib/survey/active_record.rb index a9d19e5..8d259df 100644 --- a/lib/survey/active_record.rb +++ b/lib/survey/active_record.rb @@ -11,18 +11,9 @@ def has_surveys end end - def acceptable_attributes(*args) - self.const_set('AccessibleAttributes', args + [:id, :_destroy]) - - in_rails_3 do - if defined?(self.respond_to?(:attr_accessible)) - attr_accessible(*self.const_get('AccessibleAttributes').map { |k| k.is_a?(Hash) ? k.keys.first : k }) - end - end - end end end -end \ No newline at end of file +end diff --git a/lib/survey/version.rb b/lib/survey/version.rb index 98163a2..cfdfc9c 100644 --- a/lib/survey/version.rb +++ b/lib/survey/version.rb @@ -1,3 +1,3 @@ module Survey - VERSION = "0.1" -end \ No newline at end of file + VERSION = "1.0.0" +end diff --git a/survey.gemspec b/survey.gemspec index 31d8e3e..11c229b 100644 --- a/survey.gemspec +++ b/survey.gemspec @@ -5,15 +5,20 @@ require "survey/version" Gem::Specification.new do |s| s.name = "survey" s.version = Survey::VERSION + s.authors = %Q{Runtime Revolution} + s.summary = %Q{Survey is a user oriented tool that brings surveys into Rails applications.} s.description = %Q{A rails gem to enable surveys in your application as easy as possible} - s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.md"] - s.authors = %Q{Runtime Revolution} + s.homepage = 'https://github.com/runtimerevolution/survey' + s.license = 'MIT' + s.required_ruby_version = Gem::Requirement.new('>= 2.5.0') + + s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.md"] s.require_paths = %w(lib) - s.add_dependency("rails", [">= 3.2.6", "< 5"]) - s.add_dependency("railties", ">= 3.2.6", "< 5") - s.add_development_dependency("mocha") - s.add_development_dependency("faker") - s.add_development_dependency("rake") + s.add_dependency("rails", ["~> 5.0.7"]) + s.add_dependency("railties", "~> 5.0.7") + s.add_development_dependency("mocha", ['~> 1.11']) + s.add_development_dependency("faker", ['~> 1.8', '>= 1.8.7']) + s.add_development_dependency("rake", ['~> 13.0', '>= 13.0.1']) end diff --git a/test/dummy/Gemfile b/test/dummy/Gemfile index e7f8331..9d41a05 100644 --- a/test/dummy/Gemfile +++ b/test/dummy/Gemfile @@ -1,30 +1,26 @@ source 'https://rubygems.org' -ruby "1.9.3" +ruby "2.5.0" -gem 'rails', '3.2.16' +gem 'rails', '5.0.7' gem 'therubyracer' gem 'execjs' +gem 'sqlite3', '1.3.13' +gem 'jquery-rails', '~> 4.0', '>= 4.0.5' + group :development, :test do gem 'pry-rails' - gem 'faker' - gem 'jquery-rails' + gem 'faker', '~> 1.8', '>= 1.8.7' + gem 'jquery-rails', '~> 4.0', '>= 4.0.5' end -gem 'sqlite3' - - # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' + gem 'sass-rails', '~> 5.0', '>= 5.0.7' + gem 'coffee-rails', '~> 4.2', '>= 4.2.2' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end - -gem 'jquery-rails' - - diff --git a/test/dummy/Gemfile.lock b/test/dummy/Gemfile.lock index b2fa361..20cb157 100644 --- a/test/dummy/Gemfile.lock +++ b/test/dummy/Gemfile.lock @@ -1,131 +1,167 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.16) - actionpack (= 3.2.16) - mail (~> 2.5.4) - actionpack (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - builder (~> 3.0.0) + actioncable (5.0.7) + actionpack (= 5.0.7) + nio4r (>= 1.2, < 3.0) + websocket-driver (~> 0.6.1) + actionmailer (5.0.7) + actionpack (= 5.0.7) + actionview (= 5.0.7) + activejob (= 5.0.7) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.7) + actionview (= 5.0.7) + activesupport (= 5.0.7) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.7) + activesupport (= 5.0.7) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.16) - activesupport (= 3.2.16) - builder (~> 3.0.0) - activerecord (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - activesupport (3.2.16) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - arel (3.0.3) - builder (3.0.4) - coderay (1.0.8) - coffee-rails (3.2.2) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.7) + activesupport (= 5.0.7) + globalid (>= 0.3.6) + activemodel (5.0.7) + activesupport (= 5.0.7) + activerecord (5.0.7) + activemodel (= 5.0.7) + activesupport (= 5.0.7) + arel (~> 7.0) + activesupport (5.0.7) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (7.1.4) + builder (3.2.4) + coderay (1.1.2) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.4.0) + coffee-script-source (1.12.2) + concurrent-ruby (1.1.6) + crass (1.0.6) erubis (2.7.0) - execjs (1.4.0) - multi_json (~> 1.0) - faker (1.1.2) - i18n (~> 0.5) - hike (1.2.3) - i18n (0.6.9) - journey (1.0.4) - jquery-rails (2.2.0) - railties (>= 3.0, < 5.0) + execjs (2.7.0) + faker (1.9.6) + i18n (>= 0.7) + ffi (1.12.2) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.2) + concurrent-ruby (~> 1.0) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.1) - libv8 (3.11.8.13) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - method_source (0.8.1) - mime-types (1.25.1) - multi_json (1.8.2) - polyglot (0.3.3) - pry (0.9.11.4) - coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.4) - pry-rails (0.2.2) - pry (>= 0.9.10) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.3) - rack - rack-test (0.6.2) + libv8 (3.16.14.19) + loofah (2.4.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + method_source (0.9.2) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.14.0) + nio4r (2.5.2) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-rails (0.3.9) + pry (>= 0.10.4) + rack (2.2.2) + rack-test (0.6.3) rack (>= 1.0) - rails (3.2.16) - actionmailer (= 3.2.16) - actionpack (= 3.2.16) - activerecord (= 3.2.16) - activeresource (= 3.2.16) - activesupport (= 3.2.16) - bundler (~> 1.0) - railties (= 3.2.16) - railties (3.2.16) - actionpack (= 3.2.16) - activesupport (= 3.2.16) - rack-ssl (~> 1.3.2) + rails (5.0.7) + actioncable (= 5.0.7) + actionmailer (= 5.0.7) + actionpack (= 5.0.7) + actionview (= 5.0.7) + activejob (= 5.0.7) + activemodel (= 5.0.7) + activerecord (= 5.0.7) + activesupport (= 5.0.7) + bundler (>= 1.3.0) + railties (= 5.0.7) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.0.7) + actionpack (= 5.0.7) + activesupport (= 5.0.7) + method_source rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.1.0) - rdoc (3.12.2) - json (~> 1.4) - ref (1.0.2) - sass (3.2.5) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - slop (3.4.3) - sprockets (2.2.2) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.7) - therubyracer (0.11.3) - libv8 (~> 3.11.8.12) + thor (>= 0.18.1, < 2.0) + rake (13.0.1) + rb-fsevent (0.10.3) + rb-inotify (0.10.1) + ffi (~> 1.0) + ref (2.0.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + therubyracer (0.12.3) + libv8 (~> 3.16.14.15) ref - thor (0.18.1) - tilt (1.4.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.38) - uglifier (1.3.0) - execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) + thor (1.0.1) + thread_safe (0.3.6) + tilt (2.0.10) + tzinfo (1.2.6) + thread_safe (~> 0.1) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + websocket-driver (0.6.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) PLATFORMS ruby DEPENDENCIES - coffee-rails (~> 3.2.1) + coffee-rails (~> 4.2, >= 4.2.2) execjs - faker - jquery-rails + faker (~> 1.8, >= 1.8.7) + jquery-rails (~> 4.0, >= 4.0.5) pry-rails - rails (= 3.2.16) - sass-rails (~> 3.2.3) - sqlite3 + rails (= 5.0.7) + sass-rails (~> 5.0, >= 5.0.7) + sqlite3 (= 1.3.13) therubyracer uglifier (>= 1.0.3) + +RUBY VERSION + ruby 2.5.0p0 + +BUNDLED WITH + 2.1.4 diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js new file mode 100644 index 0000000..b16e53d --- /dev/null +++ b/test/dummy/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/test/dummy/db/migrate/20130123110019_create_users.rb b/test/dummy/db/migrate/20130123110019_create_users.rb index 37ce317..7187df3 100644 --- a/test/dummy/db/migrate/20130123110019_create_users.rb +++ b/test/dummy/db/migrate/20130123110019_create_users.rb @@ -1,4 +1,4 @@ -class CreateUsers < ActiveRecord::Migration +class CreateUsers < ActiveRecord::Migration[4.2] def change create_table :users do |t| t.string :name diff --git a/test/dummy/db/migrate/20130201105206_create_survey.rb b/test/dummy/db/migrate/20130201105206_create_survey.rb index c9a1111..c9b47e3 100644 --- a/test/dummy/db/migrate/20130201105206_create_survey.rb +++ b/test/dummy/db/migrate/20130201105206_create_survey.rb @@ -1,4 +1,4 @@ -class CreateSurvey < ActiveRecord::Migration +class CreateSurvey < ActiveRecord::Migration[4.2] def self.up # survey surveys logic diff --git a/test/test_helper.rb b/test/test_helper.rb index 5e8687a..0d71e97 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,4 @@ - # Configure Rails Envinronment +# Configure Rails Envinronment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) @@ -9,7 +9,12 @@ Rails.backtrace_cleaner.remove_silencers! # Run any available migration -ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) +if ::Rails::VERSION::MAJOR == 5 && ::Rails::VERSION::MINOR >= 2 + ActiveRecord::MigrationContext.new(File.expand_path("../dummy/db/migrate/", __FILE__)).migrate +else + ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__) +end + # Load support files # Add support to load paths so we can overwrite broken webrat setup