generic_app 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'generic_app'
3
+ require 'string_in_file'
4
+
5
+ dir_app_1 = "#{ENV['DIR_PARENT']}/tmp1"
6
+
7
+ describe GenericApp do
8
+ it "New Rails app" do
9
+ puts
10
+ puts '**************'
11
+ puts 'CREATING APP 1'
12
+ puts 'New Rails app'
13
+ system("rm -rf #{dir_app_1}")
14
+ Dir.chdir("#{ENV['DIR_PARENT']}") do
15
+ GenericApp.create_new('tmp1', '007@railstutorial.org')
16
+ end
17
+ end
18
+
19
+ it 'Email address should be updated' do
20
+ expect(StringInFile.present('007@railstutorial.org', "#{dir_app_1}/config/initializers/devise.rb")).to eq(true)
21
+ end
22
+
23
+ it "Bash scripts should be provided" do
24
+ expect(StringInFile.present("heroku run rake db:migrate", "#{dir_app_1}/heroku_upload.sh")).to eq(true)
25
+ expect(StringInFile.present("pkill", "#{dir_app_1}/kill_spring.sh")).to eq(true)
26
+ expect(StringInFile.present("ls -R1 -I concerns app/controllers", "#{dir_app_1}/list_files.sh")).to eq(true)
27
+ expect(StringInFile.present("rails console --sandbox", "#{dir_app_1}/sandbox.sh")).to eq(true)
28
+ expect(StringInFile.present("rake db:seed", "#{dir_app_1}/seed.sh")).to eq(true)
29
+ expect(StringInFile.present("rails server -b 0.0.0.0", "#{dir_app_1}/server.sh")).to eq(true)
30
+ expect(StringInFile.present("bundle install", "#{dir_app_1}/test_app.sh")).to eq(true)
31
+ end
32
+
33
+ it "New README.md file should be provided" do
34
+ expect(StringInFile.present("list_files.sh", "#{dir_app_1}/README.md")).to eq(true)
35
+ end
36
+
37
+ it "Guardfile should be set to automatically run tests upon startup" do
38
+ expect(StringInFile.present("all_on_start: true", "#{dir_app_1}/Guardfile")).to eq(true)
39
+ end
40
+
41
+ it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
42
+ expect(StringInFile.present("tmp", "#{dir_app_1}/.gitignore")).to eq(true)
43
+ expect(StringInFile.present("tmp*", "#{dir_app_1}/.gitignore")).to eq(true)
44
+ expect(StringInFile.present(".DS_Store", "#{dir_app_1}/.gitignore")).to eq(true)
45
+ end
46
+
47
+ it "The notes/1-file_list.txt file should be in place" do
48
+ expect(StringInFile.present("app/models", "#{dir_app_1}/notes/1-file_list.txt")).to eq(true)
49
+ expect(StringInFile.present("app/views", "#{dir_app_1}/notes/1-file_list.txt")).to eq(true)
50
+ expect(StringInFile.present("app/controllers", "#{dir_app_1}/notes/1-file_list.txt")).to eq(true)
51
+ end
52
+
53
+ it "The notes/mvc-users.txt file should be in place" do
54
+ expect(StringInFile.present("users_controller.rb", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
55
+ expect(StringInFile.present("users_controller_test.rb", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
56
+ expect(StringInFile.present("users_helper.rb", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
57
+ expect(StringInFile.present("def index", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
58
+ expect(StringInFile.present("def show", "#{dir_app_1}/notes/mvc-users.txt")).to eq(true)
59
+ end
60
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'generic_app'
3
+ require 'string_in_file'
4
+
5
+ dir_app_2 = "#{ENV['DIR_PARENT']}/tmp2"
6
+
7
+ describe GenericApp do
8
+ it 'Legacy app' do
9
+ puts
10
+ puts '**************'
11
+ puts 'STARTING APP 2'
12
+ puts 'Legacy Rails app'
13
+
14
+ system("rm -rf #{dir_app_2}")
15
+ Dir.chdir("#{ENV['DIR_PARENT']}") do
16
+ t1 = Thread.new {
17
+ puts '------------------'
18
+ puts 'Getting legacy app'
19
+ system('git clone https://github.com/mhartl/sample_app_3rd_edition.git tmp2')
20
+ system("git checkout remotes/origin/account-activation-password-reset")
21
+ puts 'Finished acquiring legacy app'
22
+ puts '-----------------------------'
23
+ }
24
+ t1.join
25
+ GenericApp.add ('tmp2')
26
+ end
27
+ end
28
+
29
+ it "Bash scripts should be provided" do
30
+ expect(StringInFile.present("heroku run rake db:migrate", "#{dir_app_2}/heroku_upload.sh")).to eq(true)
31
+ expect(StringInFile.present("pkill", "#{dir_app_2}/kill_spring.sh")).to eq(true)
32
+ expect(StringInFile.present("ls -R1 -I concerns app/controllers", "#{dir_app_2}/list_files.sh")).to eq(true)
33
+ expect(StringInFile.present("rails console --sandbox", "#{dir_app_2}/sandbox.sh")).to eq(true)
34
+ expect(StringInFile.present("rake db:seed", "#{dir_app_2}/seed.sh")).to eq(true)
35
+ expect(StringInFile.present("rails server -b 0.0.0.0", "#{dir_app_2}/server.sh")).to eq(true)
36
+ expect(StringInFile.present("bundle install", "#{dir_app_2}/test_app.sh")).to eq(true)
37
+ end
38
+
39
+ it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
40
+ expect(StringInFile.present("tmp", "#{dir_app_2}/.gitignore")).to eq(true)
41
+ expect(StringInFile.present("tmp*", "#{dir_app_2}/.gitignore")).to eq(true)
42
+ expect(StringInFile.present(".DS_Store", "#{dir_app_2}/.gitignore")).to eq(true)
43
+ end
44
+ end
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.1.1
4
+ version: 1.0.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-03-30 00:00:00.000000000 Z
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: figaro
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 1.1.0
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 1.1.0
83
69
  description: Instead of creating your Rails app from scratch, start with a generic
84
70
  app.
85
71
  email:
@@ -104,32 +90,9 @@ files:
104
90
  - generic_app.gemspec
105
91
  - lib/generic_app.rb
106
92
  - lib/generic_app/version.rb
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
93
+ - spec/lib/1_new_app_spec.rb
94
+ - spec/lib/2_legacy_app_spec.rb
111
95
  - spec/spec_helper.rb
112
- - to_add/README.md
113
- - to_add/heroku_upload.sh
114
- - to_add/kill_spring.sh
115
- - to_add/list_files.sh
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
127
- - to_add/notes/tests.txt
128
- - to_add/sandbox.sh
129
- - to_add/seed.sh
130
- - to_add/server.sh
131
- - to_add/test.sh
132
- - to_add_pg/config/database.yml
133
96
  homepage: https://github.com/jhsu802701/generic_app
134
97
  licenses:
135
98
  - MIT
@@ -150,13 +113,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
113
  version: '0'
151
114
  requirements: []
152
115
  rubyforge_project:
153
- rubygems_version: 2.4.6
116
+ rubygems_version: 2.4.8
154
117
  signing_key:
155
118
  specification_version: 4
156
119
  summary: Save time by instantly create a generic Rails app.
157
120
  test_files:
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
121
+ - spec/lib/1_new_app_spec.rb
122
+ - spec/lib/2_legacy_app_spec.rb
162
123
  - spec/spec_helper.rb
@@ -1,62 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- describe GenericApp do
6
- it "SQLite version should execute" do
7
- puts
8
- puts "****************************"
9
- puts "Testing the SQLite procedure"
10
- system("rm -rf tmp1")
11
- GenericApp.sq("tmp1")
12
- GenericApp.git_init("tmp1")
13
-
14
- end
15
-
16
- it "Bash scripts should be provided" do
17
- expect(StringInFile.present("heroku run rake db:migrate", "tmp1/heroku_upload.sh")).to eq(true)
18
- expect(StringInFile.present("pkill", "tmp1/kill_spring.sh")).to eq(true)
19
- expect(StringInFile.present("ls -R1 -I concerns app/controllers", "tmp1/list_files.sh")).to eq(true)
20
- expect(StringInFile.present("rails console --sandbox", "tmp1/sandbox.sh")).to eq(true)
21
- expect(StringInFile.present("rake db:seed", "tmp1/seed.sh")).to eq(true)
22
- expect(StringInFile.present("rails server -b 0.0.0.0", "tmp1/server.sh")).to eq(true)
23
- expect(StringInFile.present("bundle install", "tmp1/test.sh")).to eq(true)
24
- end
25
-
26
- it "New README.md file should be provided" do
27
- expect(StringInFile.present("list_files.sh", "tmp1/README.md")).to eq(true)
28
- end
29
-
30
- it "Guardfile should be set to automatically run tests upon startup" do
31
- expect(StringInFile.present("all_on_start: true", "tmp1/Guardfile")).to eq(true)
32
- end
33
-
34
- it "Suggestions to use password management software should be provided" do
35
- expect(StringInFile.present("KeePassX", "tmp1/app/views/users/new.html.erb")).to eq(true)
36
- expect(StringInFile.present("KeePassX", "tmp1/app/views/users/edit.html.erb")).to eq(true)
37
- expect(StringInFile.present("KeePassX", "tmp1/app/views/password_resets/new.html.erb")).to eq(true)
38
- expect(StringInFile.present("KeePassX", "tmp1/app/views/password_resets/edit.html.erb")).to eq(true)
39
- end
40
-
41
- it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
42
- expect(StringInFile.present("tmp", "tmp1/.gitignore")).to eq(true)
43
- expect(StringInFile.present("tmp*", "tmp1/.gitignore")).to eq(true)
44
- expect(StringInFile.present(".DS_Store", "tmp1/.gitignore")).to eq(true)
45
- end
46
-
47
- it "The notes/1-file_list.txt file should be in place" do
48
- expect(StringInFile.present("app/models", "tmp1/notes/1-file_list.txt")).to eq(true)
49
- expect(StringInFile.present("app/views", "tmp1/notes/1-file_list.txt")).to eq(true)
50
- expect(StringInFile.present("app/controllers", "tmp1/notes/1-file_list.txt")).to eq(true)
51
- end
52
-
53
- it "The notes/mvc-users.txt file should be in place" do
54
- expect(StringInFile.present("app/controllers/users_controller.rb", "tmp1/notes/mvc-users.txt")).to eq(true)
55
- expect(StringInFile.present("test/controllers/users_controller_test.rb", "tmp1/notes/mvc-users.txt")).to eq(true)
56
- expect(StringInFile.present("app/helpers/users_helper.rb", "tmp1/notes/mvc-users.txt")).to eq(true)
57
- expect(StringInFile.present("def index", "tmp1/notes/mvc-users.txt")).to eq(true)
58
- expect(StringInFile.present("def show", "tmp1/notes/mvc-users.txt")).to eq(true)
59
- end
60
-
61
- end
62
-
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- describe GenericApp do
6
- it "PostgreSQL version should execute" do
7
- puts
8
- puts "********************************"
9
- puts "Testing the PostgreSQL procedure"
10
- system("rm -rf tmp2")
11
-
12
- n = Time.now.to_i
13
-
14
- GenericApp.pg("tmp2", "db_tmp2_#{n}", "eu_tmp2_#{n}", "ep_tmp2_#{n}", "u_tmp2_#{n}", "abcdef")
15
-
16
- GenericApp.git_init("tmp2")
17
-
18
- expect(StringInFile.present("sqlite", "tmp2/Gemfile")).to eq(false)
19
- expect(StringInFile.present("gem 'pg'", "tmp2/Gemfile")).to eq(true)
20
- end
21
-
22
- end
23
-
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- describe GenericApp do
6
- it "PostgreSQL version works with changed parameters" do
7
- puts
8
- puts "************************************************************************************"
9
- puts "Testing the PostgreSQL procedure given new databases, a new user, and a new password"
10
- puts "Copying the PostgreSQL-based Rails app previously created."
11
- system("rm -rf tmp3")
12
- t1 = Thread.new {
13
- system("cp -rf tmp2 tmp3")
14
- }
15
- t1.join
16
- n = (Time.now.to_i ) * 2
17
-
18
- GenericApp.set_pg_params("tmp3", "db_tmp3_#{n}", "eu_tmp3_#{n}", "ep_tmp3_#{n}", "u_tmp3_#{n}", "fedcba")
19
-
20
- expect(StringInFile.present("sqlite", "tmp3/Gemfile")).to eq(false)
21
- expect(StringInFile.present("gem 'pg'", "tmp3/Gemfile")).to eq(true)
22
- expect(StringInFile.present("u_tmp3_#{n}", "tmp3/config/application.yml")).to eq(true)
23
- expect(StringInFile.present("fedcba", "tmp3/config/application.yml")).to eq(true)
24
- expect(StringInFile.present("eu_tmp3_#{n}", "tmp3/config/application.yml")).to eq(true)
25
- expect(StringInFile.present("ep_tmp3_#{n}", "tmp3/config/application.yml")).to eq(true)
26
- expect(StringInFile.present("db_tmp3_#{n}_dev", "tmp3/config/database.yml")).to eq(true)
27
- expect(StringInFile.present("db_tmp3_#{n}_test", "tmp3/config/database.yml")).to eq(true)
28
- expect(StringInFile.present("db_tmp3_#{n}_pro", "tmp3/config/database.yml")).to eq(true)
29
- expect(StringInFile.present("eu_tmp3_#{n}", "tmp3/config/database.yml")).to eq(true)
30
- expect(StringInFile.present("ep_tmp3_#{n}", "tmp3/config/database.yml")).to eq(true)
31
- end
32
- end
33
-
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
- require 'generic_app'
3
- require 'string_in_file'
4
-
5
- describe GenericApp do
6
-
7
- it "Adding scripts to an existing app should work" do
8
- puts
9
- puts "********************************************************"
10
- puts "Testing the addition of scripts to an existing Rails app"
11
- system("rm -rf tmp4")
12
- t1 = Thread.new {
13
- system("git clone https://github.com/mhartl/sample_app_3rd_edition.git tmp4")
14
- }
15
- t1.join
16
- GenericApp.add_scripts ("tmp4")
17
- GenericApp.update_gitignore ("tmp4")
18
- end
19
-
20
- it "Bash scripts should be provided" do
21
- expect(StringInFile.present("heroku run rake db:migrate", "tmp4/heroku_upload.sh")).to eq(true)
22
- expect(StringInFile.present("pkill", "tmp4/kill_spring.sh")).to eq(true)
23
- expect(StringInFile.present("ls -R1 -I concerns app/controllers", "tmp4/list_files.sh")).to eq(true)
24
- expect(StringInFile.present("rails console --sandbox", "tmp4/sandbox.sh")).to eq(true)
25
- expect(StringInFile.present("rake db:seed", "tmp4/seed.sh")).to eq(true)
26
- expect(StringInFile.present("rails server -b 0.0.0.0", "tmp4/server.sh")).to eq(true)
27
- expect(StringInFile.present("bundle install", "tmp4/test.sh")).to eq(true)
28
- end
29
-
30
- it "The .gitignore file includes tmp, tmp*, and ,DS_Store" do
31
- expect(StringInFile.present("tmp", "tmp4/.gitignore")).to eq(true)
32
- expect(StringInFile.present("tmp*", "tmp4/.gitignore")).to eq(true)
33
- expect(StringInFile.present(".DS_Store", "tmp4/.gitignore")).to eq(true)
34
- end
35
-
36
- it "The notes/1-file_list.txt file should be in place" do
37
- expect(StringInFile.present("app/models", "tmp4/notes/1-file_list.txt")).to eq(true)
38
- expect(StringInFile.present("app/views", "tmp4/notes/1-file_list.txt")).to eq(true)
39
- expect(StringInFile.present("app/controllers", "tmp4/notes/1-file_list.txt")).to eq(true)
40
- end
41
-
42
- end
43
-
data/to_add/README.md DELETED
@@ -1,32 +0,0 @@
1
- # Generic App
2
-
3
- This is the generic Rails app created with the use of the generic_app Ruby gem. More details on the generic_app Ruby gem are available at https://github.com/jhsu802701/generic_app .
4
-
5
- This app consists of all of the features of the Rails Tutorial Sample App except for microposts and relationships. The basic elements essential to most Rails apps are included. It is up to you to customize this app and add the features and capabilities specific to your endeavor.
6
-
7
- The original Rails Tutorial Sample App provides the following features:
8
-
9
- 1. Static pages
10
- 2. Tests
11
- 3. Automated tests through Guard
12
- 4. Twitter bootstrap
13
- 5. Databases: SQLite3 for development and PostgreSQL for production
14
- 6. Ready for Heroku deployment
15
- 7. User functionality: includes hashed passwords, administrative users, account activations, and password resets
16
-
17
- This generic Rails app provides the above features PLUS these additional features:
18
-
19
- 1. Bash scripts in the root directory that allow you to perform routine tasks in only one step. (These scripts are likely to be useful in Rails apps that were not created with this generic_app Ruby gem.)
20
- 2. Recommendations that the user make use of password management software to generate and store secure passwords
21
- 3. Outlines of the MVC, test suite, and database seeding process in the notes folder
22
- 4. Guard automatically runs tests upon startup.
23
-
24
- To execute the Bash (*.sh) scripts, enter the command "sh (name of script)". The Bash scripts provided are:
25
-
26
- 1. test.sh: When you first create the app, or anytime that you clone this app, you must run the setup.sh script to set up the app. This is a prerequisite for running Guard, running the local server, and many other basic tasks.
27
- 2. server.sh: This script runs your local Rails server. Note that it specifies port 0.0.0.0 so that you can view your Rails app in your web browser when you do your Rails development in Vagrant.
28
- 3. seed.sh: This script populates the database in the development environment with simulated data.
29
- 4. sandbox.sh: This script gives you the Rails console sandbox environment.
30
- 5. heroku_upload.sh: This script uploads your Rails source code to Heroku AND runs the "rake db:migrate" command in the Heroku environment.
31
- 6. kill_spring.sh: The Spring tool is useful but may occasionally slow down your Rails app. If you believe that this is happening, run this script to kill the Spring tool.
32
- 7. list_files.sh: This script prints outlines of the path structure of the MVC and testing architectures in your Rails app into the file notes/1-list_files.txt. While this script has no impact on how your Rails app runs, it aids the process of outlining the MVC structure and the testing procedure in your app.
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
- # Proper header for a Bash script.
3
-
4
- git push heroku
5
- heroku run rake db:migrate
@@ -1,4 +0,0 @@
1
- #!/bin/bash
2
- # Proper header for a Bash script.
3
-
4
- pkill -9 -f spring
data/to_add/list_files.sh DELETED
@@ -1,42 +0,0 @@
1
- #!/bin/bash
2
- # Proper header for a Bash script.
3
-
4
- echo "****************************************************************"
5
- echo "BEGIN compiling the list of files that make up the MVC structure"
6
-
7
- mkdir -p notes
8
-
9
- echo "This file was AUTOMATICALLY generated by the list_files.sh script." > notes/1-file_list.txt
10
-
11
- echo "" >> notes/1-file_list.txt
12
- ls -R1 -I concerns app/controllers >> notes/1-file_list.txt
13
-
14
- echo "" >> notes/1-file_list.txt
15
- ls -R1 -I concerns app/helpers >> notes/1-file_list.txt
16
-
17
- echo "" >> notes/1-file_list.txt
18
- ls -R1 -I concerns app/mailers >> notes/1-file_list.txt
19
-
20
- echo "" >> notes/1-file_list.txt
21
- ls -R1 -I concerns app/models >> notes/1-file_list.txt
22
-
23
- echo "" >> notes/1-file_list.txt
24
- ls -R1 -I concerns app/views >> notes/1-file_list.txt
25
-
26
- echo "" >> notes/1-file_list.txt
27
- ls -R1 -I concerns db >> notes/1-file_list.txt
28
-
29
- echo "" >> notes/1-file_list.txt
30
- ls -R1 -I concerns features >> notes/1-file_list.txt
31
-
32
- echo "" >> notes/1-file_list.txt
33
- ls -R1 -I concerns spec >> notes/1-file_list.txt
34
-
35
- echo "" >> notes/1-file_list.txt
36
- ls -R1 -I concerns test >> notes/1-file_list.txt
37
-
38
- echo "" >> notes/1-file_list.txt
39
- cat config/routes.rb >> notes/1-file_list.txt
40
-
41
- echo "FINISHED compiling the list of files that make up the MVC structure"
42
- echo "*******************************************************************"
@@ -1,9 +0,0 @@
1
- # NOTES DIRECTORY
2
-
3
- ## 1-file_list.txt
4
-
5
- * The file 1-file_list.txt lists the contents of the app/controllers, app/helpers, app/mailers, app/views, db, features, spec, and test directories.
6
-
7
- * The file 1-file_list.txt is AUTOMATICALLY generated by the list_files.sh script. Please do NOT manually edit the 1-file_list.txt file, because your changes will be wiped out the next time you run the list_files.sh script.
8
-
9
- * The purpose of this file is to aid the process of outlining the MVC structure of this Rails app.
@@ -1,77 +0,0 @@
1
- ============
2
- db/schema.rb
3
- create_table "users", force: :cascade do |t|
4
- t.string "name"
5
- t.string "email"
6
- t.datetime "created_at", null: false
7
- t.datetime "updated_at", null: false
8
- t.string "password_digest"
9
- t.string "remember_digest"
10
- t.boolean "admin", default: false
11
- t.string "activation_digest"
12
- t.boolean "activated", default: false
13
- t.datetime "activated_at"
14
- t.string "reset_digest"
15
- t.datetime "reset_sent_at"
16
- end
17
-
18
- add_index "users", ["email"], name: "index_users_on_email", unique: true
19
-
20
- ===========
21
- db/migrate:
22
- 20141014183645_create_users.rb
23
- def change
24
- create_table :users do |t|
25
- t.string :name
26
- t.string :email
27
-
28
- t.timestamps null: false
29
- end
30
- end
31
- 20141014205756_add_index_to_users_email.rb
32
- def change
33
- add_index :users, :email, unique: true
34
- end
35
- 20141014234032_add_password_digest_to_users.rb
36
- def change
37
- add_column :users, :password_digest, :string
38
- end
39
- 20141030174712_add_remember_digest_to_users.rb
40
- def change
41
- add_column :users, :remember_digest, :string
42
- end
43
- 20141104004736_add_admin_to_users.rb
44
- def change
45
- add_column :users, :admin, :boolean, default: false
46
- end
47
- 20141106193737_add_activation_to_users.rb
48
- def change
49
- add_column :users, :activation_digest, :string
50
- add_column :users, :activated, :boolean, default: false
51
- add_column :users, :activated_at, :datetime
52
- end
53
- 20141107180258_add_reset_to_users.rb
54
- def change
55
- add_column :users, :reset_digest, :string
56
- add_column :users, :reset_sent_at, :datetime
57
- end
58
- ===========
59
- db/seeds.rb
60
- User.create!(name: "Example User",
61
- email: "example@railstutorial.org",
62
- password: "foobar",
63
- password_confirmation: "foobar",
64
- admin: true,
65
- activated: true,
66
- activated_at: Time.zone.now)
67
- 99.times do |n|
68
- name = Faker::Name.name
69
- email = "example-#{n+1}@railstutorial.org"
70
- password = "password"
71
- User.create!(name: name,
72
- email: email,
73
- password: password,
74
- password_confirmation: password,
75
- activated: true,
76
- activated_at: Time.zone.now)
77
- end
@@ -1,19 +0,0 @@
1
- TABLES
2
- users (name, email, created_at, updated_at, timestamps, password_digest, remember_digest, admin, activation_digest, activated, activated_at, reset_digest, reset_sent_at)
3
- index: named "index_users_on_email", based on email (must be unique)
4
-
5
- SEED
6
- Create user
7
- name: "Example User",
8
- email: "example@railstutorial.org",
9
- password: "foobar",
10
- password_confirmation: "foobar",
11
- admin: true,
12
- activated: true,
13
- activated_at: Time.zone.now
14
- Create users example-1@railstutorial.org to example-99@railstutorial.org
15
- name = Faker::Name.name
16
- email = "example-#{n+1}@railstutorial.org",
17
- password, password_confirmation = "password"
18
- activated: true,
19
- activated_at: Time.zone.now)
@@ -1,10 +0,0 @@
1
- ACCOUNT ACTIVATIONS
2
- app/controllers/account_activations_controller.rb
3
- def edit
4
- test/controllers/account_activations_controller_test.rb
5
- app/helpers/account_activations_helper.rb
6
- app/views/user_mailer/account_activation.html.erb
7
- app/views/user_mailer/account_activation.text.erb
8
- config/routes.rb
9
- get 'account_activations/edit'
10
- resources :account_activations, only: [:edit]
@@ -1,7 +0,0 @@
1
- APPLICATION
2
- app/controllers/application_controller.rb
3
- include SessionsHelper
4
- app/helpers/application_helper.rb
5
- def full_title(page_title = '')
6
- app/mailers/application_mailer.rb
7
- app/views/layouts/application.html.erb
@@ -1,9 +0,0 @@
1
- LAYOUTS
2
-
3
- app/views/layouts
4
- application.html.erb
5
- _footer.html.erb
6
- _header.html.erb
7
- mailer.html.erb
8
- mailer.text.erb
9
- _shim.html.erb
@@ -1,25 +0,0 @@
1
- app/controllers/password_resets_controller.rb
2
- before_action :get_user, only: [:edit, :update]
3
- before_action :valid_user, only: [:edit, :update]
4
- before_action :check_expiration, only: [:edit, :update]
5
- def new
6
- def create
7
- def edit
8
- def update
9
- private
10
- def user_params
11
- def both_passwords_blank?
12
- def get_user
13
- def valid_user
14
- def check_expiration
15
- app/helpers/password_resets_helper.rb
16
- app/views/password_resets
17
- edit.html.erb
18
- new.html.erb
19
- app/views/user_mailer
20
- password_reset.html.erb
21
- password_reset.text.erb
22
- config/routes.rb
23
- get 'password_resets/new'
24
- get 'password_resets/edit'
25
- resources :password_resets, only: [:new, :create, :edit, :update]
@@ -1,27 +0,0 @@
1
- SESSIONS
2
- app/controllers/sessions_controller.rb
3
- def new
4
- def create
5
- def destroy
6
- test/controllers/sessions_controller_test.rb
7
- test "should get new" do
8
- app/helpers/sessions_helper.rb
9
- def log_in(user)
10
- def remember(user)
11
- def current_user?(user)
12
- def current_user
13
- def logged_in?
14
- def forget(user)
15
- def log_out
16
- def redirect_back_or(default)
17
- def store_location
18
- test/helpers/sessions_helper_test.rb
19
- def setup
20
- test "current_user returns right user when session is nil" do
21
- test "current_user returns nil when remember digest is wrong" do
22
- app/views/sessions/new.html.erb
23
- config/routes.rb
24
- get 'sessions/new'
25
- get 'login' => 'sessions#new'
26
- post 'login' => 'sessions#create'
27
- delete 'logout' => 'sessions#destroy'
@@ -1,4 +0,0 @@
1
- SHARED VIEWS
2
-
3
- app/views/shared
4
- _error_messages.html.erb