generic_app 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/README.md +15 -14
- data/Rakefile +0 -2
- data/bin/generic_app +110 -4
- data/bin/generic_app_add +32 -0
- data/bin/setup +7 -0
- data/gem_install.sh +9 -0
- data/gem_test.sh +50 -0
- data/generic_app.gemspec +2 -1
- data/lib/generic_app/version.rb +2 -2
- data/lib/generic_app.rb +203 -46
- data/spec/lib/1_sq_spec.rb +62 -0
- data/spec/lib/2_pg_spec.rb +23 -0
- data/spec/lib/3_pg_spec.rb +33 -0
- data/spec/lib/4_addon_spec.rb +43 -0
- data/to_add/README.md +17 -42
- data/to_add/list_files.sh +32 -15
- data/to_add/notes/0-README.md +9 -0
- data/to_add/notes/2-db.txt +77 -0
- data/to_add/notes/3-db-summary.txt +19 -0
- data/to_add/notes/mvc-account_activations.txt +10 -0
- data/to_add/notes/mvc-application.txt +7 -0
- data/to_add/notes/mvc-layouts.txt +9 -0
- data/to_add/notes/mvc-password_resets.txt +25 -0
- data/to_add/notes/mvc-sessions.txt +27 -0
- data/to_add/notes/mvc-shared_views.txt +4 -0
- data/to_add/notes/mvc-static.txt +22 -0
- data/to_add/notes/mvc-users.txt +96 -0
- data/to_add/notes/tests.txt +2 -59
- data/to_add/{setup.sh → test.sh} +1 -0
- data/to_add_pg/config/database.yml +26 -0
- metadata +45 -10
- data/setup.sh +0 -5
- data/spec/lib/generic_app_spec.rb +0 -45
- data/to_add/notes/mvc_by_object.txt +0 -160
- data/to_add/notes/seed.txt +0 -18
data/to_add/notes/tests.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
NOTE: controller, model, mailer, and helper tests are in the notes/mvc-*.txt file.
|
2
|
+
|
1
3
|
test_helper.rb
|
2
4
|
fixtures :all
|
3
5
|
def is_logged_in?
|
@@ -14,32 +16,6 @@ users.yml
|
|
14
16
|
<% 30.times do |n| %>
|
15
17
|
user_<%= n %>:
|
16
18
|
|
17
|
-
test/controllers:
|
18
|
-
account_activations_controller_test.rb
|
19
|
-
sessions_controller_test.rb
|
20
|
-
test "should get new" do
|
21
|
-
static_pages_controller_test.rb
|
22
|
-
test "should get home" do
|
23
|
-
test "should get help" do
|
24
|
-
test "should get about" do
|
25
|
-
test "should get contact" do
|
26
|
-
users_controller_test.rb
|
27
|
-
def setup
|
28
|
-
test "should redirect index when not logged in" do
|
29
|
-
test "should get new" do
|
30
|
-
test "should redirect edit when not logged in" do
|
31
|
-
test "should redirect update when not logged in" do
|
32
|
-
test "should redirect edit when logged in as wrong user" do
|
33
|
-
test "should redirect update when logged in as wrong user" do
|
34
|
-
test "should redirect destroy when not logged in" do
|
35
|
-
test "should redirect destroy when logged in as a non-admin" do
|
36
|
-
|
37
|
-
test/helpers:
|
38
|
-
sessions_helper_test.rb
|
39
|
-
def setup
|
40
|
-
test "current_user returns right user when session is nil" do
|
41
|
-
test "current_user returns nil when remember digest is wrong" do
|
42
|
-
|
43
19
|
test/integration:
|
44
20
|
password_resets_test.rb
|
45
21
|
def setup
|
@@ -74,36 +50,3 @@ users_signup_test.rb
|
|
74
50
|
def setup
|
75
51
|
test "invalid signup information" do
|
76
52
|
test "valid signup information" do
|
77
|
-
|
78
|
-
test/mailers:
|
79
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/account_activation
|
80
|
-
def account_activation
|
81
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/password_reset
|
82
|
-
def password_reset
|
83
|
-
previews
|
84
|
-
user_mailer_test.rb
|
85
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/account_activation
|
86
|
-
def account_activation
|
87
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/password_reset
|
88
|
-
def password_reset
|
89
|
-
|
90
|
-
test/mailers/previews:
|
91
|
-
user_mailer_preview.rb
|
92
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/account_activation
|
93
|
-
def account_activation
|
94
|
-
# Preview this email at http://localhost:3000/rails/mailers/user_mailer/password_reset
|
95
|
-
def password_reset
|
96
|
-
|
97
|
-
test/models:
|
98
|
-
user_test.rb
|
99
|
-
def setup
|
100
|
-
test "should be valid" do
|
101
|
-
test "name should be present" do
|
102
|
-
test "email should be present" do
|
103
|
-
test "name should not be too long" do
|
104
|
-
test "email should not be too long" do
|
105
|
-
test "email validation should accept valid addresses" do
|
106
|
-
test "email validation should reject invalid addresses" do
|
107
|
-
test "email address should be unique" do
|
108
|
-
test "password should have a minimum length" do
|
109
|
-
test "authenticated? should return false for a user with nil digest" do
|
data/to_add/{setup.sh → test.sh}
RENAMED
@@ -0,0 +1,26 @@
|
|
1
|
+
# POSTGRESQL DATABASE PARAMETERS:
|
2
|
+
# Database name (development)
|
3
|
+
# Database name (testing)
|
4
|
+
# Database name (production)
|
5
|
+
# Username
|
6
|
+
# Password
|
7
|
+
# NOTE: All three databases use the same username and password.
|
8
|
+
|
9
|
+
default: &default
|
10
|
+
adapter: postgresql
|
11
|
+
pool: 5
|
12
|
+
timeout: 5000
|
13
|
+
username: <%= ENV['VAR_STORE_USERNAME'] %>
|
14
|
+
password: <%= ENV['VAR_STORE_PASSWORD'] %>
|
15
|
+
|
16
|
+
development:
|
17
|
+
<<: *default
|
18
|
+
database: DB_NAME_DEV
|
19
|
+
|
20
|
+
test:
|
21
|
+
<<: *default
|
22
|
+
database: DB_NAME_TEST
|
23
|
+
|
24
|
+
production:
|
25
|
+
<<: *default
|
26
|
+
database: DB_NAME_PRO
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generic_app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Hsu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: line_containing
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: figaro
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -72,6 +86,8 @@ email:
|
|
72
86
|
- rubyist@jasonhsu.com
|
73
87
|
executables:
|
74
88
|
- generic_app
|
89
|
+
- generic_app_add
|
90
|
+
- setup
|
75
91
|
extensions: []
|
76
92
|
extra_rdoc_files: []
|
77
93
|
files:
|
@@ -81,23 +97,39 @@ files:
|
|
81
97
|
- README.md
|
82
98
|
- Rakefile
|
83
99
|
- bin/generic_app
|
100
|
+
- bin/generic_app_add
|
101
|
+
- bin/setup
|
102
|
+
- gem_install.sh
|
103
|
+
- gem_test.sh
|
84
104
|
- generic_app.gemspec
|
85
105
|
- lib/generic_app.rb
|
86
106
|
- lib/generic_app/version.rb
|
87
|
-
-
|
88
|
-
- spec/lib/
|
107
|
+
- spec/lib/1_sq_spec.rb
|
108
|
+
- spec/lib/2_pg_spec.rb
|
109
|
+
- spec/lib/3_pg_spec.rb
|
110
|
+
- spec/lib/4_addon_spec.rb
|
89
111
|
- spec/spec_helper.rb
|
90
112
|
- to_add/README.md
|
91
113
|
- to_add/heroku_upload.sh
|
92
114
|
- to_add/kill_spring.sh
|
93
115
|
- to_add/list_files.sh
|
94
|
-
- to_add/notes/
|
95
|
-
- to_add/notes/
|
116
|
+
- to_add/notes/0-README.md
|
117
|
+
- to_add/notes/2-db.txt
|
118
|
+
- to_add/notes/3-db-summary.txt
|
119
|
+
- to_add/notes/mvc-account_activations.txt
|
120
|
+
- to_add/notes/mvc-application.txt
|
121
|
+
- to_add/notes/mvc-layouts.txt
|
122
|
+
- to_add/notes/mvc-password_resets.txt
|
123
|
+
- to_add/notes/mvc-sessions.txt
|
124
|
+
- to_add/notes/mvc-shared_views.txt
|
125
|
+
- to_add/notes/mvc-static.txt
|
126
|
+
- to_add/notes/mvc-users.txt
|
96
127
|
- to_add/notes/tests.txt
|
97
128
|
- to_add/sandbox.sh
|
98
129
|
- to_add/seed.sh
|
99
130
|
- to_add/server.sh
|
100
|
-
- to_add/
|
131
|
+
- to_add/test.sh
|
132
|
+
- to_add_pg/config/database.yml
|
101
133
|
homepage: https://github.com/jhsu802701/generic_app
|
102
134
|
licenses:
|
103
135
|
- MIT
|
@@ -118,10 +150,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
150
|
version: '0'
|
119
151
|
requirements: []
|
120
152
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.4.
|
153
|
+
rubygems_version: 2.4.6
|
122
154
|
signing_key:
|
123
155
|
specification_version: 4
|
124
156
|
summary: Save time by instantly create a generic Rails app.
|
125
157
|
test_files:
|
126
|
-
- spec/lib/
|
158
|
+
- spec/lib/1_sq_spec.rb
|
159
|
+
- spec/lib/2_pg_spec.rb
|
160
|
+
- spec/lib/3_pg_spec.rb
|
161
|
+
- spec/lib/4_addon_spec.rb
|
127
162
|
- spec/spec_helper.rb
|
data/setup.sh
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'generic_app'
|
3
|
-
require 'string_in_file'
|
4
|
-
require 'string_in_path'
|
5
|
-
|
6
|
-
describe GenericApp do
|
7
|
-
it "should copy the Rails tutorial" do
|
8
|
-
puts "*********************************"
|
9
|
-
puts "Clearing space for Rails tutorial"
|
10
|
-
system("rm -rf tmp")
|
11
|
-
|
12
|
-
t1 = Thread.new {
|
13
|
-
generic_app = GenericApp.new
|
14
|
-
generic_app.create("tmp")
|
15
|
-
}
|
16
|
-
t1.join
|
17
|
-
|
18
|
-
t1 = Thread.new {
|
19
|
-
puts "\nChecking Bash scripts"
|
20
|
-
expect(StringInFile.present("heroku run rake db:migrate", "tmp/heroku_upload.sh")).to eq(true)
|
21
|
-
expect(StringInFile.present("pkill", "tmp/kill_spring.sh")).to eq(true)
|
22
|
-
expect(StringInFile.present("ls -R1 -I concerns app/controllers", "tmp/list_files.sh")).to eq(true)
|
23
|
-
expect(StringInFile.present("rails console --sandbox", "tmp/sandbox.sh")).to eq(true)
|
24
|
-
expect(StringInFile.present("rake db:seed", "tmp/seed.sh")).to eq(true)
|
25
|
-
expect(StringInFile.present("rails server -b 0.0.0.0", "tmp/server.sh")).to eq(true)
|
26
|
-
expect(StringInFile.present("bundle install", "tmp/setup.sh")).to eq(true)
|
27
|
-
|
28
|
-
puts "\nChecking README.md"
|
29
|
-
expect(StringInFile.present("list_files.sh", "tmp/README.md")).to eq(true)
|
30
|
-
|
31
|
-
puts "\nChecking Guardfile"
|
32
|
-
expect(StringInFile.present("all_on_start: true", "tmp/Guardfile")).to eq(true)
|
33
|
-
|
34
|
-
|
35
|
-
puts "\nChecking for suggestion to use password management software"
|
36
|
-
expect(StringInFile.present("KeePassX", "tmp/app/views/users/new.html.erb")).to eq(true)
|
37
|
-
expect(StringInFile.present("KeePassX", "tmp/app/views/users/edit.html.erb")).to eq(true)
|
38
|
-
expect(StringInFile.present("KeePassX", "tmp/app/views/password_resets/new.html.erb")).to eq(true)
|
39
|
-
expect(StringInFile.present("KeePassX", "tmp/app/views/password_resets/edit.html.erb")).to eq(true)
|
40
|
-
}
|
41
|
-
t1.join
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
@@ -1,160 +0,0 @@
|
|
1
|
-
MIGRATIONS
|
2
|
-
db/migrate
|
3
|
-
20141014183645_create_users.rb
|
4
|
-
create_table :users (name, email)
|
5
|
-
20141014205756_add_index_to_users_email.rb
|
6
|
-
add_index :users, :email
|
7
|
-
20141014234032_add_password_digest_to_users.rb
|
8
|
-
add_column :users, :password_digest, :string
|
9
|
-
20141030174712_add_remember_digest_to_users.rb
|
10
|
-
add_column :users, :remember_digest, :string
|
11
|
-
20141104004736_add_admin_to_users.rb
|
12
|
-
add_column :users, :admin, :boolean, default: false
|
13
|
-
20141106193737_add_activation_to_users.rb
|
14
|
-
add_column :users, :activation_digest, :string
|
15
|
-
add_column :users, :activated, :boolean, default: false
|
16
|
-
add_column :users, :activated_at, :datetime
|
17
|
-
20141107180258_add_reset_to_users.rb
|
18
|
-
add_column :users, :reset_digest, :string
|
19
|
-
add_column :users, :reset_sent_at, :datetime
|
20
|
-
|
21
|
-
ACCOUNT ACTIVATIONS
|
22
|
-
app/controllers/account_activations_controller.rb
|
23
|
-
def edit
|
24
|
-
app/helpers/account_activations_helper.rb
|
25
|
-
config/routes.rb
|
26
|
-
get 'account_activations/edit'
|
27
|
-
resources :account_activations, only: [:edit]
|
28
|
-
|
29
|
-
APPLICATION
|
30
|
-
app/controllers/application_controller.rb
|
31
|
-
include SessionsHelper
|
32
|
-
app/helpers/application_helper.rb
|
33
|
-
def full_title(page_title = '')
|
34
|
-
|
35
|
-
PASSWORD RESETS
|
36
|
-
app/controllers/password_resets_controller.rb
|
37
|
-
before_action :get_user, only: [:edit, :update]
|
38
|
-
before_action :valid_user, only: [:edit, :update]
|
39
|
-
before_action :check_expiration, only: [:edit, :update]
|
40
|
-
def new
|
41
|
-
def create
|
42
|
-
def edit
|
43
|
-
def update
|
44
|
-
private
|
45
|
-
def user_params
|
46
|
-
def both_passwords_blank?
|
47
|
-
def get_user
|
48
|
-
def valid_user
|
49
|
-
def check_expiration
|
50
|
-
app/views/password_resets
|
51
|
-
edit.html.erb
|
52
|
-
new.html.erb
|
53
|
-
config/routes.rb
|
54
|
-
get 'password_resets/new'
|
55
|
-
get 'password_resets/edit'
|
56
|
-
resources :password_resets, only: [:new, :create, :edit, :update]
|
57
|
-
|
58
|
-
SESSIONS
|
59
|
-
app/controllers/sessions_controller.rb
|
60
|
-
def new
|
61
|
-
def create
|
62
|
-
def destroy
|
63
|
-
app/views/sessions/new.html.erb
|
64
|
-
config/routes.rb
|
65
|
-
get 'sessions/new'
|
66
|
-
get 'login' => 'sessions#new'
|
67
|
-
post 'login' => 'sessions#create'
|
68
|
-
delete 'logout' => 'sessions#destroy'
|
69
|
-
|
70
|
-
STATIC PAGES
|
71
|
-
app/controllers/static_pages_controller.rb
|
72
|
-
def home
|
73
|
-
def help
|
74
|
-
def about
|
75
|
-
def contact
|
76
|
-
app/views/static_pages
|
77
|
-
about.html.erb
|
78
|
-
contact.html.erb
|
79
|
-
help.html.erb
|
80
|
-
home.html.erb
|
81
|
-
config/routes.rb
|
82
|
-
root 'static_pages#home'
|
83
|
-
get 'help' => 'static_pages#help'
|
84
|
-
get 'about' => 'static_pages#about'
|
85
|
-
get 'contact' => 'static_pages#contact'
|
86
|
-
|
87
|
-
USERS
|
88
|
-
app/controllers/users_controller.rb
|
89
|
-
before_action :logged_in_user, only: [:index, :edit, :update, :destroy]
|
90
|
-
before_action :correct_user, only: [:edit, :update]
|
91
|
-
before_action :admin_user, only: :destroy
|
92
|
-
def index
|
93
|
-
def show
|
94
|
-
def new
|
95
|
-
def create
|
96
|
-
def edit
|
97
|
-
def update
|
98
|
-
def destroy
|
99
|
-
private
|
100
|
-
def user_params
|
101
|
-
def logged_in_user
|
102
|
-
def correct_user
|
103
|
-
def admin_user
|
104
|
-
app/models/user.rb
|
105
|
-
attr_accessor :remember_token, :activation_token, :reset_token
|
106
|
-
before_save :downcase_email
|
107
|
-
before_create :create_activation_digest
|
108
|
-
validates :name, presence: true, length: { maximum: 50 }
|
109
|
-
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\-.]+\.[a-z]+\z/i
|
110
|
-
validates :email, presence: true, length: { maximum: 255 },
|
111
|
-
format: { with: VALID_EMAIL_REGEX },
|
112
|
-
uniqueness: { case_sensitive: false }
|
113
|
-
has_secure_password
|
114
|
-
validates :password, length: { minimum: 6 }, allow_blank: true
|
115
|
-
def User.digest(string)
|
116
|
-
def User.new_token
|
117
|
-
def remember
|
118
|
-
def forget
|
119
|
-
def authenticated?(attribute, token)
|
120
|
-
def activate
|
121
|
-
def send_activation_email
|
122
|
-
def create_reset_digest
|
123
|
-
def send_password_reset_email
|
124
|
-
def password_reset_expired?
|
125
|
-
private
|
126
|
-
def downcase_email
|
127
|
-
def create_activation_digest
|
128
|
-
app/views/users
|
129
|
-
edit.html.erb
|
130
|
-
index.html.erb
|
131
|
-
new.html.erb
|
132
|
-
show.html.erb
|
133
|
-
_user.html.erb
|
134
|
-
database params:
|
135
|
-
users (name, email, index, password_digest, remember_digest, admin,
|
136
|
-
activation_digest, activated, activated_at, reset_digest, reset_sent_at)
|
137
|
-
config/routes.rb
|
138
|
-
get 'signup' => 'users#new'
|
139
|
-
resources :users
|
140
|
-
|
141
|
-
MAILERS
|
142
|
-
app/mailers/user_mailer.rb
|
143
|
-
def account_activation(user)
|
144
|
-
def password_reset(user)
|
145
|
-
app/views/user_mailer
|
146
|
-
account_activation.html.erb
|
147
|
-
account_activation.text.erb
|
148
|
-
password_reset.html.erb
|
149
|
-
password_reset.text.erb
|
150
|
-
|
151
|
-
LAYOUTS
|
152
|
-
app/views/layouts
|
153
|
-
application.html.erb
|
154
|
-
_footer.html.erb
|
155
|
-
_header.html.erb
|
156
|
-
_shim.html.erb
|
157
|
-
|
158
|
-
SHARED VIEWS
|
159
|
-
app/views/shared
|
160
|
-
_error_messages.html.erb
|
data/to_add/notes/seed.txt
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
User.create!(name: "Example User",
|
2
|
-
email: "example@railstutorial.org",
|
3
|
-
password: "foobar",
|
4
|
-
password_confirmation: "foobar",
|
5
|
-
admin: true,
|
6
|
-
activated: true,
|
7
|
-
activated_at: Time.zone.now)
|
8
|
-
99.times do |n|
|
9
|
-
name = Faker::Name.name
|
10
|
-
email = "example-#{n+1}@railstutorial.org"
|
11
|
-
password = "password"
|
12
|
-
User.create!(name: name,
|
13
|
-
email: email,
|
14
|
-
password: password,
|
15
|
-
password_confirmation: password,
|
16
|
-
activated: true,
|
17
|
-
activated_at: Time.zone.now)
|
18
|
-
end
|