account_subdomain 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/MIT-LICENSE +20 -0
- data/README.md +63 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/account_subdomain/accounts.js +2 -0
- data/app/assets/javascripts/account_subdomain/application.js +13 -0
- data/app/assets/stylesheets/account_subdomain/accounts.css +4 -0
- data/app/assets/stylesheets/account_subdomain/application.css +13 -0
- data/app/controllers/account_subdomain/accounts_controller.rb +49 -0
- data/app/controllers/account_subdomain/application_controller.rb +7 -0
- data/app/helpers/account_subdomain/accounts_helper.rb +17 -0
- data/app/helpers/account_subdomain/application_helper.rb +4 -0
- data/app/helpers/account_subdomain/url_helper.rb +16 -0
- data/app/models/account_subdomain/account.rb +10 -0
- data/app/views/account_subdomain/accounts/_form.html.erb +21 -0
- data/app/views/account_subdomain/accounts/index.html.erb +25 -0
- data/app/views/account_subdomain/accounts/new.html.erb +5 -0
- data/app/views/account_subdomain/accounts/show.html.erb +8 -0
- data/app/views/layouts/account_subdomain/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/lib/account_subdomain.rb +15 -0
- data/lib/account_subdomain/engine.rb +11 -0
- data/lib/account_subdomain/version.rb +3 -0
- data/lib/generators/account_subdomain/install_generator.rb +28 -0
- data/lib/generators/templates/account_subdomain.rb +27 -0
- data/lib/generators/templates/migration.rb +9 -0
- data/lib/tasks/account_subdomain_tasks.rake +4 -0
- data/test/account_subdomain_test.rb +7 -0
- data/test/controllers/account_subdomain/accounts_controller_test.rb +51 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/users.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/users.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +6 -0
- data/test/dummy/app/controllers/users_controller.rb +59 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/users_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/users/_form.html.erb +25 -0
- data/test/dummy/app/views/users/edit.html.erb +6 -0
- data/test/dummy/app/views/users/index.html.erb +28 -0
- data/test/dummy/app/views/users/new.html.erb +5 -0
- data/test/dummy/app/views/users/show.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/account_subdomain.rb +5 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140912064633_create_users.rb +10 -0
- data/test/dummy/db/migrate/20140920121606_create_account_subdomain_accounts.rb +9 -0
- data/test/dummy/db/schema.rb +29 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +6631 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/users_controller_test.rb +49 -0
- data/test/dummy/test/fixtures/users.yml +9 -0
- data/test/dummy/test/helpers/users_helper_test.rb +4 -0
- data/test/dummy/test/models/user_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0c0329181a3363da2bcd11252797b755 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/17e7f32238d11fec6a6cbf29fa85aaf7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2dafc88a1510883b67ef2ee10f87c949 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/404131fd29f507473a1c43a994b0c0e4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/545fd3d55a6920ef64aa644a8c96677e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/612b91c67ba90d7fd7705f80419c154b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6e9bf44b62aa4a722191aeb77c8501f7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6f41a7af67d2a48a8777092b5614b3f8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/717de5d3ac12676eb97871f93603998f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7608e445d62cfdf9144c7bcd34cdcb9b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/97c215e1c4f1ed90472115037f06eea9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a08d9066d13c1b0ffdeb4b5e72430618 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b9d625a779fb8b1e853c316e695b4102 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b9f32bee6b9ed727384329d0ab870061 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f53273fd778c49ffd1b612633d95df5e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/fixtures/account_subdomain/accounts.yml +7 -0
- data/test/helpers/account_subdomain/accounts_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/account_subdomain/account_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- metadata +278 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module AccountSubdomain
|
4
|
+
class AccountsControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@account = accounts(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get index" do
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert_not_nil assigns(:accounts)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get new" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should create account" do
|
21
|
+
assert_difference('Account.count') do
|
22
|
+
post :create, account: { subdomain: @account.subdomain }
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to account_path(assigns(:account))
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should show account" do
|
29
|
+
get :show, id: @account
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should get edit" do
|
34
|
+
get :edit, id: @account
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should update account" do
|
39
|
+
patch :update, id: @account, account: { subdomain: @account.subdomain }
|
40
|
+
assert_redirected_to account_path(assigns(:account))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should destroy account" do
|
44
|
+
assert_difference('Account.count', -1) do
|
45
|
+
delete :destroy, id: @account
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_redirected_to accounts_path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
before_filter :validate_subdomain#, :only => [:show]
|
3
|
+
before_action :set_user, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
# GET /users
|
6
|
+
def index
|
7
|
+
@users = current_subdomain.users.load
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /users/1
|
11
|
+
def show
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /users/new
|
15
|
+
def new
|
16
|
+
@user = current_subdomain.users.build
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /users/1/edit
|
20
|
+
def edit
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /users
|
24
|
+
def create
|
25
|
+
@user = current_subdomain.users.new(user_params)
|
26
|
+
|
27
|
+
if @user.save
|
28
|
+
redirect_to @user, notice: 'User was successfully created.'
|
29
|
+
else
|
30
|
+
render action: 'new'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# PATCH/PUT /users/1
|
35
|
+
def update
|
36
|
+
if @user.update(user_params)
|
37
|
+
redirect_to @user, notice: 'User was successfully updated.'
|
38
|
+
else
|
39
|
+
render action: 'edit'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE /users/1
|
44
|
+
def destroy
|
45
|
+
@user.destroy
|
46
|
+
redirect_to users_url, notice: 'User was successfully destroyed.'
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
# Use callbacks to share common setup or constraints between actions.
|
51
|
+
def set_user
|
52
|
+
@user = current_subdomain.users.find(params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Only allow a trusted parameter "white list" through.
|
56
|
+
def user_params
|
57
|
+
params.require(:user).permit(:name, :account_id)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%= form_for(@user) do |f| %>
|
2
|
+
<% if @user.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @user.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :name %><br>
|
16
|
+
<%= f.text_field :name %>
|
17
|
+
</div>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :account_id %><br>
|
20
|
+
<%= f.select :account_id, AccountSubdomain::Account.all.collect {|p| [ p.subdomain, p.id ] }, { include_blank: true } %>
|
21
|
+
</div>
|
22
|
+
<div class="actions">
|
23
|
+
<%= f.submit %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<h1>Listing users</h1>
|
2
|
+
<table>
|
3
|
+
<thead>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Account</th>
|
7
|
+
<th></th>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
|
13
|
+
<tbody>
|
14
|
+
<% @users.each do |user| %>
|
15
|
+
<tr>
|
16
|
+
<td><%= user.name %></td>
|
17
|
+
<td><%= user.account_id %></td>
|
18
|
+
<td><%= link_to 'Show', user_url(user, :host => with_subdomain(current_subdomain.subdomain)) %></td>
|
19
|
+
<td><%= link_to 'Edit', edit_user_url(user) %></td>
|
20
|
+
<td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
|
26
|
+
<br>
|
27
|
+
|
28
|
+
<%= link_to 'New User', new_user_path %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<strong>Name:</strong>
|
5
|
+
<%= @user.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<strong>Account:</strong>
|
10
|
+
<%= @user.account_id %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<%= link_to 'Edit', edit_user_path(@user) %> |
|
14
|
+
<%= link_to 'Back', users_path %>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "account_subdomain"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|