happy_seed 0.0.13 → 0.0.14
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/happy_seed.rb +24 -9
- data/lib/.DS_Store +0 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/happy_seed/.DS_Store +0 -0
- data/lib/generators/happy_seed/admin/admin_generator.rb +1 -1
- data/lib/generators/happy_seed/admin/templates/spec/controllers/admin/stats_controller_spec.rb +6 -6
- data/lib/generators/happy_seed/base/.DS_Store +0 -0
- data/lib/generators/happy_seed/base/base_generator.rb +10 -2
- data/lib/generators/happy_seed/base/templates/.DS_Store +0 -0
- data/lib/generators/happy_seed/base/templates/spec/.DS_Store +0 -0
- data/lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb +12 -0
- data/lib/generators/happy_seed/devise/devise_generator.rb +1 -1
- data/lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc +4 -1
- data/lib/generators/happy_seed/devise/templates/spec/.DS_Store +0 -0
- data/lib/generators/happy_seed/facebook/templates/docs/README.06.facebook.rdoc +0 -1
- data/lib/generators/happy_seed/github/github_generator.rb +24 -0
- data/lib/generators/happy_seed/github/templates/docs/README.06.github.rdoc +28 -0
- data/lib/generators/happy_seed/googleoauth/googleoauth_generator.rb +2 -3
- data/lib/generators/happy_seed/googleoauth/templates/app/models/google_apps_client.rb +62 -0
- data/lib/generators/happy_seed/splash/splash_generator.rb +1 -0
- data/lib/happy_seed/version.rb +1 -1
- data/test/dummy/log/test.log +5 -0
- metadata +12 -3
- data/lib/generators/happy_seed/googleoauth/templates/lib/google_api_client.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e17008087370b971db64b54abfff2ffdccccb89
|
4
|
+
data.tar.gz: 989a07389f09f8ba42d1747e84d5444bed345541
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43fce02fc87d2f163da0f9ff88d616205743858e3e663754219274c3d1d8d299063856745ea933a217a74b368803918961fd21a8d4cf2783efa7af74827845dd
|
7
|
+
data.tar.gz: 7b02cd24a4ff463a1e4a949084a9ca8b281fd9cc60dcbfdf33831b6b73500b2504f445f084c1001ff3a877844516c01dee4aa0789ccd48532da750d0cc38289c
|
data/happy_seed.rb
CHANGED
@@ -16,8 +16,10 @@ gem_group :development, :test do
|
|
16
16
|
gem "guard-cucumber"
|
17
17
|
gem "database_cleaner"
|
18
18
|
gem "spring-commands-rspec"
|
19
|
+
gem 'spring-commands-cucumber'
|
19
20
|
gem "quiet_assets"
|
20
21
|
gem "launchy"
|
22
|
+
gem "vcr"
|
21
23
|
end
|
22
24
|
|
23
25
|
gem_group :test do
|
@@ -34,6 +36,8 @@ else
|
|
34
36
|
gem 'happy_seed'
|
35
37
|
end
|
36
38
|
|
39
|
+
packages = []
|
40
|
+
|
37
41
|
Bundler.with_clean_env do
|
38
42
|
run "bundle install > /dev/null"
|
39
43
|
|
@@ -66,8 +70,6 @@ After{ Warden.test_reset! }"
|
|
66
70
|
all_in = false
|
67
71
|
all_in = true if yes? "Would you like to install everything?"
|
68
72
|
|
69
|
-
packages = []
|
70
|
-
|
71
73
|
if all_in || yes?( "Would you like to install jazz hands?" )
|
72
74
|
generate "happy_seed:jazz_hands"
|
73
75
|
packages << "jazz_hands"
|
@@ -92,20 +94,33 @@ After{ Warden.test_reset! }"
|
|
92
94
|
packages << "devise_invitable"
|
93
95
|
end
|
94
96
|
|
95
|
-
if all_in || yes?( "Would you like to install twitter?" )
|
96
|
-
generate "happy_seed:twitter"
|
97
|
-
packages << "twitter"
|
98
|
-
end
|
99
97
|
|
100
|
-
|
98
|
+
all_connectors = yes?( "Would you like to install all of the oauth connectors?" )
|
99
|
+
|
100
|
+
if all_connectors || yes?( "Would you like to install facebook connect?" )
|
101
101
|
generate "happy_seed:facebook"
|
102
102
|
packages << "facebook"
|
103
103
|
end
|
104
104
|
|
105
|
-
if
|
105
|
+
if all_connectors || yes?( "Would you like to install github?" )
|
106
|
+
generate "happy_seed:github"
|
107
|
+
packages << "github"
|
108
|
+
end
|
109
|
+
|
110
|
+
if all_connectors || yes?( "Would you like to install google authentication?" )
|
111
|
+
generate "happy_seed:googleoauth"
|
112
|
+
packages << "googleoauth"
|
113
|
+
end
|
114
|
+
|
115
|
+
if all_connectors || yes?( "Would you like to install instagram?" )
|
106
116
|
generate "happy_seed:instagram"
|
107
117
|
packages << "instagram"
|
108
118
|
end
|
119
|
+
|
120
|
+
if all_connectors || yes?( "Would you like to install twitter?" )
|
121
|
+
generate "happy_seed:twitter"
|
122
|
+
packages << "twitter"
|
123
|
+
end
|
109
124
|
end
|
110
125
|
|
111
126
|
if all_in || yes?( "Would you like to install active admin?" )
|
@@ -122,4 +137,4 @@ After{ Warden.test_reset! }"
|
|
122
137
|
git :init
|
123
138
|
git add: "."
|
124
139
|
git commit: "-a -m 'Based off of happy_seed: #{packages.join( ', ')} included'"
|
125
|
-
end
|
140
|
+
end
|
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -6,7 +6,7 @@ module HappySeed
|
|
6
6
|
def install_landing_page
|
7
7
|
gem 'devise'
|
8
8
|
gem 'activeadmin', github: 'activeadmin', branch: 'master'
|
9
|
-
gem 'inherited_resources', github: 'josevalim/inherited_resources', branch: 'rails-4-2'
|
9
|
+
gem 'inherited_resources' # , github: 'josevalim/inherited_resources', branch: 'rails-4-2'
|
10
10
|
gem 'dateslices'
|
11
11
|
|
12
12
|
Bundler.with_clean_env do
|
data/lib/generators/happy_seed/admin/templates/spec/controllers/admin/stats_controller_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe Admin::StatsController, :type => :controller do
|
4
|
-
before( :each ) do
|
5
|
-
|
6
|
-
|
7
|
-
end
|
4
|
+
# before( :each ) do
|
5
|
+
# @request.env["devise.mapping"] = Devise.mappings[:admin_user]
|
6
|
+
# # @request.env["warden"] ||= Whatever.new
|
7
|
+
# end
|
8
8
|
|
9
9
|
it "should require the scope param" do
|
10
|
-
|
10
|
+
login_with create( :admin_user ), :admin_user
|
11
11
|
|
12
12
|
get :stats, scope: ''
|
13
13
|
expect( response.status ).to eq( 422 )
|
@@ -16,7 +16,7 @@ RSpec.describe Admin::StatsController, :type => :controller do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should return data for a logged in user" do
|
19
|
-
|
19
|
+
login_with create( :admin_user ), :admin_user
|
20
20
|
|
21
21
|
get :stats, scope: 'user'
|
22
22
|
expect( response.status ).to eq( 200 )
|
Binary file
|
@@ -21,6 +21,13 @@ module HappySeed
|
|
21
21
|
inject_into_file 'app/controllers/application_controller.rb', File.read( find_in_source_paths('application_controller.rb') ), :after=>/protect_from_forgery.*\n/
|
22
22
|
inject_into_file 'config/environments/test.rb', " config.log_level = :error\n", before: "end\n"
|
23
23
|
|
24
|
+
begin
|
25
|
+
inject_into_file 'spec/spec_helper.rb', "\n config.include ControllerHelpers\n Warden.test_mode!\n", :before => "\nend\n"
|
26
|
+
rescue
|
27
|
+
say_status :spec, "Unable to add login helpers to spec_helper.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
|
24
31
|
begin
|
25
32
|
inject_into_file 'spec/rails_helper.rb', "require 'webmock/rspec'\n", after: "'rspec/rails'\n"
|
26
33
|
rescue
|
@@ -28,9 +35,10 @@ module HappySeed
|
|
28
35
|
end
|
29
36
|
|
30
37
|
begin
|
31
|
-
inject_into_file 'spec/rails_helper.rb', "\n config.include FactoryGirl::Syntax::Methods\n", :before => "\nend\n"
|
38
|
+
inject_into_file 'spec/rails_helper.rb', "\n config.include Devise::TestHelpers, type: :controller\n config.include Warden::Test::Helpers, type: :feature\n config.include FactoryGirl::Syntax::Methods\n", :before => "\nend\n"
|
39
|
+
append_to_file 'spec/rails_helper.rb', "\nVCR.configure do |c|\n c.cassette_library_dir = Rails.root.join('spec', 'vcr')\n c.hook_into :webmock\nend\n"
|
32
40
|
rescue
|
33
|
-
say_status :spec, "Unable to add factory girl to rails_helper.rb", :red
|
41
|
+
say_status :spec, "Unable to add factory girl and VCR to rails_helper.rb", :red
|
34
42
|
end
|
35
43
|
|
36
44
|
route "get '/setup' => 'setup#index'"
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ControllerHelpers
|
2
|
+
def login_with(user = double('user'), scope = :user)
|
3
|
+
current_user = "current_#{scope}".to_sym
|
4
|
+
if user.nil?
|
5
|
+
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => scope})
|
6
|
+
allow(controller).to receive(current_user).and_return(nil)
|
7
|
+
else
|
8
|
+
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
|
9
|
+
allow(controller).to receive(current_user).and_return(user)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -32,7 +32,7 @@ module HappySeed
|
|
32
32
|
|
33
33
|
begin
|
34
34
|
prepend_to_file 'spec/spec_helper.rb', "require 'devise'\n"
|
35
|
-
|
35
|
+
prepend_to_file 'spec/spec_helper.rb', "require_relative 'support/controller_helpers'\n"
|
36
36
|
rescue
|
37
37
|
say_status :spec, "Unable to add devise helpers to spec_helper.rb", :red
|
38
38
|
end
|
@@ -23,4 +23,7 @@ na
|
|
23
23
|
|
24
24
|
Take a look at the user model to see if you want to configure any other features in devise. Look at the migration to see if there are any other fields you wish the users to have.
|
25
25
|
|
26
|
-
Once you feel good about it run "rake db:migrate" and you should be good to go.
|
26
|
+
Once you feel good about it run "rake db:migrate" and you should be good to go.
|
27
|
+
|
28
|
+
## Writing tests
|
29
|
+
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
|
3
|
+
module HappySeed
|
4
|
+
module Generators
|
5
|
+
class GithubGenerator < HappySeedGenerator
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def install_github
|
9
|
+
require_omniauth
|
10
|
+
|
11
|
+
gem 'omniauth-github'
|
12
|
+
gem 'github_api'
|
13
|
+
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
run "bundle install > /dev/null"
|
16
|
+
end
|
17
|
+
|
18
|
+
directory 'docs'
|
19
|
+
|
20
|
+
add_omniauth :github, "user", "Github"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
HappySeed Github Install
|
2
|
+
====================
|
3
|
+
|
4
|
+
### What does this do?
|
5
|
+
|
6
|
+
The `happy_seed:github` depends upon `happy_seed:omniauth` and
|
7
|
+
|
8
|
+
* Installs github authentication
|
9
|
+
* Installs github api gem
|
10
|
+
|
11
|
+
### Why do you want this?
|
12
|
+
|
13
|
+
If you want to have the user connect via github, this is the one line command for it.
|
14
|
+
|
15
|
+
### Environment Variables
|
16
|
+
|
17
|
+
```
|
18
|
+
GITHUB_APP_ID=
|
19
|
+
GITHUB_APP_SECRET=
|
20
|
+
```
|
21
|
+
|
22
|
+
### What needs to be done?
|
23
|
+
|
24
|
+
In config/initializers/devise.rb make sure that the scope you are requesting is correct.
|
25
|
+
|
26
|
+
Since you need to set the callbacks as urls, you'll need to create one app for local development and another app for production. (Possibly one for staging as well.)
|
27
|
+
|
28
|
+
https://github.com/settings/applications
|
@@ -17,10 +17,9 @@ module HappySeed
|
|
17
17
|
end
|
18
18
|
|
19
19
|
directory 'docs'
|
20
|
-
directory '
|
20
|
+
directory 'app'
|
21
21
|
|
22
|
-
add_omniauth :google_oauth2, 'email,profile,offline", prompt: "consent', '
|
23
|
-
prepend_file "app/models/user.rb", "require 'google_api_client'\n"
|
22
|
+
add_omniauth :google_oauth2, 'email,profile,offline", prompt: "consent', 'GoogleAppsClient', "google_oauth2"
|
24
23
|
insert_into_file "app/models/identity.rb", "\n identity.refreshtoken = auth.credentials.refresh_token", after: "identity.accesstoken = auth.credentials.token"
|
25
24
|
migration_template("add_refresh_token_to_identity.rb", "db/migrate/add_refresh_token_to_identity.rb" )
|
26
25
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class GoogleAppsClient
|
2
|
+
def initialize( client )
|
3
|
+
@client = client
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.client( identity )
|
7
|
+
client = Google::APIClient.new(:application_name => 'HappySeed App', :application_version => "1.0.0" )
|
8
|
+
client.authorization.update_token!({:access_token => identity.accesstoken, :refresh_token => identity.refreshtoken})
|
9
|
+
GoogleAppsClient.new( client )
|
10
|
+
end
|
11
|
+
|
12
|
+
def admin_api
|
13
|
+
@admin_api ||= @client.discovered_api("admin", "directory_v1")
|
14
|
+
end
|
15
|
+
|
16
|
+
def list_users( domain = "happyfuncorp.com" )
|
17
|
+
request = { api_method: admin_api.users.list }
|
18
|
+
request[:parameters] = { domain: domain }
|
19
|
+
@client.execute request
|
20
|
+
end
|
21
|
+
|
22
|
+
def is_valid_user?( email, domain = "happyfuncorp.com" )
|
23
|
+
users = list_users( domain )
|
24
|
+
users.data['users'].each do |user|
|
25
|
+
if user['primaryEmail'].downcase == email.downcase
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
def ensure_user( email, first_name, last_name )
|
33
|
+
if !is_valid_user?( email )
|
34
|
+
new_user = admin_api.users.insert.request_schema.new({
|
35
|
+
'password' => 'happiness4u',
|
36
|
+
'primaryEmail' => email,
|
37
|
+
'name' => {
|
38
|
+
'familyName' => last_name,
|
39
|
+
'givenName' => first_name
|
40
|
+
},
|
41
|
+
changePasswordAtNextLogin: true
|
42
|
+
})
|
43
|
+
|
44
|
+
result = @client.execute(
|
45
|
+
:api_method => admin_api.users.insert,
|
46
|
+
:body_object => new_user
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def list_groups( domain = "happyfuncorp.com" )
|
52
|
+
request = { api_method: admin_api.groups.list }
|
53
|
+
request[:parameters] = { domain: domain }
|
54
|
+
@client.execute request
|
55
|
+
end
|
56
|
+
|
57
|
+
def list_members( group_key )
|
58
|
+
request = { api_method: admin_api.members.list }
|
59
|
+
request[:parameters] = { groupKey: group_key }
|
60
|
+
@client.execute request
|
61
|
+
end
|
62
|
+
end
|
data/lib/happy_seed/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -6,5 +6,10 @@ HappySeedTest: test_truth
|
|
6
6
|
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
7
7
|
-------------------------
|
8
8
|
HappySeedTest: test_truth
|
9
|
+
-------------------------
|
10
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
11
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
12
|
+
-------------------------
|
13
|
+
HappySeedTest: test_truth
|
9
14
|
-------------------------
|
10
15
|
[1m[35m (0.0ms)[0m rollback transaction
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happy_seed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Schenk
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -66,6 +66,8 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- bin/happy_seed
|
68
68
|
- happy_seed.rb
|
69
|
+
- lib/.DS_Store
|
70
|
+
- lib/generators/.DS_Store
|
69
71
|
- lib/generators/happy_seed/.DS_Store
|
70
72
|
- lib/generators/happy_seed/admin/admin_generator.rb
|
71
73
|
- lib/generators/happy_seed/admin/templates/app/admin/campaigns.rb
|
@@ -88,7 +90,9 @@ files:
|
|
88
90
|
- lib/generators/happy_seed/angular_view/templates/app/assets/javascripts/controllers/controller.js.coffee
|
89
91
|
- lib/generators/happy_seed/angular_view/templates/app/assets/templates/view.html
|
90
92
|
- lib/generators/happy_seed/angular_view/templates/docs/README.11.angular_view.rdoc
|
93
|
+
- lib/generators/happy_seed/base/.DS_Store
|
91
94
|
- lib/generators/happy_seed/base/base_generator.rb
|
95
|
+
- lib/generators/happy_seed/base/templates/.DS_Store
|
92
96
|
- lib/generators/happy_seed/base/templates/.env
|
93
97
|
- lib/generators/happy_seed/base/templates/.foreman
|
94
98
|
- lib/generators/happy_seed/base/templates/Procfile
|
@@ -98,8 +102,10 @@ files:
|
|
98
102
|
- lib/generators/happy_seed/base/templates/config/unicorn.rb
|
99
103
|
- lib/generators/happy_seed/base/templates/docs/README.00.base.rdoc
|
100
104
|
- lib/generators/happy_seed/base/templates/lib/tasks/haml2erb.rake
|
105
|
+
- lib/generators/happy_seed/base/templates/spec/.DS_Store
|
101
106
|
- lib/generators/happy_seed/base/templates/spec/controllers/application_controller_spec.rb
|
102
107
|
- lib/generators/happy_seed/base/templates/spec/controllers/setup_controller_spec.rb
|
108
|
+
- lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb
|
103
109
|
- lib/generators/happy_seed/bootstrap/bootstrap_generator.rb
|
104
110
|
- lib/generators/happy_seed/bootstrap/templates/app/assets/javascripts/application.js
|
105
111
|
- lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application.css.scss
|
@@ -128,6 +134,7 @@ files:
|
|
128
134
|
- lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml
|
129
135
|
- lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml
|
130
136
|
- lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc
|
137
|
+
- lib/generators/happy_seed/devise/templates/spec/.DS_Store
|
131
138
|
- lib/generators/happy_seed/devise/templates/spec/factories/users.rb
|
132
139
|
- lib/generators/happy_seed/devise/templates/spec/features/forgot_password_spec.rb
|
133
140
|
- lib/generators/happy_seed/devise/templates/test/mailers/previews/devise_preview.rb
|
@@ -137,12 +144,14 @@ files:
|
|
137
144
|
- lib/generators/happy_seed/devise_invitable/templates/docs/README.03.devise_invitable.rdoc
|
138
145
|
- lib/generators/happy_seed/facebook/facebook_generator.rb
|
139
146
|
- lib/generators/happy_seed/facebook/templates/docs/README.06.facebook.rdoc
|
147
|
+
- lib/generators/happy_seed/github/github_generator.rb
|
148
|
+
- lib/generators/happy_seed/github/templates/docs/README.06.github.rdoc
|
140
149
|
- lib/generators/happy_seed/googleoauth/.DS_Store
|
141
150
|
- lib/generators/happy_seed/googleoauth/googleoauth_generator.rb
|
142
151
|
- lib/generators/happy_seed/googleoauth/templates/.DS_Store
|
143
152
|
- lib/generators/happy_seed/googleoauth/templates/add_refresh_token_to_identity.rb
|
153
|
+
- lib/generators/happy_seed/googleoauth/templates/app/models/google_apps_client.rb
|
144
154
|
- lib/generators/happy_seed/googleoauth/templates/docs/README.06.googleoauth.rdoc
|
145
|
-
- lib/generators/happy_seed/googleoauth/templates/lib/google_api_client.rb
|
146
155
|
- lib/generators/happy_seed/happy_seed_generator.rb
|
147
156
|
- lib/generators/happy_seed/instagram/instagram_generator.rb
|
148
157
|
- lib/generators/happy_seed/instagram/templates/docs/README.05.instagram.rdoc
|
@@ -1,7 +0,0 @@
|
|
1
|
-
class GoogleApiClient
|
2
|
-
def self.client( identity )
|
3
|
-
client = Google::APIClient.new(:application_name => 'HappySeed App', :application_version => "1.0.0" )
|
4
|
-
client.authorization.update_token!({:access_token => identity.accesstoken, :refresh_token => identity.refreshtoken})
|
5
|
-
client
|
6
|
-
end
|
7
|
-
end
|