Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rendezvous
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
rendezvous
Commits
1e2c9a53
Commit
1e2c9a53
authored
Mar 09, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup turnip & devise login mock
parent
a44eaa40
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
16 deletions
+61
-16
Gemfile
+1
-1
app/models/user.rb
+5
-5
app/views/home/login.html.erb
+1
-0
app/views/posts/index.html.erb
+1
-0
spec/acceptance/access.feature
+34
-0
spec/acceptance/attack_monster.feature
+0
-9
spec/spec_helper.rb
+10
-0
spec/steps/hoge_steps.rb
+9
-1
No files found.
Gemfile
View file @
1e2c9a53
...
...
@@ -95,7 +95,7 @@ group :test do
gem
'
capybara
'
gem
'
launchy
'
gem
'
poltergeist
'
gem
'
coveralls
'
,
:require
=>
false
gem
'
coveralls
'
,
require:
false
gem
'
turnip
'
end
...
...
app/models/user.rb
View file @
1e2c9a53
...
...
@@ -12,13 +12,13 @@ class User < ActiveRecord::Base
# Device
def
self
.
find_for_google_oauth2
(
access_token
,
signed_in_resource
=
nil
)
data
=
access_token
.
info
user
=
User
.
where
(
email:
data
[
'email'
]).
first
info
=
access_token
.
info
user
=
User
.
where
(
email:
info
[
'email'
]).
first
unless
user
user
=
User
.
create
(
name:
data
[
'name'
],
image_url:
data
[
'image'
],
email:
data
[
'email'
],
user
=
User
.
create
(
name:
info
[
'name'
],
image_url:
info
[
'image'
],
email:
info
[
'email'
],
password:
Devise
.
friendly_token
[
0
,
20
]
)
end
...
...
app/views/home/login.html.erb
View file @
1e2c9a53
<!-- view:home/login -->
<div
class=
"login"
>
<!-- Marketing messaging and featurettes
...
...
app/views/posts/index.html.erb
View file @
1e2c9a53
<!-- view:post/index -->
<div
class=
"row"
>
<div
class=
"col-xs-6 col-md-4"
id=
"sidebar"
role=
"navigation"
>
...
...
spec/acceptance/access.feature
0 → 100644
View file @
1e2c9a53
Feature
:
アクセス制限
Scenario
:
非ログイン --> TOPページ
When
visit '/'
Then
response code is 200
Then response includes '<!-- view
:
home/login
-->'
Scenario
:
非ログイン --> postsページ
When
visit '/posts'
Then
response code is 200
Then response includes '<!-- view
:
home/login
-->'
# Scenario: 禁止ユーザーログイン --> TOPページ
# Given login via google with 'taro@example.com'
# Then response code is 200
# Then page includes 'Your email address is not permitted'
# Scenario: 禁止ユーザーログイン --> postsページ
# Given login via google with 'taro@example.com'
# When visit '/posts'
# Then response code is 200
# Then response includes '<!-- view:home/login -->'
Scenario
:
ログイン --> TOPページ
Given
user login
When
visit '/'
Then
response code is 200
Then response includes '<!-- view
:
post/index
-->'
Scenario
:
ログイン --> postsページ
Given
user login
When
visit '/posts'
Then
response code is 200
Then response includes '<!-- view
:
post/index
-->'
spec/acceptance/attack_monster.feature
deleted
100644 → 0
View file @
a44eaa40
Feature
:
ログインしていないユーザーのアクセス
Scenario
:
TOPページにアクセス
When
visit '/'
Then
response code is '200'
Scenario
:
TOP以外にアクセス
When
visit '/posts'
Then
response code is '999'
spec/spec_helper.rb
View file @
1e2c9a53
...
...
@@ -86,4 +86,14 @@ RSpec.configure do |config|
config
.
after
:each
do
DatabaseRewinder
.
clean
end
OmniAuth
.
config
.
test_mode
=
true
OmniAuth
.
config
.
add_mock
(
:google_oauth2
,
{
'uid'
=>
'12345'
,
'provider'
=>
'google_oauth2'
,
'info'
=>
{
'name'
=>
'Taro Yamada'
,
'email'
=>
'taro@zigexn.co.jp'
},
'credentials'
=>
{
'token'
=>
'aaaaa'
,
'refresh_token'
=>
'bbbbb'
,
'expires_at'
=>
9999999999
}
})
end
spec/steps/hoge_steps.rb
View file @
1e2c9a53
...
...
@@ -10,10 +10,18 @@ step 'response code is :code' do |code|
expect
(
page
.
status_code
.
to_i
).
to
eq
(
code
.
to_i
)
end
step
'
response include
:string'
do
|
string
|
step
'
page includes
:string'
do
|
string
|
expect
(
page
).
to
have_content
(
string
)
end
step
'response includes :string'
do
|
string
|
expect
(
page
.
body
).
to
include
(
string
)
end
step
'h1 include :string'
do
|
string
|
expect
(
page
.
find
(
'h1'
)).
to
have_content
(
string
)
end
step
'user login'
do
visit
'/users/auth/google_oauth2'
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment