whodat 1.0.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.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +4 -0
  4. data/.travis.yml +3 -0
  5. data/CODE-OF-CONDUCT.md +60 -0
  6. data/Gemfile +19 -0
  7. data/Gemfile.lock +173 -0
  8. data/HOW-TO-CONTRIBUTE.md +19 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +99 -0
  11. data/Rakefile +24 -0
  12. data/Users +0 -0
  13. data/Whodat +0 -0
  14. data/app/assets/config/whodat_manifest.js +2 -0
  15. data/app/assets/images/whodat/.keep +0 -0
  16. data/app/assets/images/whodat/example-app-screencap.png +0 -0
  17. data/app/assets/images/whodat/navbar-pic-readme.png +0 -0
  18. data/app/assets/images/whodat/whodat-logo-tiny.png +0 -0
  19. data/app/assets/images/whodat/whodat-logo-wide.png +0 -0
  20. data/app/assets/images/whodat/whodat-logo.png +0 -0
  21. data/app/assets/javascripts/whodat/application.js +15 -0
  22. data/app/assets/javascripts/whodat/dashboard.js +2 -0
  23. data/app/assets/javascripts/whodat/sessions.js +2 -0
  24. data/app/assets/javascripts/whodat/users.js +2 -0
  25. data/app/assets/stylesheets/whodat/application.css +15 -0
  26. data/app/assets/stylesheets/whodat/dashboard.css +41 -0
  27. data/app/assets/stylesheets/whodat/navbar.css +45 -0
  28. data/app/assets/stylesheets/whodat/sessions.css +4 -0
  29. data/app/assets/stylesheets/whodat/users.css +4 -0
  30. data/app/controllers/whodat/application_controller.rb +30 -0
  31. data/app/controllers/whodat/dashboard_controller.rb +19 -0
  32. data/app/controllers/whodat/sessions_controller.rb +34 -0
  33. data/app/controllers/whodat/users_controller.rb +29 -0
  34. data/app/helpers/whodat/application_helper.rb +12 -0
  35. data/app/helpers/whodat/sessions_helper.rb +19 -0
  36. data/app/jobs/whodat/application_job.rb +4 -0
  37. data/app/mailers/whodat/application_mailer.rb +6 -0
  38. data/app/models/whodat/application_record.rb +5 -0
  39. data/app/models/whodat/user.rb +15 -0
  40. data/app/views/layouts/whodat/application.html.erb +23 -0
  41. data/app/views/whodat/application/_navbar.html.erb +26 -0
  42. data/app/views/whodat/dashboard/_navbar.html.erb +16 -0
  43. data/app/views/whodat/dashboard/index.html.erb +14 -0
  44. data/app/views/whodat/sessions/new.html.erb +29 -0
  45. data/app/views/whodat/users/create.html.erb +2 -0
  46. data/app/views/whodat/users/index.html.erb +2 -0
  47. data/app/views/whodat/users/new.html.erb +34 -0
  48. data/bin/rails +14 -0
  49. data/bin/rspec +29 -0
  50. data/config/routes.rb +15 -0
  51. data/db/migrate/20180717210347_create_whodat_users.rb +12 -0
  52. data/lib/tasks/boolean_as_integer.rake +20 -0
  53. data/lib/tasks/whodat_tasks.rake +4 -0
  54. data/lib/whodat.rb +23 -0
  55. data/lib/whodat/engine.rb +5 -0
  56. data/lib/whodat/version.rb +3 -0
  57. data/spec/controllers/sessions_controller_spec.rb +71 -0
  58. data/spec/controllers/users_controller_spec.rb +104 -0
  59. data/spec/dummy/Rakefile +6 -0
  60. data/spec/dummy/app/assets/config/manifest.js +4 -0
  61. data/spec/dummy/app/assets/javascripts/application.js +14 -0
  62. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  63. data/spec/dummy/app/assets/javascripts/welcome.js +2 -0
  64. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  65. data/spec/dummy/app/assets/stylesheets/welcome.css +100 -0
  66. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  67. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  68. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  69. data/spec/dummy/app/controllers/welcome_controller.rb +4 -0
  70. data/spec/dummy/app/jobs/application_job.rb +2 -0
  71. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  72. data/spec/dummy/app/models/application_record.rb +3 -0
  73. data/spec/dummy/app/views/layouts/application.html.erb +17 -0
  74. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  75. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  76. data/spec/dummy/app/views/welcome/index.html.erb +18 -0
  77. data/spec/dummy/bin/bundle +3 -0
  78. data/spec/dummy/bin/rails +4 -0
  79. data/spec/dummy/bin/rake +4 -0
  80. data/spec/dummy/bin/setup +36 -0
  81. data/spec/dummy/bin/update +31 -0
  82. data/spec/dummy/bin/yarn +11 -0
  83. data/spec/dummy/config.ru +5 -0
  84. data/spec/dummy/config/application.rb +35 -0
  85. data/spec/dummy/config/boot.rb +5 -0
  86. data/spec/dummy/config/cable.yml +10 -0
  87. data/spec/dummy/config/database.yml +25 -0
  88. data/spec/dummy/config/environment.rb +5 -0
  89. data/spec/dummy/config/environments/development.rb +61 -0
  90. data/spec/dummy/config/environments/production.rb +98 -0
  91. data/spec/dummy/config/environments/test.rb +53 -0
  92. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  93. data/spec/dummy/config/initializers/assets.rb +14 -0
  94. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  95. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  96. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  97. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  98. data/spec/dummy/config/initializers/inflections.rb +16 -0
  99. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  100. data/spec/dummy/config/initializers/routes.rb +23 -0
  101. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  102. data/spec/dummy/config/locales/en.yml +33 -0
  103. data/spec/dummy/config/puma.rb +34 -0
  104. data/spec/dummy/config/routes.rb +9 -0
  105. data/spec/dummy/config/spring.rb +6 -0
  106. data/spec/dummy/config/storage.yml +34 -0
  107. data/spec/dummy/db/schema.rb +24 -0
  108. data/spec/dummy/db/seeds.rb +21 -0
  109. data/spec/dummy/package.json +5 -0
  110. data/spec/dummy/public/404.html +67 -0
  111. data/spec/dummy/public/422.html +67 -0
  112. data/spec/dummy/public/500.html +66 -0
  113. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  114. data/spec/dummy/public/apple-touch-icon.png +0 -0
  115. data/spec/dummy/public/favicon.ico +0 -0
  116. data/spec/dummy/spec/controllers/welcome_controller_spec.rb +12 -0
  117. data/spec/factories.rb +8 -0
  118. data/spec/rails_helper.rb +70 -0
  119. data/spec/spec_helper.rb +108 -0
  120. data/spec/support/factory_bot.rb +7 -0
  121. data/whodat-logo-wide.png +0 -0
  122. data/whodat.gemspec +36 -0
  123. metadata +3065 -0
