jinda 0.2.9 → 0.3.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/README.md +1 -1
- data/lib/generators/jinda/config_generator.rb +2 -1
- data/lib/generators/jinda/install_generator.rb +1 -0
- data/lib/generators/jinda/templates/app/models/jinda/user.rb +5 -0
- data/lib/generators/jinda/templates/app/views/jinda/index.html.haml +1 -1
- data/lib/generators/jinda/templates/spec/controllers/sessions_controller_spec.rb +9 -15
- data/lib/generators/jinda/templates/spec/features/userlogins_spec.rb +1 -1
- data/lib/generators/jinda/templates/spec/models/user_spec.rb +12 -0
- data/lib/generators/jinda/templates/spec/spec_helper.rb +11 -48
- data/lib/generators/jinda/templates/spec/support/factory_bot.rb +1 -1
- data/lib/jinda/version.rb +1 -1
- metadata +3 -3
- data/lib/generators/jinda/templates/spec/models/user_spec.rbx +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567b8dc24404ca3a968b2d10b839c3a963262f0a8ac1d3467e4c7e26d5bef3dd
|
4
|
+
data.tar.gz: aabeee85f5f36c04842249aba34e28527523dfa1342be37812c2a8cfe1adff25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23f83eec02e541752afc67c5749907621f1987c93f29e442ca89e37154d7bffe6793b15286a7cc0882166ea19e50786e56ae2263587a2d220d2af8bd8f3ccaef
|
7
|
+
data.tar.gz: 55dc1154aeb252884d8291d9e3a214a1b330bbfa28b91e500bf64c48351e64f8c4cdb94307f5967efc0fc6514cf53e31da021c2f33c0e7f08084aa0d052cd4f6
|
data/README.md
CHANGED
@@ -84,6 +84,7 @@ end
|
|
84
84
|
puts " To config rspect run:"
|
85
85
|
puts "-----------------------------------------\n"
|
86
86
|
puts "rails g jinda:rspec\n"
|
87
|
+
puts "run $chromediver for Capybara & Chrome\n"
|
87
88
|
puts "-----------------------------------------\n"
|
88
89
|
puts " To config minitest run:"
|
89
90
|
puts "-----------------------------------------\n"
|
@@ -93,7 +94,7 @@ end
|
|
93
94
|
puts "-----------------------------------------\n"
|
94
95
|
puts "Please config. in .env or restore from .env-bak \n"
|
95
96
|
puts "-----------------------------------------\n"
|
96
|
-
|
97
|
+
end
|
97
98
|
end
|
98
99
|
end
|
99
100
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Jinda::User
|
2
2
|
include Mongoid::Document
|
3
|
+
# https://docs.mongodb.com/mongoid/master/tutorials/mongoid-indexes/
|
4
|
+
index({ code: 1 }, { unique: true, name: "code_index" })
|
3
5
|
before_create {generate_token(:auth_token)}
|
4
6
|
field :provider, :type => String
|
5
7
|
field :uid, :type => String
|
@@ -14,6 +16,9 @@ class Jinda::User
|
|
14
16
|
|
15
17
|
belongs_to :identity, :polymorphic => true, :optional => true
|
16
18
|
has_many :xmains, :class_name => "Jinda::Xmain"
|
19
|
+
validates :code,
|
20
|
+
presence: true,
|
21
|
+
uniqueness: true
|
17
22
|
|
18
23
|
## Add to create forgot password
|
19
24
|
def generate_token(column)
|
@@ -1,22 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# sessions_controller_spec.rb
|
2
|
+
# 1. Set up the mock
|
3
|
+
# 2. Make the request
|
4
|
+
# 3. Test whatever code is attached to the callback
|
5
|
+
# require 'spec_helper'
|
6
|
+
require 'rails_helper'
|
4
7
|
describe SessionsController do
|
5
8
|
|
6
9
|
describe "Google" do
|
7
10
|
|
8
11
|
before do
|
12
|
+
|
9
13
|
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:google_oauth2]
|
14
|
+
visit '/auth/google_oauth2'
|
10
15
|
end
|
11
16
|
|
12
17
|
describe "#create" do
|
13
18
|
|
14
|
-
it "should successfully create a user" do
|
15
|
-
expect {
|
16
|
-
post :create, params: {provider: :google_oauth2}
|
17
|
-
}.to change{ Jinda::User.count }.by(1)
|
18
|
-
end
|
19
|
-
|
20
19
|
it "should successfully create a session" do
|
21
20
|
session[:user_id].should be_nil
|
22
21
|
post :create, params: {provider: :google_oauth2}
|
@@ -54,16 +53,11 @@ describe SessionsController do
|
|
54
53
|
|
55
54
|
before do
|
56
55
|
request.env['omniauth.auth'] = OmniAuth.config.mock_auth[:facebook]
|
56
|
+
visit '/auth/facebook'
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "#create" do
|
60
60
|
|
61
|
-
it "should successfully create a user" do
|
62
|
-
expect {
|
63
|
-
post :create, params: {provider: :facebook}
|
64
|
-
}.to change{ Jinda::User.count }.by(1)
|
65
|
-
end
|
66
|
-
|
67
61
|
it "should successfully create a session" do
|
68
62
|
session[:user_id].should be_nil
|
69
63
|
post :create, params: {provider: :facebook}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe "Jinda::User", :type => :model do
|
4
|
+
it "prevents duplicates " do
|
5
|
+
user1 = create(:user, code: 'abc', email: 'test@email.com')
|
6
|
+
user2 = build(:user, code: 'abc', email: 'test@email.com')
|
7
|
+
|
8
|
+
user1.should be_valid
|
9
|
+
#user2.should be_valid
|
10
|
+
user2.should_not have_valid(:code)
|
11
|
+
end
|
12
|
+
end
|
@@ -2,54 +2,10 @@
|
|
2
2
|
# spec_helper.rb
|
3
3
|
require 'rubygems'
|
4
4
|
require 'capybara/rspec'
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
'uid' => '105362273761620533373',
|
9
|
-
'info' => {
|
10
|
-
'name' => 'Kulsoft',
|
11
|
-
'email' => 'kulsoft.net@gmail.com',
|
12
|
-
'nickname' => 'kulsoft'
|
13
|
-
},
|
14
|
-
'extra' => {'raw_info' =>
|
15
|
-
{ 'location' => 'San Francisco',
|
16
|
-
'gravatar_id' => '123456789'
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
OmniAuth.config.add_mock(:google_oauth2, omniauth_hash)
|
5
|
+
# Set up the mock
|
6
|
+
require 'support/omniauth_macros'
|
7
|
+
require 'valid_attribute'
|
21
8
|
|
22
|
-
omniauth_hash = { 'provider' => 'facebook',
|
23
|
-
'uid' => '105362273761620533373',
|
24
|
-
'info' => {
|
25
|
-
'name' => 'Peter Colling',
|
26
|
-
'email' => '1.0@kul.asia',
|
27
|
-
'nickname' => 'Peter C'
|
28
|
-
},
|
29
|
-
'extra' => {'raw_info' =>
|
30
|
-
{'location' => 'LA',
|
31
|
-
'gravatar_id' => '13'
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
OmniAuth.config.add_mock(:facebook, omniauth_hash)
|
36
|
-
|
37
|
-
|
38
|
-
###########################################################################################
|
39
|
-
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
40
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
41
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
42
|
-
# this file to always be loaded, without a need to explicitly require it in any
|
43
|
-
# files.
|
44
|
-
#
|
45
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
46
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
47
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
48
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
49
|
-
# a separate helper file that requires the additional dependencies and performs
|
50
|
-
# the additional setup, and require it from the spec files that actually need
|
51
|
-
# it.
|
52
|
-
#
|
53
9
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
54
10
|
RSpec.configure do |config|
|
55
11
|
# config.include SpecTestHelper, :type => :controller
|
@@ -63,8 +19,15 @@ RSpec.configure do |config|
|
|
63
19
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
64
20
|
|
65
21
|
# https://github.com/DatabaseCleaner/database_cleaner #
|
66
|
-
|
67
22
|
config.use_transactional_fixtures = false
|
23
|
+
# https://stackoverflow.com/questions/15148585/undefined-method-visit-when-using-rspec-and-capybara-in-rails
|
24
|
+
config.include Capybara::DSL
|
25
|
+
|
26
|
+
# https://stackoverflow.com/questions/21445164/set-chrome-as-default-browser-for-rspec-capybara/30551595
|
27
|
+
Capybara.register_driver :chrome do |app|
|
28
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
29
|
+
end
|
30
|
+
Capybara.javascript_driver = :chrome
|
68
31
|
|
69
32
|
config.before(:suite) do
|
70
33
|
if config.use_transactional_fixtures?
|
data/lib/jinda/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jinda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Prateep Kul
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-10-
|
12
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -429,7 +429,7 @@ files:
|
|
429
429
|
- lib/generators/jinda/templates/seeds.rb
|
430
430
|
- lib/generators/jinda/templates/spec/controllers/sessions_controller_spec.rb
|
431
431
|
- lib/generators/jinda/templates/spec/features/userlogins_spec.rb
|
432
|
-
- lib/generators/jinda/templates/spec/models/user_spec.
|
432
|
+
- lib/generators/jinda/templates/spec/models/user_spec.rb
|
433
433
|
- lib/generators/jinda/templates/spec/rails_helper.rb
|
434
434
|
- lib/generators/jinda/templates/spec/spec_helper.rb
|
435
435
|
- lib/generators/jinda/templates/spec/support/factory_bot.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
# RSpec.describe "Jinda::User", :type => :model do
|
4
|
-
RSpec.describe "Jinda/User", :type => :model do
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
@user1 = create "Jinda/User"
|
8
|
-
end
|
9
|
-
|
10
|
-
it "has a unique code name" do
|
11
|
-
user2 = build("Jinda/User", code: "tester", email: "tester@test.com")
|
12
|
-
expect(user2).to be_valid
|
13
|
-
end
|
14
|
-
|
15
|
-
it "is valid with valid attributes" do
|
16
|
-
expect(@user1).to be_valid
|
17
|
-
end
|
18
|
-
|
19
|
-
xit "is not valid without a code" do
|
20
|
-
user2 = build("Jinda/User", code: nil)
|
21
|
-
expect(user2).to_not be_valid
|
22
|
-
end
|
23
|
-
|
24
|
-
xit "is not valid without an email" do
|
25
|
-
user2 = build("Jinda/User", email: nil)
|
26
|
-
expect(user2).to_not be_valid
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|