Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ace6ffa
[Resolves] Basic support for Rails 6
rpbaltazar Jan 3, 2020
675e6a2
[Hotfix] Updated readme
rpbaltazar Jan 3, 2020
b5cfd18
[Hotfix] preparing version 2.3.0
rpbaltazar Jan 3, 2020
700c548
[Hotfix] Updated travis config and history.md
rpbaltazar Jan 3, 2020
8aa5b13
[Hotfix] updated README to include require
rpbaltazar Feb 4, 2020
428a035
[Hotfix] Added story_branch local config
rpbaltazar Feb 16, 2020
4a4c62c
[Hotfix] added rubocop to the project
rpbaltazar Feb 16, 2020
3846636
WIP - moved rubocop to gemfile instead of dev dependency
rpbaltazar Feb 17, 2020
44e86eb
WIP - moved rails 5.2 with ruby 2.2.9 to allowed failures
rpbaltazar Feb 17, 2020
812d129
WIP - added rubocop lint
rpbaltazar Feb 17, 2020
92960de
Merge pull request #10 from rails-on-services/fix-rubocop-usage
rpbaltazar Feb 17, 2020
40d3350
WIP - starting to cleanup
rpbaltazar Feb 16, 2020
b335c2a
WIP - ran autocorrect
rpbaltazar Feb 16, 2020
017c7a8
[Hotfix] Fixed modifier indentation
rpbaltazar Feb 16, 2020
7d66739
WIP - fixed braces around hash params
rpbaltazar Feb 16, 2020
0cadb66
WIP - fixed array of strings
rpbaltazar Feb 16, 2020
8ba3245
[Hotfix] fixed array of strings for schemas rb
rpbaltazar Feb 16, 2020
b437189
WIP - removed a few more broken rules in rubocop
rpbaltazar Feb 16, 2020
2bc9f84
WIP - cleanup a few more rubocop
rpbaltazar Feb 16, 2020
f6ec075
WIP - fixed a couple more of rubocops
rpbaltazar Feb 16, 2020
8d127c5
WIP -
rpbaltazar Feb 16, 2020
a22737d
WIP - removed extra blank lines
rpbaltazar Feb 16, 2020
7f68591
WIP - fixed EmptyLinesAroundBlockBody
rpbaltazar Feb 16, 2020
e7cd59b
WIP - Fixed EmptyLinesAroundModuleBody
rpbaltazar Feb 16, 2020
ea46027
WIP - ran more auto correct
rpbaltazar Feb 16, 2020
9495f79
WIP - fixed SpaceBeforeBlockBraces
rpbaltazar Feb 16, 2020
127883b
WIP - fixed spacing related issues
rpbaltazar Feb 16, 2020
edf9d24
WIP - ran some more auto correct
rpbaltazar Feb 16, 2020
bacd618
WIP - fixed dynamic find by
rpbaltazar Feb 16, 2020
d2e8248
WIP - fixed rails output and preferred alias method
rpbaltazar Feb 16, 2020
7fc7d33
WIP - sorted gemfiels
rpbaltazar Feb 16, 2020
ea8f97c
WIP - fixed unused argument
rpbaltazar Feb 16, 2020
6c7d1fe
WIP - fixed yaml safe load
rpbaltazar Feb 16, 2020
6efd1e5
WIP - fixed block delimiters
rpbaltazar Feb 16, 2020
edb6ced
WIP - fixed keyword todo and empty method definition
rpbaltazar Feb 16, 2020
e6f3e44
WIP - fixed expand path
rpbaltazar Feb 16, 2020
8f55e25
WIP - fixed a couple more rules
rpbaltazar Feb 16, 2020
5b04164
WIP -
rpbaltazar Feb 16, 2020
0dcea87
WIP - fixed if unless modifier
rpbaltazar Feb 16, 2020
0af1784
WIP - fixed multiline modifier
rpbaltazar Feb 16, 2020
af4dd0c
WIP - fixed mutable constants
rpbaltazar Feb 16, 2020
9adea7f
WIP - fixed all immediatly fixable issues
rpbaltazar Feb 16, 2020
1b1476e
WIP - added base application record class
rpbaltazar Feb 17, 2020
6e89883
WIP - fixed ignored_first_subdomains
rpbaltazar Feb 17, 2020
d2cf4b9
WIP - fixed failing specs after rubocop cleanup
rpbaltazar Feb 17, 2020
7dd413b
WIP - reverted sqlite3 as it is not an issue atm
rpbaltazar Feb 17, 2020
daad79b
WIP - cleaning up rubocop
rpbaltazar Feb 17, 2020
4aa741b
WIP -
rpbaltazar Feb 17, 2020
79e6eb4
Merge pull request #8 from rails-on-services/fix-rubocop
rpbaltazar Feb 17, 2020
68b6cbc
WIP - working on travis config
rpbaltazar Feb 17, 2020
e613386
WIP - including master in branches to test
rpbaltazar Feb 17, 2020
65db2c6
Merge pull request #13 from rails-on-services/update-travis-config-to…
rpbaltazar Feb 17, 2020
4eb1681
Don't crash when no database connection is present
Mar 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/.rubocop-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Rubocop Lint