@@ -0,0 +1,29 @@
1
+ <h2>Log in</h2>
2
+
3
+ <% if flash[:notice] %>
4
+ <div class="notice"><%= flash[:notice] %></div>
5
+ <% end %>
6
+
7
+ <div class="row">
8
+ <div class="col-md-8">
9
+ <%= form_for :session, url: sessions_path do |f| %>
10
+ <div class="form-group">
11
+ <%= f.label :name %>
12
+ <%= f.text_field :name, autofocus: true, class: 'form-control', placeholder: "enter name" %>
13
+ </div>
14
+ <div class="form-group">
15
+ <%= f.label :email %>
16
+ <%= f.email_field :email, class: 'form-control', placeholder: "enter email" %>
17
+ </div>
18
+ <div class="form-group">
19
+ <%= f.label :password %>
20
+ <%= f.password_field :password, class: 'form-control', placeholder: "enter password" %>
21
+ </div>
22
+ <div>
23
+ <%= f.submit "sign in", class: 'btn btn-success' %>
24
+ </div>
25
+ <% end %>
26
+ </div>
27
+ </div>
28
+
29
+
@@ -0,0 +1,2 @@
1
+ <h1>Users#create</h1>
2
+ <p>Find me in app/views/whodat/users/create.html.erb</p>
@@ -0,0 +1,2 @@
1
+ <h1>Users#index</h1>
2
+ <p>Find me in app/views/whodat/users/index.html.erb</p>
@@ -0,0 +1,34 @@
1
+ <h2>Create your account</h2>
2
+
3
+ <% if flash[:notice] %>
4
+ <div class="notice"><%= flash[:notice] %></div>
5
+ <% end %>
6
+
7
+ <div class="row">
8
+ <div class="col-md-8">
9
+ <%= form_for @user do |f| %>
10
+ <div class="form-group">
11
+ <%= f.label :name %>
12
+ <%= f.text_field :name, autofocus: true, class: 'form-control', placeholder: "enter name" %>
13
+ </div>
14
+ <div class="form-group">
15
+ <%= f.label :email %>
16
+ <%= f.email_field :email, class: 'form-control', placeholder: "enter email" %>
17
+ </div>
18
+ <div class="form-group">
19
+ <%= f.label :password %>
20
+ <%= f.password_field :password, class: 'form-control', placeholder: "enter password" %>
21
+ </div>
22
+ <div class ="form-group">
23
+ <%= f.label :password_confirmation %>
24
+ <%= f.password_field :password_confirmation, class: 'form-control', placeholder: "confirm password" %>
25
+ </div>
26
+ <div class="form-group">
27
+ <%= f.submit "Create User Account", class: 'btn btn-success' %>
28
+ </div>
29
+ <% end %>
30
+ </div>
31
+ </div>
32
+
33
+
34
+
data/bin/rails ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/whodat/engine', __dir__)
7
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require 'rails/all'
14
+ require 'rails/engine/commands'
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/config/routes.rb ADDED
@@ -0,0 +1,15 @@
1
+ Whodat::Engine.routes.draw do
2
+
3
+ get 'users/index'
4
+ get 'users/new'
5
+ get 'users/create'
6
+ resources :users, only: [:new, :create]
7
+
8
+ resources :sessions, only: [:new, :create, :destroy]
9
+
10
+ root to: 'dashboard#index'
11
+ #root 'dashboard#index'
12
+
13
+ get 'dashboard/index' => 'dashboard#index', as: :dashboard
14
+
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateWhodatUsers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :whodat_users do |t|
4
+ t.string :name
5
+ t.string :email
6
+ t.string :password_digest
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :whodat_users, :email, unique: true
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ desc 'see comment below for error message'
2
+ task :converting_boolean_to_integer do
3
+ ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1)
4
+ ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0)
5
+ end
6
+
7
+ # DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`
8
+ # set to false is deprecated. SQLite databases have used 't' and 'f' to serialize
9
+ # boolean values and must have old data converted to 1 and 0 (its native boolean
10
+ # serialization) before setting this flag to true. Conversion can be accomplished
11
+ # by setting up a rake task which runs
12
+
13
+ # ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1)
14
+ # ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0)
15
+
16
+ # for all models and all boolean columns, after which the flag must be set to
17
+ # true by adding the following to your application.rb file:
18
+
19
+ # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
20
+ # (called from <top (required)> at /Users/bperlik/code/bloc/whodat/spec/rails_helper.rb:31)
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :whodat do
3
+ # # Task goes here
4
+ # end
data/lib/whodat.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "whodat/engine"
2
+
3
+ module Whodat
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Whodat
6
+
7
+ initializer "whodat.load_helpers" do
8
+ ActiveSupport.on_load(:action_controller) do
9
+ helper Whodat::Engine.helpers
10
+ end
11
+ end
12
+
13
+ initializer :assets do |config|
14
+ Rails.application.config.assets.paths << root.join("app", "assets", "images", "whodat")
15
+ end
16
+
17
+ initializer "whodat.assets.precompile" do |app|
18
+ app.config.assets.precompile += %w( application_controller.rb )
19
+ end
20
+
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ module Whodat
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Whodat
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Whodat
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,71 @@
1
+ require 'rails_helper'
2
+
3
+ def main_app
4
+ Rails.application.class.routes.url_helpers
5
+ end
6
+
7
+ main_app.root_path
8
+
9
+ RSpec.describe Whodat::SessionsController, type: :controller do
10
+ routes { Whodat::Engine.routes }
11
+
12
+ # let(:my_user) { User.create!(name: "Testname", email: "test@test.io", password: "password", password_confirmation: "password") }
13
+ let(:my_user) { create(:user) }
14
+
15
+ describe "GET new" do
16
+ it "returns http success" do
17
+ get :new
18
+ expect(response).to have_http_status(:success)
19
+ end
20
+ end
21
+
22
+ describe "POST create" do
23
+ it "returns http success" do
24
+ post :create, :params => { :session => { email: my_user.email } }
25
+ expect(response).to have_http_status(:success)
26
+ end
27
+
28
+ it "initializes a session" do
29
+ post :create, params: { session: { email: my_user.email } }
30
+ expect(session[:user_id]).to eq assigns(my_user.id)
31
+ end
32
+
33
+ it "does not add a user id to session due to missing password" do
34
+ post :create, params: { session: { email: my_user.email } }
35
+ expect(session[:user_id]).to be_nil
36
+ end
37
+
38
+ it "flashes #error with bad email address" do
39
+ post :create, :params => { :session => { email: "not a good email address" } }
40
+ expect(flash.now[:notice]).to be_present
41
+ end
42
+
43
+ it "renders #new with bad email address" do
44
+ post :create, :params => { :session => { email: "not a good email address" } }
45
+ expect(response).to render_template :new
46
+ end
47
+
48
+ it "redirects to the root view" do
49
+ post :create, :params => { :session => { name: my_user.name, email: my_user.email, password: my_user.password } }
50
+ expect(response).to redirect_to(main_app.root_path)
51
+ end
52
+ end
53
+
54
+ describe "DELETE sessions/id" do
55
+ it "render the #welcome view" do
56
+ delete :destroy, :params => { id: (my_user.id) }
57
+ expect(response).to redirect_to (main_app.root_path)
58
+ end
59
+
60
+ it "deletes the user's session" do
61
+ delete :destroy, :params => { id: (my_user.id) }
62
+ expect(assigns(:session)).to be_nil
63
+ end
64
+
65
+ it "flashes #notice" do
66
+ delete :destroy, :params => { id: (my_user.id) }
67
+ expect(flash[:notice]).to be_present
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,104 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe Whodat::UsersController, :type => :controller do
4
+ routes { Whodat::Engine.routes }
5
+
6
+ #create a hash of attributes to use throughout spec
7
+ let(:new_user_attributes) do
8
+ {
9
+ name: "TestName",
10
+ email: "testemail@test.io",
11
+ password: "password",
12
+ password_confirmation: "password"
13
+ }
14
+ end
15
+
16
+ # add tests for new for response & instantiate a new user
17
+ describe "GET new" do
18
+ it "returns http success" do
19
+ get :new
20
+ expect(response).to have_http_status(:success)
21
+ end
22
+
23
+ it "instantiates a new user" do
24
+ get :new
25
+ expect(assigns(:user)).to_not be_nil
26
+ end
27
+ end
28
+
29
+ # Test for http success when issuing post with new_user_attributes
30
+ describe "POST create" do
31
+ it "returns an http redirect" do
32
+ post :create, :params => { :user => new_user_attributes } # Riz recommended
33
+ # post :create, users: new_user_attributes
34
+ expect(response).to redirect_to(main_app.root_path)
35
+ end
36
+
37
+ # Test that users table increases by one
38
+ it "creates a new user" do
39
+ expect{
40
+ post :create, :params => { :user => {
41
+ name: "TestName",
42
+ email: "testemail@test.io",
43
+ password: "password",
44
+ password_confirmation: "password" }
45
+ }
46
+ }.to change(Whodat::User, :count).by(1)
47
+ end
48
+
49
+ # Test that user.name is set to new name
50
+ it "sets user name properly" do
51
+ post :create, :params => { :user => {
52
+ name: "TestName",
53
+ email: "testemail@test.io",
54
+ password: "password",
55
+ password_confirmation: "password" }
56
+ }
57
+ expect(assigns(:user).name).to eq new_user_attributes[:name]
58
+ end
59
+
60
+ # Test that user.email is set
61
+ it "sets user email properly" do
62
+ post :create, :params => { :user => {
63
+ name: "TestName",
64
+ email: "testemail@test.io",
65
+ password: "password",
66
+ password_confirmation: "password" }
67
+ }
68
+ expect(assigns(:user).email).to eq new_user_attributes[:email]
69
+ end
70
+
71
+ # Test that user.password is set
72
+ it "sets user password properly" do
73
+ post :create, :params => { :user => {
74
+ name: "TestName",
75
+ email: "testemail@test.io",
76
+ password: "password",
77
+ password_confirmation: "password" }
78
+ }
79
+ expect(assigns(:user).password).to eq new_user_attributes[:password]
80
+ end
81
+
82
+ # Test that password confirmation is set
83
+ it "sets user password_confirmation properly" do
84
+ post :create, :params => { :user => {
85
+ name: "TestName",
86
+ email: "testemail@test.io",
87
+ password: "password",
88
+ password_confirmation: "password" }
89
+ }
90
+ expect(assigns(:user).password_confirmation).to eq new_user_attributes[:password_confirmation]
91
+ end
92
+
93
+ # Test that the session opens for user
94
+ it "logs the user in after sign up" do
95
+ post :create, :params => { :user => {
96
+ name: "TestName",
97
+ email: "testemail@test.io",
98
+ password: "password",
99
+ password_confirmation: "password" }
100
+ }
101
+ expect(session[:user_id]).to eq assigns(:user).id
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
4
+ //= link whodat_manifest.js
@@ -0,0 +1,14 @@
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 any plugin's vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.