comable-apartment 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +22 -0
- data/README.md +56 -0
- data/Rakefile +19 -0
- data/app/assets/javascripts/comable/apartment/application.coffee +14 -0
- data/app/assets/javascripts/comable/apartment/dispatcher.coffee +0 -0
- data/app/assets/stylesheets/comable/apartment/application.scss +10 -0
- data/app/controllers/comable/apartment/application_controller.rb +57 -0
- data/app/controllers/comable/apartment/dashboard_controller.rb +10 -0
- data/app/controllers/comable/apartment/tenants_controller.rb +55 -0
- data/app/controllers/comable/apartment/user_sessions_controller.rb +8 -0
- data/app/controllers/comable/apartment/users_controller.rb +67 -0
- data/app/decorators/comable/ability_decorator.rb +17 -0
- data/app/decorators/comable/user_decorator.rb +8 -0
- data/app/helpers/comable/apartment/application_helper.rb +19 -0
- data/app/models/comable/tenant.rb +59 -0
- data/app/navigations/comable/apartment/application.rb +34 -0
- data/app/views/comable/apartment/dashboard/show.slim +8 -0
- data/app/views/comable/apartment/tenants/_form.slim +19 -0
- data/app/views/comable/apartment/tenants/edit.slim +27 -0
- data/app/views/comable/apartment/tenants/index.slim +54 -0
- data/app/views/comable/apartment/tenants/new.slim +16 -0
- data/app/views/comable/apartment/user_sessions/new.slim +25 -0
- data/app/views/comable/apartment/users/_form.slim +24 -0
- data/app/views/comable/apartment/users/edit.slim +34 -0
- data/app/views/comable/apartment/users/index.slim +34 -0
- data/app/views/comable/apartment/users/new.slim +21 -0
- data/app/views/comable/apartment/users/show.slim +33 -0
- data/app/views/layouts/comable/apartment/application.slim +17 -0
- data/comable-apartment.gemspec +46 -0
- data/config/initializers/comable-apartment.rb +4 -0
- data/config/initializers/devise.rb +3 -0
- data/config/locales/en.yml +27 -0
- data/config/locales/ja.yml +27 -0
- data/config/routes.rb +14 -0
- data/db/migrate/20150729091221_create_comable_tenant.rb +9 -0
- data/db/seeds.rb +5 -0
- data/db/seeds/comable/users.rb +51 -0
- data/gemfiles/active_record_40.gemfile +4 -0
- data/gemfiles/active_record_41.gemfile +4 -0
- data/gemfiles/active_record_42.gemfile +4 -0
- data/gemfiles/active_record_edge.gemfile +8 -0
- data/gemfiles/common.gemfile +2 -0
- data/lib/comable/apartment.rb +62 -0
- data/lib/comable/apartment/constraint.rb +19 -0
- data/lib/comable/apartment/engine.rb +13 -0
- data/lib/comable/apartment/tasks/release.rake +50 -0
- data/lib/comable/apartment/version.rb +5 -0
- data/test/controllers/comable/apartment/tenants_controller_test.rb +71 -0
- data/test/controllers/comable/apartment/users_controller_test.rb +80 -0
- data/test/dummy/Rakefile +2 -0
- data/test/dummy/bin/rails +3 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/config/application.rb +53 -0
- data/test/dummy/config/database.yml +18 -0
- data/test/dummy/db/.gitkeep +0 -0
- data/test/dummy/db/migrate/20150814140744_create_comable_products.comable.rb +16 -0
- data/test/dummy/db/migrate/20150814140745_create_comable_users.comable.rb +47 -0
- data/test/dummy/db/migrate/20150814140746_create_comable_stocks.comable.rb +15 -0
- data/test/dummy/db/migrate/20150814140747_create_comable_orders.comable.rb +21 -0
- data/test/dummy/db/migrate/20150814140748_create_comable_order_items.comable.rb +20 -0
- data/test/dummy/db/migrate/20150814140749_create_comable_payment_methods.comable.rb +14 -0
- data/test/dummy/db/migrate/20150814140750_create_comable_shipment_methods.comable.rb +12 -0
- data/test/dummy/db/migrate/20150814140751_create_comable_stores.comable.rb +12 -0
- data/test/dummy/db/migrate/20150814140752_create_comable_addresses.comable.rb +18 -0
- data/test/dummy/db/migrate/20150814140753_create_comable_categories.comable.rb +11 -0
- data/test/dummy/db/migrate/20150814140754_create_comable_products_categories.comable.rb +9 -0
- data/test/dummy/db/migrate/20150814140755_create_comable_images.comable.rb +10 -0
- data/test/dummy/db/migrate/20150814140756_create_comable_shipments.comable.rb +14 -0
- data/test/dummy/db/migrate/20150814140757_create_comable_payments.comable.rb +13 -0
- data/test/dummy/db/migrate/20150814140758_create_comable_trackers.comable.rb +13 -0
- data/test/dummy/db/migrate/20150814140759_create_comable_pages.comable.rb +18 -0
- data/test/dummy/db/migrate/20150814140760_create_comable_themes.comable.rb +16 -0
- data/test/dummy/db/migrate/20150814140761_add_theme_id_to_comable_stores.comable.rb +8 -0
- data/test/factories/comable/tenants.rb +6 -0
- data/test/factories/comable/users.rb +6 -0
- data/test/lib/comable/apartment/version_test.rb +7 -0
- data/test/lib/comable/apartment_test.rb +27 -0
- data/test/minitest_helper.rb +29 -0
- data/test/models/comable/tenant_test.rb +81 -0
- data/test/support/have_attributes.rb +36 -0
- metadata +529 -0
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
2
|
+
|
3
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
4
|
+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|
5
|
+
|
6
|
+
# Pick the frameworks you want:
|
7
|
+
require 'active_record/railtie'
|
8
|
+
require 'action_controller/railtie'
|
9
|
+
require 'action_view/railtie'
|
10
|
+
require 'sprockets/railtie'
|
11
|
+
require 'comable/apartment'
|
12
|
+
|
13
|
+
Bundler.require(*Rails.groups)
|
14
|
+
|
15
|
+
Devise.setup do |config|
|
16
|
+
config.secret_key = '3404ed4c6c43ece78b1531f9e63e8bc5d01b3b89fd684d713fea8eea9b404cfc77d3fe195eaacf2dcae14ebdcb7911fc230e84fbd49f151403818d0a89960920'
|
17
|
+
end
|
18
|
+
|
19
|
+
module Dummy
|
20
|
+
class Application < Rails::Application
|
21
|
+
config.secret_token = '4c9d8af558e4d6d1fe799ca86af92235'
|
22
|
+
config.session_store :cookie_store, key: '_dummy_app_session'
|
23
|
+
config.active_support.deprecation = :log
|
24
|
+
config.eager_load = false
|
25
|
+
config.root = File.expand_path('../../', __FILE__)
|
26
|
+
|
27
|
+
# Show full error reports and disable caching.
|
28
|
+
config.consider_all_requests_local = true
|
29
|
+
config.action_controller.perform_caching = false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Rails.backtrace_cleaner.remove_silencers!
|
34
|
+
|
35
|
+
Dummy::Application.initialize!
|
36
|
+
|
37
|
+
# Routes
|
38
|
+
Rails.application.routes.draw do
|
39
|
+
Comable::Apartment.routes self
|
40
|
+
mount Comable::Core::Engine, at: '/'
|
41
|
+
get ':page', controller: :dummy, action: :show
|
42
|
+
end
|
43
|
+
|
44
|
+
# Controllers
|
45
|
+
class DummyController < ActionController::Base
|
46
|
+
def show
|
47
|
+
@title = params[:page].capitalize if params[:page]
|
48
|
+
render inline: <<-ERB
|
49
|
+
<h1><%= @title %></h1>
|
50
|
+
<h2>This is <%= @title %> Page.</h2>
|
51
|
+
ERB
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
pool: 5
|
5
|
+
username: vagrant
|
6
|
+
password:
|
7
|
+
|
8
|
+
development:
|
9
|
+
<<: *default
|
10
|
+
database: dummy_development
|
11
|
+
|
12
|
+
test:
|
13
|
+
<<: *default
|
14
|
+
database: dummy_test
|
15
|
+
|
16
|
+
production:
|
17
|
+
<<: *default
|
18
|
+
database: dummy_production
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This migration comes from comable (originally 20131214194807)
|
2
|
+
class CreateComableProducts < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_products do |t|
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :code, null: false
|
7
|
+
t.integer :price, null: false
|
8
|
+
t.text :caption
|
9
|
+
t.string :sku_h_item_name
|
10
|
+
t.string :sku_v_item_name
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :comable_products, :code, unique: true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# This migration comes from comable (originally 20140120032559)
|
2
|
+
class CreateComableUsers < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_users do |t|
|
5
|
+
## Database authenticatable
|
6
|
+
t.string :email, null: false
|
7
|
+
t.string :role, null: false
|
8
|
+
t.string :encrypted_password
|
9
|
+
|
10
|
+
## Recoverable
|
11
|
+
t.string :reset_password_token
|
12
|
+
t.datetime :reset_password_sent_at
|
13
|
+
|
14
|
+
## Rememberable
|
15
|
+
t.datetime :remember_created_at
|
16
|
+
|
17
|
+
## Trackable
|
18
|
+
t.integer :sign_in_count, default: 0, null: false
|
19
|
+
t.datetime :current_sign_in_at
|
20
|
+
t.datetime :last_sign_in_at
|
21
|
+
t.string :current_sign_in_ip
|
22
|
+
t.string :last_sign_in_ip
|
23
|
+
|
24
|
+
## Confirmable
|
25
|
+
# t.string :confirmation_token
|
26
|
+
# t.datetime :confirmed_at
|
27
|
+
# t.datetime :confirmation_sent_at
|
28
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
29
|
+
|
30
|
+
## Lockable
|
31
|
+
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
32
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
33
|
+
# t.datetime :locked_at
|
34
|
+
|
35
|
+
## Others
|
36
|
+
t.references :bill_address
|
37
|
+
t.references :ship_address
|
38
|
+
|
39
|
+
t.timestamps null: false
|
40
|
+
end
|
41
|
+
|
42
|
+
add_index :comable_users, :email, unique: true
|
43
|
+
add_index :comable_users, :reset_password_token, unique: true
|
44
|
+
# add_index :comable_users, :confirmation_token, unique: true
|
45
|
+
# add_index :comable_users, :unlock_token, unique: true
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This migration comes from comable (originally 20140502060116)
|
2
|
+
class CreateComableStocks < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_stocks do |t|
|
5
|
+
t.references :product, null: false
|
6
|
+
t.string :code, null: false
|
7
|
+
t.integer :quantity, null: false, default: 0
|
8
|
+
t.string :sku_h_choice_name
|
9
|
+
t.string :sku_v_choice_name
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :comable_stocks, :code, unique: true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This migration comes from comable (originally 20140723175431)
|
2
|
+
class CreateComableOrders < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_orders do |t|
|
5
|
+
t.references :user
|
6
|
+
t.string :guest_token
|
7
|
+
t.string :code
|
8
|
+
t.string :email
|
9
|
+
t.integer :payment_fee, null: false, default: 0
|
10
|
+
t.integer :shipment_fee, null: false, default: 0
|
11
|
+
t.integer :total_price
|
12
|
+
t.references :bill_address
|
13
|
+
t.references :ship_address
|
14
|
+
t.string :state
|
15
|
+
t.datetime :completed_at
|
16
|
+
t.timestamps null: false
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index :comable_orders, :code, unique: true
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This migration comes from comable (originally 20140723175810)
|
2
|
+
class CreateComableOrderItems < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_order_items do |t|
|
5
|
+
t.references :order, null: false
|
6
|
+
t.references :stock, null: false
|
7
|
+
t.string :name, null: false
|
8
|
+
t.string :code, null: false
|
9
|
+
t.integer :price, null: false
|
10
|
+
t.string :sku_h_item_name
|
11
|
+
t.string :sku_v_item_name
|
12
|
+
t.string :sku_h_choice_name
|
13
|
+
t.string :sku_v_choice_name
|
14
|
+
t.integer :quantity, default: 1, null: false
|
15
|
+
t.timestamps null: false
|
16
|
+
end
|
17
|
+
|
18
|
+
add_index :comable_order_items, [:order_id, :stock_id], unique: true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This migration comes from comable (originally 20140817194104)
|
2
|
+
class CreateComablePaymentMethods < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_payment_methods do |t|
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :payment_provider_type, null: false
|
7
|
+
t.integer :payment_provider_kind, null: false
|
8
|
+
t.integer :fee, null: false
|
9
|
+
t.integer :enable_price_from
|
10
|
+
t.integer :enable_price_to
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This migration comes from comable (originally 20140921191416)
|
2
|
+
class CreateComableShipmentMethods < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_shipment_methods do |t|
|
5
|
+
t.boolean :activated_flag, null: false, default: true
|
6
|
+
t.string :name, null: false
|
7
|
+
t.integer :fee, null: false
|
8
|
+
t.string :traking_url
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This migration comes from comable (originally 20140926063541)
|
2
|
+
class CreateComableStores < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_stores do |t|
|
5
|
+
t.string :name
|
6
|
+
t.string :meta_keywords
|
7
|
+
t.string :meta_description
|
8
|
+
t.string :email
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This migration comes from comable (originally 20141024025526)
|
2
|
+
class CreateComableAddresses < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_addresses do |t|
|
5
|
+
t.references :user
|
6
|
+
t.string :family_name, null: false
|
7
|
+
t.string :first_name, null: false
|
8
|
+
t.string :zip_code, null: false
|
9
|
+
t.references :state
|
10
|
+
t.string :state_name, null: false
|
11
|
+
t.string :city, null: false
|
12
|
+
t.string :detail
|
13
|
+
t.string :phone_number, null: false
|
14
|
+
t.datetime :last_used_at
|
15
|
+
t.timestamps null: false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This migration comes from comable (originally 20150111031228)
|
2
|
+
class CreateComableCategories < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_categories do |t|
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :ancestry, index: true
|
7
|
+
t.integer :position
|
8
|
+
t.timestamps null: false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This migration comes from comable (originally 20150111031229)
|
2
|
+
class CreateComableProductsCategories < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_products_categories do |t|
|
5
|
+
t.references :product, null: false, index: true
|
6
|
+
t.references :category, null: false, index: true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This migration comes from comable (originally 20150112173706)
|
2
|
+
class CreateComableImages < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_images do |t|
|
5
|
+
t.references :product, null: false, index: true
|
6
|
+
t.string :file, null: false
|
7
|
+
t.timestamps null: false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This migration comes from comable (originally 20150423095210)
|
2
|
+
class CreateComableShipments < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_shipments do |t|
|
5
|
+
t.references :order, null: false
|
6
|
+
t.references :shipment_method, null: false
|
7
|
+
t.integer :fee, null: false
|
8
|
+
t.string :state, null: false
|
9
|
+
t.string :tracking_number
|
10
|
+
t.datetime :completed_at
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This migration comes from comable (originally 20150511171940)
|
2
|
+
class CreateComablePayments < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_payments do |t|
|
5
|
+
t.references :order, null: false
|
6
|
+
t.references :payment_method, null: false
|
7
|
+
t.integer :fee, null: false
|
8
|
+
t.string :state, null: false
|
9
|
+
t.datetime :completed_at
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This migration comes from comable (originally 20150513185230)
|
2
|
+
class CreateComableTrackers < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_trackers do |t|
|
5
|
+
t.boolean :activated_flag, null: false, default: true
|
6
|
+
t.string :name, null: false
|
7
|
+
t.string :tracker_id
|
8
|
+
t.text :code, null: false
|
9
|
+
t.string :place, null: false
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This migration comes from comable (originally 20150519080729)
|
2
|
+
class CreateComablePages < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_pages do |t|
|
5
|
+
t.string :title, null: false
|
6
|
+
t.text :content, null: false
|
7
|
+
t.string :page_title
|
8
|
+
t.string :meta_description
|
9
|
+
t.string :meta_keywords
|
10
|
+
t.string :slug, null: false
|
11
|
+
t.datetime :published_at
|
12
|
+
|
13
|
+
t.timestamps null: false
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index :comable_pages, :slug, unique: true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This migration comes from comable (originally 20150612143226)
|
2
|
+
class CreateComableThemes < ActiveRecord::Migration
|
3
|
+
def change
|
4
|
+
create_table :comable_themes do |t|
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :version, null: false
|
7
|
+
t.string :display
|
8
|
+
t.string :description
|
9
|
+
t.string :homepage
|
10
|
+
t.string :author
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :comable_themes, [:name, :version], unique: true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
class ApartmentTest < ActiveSupport::TestCase
|
4
|
+
test '.config should yield with self' do
|
5
|
+
Comable::Apartment.config { |config| assert_equal config, Comable::Apartment }
|
6
|
+
end
|
7
|
+
|
8
|
+
test '.excluded_models should be delegated' do
|
9
|
+
assert_equal Comable::Apartment.excluded_models, Apartment.excluded_models
|
10
|
+
end
|
11
|
+
|
12
|
+
test '.tenant_names should be delegated' do
|
13
|
+
assert_equal Comable::Apartment.tenant_names, Apartment.tenant_names
|
14
|
+
end
|
15
|
+
|
16
|
+
test '.excluded_models= should set value to Apartment' do
|
17
|
+
model_name = 'Test'
|
18
|
+
Comable::Apartment.excluded_models = [model_name]
|
19
|
+
assert_equal [model_name], Apartment.excluded_models
|
20
|
+
end
|
21
|
+
|
22
|
+
test '.tenant_names= should set value to Apartment' do
|
23
|
+
tenant_name = 'test'
|
24
|
+
Comable::Apartment.tenant_names = [tenant_name]
|
25
|
+
assert_equal [tenant_name], Apartment.tenant_names
|
26
|
+
end
|
27
|
+
end
|