diff --git a/.gitignore b/.gitignore index e629a803..0a69a31f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ spec/dummy/db/migrate/*blogit* 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..0317a898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: ruby rvm: - - 2.2.0 + - 2.4.0 addons: code_climate: @@ -13,6 +13,7 @@ env: - DB=postgresql gemfile: + - gemfiles/rails_5.1.gemfile - gemfiles/rails_4.2.gemfile - gemfiles/rails_4.1.gemfile - gemfiles/rails_4.0.gemfile @@ -33,4 +34,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 rspec + +after_success: + - bundle exec codeclimate-test-reporter diff --git a/Appraisals b/Appraisals index a1374fb9..91ed8de7 100644 --- a/Appraisals +++ b/Appraisals @@ -4,6 +4,12 @@ # gem "sass-rails", "~> 5.0.0" # end +appraise "rails-5.1" do + gem "rails", "~> 5.1.0.rc1" + 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" @@ -23,4 +29,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 diff --git a/Gemfile b/Gemfile index dd7d2b66..8eaf239c 100644 --- a/Gemfile +++ b/Gemfile @@ -25,8 +25,17 @@ 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 # 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 f5a5028f..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' @@ -40,17 +39,14 @@ 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" 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 "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" 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/gemfiles/rails_3.2.gemfile b/gemfiles/rails_3.2.gemfile index 5a5f8190..26f018e6 100644 --- a/gemfiles/rails_3.2.gemfile +++ b/gemfiles/rails_3.2.gemfile @@ -2,9 +2,14 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 3.2.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.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..0e0db915 100644 --- a/gemfiles/rails_4.0.gemfile +++ b/gemfiles/rails_4.0.gemfile @@ -2,8 +2,12 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.0.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on" +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 f9473130..d9160260 100644 --- a/gemfiles/rails_4.1.gemfile +++ b/gemfiles/rails_4.1.gemfile @@ -2,8 +2,12 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.1.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on" +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 5827bbac..7b12f32a 100644 --- a/gemfiles/rails_4.2.gemfile +++ b/gemfiles/rails_4.2.gemfile @@ -2,8 +2,12 @@ source "http://rubygems.org" -gem "rake" gem "rails", "~> 4.2.0" +gem "rake" +gem "rb-inotify" +gem "acts-as-taggable-on" +gem "simplecov" +gem "codeclimate-test-reporter", "~> 1.0.0" gem "sass-rails", "~> 5.0.0" gemspec :path => "../" diff --git a/gemfiles/rails_5.1.gemfile b/gemfiles/rails_5.1.gemfile new file mode 100644 index 00000000..e6396262 --- /dev/null +++ b/gemfiles/rails_5.1.gemfile @@ -0,0 +1,14 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +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" + +gemspec :path => "../" 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/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 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 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/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" 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 e4e2df97..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. @@ -9,66 +8,62 @@ # 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" + 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 => 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 - t.integer "blogger_id" - t.string "blogger_type", :limit => nil + 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.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 => 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| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type", :limit => nil - t.integer "tagger_id" - t.string "tagger_type", :limit => nil - t.string "context", :limit => 128 + create_table "taggings", force: :cascade do |t| + 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 => 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 + 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 => 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 diff --git a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb index adb24c90..d8d1dbc5 100644 --- a/spec/dummy/spec/controllers/sub_posts_controller_spec.rb +++ b/spec/dummy/spec/controllers/sub_posts_controller_spec.rb @@ -15,13 +15,13 @@ describe "GET 'index'" do before do - Post.expects(:for_index).with(nil).returns(posts) + Post.expects(:for_index).with('').returns(posts) end let(:posts) { [] } def do_get(page=nil) - get :index, page: page + get :index, params: { page: page.to_s } end context "when super is called with a block" do @@ -40,14 +40,14 @@ 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 let(:posts) { [] } def do_get(page=nil) - get :tagged, page: page, tag: "one" + get :tagged, params: { page: page.to_s, 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 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 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 - 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'