-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
174 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file was generated by Appraisal | ||
|
||
source 'http://rubygems.org' | ||
source "http://rubygems.org" | ||
|
||
gem 'activerecord', '~> 3.2.22' | ||
gem 'activesupport', '~> 3.2.22' | ||
gem 'ancestry' | ||
gem 'railties', '~> 3.2.22' | ||
gem "activerecord", "~> 3.2.22" | ||
gem "activesupport", "~> 3.2.22" | ||
gem "ancestry" | ||
gem "railties", "~> 3.2.22" | ||
|
||
group :development do | ||
gem 'appraisal' | ||
gem 'coveralls', require: false | ||
gem 'jeweler' | ||
gem 'rspec' | ||
gem 'rubocop', require: false | ||
gem 'sqlite3', '~> 1.3.6' | ||
gem 'timecop' | ||
gem "appraisal" | ||
gem "coveralls", require: false | ||
gem "jeweler" | ||
gem "rspec" | ||
gem "rubocop", require: false | ||
gem "sqlite3", "~> 1.3.6" | ||
gem "timecop" | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "http://rubygems.org" | ||
|
||
gem "activerecord", "~> 4.2" | ||
gem "activesupport", "~> 4.2" | ||
gem "ancestry" | ||
gem "railties", "~> 4.2" | ||
gem "rdoc", "6.2.0" | ||
|
||
group :development do | ||
gem "appraisal" | ||
gem "coveralls", require: false | ||
gem "jeweler" | ||
gem "rspec" | ||
gem "rubocop", require: false | ||
gem "sqlite3", "~> 1.3.6" | ||
gem "timecop" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file was generated by Appraisal | ||
|
||
source 'http://rubygems.org' | ||
source "http://rubygems.org" | ||
|
||
gem 'activerecord', '~> 5.2.0' | ||
gem 'activesupport', '~> 5.2.0' | ||
gem 'ancestry' | ||
gem 'railties', '~> 5.2.0' | ||
gem "activerecord", "~> 5.2.0" | ||
gem "activesupport", "~> 5.2.0" | ||
gem "ancestry" | ||
gem "railties", "~> 5.2.0" | ||
|
||
group :development do | ||
gem 'appraisal' | ||
gem 'coveralls', require: false | ||
gem 'jeweler' | ||
gem 'rspec' | ||
gem 'rubocop', require: false | ||
gem 'sqlite3', '~> 1.3.6' | ||
gem 'timecop' | ||
gem "appraisal" | ||
gem "coveralls", require: false | ||
gem "jeweler" | ||
gem "rspec" | ||
gem "rubocop", require: false | ||
gem "sqlite3", "~> 1.3.6" | ||
gem "timecop" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file was generated by Appraisal | ||
|
||
source 'http://rubygems.org' | ||
source "http://rubygems.org" | ||
|
||
gem 'activerecord', '~> 6' | ||
gem 'activesupport', '~> 6' | ||
gem 'ancestry' | ||
gem 'railties', '~> 6' | ||
gem "activerecord", "~> 6" | ||
gem "activesupport", "~> 6" | ||
gem "ancestry" | ||
gem "railties", "~> 6" | ||
|
||
group :development do | ||
gem 'appraisal' | ||
gem 'coveralls', require: false | ||
gem 'jeweler' | ||
gem 'rspec' | ||
gem 'rubocop', require: false | ||
gem 'sqlite3', '~> 1.4.0' | ||
gem 'timecop' | ||
gem "appraisal" | ||
gem "coveralls", require: false | ||
gem "jeweler" | ||
gem "rspec" | ||
gem "rubocop", require: false | ||
gem "sqlite3", "~> 1.4.0" | ||
gem "timecop" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# This file was generated by Appraisal | ||
|
||
source 'http://rubygems.org' | ||
source "http://rubygems.org" | ||
|
||
gem 'activerecord', git: 'https://github.com/rails/rails.git' | ||
gem 'activesupport', git: 'https://github.com/rails/rails.git' | ||
gem 'ancestry' | ||
gem 'railties', git: 'https://github.com/rails/rails.git' | ||
gem "activerecord", git: "https://github.com/rails/rails.git" | ||
gem "activesupport", git: "https://github.com/rails/rails.git" | ||
gem "ancestry" | ||
gem "railties", git: "https://github.com/rails/rails.git" | ||
|
||
group :development do | ||
gem 'appraisal' | ||
gem 'coveralls', require: false | ||
gem 'jeweler' | ||
gem 'rspec' | ||
gem 'rubocop', require: false | ||
gem 'sqlite3' | ||
gem 'timecop' | ||
gem "appraisal" | ||
gem "coveralls", require: false | ||
gem "jeweler" | ||
gem "rspec" | ||
gem "rubocop", require: false | ||
gem "sqlite3" | ||
gem "timecop" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
lib/generators/acts_as_messageable/migration/templates/migration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/generators/acts_as_messageable/migration/templates/migration_indexes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AddIndexesToMessages < ActiveRecord::Migration[4.2] | ||
def self.up | ||
add_index :<%= table_name %>, [:sent_messageable_id, :sent_messageable_type], :name => "acts_as_messageable_sent" | ||
add_index :<%= table_name %>, [:received_messageable_id, :received_messageable_type], :name => "acts_as_messageable_received" | ||
end | ||
|
||
def self.down | ||
remove_index :<%= table_name %>, :name => "acts_as_messageable_sent" | ||
remove_index :<%= table_name %>, :name => "acts_as_messageable_received" | ||
end | ||
end |
6 changes: 3 additions & 3 deletions
6
lib/generators/acts_as_messageable/migration/templates/migration_opened_as_datetime.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class AddOpenedAtToMessages < ActiveRecord::Migration | ||
class AddOpenedAtToMessages < ActiveRecord::Migration[4.2] | ||
def self.up | ||
add_column :<%= table_name %>, :opened_at, :datetime | ||
<%= table_name.classify %>.where(opened:true).update_all(opened_at: DateTime.now) | ||
ActsAsMessageable::Message.where(opened: true).update_all(opened_at: DateTime.now) | ||
end | ||
|
||
def self.down | ||
<%= table_name.classify %>.where.not(opened_at:nil).update_all(opened: true) | ||
ActsAsMessageable::Message.where('opened_at is not null').update_all(opened: true) | ||
remove_column :<%= table_name %>, :opened_at | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
lib/generators/acts_as_messageable/migration/templates/migration_permanent.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
def create_dummy_app | ||
system 'bundle exec rails new dummy --skip-test-unit --skip-spring --skip-webpack-install --skip-bootsnap --skip-active-storage --skip-active-job -d sqlite3' | ||
end | ||
|
||
def add_gem_to_gemfile | ||
run_in_app("echo gem \"'acts-as-messageable', path: '../'\" >> Gemfile; bundle") | ||
end | ||
|
||
def run_bundler | ||
run_in_app('bundle update') | ||
end | ||
|
||
def run_generators | ||
run_in_app('bundle exec rails g acts_as_messageable:migration') | ||
end | ||
|
||
def run_migrations | ||
run_in_app('bundle exec rake db:migrate') | ||
end | ||
|
||
def rollback_migrations | ||
run_in_app('bundle exec rake db:migrate VERSION=0') | ||
end | ||
|
||
def run_in_app(command) | ||
system "cd dummy; BUNDLE_GEMFILE=./Gemfile #{command}" | ||
end | ||
|
||
def remove_dummy_app | ||
system 'rm -rf dummy' | ||
end | ||
|
||
describe 'migration' do | ||
before do | ||
create_dummy_app | ||
add_gem_to_gemfile | ||
run_bundler | ||
end | ||
|
||
after do | ||
remove_dummy_app | ||
end | ||
|
||
it 'runs migrations and revert them' do | ||
run_generators | ||
|
||
expect(run_migrations).to be_truthy | ||
expect(rollback_migrations).to be_truthy | ||
end | ||
end |
Oops, something went wrong.