on: [push]

jobs:
build:

runs-on: ubuntu-latest

container:
image: ruby:2.6.5

steps:
- uses: actions/checkout@v1
- name: Rubocop Linter
uses: andrewmcodes/[email protected]
with:
additional_gems: 'perx-rubocop:0.0.3'
fail_level: 'warning'
version: '0.77.0'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 5 additions & 3 deletions .pryrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
if defined?(Rails) && Rails.env
extend Rails::ConsoleMethods
end
# frozen_string_literal: true

# rubocop:disable Style/MixinUsage
extend Rails::ConsoleMethods if defined?(Rails) && Rails.env
# rubocop:enable Style/MixinUsage
17 changes: 17 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
inherit_from: .rubocop_todo.yml

inherit_gem:
perx-rubocop:
- default.yml

Style/WordArray:
Exclude:
- spec/schemas/**/*.rb

Style/NumericLiterals:
Exclude:
- spec/schemas/**/*.rb

Layout/EmptyLineAfterMagicComment:
Exclude:
- spec/schemas/**/*.rb
29 changes: 29 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-02-16 15:36:55 +0800 using RuboCop version 0.77.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 5
Metrics/AbcSize:
Max: 33

# Offense count: 11
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 176

# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 237

# Offense count: 4
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 24
4 changes: 4 additions & 0 deletions .story_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
tracker: github
project_id:
- rails-on-services/apartment
29 changes: 20 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
sudo: required
os: linux

language: ruby
services:
- docker
rvm:
- jruby-9.1.15.0
- jruby-9.1.17.0
- 2.1.9
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- 2.6.2
- ruby-head

branches:
only:
- master
- development

gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
Expand All @@ -29,12 +36,16 @@ before_install:
env:
RUBY_GC_MALLOC_LIMIT: 90000000
RUBY_GC_HEAP_FREE_SLOTS: 200000
matrix:
jobs:
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/rails_master.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_0.gemfile
# Rails 5.2.4.1 is currently broken. Code has been fixed but no release
# for it yet - https://github.com/rails/rails/issues/38137
- rvm: 2.2.9
gemfile: gemfiles/rails_5_2.gemfile
exclude:
- rvm: 2.1.9
gemfile: gemfiles/rails_5_0.gemfile
Expand All @@ -46,19 +57,19 @@ matrix:
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.1.9
gemfile: gemfiles/rails_master.gemfile
- rvm: 2.2.9
- rvm: 2.2.9
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.3.6
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.3
gemfile: gemfiles/rails_6_0.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_1.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_5_2.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_6_0.gemfile
- rvm: jruby-9.1.15.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/rails_master.gemfile
fast_finish: true
cache: bundler
36 changes: 18 additions & 18 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
appraise "rails-4-2" do
gem "rails", "~> 4.2.0"
# frozen_string_literal: true

appraise 'rails-4-2' do
gem 'rails', '~> 4.2.0'
platforms :ruby do
gem "pg", "< 1.0.0"
gem "mysql2", "~> 0.4.0"
gem 'pg', '< 1.0.0'
gem 'mysql2', '~> 0.4.0'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 1.3'
Expand All @@ -11,10 +13,10 @@ appraise "rails-4-2" do
end
end

appraise "rails-5-0" do
gem "rails", "~> 5.0.0"
appraise 'rails-5-0' do
gem 'rails', '~> 5.0.0'
platforms :ruby do
gem "pg", "< 1.0.0"
gem 'pg', '< 1.0.0'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 50.0'
Expand All @@ -23,10 +25,10 @@ appraise "rails-5-0" do
end
end

appraise "rails-5-1" do
gem "rails", "~> 5.1.0"
appraise 'rails-5-1' do
gem 'rails', '~> 5.1.0'
platforms :ruby do
gem "pg", "< 1.0.0"
gem 'pg', '< 1.0.0'
end
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 51.0'
Expand All @@ -35,18 +37,17 @@ appraise "rails-5-1" do
end
end

appraise "rails-5-2" do
gem "rails", "~> 5.2.0"
appraise 'rails-5-2' do
gem 'rails', '~> 5.2.0'
platforms :jruby do
gem 'activerecord-jdbc-adapter', '~> 52.0'
gem 'activerecord-jdbcpostgresql-adapter', '~> 52.0'
gem 'activerecord-jdbcmysql-adapter', '~> 52.0'
end
end


appraise "rails-6-0" do
gem "rails", "~> 6.0.0.rc1"
appraise 'rails-6-0' do
gem 'rails', '~> 6.0.0.rc1'
platforms :ruby do
gem 'sqlite3', '~> 1.4'
end
Expand All @@ -57,9 +58,8 @@ appraise "rails-6-0" do
end
end


appraise "rails-master" do
gem "rails", git: 'https://github.com/rails/rails.git'
appraise 'rails-master' do
gem 'rails', git: 'https://github.com/rails/rails.git'
platforms :ruby do
gem 'sqlite3', '~> 1.4'
end
Expand Down
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# frozen_string_literal: true

