From b132f512e905ec082e8a904dd1938d65b2f378db Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 02:19:44 +0100 Subject: [PATCH 01/21] enable development on platforms other than macOS by conditionally installing development gems --- Gemfile | 7 +++++++ blogit.gemspec | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index dd7d2b66..3b18ea4a 100644 --- a/Gemfile +++ b/Gemfile @@ -25,6 +25,13 @@ if rails_version[0] == '3' end gem 'rake' +case RUBY_PLATFORM +when /darwin/ + gem 'rb-fsevent', '~> 0.9.1' + gem 'growl' +when /linux/ + gem 'rb-inotify' +end # Removing this seems to break the Travis-CI flow. # The rake task "app:acts_as_taggable_on_engine:install:migrations" doesn't work diff --git a/blogit.gemspec b/blogit.gemspec index f5a5028f..6e8307b7 100644 --- a/blogit.gemspec +++ b/blogit.gemspec @@ -48,9 +48,7 @@ Gem::Specification.new do |s| s.add_development_dependency "autoprefixer-rails" s.add_development_dependency "rspec-rails", '~> 3.3.0' s.add_development_dependency "rspec-collection_matchers" - s.add_development_dependency "rb-fsevent", "~> 0.9.1" # OS X s.add_development_dependency "guard-rspec" - s.add_development_dependency "growl" s.add_development_dependency "factory_girl" s.add_development_dependency "mocha" s.add_development_dependency "sass" From 49061f50ccdc08e2b144f4484f13391f61e55b93 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:51:28 +0100 Subject: [PATCH 02/21] gitignore gemfiles/*.lock --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e629a803..963d2037 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,4 @@ spec/dummy/db/migrate/*blogit* spec/dummy/db/migrate/*acts_as_taggable_on_engine* spec/dummy/db/schema.rb spec/dummy/*.sqlite3 - +gemfiles/*.lock From 49e63e5d390f575db657f76d4e78304232931fd6 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:50:18 +0100 Subject: [PATCH 03/21] rails 3.2 needs test-unit explicitly because it was removed from ruby 2.2+. LoadError: Ruby 2.2+ has removed test/unit from the core library. Rails requires this as a dependency. Please add test-unit gem to your Gemfile: `gem 'test-unit', '~> 3.0'` (cannot load such file -- test/unit)" --- Appraisals | 1 + 1 file changed, 1 insertion(+) diff --git a/Appraisals b/Appraisals index a1374fb9..06407670 100644 --- a/Appraisals +++ b/Appraisals @@ -23,4 +23,5 @@ appraise "rails-3.2" do gem "rails", "~> 3.2.0" gem 'strong_parameters' gem "sass-rails", "~> 3.2.0" + gem 'test-unit', '~> 3.0' end From efa5ce79952a16fe74ae52291f95a781d29a3e3a Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:50:32 +0100 Subject: [PATCH 04/21] updated appraisal gemfiles --- gemfiles/rails_3.2.gemfile | 5 ++++- gemfiles/rails_4.0.gemfile | 4 +++- gemfiles/rails_4.1.gemfile | 4 +++- gemfiles/rails_4.2.gemfile | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile index 5a5f8190..c3af6f80 100644 --- a/gemfiles/rails_3.2.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -2,9 +2,12 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 3.2.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on", "~> 3.5.0" gem "strong_parameters" gem "sass-rails", "~> 3.2.0" +gem "test-unit", "~> 3.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.0.gemfile b/gemfiles/rails_4.0.gemfile index 785addcf..aa201627 100644 --- a/gemfiles/rails_4.0.gemfile +++ b/gemfiles/rails_4.0.gemfile @@ -2,8 +2,10 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.0.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on", "~> 3.5.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.1.gemfile b/gemfiles/rails_4.1.gemfile index f9473130..d16ede92 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -2,8 +2,10 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.1.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on", "~> 3.5.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index 5827bbac..8135036b 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -2,8 +2,10 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.2.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on", "~> 3.5.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" From d28f17292b8b6e27beaa0c8e1bd04d58a8d932e6 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:35:38 +0100 Subject: [PATCH 05/21] updated schema dump --- spec/dummy/db/schema.rb | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index e4e2df97..7e391018 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -9,66 +9,66 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150619080555) do +ActiveRecord::Schema.define(version: 20150705003228) do - create_table "blogit_comments", :force => true do |t| - t.string "name", :limit => nil, :null => false - t.string "email", :limit => nil, :null => false - t.string "website", :limit => nil - t.text "body", :null => false - t.integer "post_id", :null => false - t.string "state", :limit => nil + create_table "blogit_comments", force: :cascade do |t| + t.string "name", null: false + t.string "email", null: false + t.string "website" + t.text "body", null: false + t.integer "post_id", null: false + t.string "state" t.datetime "created_at" t.datetime "updated_at" end - add_index "blogit_comments", ["post_id"], :name => "index_blogit_comments_on_post_id" + add_index "blogit_comments", ["post_id"], name: "index_blogit_comments_on_post_id" - create_table "blogit_posts", :force => true do |t| - t.string "title", :limit => nil, :null => false - t.text "body", :null => false - t.string "state", :limit => nil, :default => "draft", :null => false - t.integer "comments_count", :default => 0, :null => false + create_table "blogit_posts", force: :cascade do |t| + t.string "title", null: false + t.text "body", null: false + t.string "state", default: "draft", null: false + t.integer "comments_count", default: 0, null: false t.integer "blogger_id" - t.string "blogger_type", :limit => nil + t.string "blogger_type" t.datetime "created_at" t.datetime "updated_at" t.text "description" end - add_index "blogit_posts", ["blogger_type", "blogger_id"], :name => "index_blogit_posts_on_blogger_type_and_blogger_id" + add_index "blogit_posts", ["blogger_type", "blogger_id"], name: "index_blogit_posts_on_blogger_type_and_blogger_id" - create_table "people", :force => true do |t| - t.string "name", :limit => nil + create_table "people", force: :cascade do |t| + t.string "name" t.datetime "created_at" t.datetime "updated_at" end - create_table "taggings", :force => true do |t| + create_table "taggings", force: :cascade do |t| t.integer "tag_id" t.integer "taggable_id" - t.string "taggable_type", :limit => nil + t.string "taggable_type" t.integer "tagger_id" - t.string "tagger_type", :limit => nil - t.string "context", :limit => 128 + t.string "tagger_type" + t.string "context", limit: 128 t.datetime "created_at" end - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], :name => "taggings_idx", :unique => true - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true + add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" - create_table "tags", :force => true do |t| - t.string "name", :limit => nil - t.integer "taggings_count", :default => 0 + create_table "tags", force: :cascade do |t| + t.string "name" + t.integer "taggings_count", default: 0 end - add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true + add_index "tags", ["name"], name: "index_tags_on_name", unique: true - create_table "users", :force => true do |t| - t.string "username", :limit => nil - t.string "password", :limit => nil + create_table "users", force: :cascade do |t| + t.string "username" + t.string "password" t.datetime "created_at" t.datetime "updated_at" end From 36b5b40d7dbc5145959cc2224cdc3681637cfdd1 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 02:43:16 +0100 Subject: [PATCH 06/21] setup code climate according to docs https://docs.codeclimate.com/v1.0/docs/travis-ci-ruby-test-coverage removed from spec helper since it complained as follows: This usage of the Code Climate Test Reporter is now deprecated. Since version 1.0, we now require you to run `SimpleCov` in your test/spec helper, and then run the provided `codeclimate-test-reporter` binary separately to report your results to Code Climate. --- .gitignore | 1 + .travis.yml | 5 ++++- Gemfile | 2 ++ blogit.gemspec | 1 - gemfiles/rails_3.2.gemfile | 2 ++ gemfiles/rails_4.0.gemfile | 2 ++ gemfiles/rails_4.1.gemfile | 2 ++ gemfiles/rails_4.2.gemfile | 2 ++ spec/spec_helper.rb | 5 +++-- 9 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 963d2037..0a69a31f 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ spec/dummy/db/migrate/*acts_as_taggable_on_engine* spec/dummy/db/schema.rb spec/dummy/*.sqlite3 gemfiles/*.lock +coverage/ diff --git a/.travis.yml b/.travis.yml index 64c13766..f1be32cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,7 @@ before_script: script: - bundle exec rake db:create RAILS_ENV=test - bundle exec rake db:migrate RAILS_ENV=test - - bundle exec rake spec \ No newline at end of file + - bundle exec rake spec + +after_success: + - bundle exec codeclimate-test-reporter diff --git a/Gemfile b/Gemfile index 3b18ea4a..6071742f 100644 --- a/Gemfile +++ b/Gemfile @@ -37,3 +37,5 @@ end # The rake task "app:acts_as_taggable_on_engine:install:migrations" doesn't work # without it here gem 'acts-as-taggable-on', "~> 3.5.0" +gem 'simplecov' +gem 'codeclimate-test-reporter', '~> 1.0.0' diff --git a/blogit.gemspec b/blogit.gemspec index 6e8307b7..14b74217 100644 --- a/blogit.gemspec +++ b/blogit.gemspec @@ -40,7 +40,6 @@ Gem::Specification.new do |s| s.add_development_dependency "pg" # Testing - s.add_development_dependency "codeclimate-test-reporter" s.add_development_dependency "spring", ">=1.3.6" s.add_development_dependency 'spring-commands-rspec' s.add_development_dependency "wwtd" diff --git a/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile index c3af6f80..7dbf43a2 100644 --- a/gemfiles/rails_3.2.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -6,6 +6,8 @@ gem "rails", "~> 3.2.0" gem "rake" gem "rb-inotify" gem "acts-as-taggable-on", "~> 3.5.0" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" gem "strong_parameters" gem "sass-rails", "~> 3.2.0" gem "test-unit", "~> 3.0" diff --git a/gemfiles/rails_4.0.gemfile b/gemfiles/rails_4.0.gemfile index aa201627..e31f41e2 100644 --- a/gemfiles/rails_4.0.gemfile +++ b/gemfiles/rails_4.0.gemfile @@ -6,6 +6,8 @@ gem "rails", "~> 4.0.0" gem "rake" gem "rb-inotify" gem "acts-as-taggable-on", "~> 3.5.0" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.1.gemfile b/gemfiles/rails_4.1.gemfile index d16ede92..0199891b 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -6,6 +6,8 @@ gem "rails", "~> 4.1.0" gem "rake" gem "rb-inotify" gem "acts-as-taggable-on", "~> 3.5.0" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index 8135036b..eb30083a 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -6,6 +6,8 @@ gem "rails", "~> 4.2.0" gem "rake" gem "rb-inotify" gem "acts-as-taggable-on", "~> 3.5.0" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b9c2fb49..d60e0d16 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ -require "codeclimate-test-reporter" -CodeClimate::TestReporter.start +require 'simplecov' +SimpleCov.start + require 'rspec' require "rspec/collection_matchers" require 'pry' From fc129a30d23d983a3adc4989eb2ce7a8fa685904 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:33:00 +0100 Subject: [PATCH 07/21] suppress stdout of `system` during tests --- spec/lib/blogit/parsers/markdown_parser_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/blogit/parsers/markdown_parser_spec.rb b/spec/lib/blogit/parsers/markdown_parser_spec.rb index bb4246cd..279a8e28 100644 --- a/spec/lib/blogit/parsers/markdown_parser_spec.rb +++ b/spec/lib/blogit/parsers/markdown_parser_spec.rb @@ -16,7 +16,7 @@ } it "requires pymentize to run" do - expect(system("which pygmentize")).not_to eql(false), + expect(system("which pygmentize > /dev/null")).not_to eql(false), "It seems that pygmentize is not installed on your system" end From a234fc977dd571cbce870f4ca60176c3dd26f2fc Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 22:38:03 +0100 Subject: [PATCH 08/21] make config class compatible with rails < 4 AS::Configurable's `config_accessor` supports a default block only since rails 4 -- see rails/rails#7645. --- lib/blogit/configuration.rb | 42 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/blogit/configuration.rb b/lib/blogit/configuration.rb index df660ac6..702e0602 100644 --- a/lib/blogit/configuration.rb +++ b/lib/blogit/configuration.rb @@ -31,7 +31,8 @@ class Configuration # How do you want to handle comments for your blog? # Valid options are :active_record, :disquss, or :no for none. # (default: :active_record) - config_accessor(:include_comments) { :active_record } + config_accessor(:include_comments) + config.include_comments = :active_record ## # When using :disqus comments, what is the shortname of your forum? @@ -40,7 +41,8 @@ class Configuration ## # Load a javascript-based share bar on each blog post?. (default: true) - config_accessor(:include_share_bar) { true } + config_accessor(:include_share_bar) + config.include_share_bar = true ## # Twitter username used in the share bar. (default: nil) @@ -49,64 +51,75 @@ class Configuration ## # The name of the controller method we'll call to return the current blogger. # (default: :current_user) - config_accessor(:current_blogger_method) { :current_user } + config_accessor(:current_blogger_method) + config.current_blogger_method = :current_user ## # What method do we call on blogger to return their display name? (default: :username) - config_accessor(:blogger_display_name_method) { :username } + config_accessor(:blogger_display_name_method) + config.blogger_display_name_method = :username ## # Which DateTime::FORMATS format do we use to display blog and comment publish time # (default: :short) - config_accessor(:datetime_format) { :short } + config_accessor(:datetime_format) + config.datetime_format = :short ## # Number of {Blogit::Post posts} to show per page. This is a configuration for {https://github.com/amatsuda/kaminari Kaminari} (default: 5) # # Returns an Integer - config_accessor(:posts_per_page) { 5 } + config_accessor(:posts_per_page) + config.posts_per_page = 5 ## # If set to true, the comments form will POST and DELETE to the comments # controller using AJAX calls. # # Returns true or false - config_accessor(:ajax_comments) { true } + config_accessor(:ajax_comments) + config.ajax_comments = true ## # The default format for parsing the blog content. # # Defaults to :markdown - config_accessor(:default_parser) { :markdown } + config_accessor(:default_parser) + config.default_parser = :markdown ## # Should text within "```" or "`" be highlighted as code? # Defaults to true # @note - At the moment this only works when default_parser is :markdown - config_accessor(:highlight_code_syntax) { true } + config_accessor(:highlight_code_syntax) + config.highlight_code_syntax = true ## # The renderer used for code highlighting # Defaults to :albino - config_accessor(:syntax_highlighter) { :albino } + config_accessor(:syntax_highlighter) + config.syntax_highlighter = :albino ## # When using redcarpet as content parser, pass these options as defaults # # Defaults to {REDCARPET_OPTIONS} - config_accessor(:redcarpet_options) { REDCARPET_OPTIONS } + config_accessor(:redcarpet_options) + config.redcarpet_options = REDCARPET_OPTIONS ## # List of states that will be visible to the public # # Defaults to ACTIVE_STATES - config_accessor(:active_states) { ACTIVE_STATES } + config_accessor(:active_states) + config.active_states = ACTIVE_STATES ## # List of states that will hide the posts from the public. # # Defaults to HIDDEN_STATES - config_accessor(:hidden_states) { HIDDEN_STATES } + config_accessor(:hidden_states) + config.hidden_states = HIDDEN_STATES ## # The title of the RSS feed for the blog posts @@ -130,7 +143,8 @@ class Configuration # and RSS feed. # # Defaults to true - config_accessor(:show_post_description) { true } + config_accessor(:show_post_description) + config.show_post_description = true def default_parser_class From cdf25ddef92224e26668b1f45feb82237dfbe5c3 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 23:40:20 +0100 Subject: [PATCH 09/21] upgraded rspec-rails since newer rake versions changed. resolves the following error: $ rake acts_as_taggable_on_engine:install:migrations rake aborted! NoMethodError: undefined method `last_comment' for # --- blogit.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blogit.gemspec b/blogit.gemspec index 14b74217..dbbcd462 100644 --- a/blogit.gemspec +++ b/blogit.gemspec @@ -45,7 +45,7 @@ Gem::Specification.new do |s| s.add_development_dependency "wwtd" s.add_development_dependency "autoprefixer-rails" - s.add_development_dependency "rspec-rails", '~> 3.3.0' + s.add_development_dependency "rspec-rails" s.add_development_dependency "rspec-collection_matchers" s.add_development_dependency "guard-rspec" s.add_development_dependency "factory_girl" From 7c099c470b6850a5945269f6e5f930d62eabb4d8 Mon Sep 17 00:00:00 2001 From: glaszig Date: Fri, 17 Mar 2017 23:48:04 +0100 Subject: [PATCH 10/21] allow acts-as-taggable-on version to be resolved based on the activerecord version being used --- Gemfile | 2 +- blogit.gemspec | 3 +-- gemfiles/rails_3.2.gemfile | 2 +- gemfiles/rails_4.0.gemfile | 2 +- gemfiles/rails_4.1.gemfile | 2 +- gemfiles/rails_4.2.gemfile | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 6071742f..8eaf239c 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,6 @@ end # Removing this seems to break the Travis-CI flow. # The rake task "app:acts_as_taggable_on_engine:install:migrations" doesn't work # without it here -gem 'acts-as-taggable-on', "~> 3.5.0" +gem 'acts-as-taggable-on' gem 'simplecov' gem 'codeclimate-test-reporter', '~> 1.0.0' diff --git a/blogit.gemspec b/blogit.gemspec index dbbcd462..f32d6633 100644 --- a/blogit.gemspec +++ b/blogit.gemspec @@ -24,8 +24,7 @@ Gem::Specification.new do |s| s.add_dependency "albino", ">=1.3.3" s.add_dependency "kaminari" s.add_dependency "jquery-rails" - s.add_dependency "acts-as-taggable-on", "~> 3.5.0" - + s.add_dependency "acts-as-taggable-on" s.add_development_dependency "appraisal" s.add_development_dependency 'thor' diff --git a/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile index 7dbf43a2..26f018e6 100644 --- a/gemfiles/rails_3.2.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -5,7 +5,7 @@ source "http://rubygems.org" gem "rails", "~> 3.2.0" gem "rake" gem "rb-inotify" -gem "acts-as-taggable-on", "~> 3.5.0" +gem "acts-as-taggable-on" gem "simplecov" gem "codeclimate-test-reporter", "~> 1.0.0" gem "strong_parameters" diff --git a/gemfiles/rails_4.0.gemfile b/gemfiles/rails_4.0.gemfile index e31f41e2..0e0db915 100644 --- a/gemfiles/rails_4.0.gemfile +++ b/gemfiles/rails_4.0.gemfile @@ -5,7 +5,7 @@ source "http://rubygems.org" gem "rails", "~> 4.0.0" gem "rake" gem "rb-inotify" -gem "acts-as-taggable-on", "~> 3.5.0" +gem "acts-as-taggable-on" gem "simplecov" gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" diff --git a/gemfiles/rails_4.1.gemfile b/gemfiles/rails_4.1.gemfile index 0199891b..d9160260 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -5,7 +5,7 @@ source "http://rubygems.org" gem "rails", "~> 4.1.0" gem "rake" gem "rb-inotify" -gem "acts-as-taggable-on", "~> 3.5.0" +gem "acts-as-taggable-on" gem "simplecov" gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" diff --git a/gemfiles/rails_4.2.gemfile b/gemfiles/rails_4.2.gemfile index eb30083a..7b12f32a 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -5,7 +5,7 @@ source "http://rubygems.org" gem "rails", "~> 4.2.0" gem "rake" gem "rb-inotify" -gem "acts-as-taggable-on", "~> 3.5.0" +gem "acts-as-taggable-on" gem "simplecov" gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" From 1bb4d5804c0378fb4836a17049764154face31a8 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 01:05:11 +0100 Subject: [PATCH 11/21] added rails 5.1.0.beta1 appraisal --- Appraisals | 6 ++++++ gemfiles/rails_5.1.0.beta1.gemfile | 14 ++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 gemfiles/rails_5.1.0.beta1.gemfile diff --git a/Appraisals b/Appraisals index 06407670..3f416584 100644 --- a/Appraisals +++ b/Appraisals @@ -4,6 +4,12 @@ # gem "sass-rails", "~> 5.0.0" # end +appraise "rails-5.1.0.beta1" do + gem "rails", "~> 5.1.0.beta1" + gem "sass-rails", github: "rails/sass-rails" + gem "rails-controller-testing" +end + appraise "rails-4.2" do gem "rails", "~> 4.2.0" gem "sass-rails", "~> 5.0.0" diff --git a/gemfiles/rails_5.1.0.beta1.gemfile b/gemfiles/rails_5.1.0.beta1.gemfile new file mode 100644 index 00000000..a011aa76 --- /dev/null +++ b/gemfiles/rails_5.1.0.beta1.gemfile @@ -0,0 +1,14 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 5.1.0.beta1" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" +gem "sass-rails", :github => "rails/sass-rails" +gem "rails-controller-testing" + +gemspec :path => "../" From 86d308b349d7304391c6ce984958327ad2a0c5b3 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 01:05:37 +0100 Subject: [PATCH 12/21] adjusted dummy app for rails 5.1 --- spec/dummy/app/assets/config/manifest.js | 3 +++ spec/dummy/config/environments/development.rb | 1 + spec/dummy/config/environments/test.rb | 1 + 3 files changed, 5 insertions(+) create mode 100644 spec/dummy/app/assets/config/manifest.js diff --git a/spec/dummy/app/assets/config/manifest.js b/spec/dummy/app/assets/config/manifest.js new file mode 100644 index 00000000..b16e53d6 --- /dev/null +++ b/spec/dummy/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb index 2b5176ca..7a5ec653 100644 --- a/spec/dummy/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -5,6 +5,7 @@ # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false + config.eager_load = false if Rails.version =~ /\A3/ # Log error messages when you accidentally call methods on nil. diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 105ca92f..759d7519 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -6,6 +6,7 @@ # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true + config.eager_load = false # Configure static asset server for tests with Cache-Control for performance if Rails.version >= "4.2.0" From 966e78ee1c9a35523d4027006422086ed63d15f4 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 01:06:28 +0100 Subject: [PATCH 13/21] rails 5.1 controller tests need keyword arguments --- spec/controllers/blogit/comments_controller_spec.rb | 4 ++-- spec/controllers/blogit/posts_controller_spec.rb | 6 +++--- spec/dummy/spec/controllers/sub_posts_controller_spec.rb | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/controllers/blogit/comments_controller_spec.rb b/spec/controllers/blogit/comments_controller_spec.rb index 5261d170..795f36ff 100644 --- a/spec/controllers/blogit/comments_controller_spec.rb +++ b/spec/controllers/blogit/comments_controller_spec.rb @@ -14,8 +14,8 @@ def do_post(format = :html) - post :create, post_id: blog_post.id, - comment: comment_attributes, format: format + post :create, params: { post_id: blog_post.id, + comment: comment_attributes, format: format } end subject { do_post(:js) } diff --git a/spec/controllers/blogit/posts_controller_spec.rb b/spec/controllers/blogit/posts_controller_spec.rb index 22ac2980..4f99f3cb 100644 --- a/spec/controllers/blogit/posts_controller_spec.rb +++ b/spec/controllers/blogit/posts_controller_spec.rb @@ -14,7 +14,7 @@ let(:posts) { [] } def do_get(page=nil) - get :index, page: page + get :index, params: { page: page } end it 'sets posts to Blogit::Post.for_index' do @@ -57,7 +57,7 @@ def do_get(page=nil) let(:posts) { [] } def do_get(page=nil) - get :index, page: page.to_s, format: :xml + get :index, params: { page: page.to_s, format: :xml } end it "loads all posts in reverse date order" do @@ -76,7 +76,7 @@ def do_get(page=nil) end def do_get - get :show, :id => 1 + get :show, params: { id: 1 } end it "finds blog post by id" do diff --git a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb index adb24c90..822b9ae3 100644 --- a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb +++ b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb @@ -21,7 +21,7 @@ let(:posts) { [] } def do_get(page=nil) - get :index, page: page + get :index, params: { page: page } end context "when super is called with a block" do @@ -47,7 +47,7 @@ def do_get(page=nil) let(:posts) { [] } def do_get(page=nil) - get :tagged, page: page, tag: "one" + get :tagged, params: { page: page, tag: "one" } end context "when super is called with a block" do @@ -72,7 +72,7 @@ def do_get(page=nil) let(:post) { [] } def do_get(id="1") - get :show, id: "1" + get :show, params: { id: "1" } end context "when super is called with a block" do From a1d6cad73734f48793ae404851e521b86f05c575 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 01:13:45 +0100 Subject: [PATCH 14/21] rails 5.1 controller tests are now integration tests which is why stubbed nil arguments will end up as "" in the controller's params hash. --- spec/dummy/spec/controllers/sub_posts_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb index 822b9ae3..cac12c5d 100644 --- a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb +++ b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb @@ -15,7 +15,7 @@ describe "GET 'index'" do before do - Post.expects(:for_index).with(nil).returns(posts) + Post.expects(:for_index).with('').returns(posts) end let(:posts) { [] } @@ -40,7 +40,7 @@ def do_get(page=nil) describe "GET 'tagged'" do before do - Post.expects(:for_index).with(nil).returns(posts) + Post.expects(:for_index).with('').returns(posts) posts.expects(:tagged_with).returns(posts) end From c24b487742a130bc101754301821f63f5f4d0515 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 23:26:40 +0100 Subject: [PATCH 15/21] travis: test on current ruby; 2.2.0 won't work with newer rails anyway --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1be32cb..79618716 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: ruby rvm: - - 2.2.0 + - 2.4.0 addons: code_climate: From 7a992998271bf8cdd4025a76e99fcdad500af93d Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 23:27:15 +0100 Subject: [PATCH 16/21] rake spec somehow does not work but rspec does. some weird things with the rakefiles going on. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 79618716..10c6f02d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ before_script: script: - bundle exec rake db:create RAILS_ENV=test - bundle exec rake db:migrate RAILS_ENV=test - - bundle exec rake spec + - bundle exec rspec after_success: - bundle exec codeclimate-test-reporter From 8de8204109e1033ff9927255b9309806925e83f3 Mon Sep 17 00:00:00 2001 From: glaszig Date: Sat, 18 Mar 2017 23:30:37 +0100 Subject: [PATCH 17/21] travis: added rails 5.1.0.beta1 gemfile --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 10c6f02d..071fbe54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ env: - DB=postgresql gemfile: + - gemfiles/rails_5.1.0.beta1.gemfile - gemfiles/rails_4.2.gemfile - gemfiles/rails_4.1.gemfile - gemfiles/rails_4.0.gemfile From b60fae458d4e9291421f706ae1439ff2b83e474a Mon Sep 17 00:00:00 2001 From: glaszig Date: Sun, 19 Mar 2017 00:32:32 +0100 Subject: [PATCH 18/21] rails 5.1 needs versioned migrations related travis log: $ bundle exec rake db:migrate RAILS_ENV=test /home/travis/build/KatanaCode/blogit/lib/tasks/blogit/doc.rake:9: warning: already initialized constant DOC_FILES /home/travis/build/KatanaCode/blogit/lib/tasks/blogit/doc.rake:9: warning: previous definition of DOC_FILES was here rake aborted! StandardError: An error has occurred, this and all later migrations canceled: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for: class CreateUsers < ActiveRecord::Migration[4.2] /home/travis/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0.beta1/lib/active_record/migration.rb:525:in `inherited' /home/travis/build/KatanaCode/blogit/spec/dummy/db/migrate/20110814091304_create_users.rb:1:in `' --- .../20110814091434_create_blogit_posts.rb | 2 +- .../20110814093229_create_blogit_comments.rb | 2 +- ...20150618184415_add_description_to_posts.rb | 2 +- .../db/migrate/20110814091304_create_users.rb | 2 +- .../migrate/20110819103335_create_people.rb | 2 +- ...on_migration.acts_as_taggable_on_engine.rb | 2 +- ...ique_indices.acts_as_taggable_on_engine.rb | 2 +- ...ache_to_tags.acts_as_taggable_on_engine.rb | 2 +- ...ggable_index.acts_as_taggable_on_engine.rb | 2 +- ...or_tag_names.acts_as_taggable_on_engine.rb | 2 +- spec/dummy/db/schema.rb | 61 +++++++++---------- 11 files changed, 38 insertions(+), 43 deletions(-) diff --git a/db/migrate/20110814091434_create_blogit_posts.rb b/db/migrate/20110814091434_create_blogit_posts.rb index e5994d17..3a0d5cb0 100644 --- a/db/migrate/20110814091434_create_blogit_posts.rb +++ b/db/migrate/20110814091434_create_blogit_posts.rb @@ -1,4 +1,4 @@ -class CreateBlogitPosts < ActiveRecord::Migration +class CreateBlogitPosts < ActiveRecord::Migration[4.2] def change create_table :blogit_posts do |t| t.with_options(null: false) do |r| diff --git a/db/migrate/20110814093229_create_blogit_comments.rb b/db/migrate/20110814093229_create_blogit_comments.rb index 015d2791..3769b264 100644 --- a/db/migrate/20110814093229_create_blogit_comments.rb +++ b/db/migrate/20110814093229_create_blogit_comments.rb @@ -1,4 +1,4 @@ -class CreateBlogitComments < ActiveRecord::Migration +class CreateBlogitComments < ActiveRecord::Migration[4.2] def change create_table :blogit_comments do |t| t.string :name, null: false diff --git a/db/migrate/20150618184415_add_description_to_posts.rb b/db/migrate/20150618184415_add_description_to_posts.rb index 571e2bd8..a69c1e7a 100644 --- a/db/migrate/20150618184415_add_description_to_posts.rb +++ b/db/migrate/20150618184415_add_description_to_posts.rb @@ -1,4 +1,4 @@ -class AddDescriptionToPosts < ActiveRecord::Migration +class AddDescriptionToPosts < ActiveRecord::Migration[4.2] def change add_column :blogit_posts, :description, :text end diff --git a/spec/dummy/db/migrate/20110814091304_create_users.rb b/spec/dummy/db/migrate/20110814091304_create_users.rb index 0312bf9b..e582557e 100644 --- a/spec/dummy/db/migrate/20110814091304_create_users.rb +++ b/spec/dummy/db/migrate/20110814091304_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 :username diff --git a/spec/dummy/db/migrate/20110819103335_create_people.rb b/spec/dummy/db/migrate/20110819103335_create_people.rb index 366c50af..8fc7defd 100644 --- a/spec/dummy/db/migrate/20110819103335_create_people.rb +++ b/spec/dummy/db/migrate/20110819103335_create_people.rb @@ -1,4 +1,4 @@ -class CreatePeople < ActiveRecord::Migration +class CreatePeople < ActiveRecord::Migration[4.2] def change create_table :people do |t| t.string :name diff --git a/spec/dummy/db/migrate/20150705003224_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/spec/dummy/db/migrate/20150705003224_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb index 6bbd5594..35daedd2 100644 --- a/spec/dummy/db/migrate/20150705003224_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +++ b/spec/dummy/db/migrate/20150705003224_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 1) -class ActsAsTaggableOnMigration < ActiveRecord::Migration +class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2] def self.up create_table :tags do |t| t.string :name diff --git a/spec/dummy/db/migrate/20150705003225_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/spec/dummy/db/migrate/20150705003225_add_missing_unique_indices.acts_as_taggable_on_engine.rb index 4ca676f6..52f9ab52 100644 --- a/spec/dummy/db/migrate/20150705003225_add_missing_unique_indices.acts_as_taggable_on_engine.rb +++ b/spec/dummy/db/migrate/20150705003225_add_missing_unique_indices.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 2) -class AddMissingUniqueIndices < ActiveRecord::Migration +class AddMissingUniqueIndices < ActiveRecord::Migration[4.2] def self.up add_index :tags, :name, unique: true diff --git a/spec/dummy/db/migrate/20150705003226_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/spec/dummy/db/migrate/20150705003226_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb index 8edb5080..5a3f71a2 100644 --- a/spec/dummy/db/migrate/20150705003226_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +++ b/spec/dummy/db/migrate/20150705003226_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 3) -class AddTaggingsCounterCacheToTags < ActiveRecord::Migration +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2] def self.up add_column :tags, :taggings_count, :integer, default: 0 diff --git a/spec/dummy/db/migrate/20150705003227_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/spec/dummy/db/migrate/20150705003227_add_missing_taggable_index.acts_as_taggable_on_engine.rb index 71f2d7f4..f2873761 100644 --- a/spec/dummy/db/migrate/20150705003227_add_missing_taggable_index.acts_as_taggable_on_engine.rb +++ b/spec/dummy/db/migrate/20150705003227_add_missing_taggable_index.acts_as_taggable_on_engine.rb @@ -1,5 +1,5 @@ # This migration comes from acts_as_taggable_on_engine (originally 4) -class AddMissingTaggableIndex < ActiveRecord::Migration +class AddMissingTaggableIndex < ActiveRecord::Migration[4.2] def self.up add_index :taggings, [:taggable_id, :taggable_type, :context] end diff --git a/spec/dummy/db/migrate/20150705003228_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/spec/dummy/db/migrate/20150705003228_change_collation_for_tag_names.acts_as_taggable_on_engine.rb index bfb06bc7..4c144a86 100644 --- a/spec/dummy/db/migrate/20150705003228_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +++ b/spec/dummy/db/migrate/20150705003228_change_collation_for_tag_names.acts_as_taggable_on_engine.rb @@ -1,7 +1,7 @@ # This migration comes from acts_as_taggable_on_engine (originally 5) # This migration is added to circumvent issue #623 and have special characters # work properly -class ChangeCollationForTagNames < ActiveRecord::Migration +class ChangeCollationForTagNames < ActiveRecord::Migration[4.2] def up if ActsAsTaggableOn::Utils.using_mysql? execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;") diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 7e391018..75b32bce 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -14,61 +13,57 @@ ActiveRecord::Schema.define(version: 20150705003228) do create_table "blogit_comments", force: :cascade do |t| - t.string "name", null: false - t.string "email", null: false - t.string "website" - t.text "body", null: false - t.integer "post_id", null: false - t.string "state" + t.string "name", null: false + t.string "email", null: false + t.string "website" + t.text "body", null: false + t.integer "post_id", null: false + t.string "state" t.datetime "created_at" t.datetime "updated_at" + t.index ["post_id"], name: "index_blogit_comments_on_post_id" end - add_index "blogit_comments", ["post_id"], name: "index_blogit_comments_on_post_id" - create_table "blogit_posts", force: :cascade do |t| - t.string "title", null: false - t.text "body", null: false - t.string "state", default: "draft", null: false - t.integer "comments_count", default: 0, null: false - t.integer "blogger_id" - t.string "blogger_type" + t.string "title", null: false + t.text "body", null: false + t.string "state", default: "draft", null: false + t.integer "comments_count", default: 0, null: false + t.string "blogger_type" + t.integer "blogger_id" t.datetime "created_at" t.datetime "updated_at" - t.text "description" + t.text "description" + t.index ["blogger_type", "blogger_id"], name: "index_blogit_posts_on_blogger_type_and_blogger_id" end - add_index "blogit_posts", ["blogger_type", "blogger_id"], name: "index_blogit_posts_on_blogger_type_and_blogger_id" - create_table "people", force: :cascade do |t| - t.string "name" + t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "taggings", force: :cascade do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", limit: 128 + t.integer "tag_id" + t.string "taggable_type" + t.integer "taggable_id" + t.string "tagger_type" + t.integer "tagger_id" + t.string "context", limit: 128 t.datetime "created_at" + t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true + t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" end - add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true - add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context" - create_table "tags", force: :cascade do |t| - t.string "name" + t.string "name" t.integer "taggings_count", default: 0 + t.index ["name"], name: "index_tags_on_name", unique: true end - add_index "tags", ["name"], name: "index_tags_on_name", unique: true - create_table "users", force: :cascade do |t| - t.string "username" - t.string "password" + t.string "username" + t.string "password" t.datetime "created_at" t.datetime "updated_at" end From 0f6f072fce3b62cbd5a96d01f2b45a0af625df8b Mon Sep 17 00:00:00 2001 From: glaszig Date: Wed, 29 Mar 2017 15:30:13 +0200 Subject: [PATCH 19/21] upgraded to rails 5.1.0.rc1 --- .travis.yml | 2 +- Appraisals | 4 ++-- gemfiles/{rails_5.1.0.beta1.gemfile => rails_5.1.gemfile} | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename gemfiles/{rails_5.1.0.beta1.gemfile => rails_5.1.gemfile} (90%) diff --git a/.travis.yml b/.travis.yml index 071fbe54..0317a898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: - DB=postgresql gemfile: - - gemfiles/rails_5.1.0.beta1.gemfile + - gemfiles/rails_5.1.gemfile - gemfiles/rails_4.2.gemfile - gemfiles/rails_4.1.gemfile - gemfiles/rails_4.0.gemfile diff --git a/Appraisals b/Appraisals index 3f416584..91ed8de7 100644 --- a/Appraisals +++ b/Appraisals @@ -4,8 +4,8 @@ # gem "sass-rails", "~> 5.0.0" # end -appraise "rails-5.1.0.beta1" do - gem "rails", "~> 5.1.0.beta1" +appraise "rails-5.1" do + gem "rails", "~> 5.1.0.rc1" gem "sass-rails", github: "rails/sass-rails" gem "rails-controller-testing" end diff --git a/gemfiles/rails_5.1.0.beta1.gemfile b/gemfiles/rails_5.1.gemfile similarity index 90% rename from gemfiles/rails_5.1.0.beta1.gemfile rename to gemfiles/rails_5.1.gemfile index a011aa76..e6396262 100644 --- a/gemfiles/rails_5.1.0.beta1.gemfile +++ b/gemfiles/rails_5.1.gemfile @@ -2,12 +2,12 @@ source "http://rubygems.org" -gem "rails", "~> 5.1.0.beta1" gem "rake" gem "rb-inotify" gem "acts-as-taggable-on" gem "simplecov" gem "codeclimate-test-reporter", "~> 1.0.0" +gem "rails", "~> 5.1.0.rc1" gem "sass-rails", :github => "rails/sass-rails" gem "rails-controller-testing" From df3d495ceef9e494dcd2ba934a9fb3bea38ae6d1 Mon Sep 17 00:00:00 2001 From: glaszig Date: Wed, 29 Mar 2017 16:18:52 +0200 Subject: [PATCH 20/21] made AR migrations compatible with rails <5 --- lib/blogit/compatibility.rb | 9 +++++++++ lib/blogit/engine.rb | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/blogit/compatibility.rb diff --git a/lib/blogit/compatibility.rb b/lib/blogit/compatibility.rb new file mode 100644 index 00000000..61b95bf2 --- /dev/null +++ b/lib/blogit/compatibility.rb @@ -0,0 +1,9 @@ +module Blogit + module Compatibility + module Migration + def [] *args + self + end + end + end +end diff --git a/lib/blogit/engine.rb b/lib/blogit/engine.rb index c5577c31..55291d7c 100644 --- a/lib/blogit/engine.rb +++ b/lib/blogit/engine.rb @@ -8,7 +8,16 @@ class Engine < Rails::Engine ::ActiveRecord::Base.send(:include, Blogit::Blogs) ::ActiveRecord::Base.send(:include, Validators) end - + + end + + initializer 'blogit.active_record' do + ActiveSupport.on_load :active_record do + unless ActiveRecord::Migration.respond_to? :[] + require "blogit/compatibility" + ActiveRecord::Migration.extend Blogit::Compatibility::Migration + end + end end end end From 49ca89b4dd08c299d4aa2b80ecadb8b929b443f6 Mon Sep 17 00:00:00 2001 From: glaszig Date: Wed, 29 Mar 2017 18:06:05 +0200 Subject: [PATCH 21/21] made controller tests compatible with rails < 5 --- .../controllers/sub_posts_controller_spec.rb | 4 ++-- spec/rails_helper.rb | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb index cac12c5d..d8d1dbc5 100644 --- a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb +++ b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb @@ -21,7 +21,7 @@ let(:posts) { [] } def do_get(page=nil) - get :index, params: { page: page } + get :index, params: { page: page.to_s } end context "when super is called with a block" do @@ -47,7 +47,7 @@ def do_get(page=nil) let(:posts) { [] } def do_get(page=nil) - get :tagged, params: { page: page, tag: "one" } + get :tagged, params: { page: page.to_s, tag: "one" } end context "when super is called with a block" do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 5e04b0da..23b0d789 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -16,8 +16,25 @@ include Blogit +module KeywordArgumentsShim + [ :head, :get, :post, :put, :patch, :delete ].each do |m| + define_method m do |url, *args| + if process_with_kwargs? + super url, *args + else + args = args[0] + super url, args[:params], args[:session], args[:flash] + end + end + end + + def process_with_kwargs? + Rails.gem_version >= Gem::Version.new('5.0') + end +end + RSpec.configure do |config| config.infer_spec_type_from_file_location! config.include FactoryGirl::Syntax::Methods + config.include KeywordArgumentsShim end -