source 'http://rubygems.org'

gemspec

gem 'rails', '>= 3.1.2'
gem 'rails', '>= 3.1.2'
gem 'perx-rubocop', '~> 0.0.3'

group :local do
gem 'pry'
gem 'guard-rspec', '~> 4.2'
gem 'pry'
end
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 2.3.0
* January 3, 2020

## Added
- Basic support for rails 6
- Released different gem name, with same API as apartment

# 2.2.1
* June 19, 2019

Expand Down
49 changes: 28 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ Apartment provides tools to help you deal with multiple tenants in your Rails
application. If you need to have certain data sequestered based on account or company,
but still allow some data to exist in a common tenant, Apartment can help.

## HELP!
## Apartment drop in replacement gem

In order to help drive the direction of development and clean up the codebase, we'd like to take a poll
on how people are currently using Apartment. If you can take 5 seconds (1 question) to answer
this poll, we'd greatly appreciated it.
After having reached out via github issues and email directly, no replies ever
came. Since we wanted to upgrade our application to Rails 6 we decided to fork
and start some development to support Rails 6. Because we don't have access
to the apartment gem itself, the solution was to release it under a different
name but providing the exact same API as it was before.

[View Poll](http://www.poll-maker.com/poll391552x4Bfb41a9-15)
## Help wanted

## Excessive Memory Issues on ActiveRecord 4.x

> If you're noticing ever growing memory issues (ie growing with each tenant you add)
> when using Apartment, that's because there's [an issue](https://github.com/rails/rails/issues/19578)
> with how ActiveRecord maps Postgresql data types into AR data types.
> This has been patched and will be released for AR 4.2.2. It's apparently hard
> to backport to 4.1 unfortunately.
> If you're noticing high memory usage from ActiveRecord with Apartment please upgrade.

```ruby
gem 'rails', '4.2.1', github: 'influitive/rails', tag: 'v4.2.1.memfix'
```
We were never involved with the development of Apartment gem in the first place
and this project started out of our own needs. We will be more than happy
to collaborate to maintain the gem alive and supporting the latest versions
of ruby and rails, but your help is appreciated. Either by reporting bugs you
may find or proposing improvements to the gem itself. Feel free to reach out.

## Installation

Expand All @@ -38,7 +33,7 @@ gem 'rails', '4.2.1', github: 'influitive/rails', tag: 'v4.2.1.memfix'
Add the following to your Gemfile:

```ruby
gem 'apartment'
gem 'ros-apartment', require: 'apartment'
```

Then generate your `Apartment` config file using
Expand Down Expand Up @@ -234,7 +229,7 @@ A Generic Elevator exists that allows you to pass a `Proc` (or anything that res
module MyApplication
class Application < Rails::Application
# Obviously not a contrived example
config.middleware.use Apartment::Elevators::Generic, Proc.new { |request| request.host.reverse }
config.middleware.use Apartment::Elevators::Generic, proc { |request| request.host.reverse }
end
end
```
Expand Down Expand Up @@ -484,7 +479,7 @@ Note that you can disable the default migrating of all tenants with `db:migrate`

Apartment supports parallelizing migrations into multiple threads when
you have a large number of tenants. By default, parallel migrations is
turned off. You can enable this by setting `parallel_migration_threads` to
turned off. You can enable this by setting `parallel_migration_threads` to
the number of threads you want to use in your initializer.

Keep in mind that because migrations are going to access the database,
Expand Down Expand Up @@ -531,7 +526,12 @@ end

## Background workers

See [apartment-sidekiq](https://github.com/influitive/apartment-sidekiq) or [apartment-activejob](https://github.com/influitive/apartment-activejob).
Both these gems have been forked as a side consequence of having a new gem name.
You can use them exactly as you were using before. They are, just like this one
a drop-in replacement.

See [apartment-sidekiq](https://github.com/rails-on-services/apartment-sidekiq)
or [apartment-activejob](https://github.com/rails-on-services/apartment-activejob).

## Callbacks

Expand Down Expand Up @@ -569,6 +569,13 @@ end

* If you're looking to help, check out the TODO file for some upcoming changes I'd like to implement in Apartment.

### Running bundle install

mysql2 gem in some cases fails to install.
If you face problems running bundle install in OSX, try installing the gem running:

`gem install mysql2 -v '0.5.3' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include`

## License

Apartment is released under the [MIT License](http://www.opensource.org/licenses/MIT).
10 changes: 9 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,18 @@ def activerecord_below_5_2?
ActiveRecord.version.release < Gem::Version.new('5.2.0')
end

def activerecord_below_6_0?
ActiveRecord.version.release < Gem::Version.new('6.0.0')
end

def migrate
if activerecord_below_5_2?
ActiveRecord::Migrator.migrate('spec/dummy/db/migrate')
else
elsif activerecord_below_6_0?
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate').migrate
else
# TODO: Figure out if there is any other possibility that can/should be
# passed here as the second argument for the migration context
ActiveRecord::MigrationContext.new('spec/dummy/db/migrate', ActiveRecord::SchemaMigration).migrate
end
end
Loading