Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for not displaying uid(WIP) #3139

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,57 @@ def setup
post :test_digest_email
assert_redirected_to '/'
end

test 'Oauth tags are in form of oauth:provider for github' do
UserSession.create(users(:jeff))
user = users(:jeff)
auth = { "provider" => "github", "uid" => "123456789"}
uid = user.id
identity = UserTag.create_with_omniauth(auth, uid)
get :profile
assert_response :redirect
assert_redirected_to '/profile/jeff'
s = "span#tag_"+identity.id.to_s
assert_select s,'omniauth:github'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jywarren can you please tell me the what I am doing wrong here. I checked in the view it is

<li><span id="tag_<%= tag.id %>" class="label <%= label_name %>" style="cursor:pointer" data-toggle="popover" data-trigger="manual" data-count=0 data-placement="top" data-content="<a href='/contributors/<%= tag.name %>'><%= Tag.tagged_node_count(tag.name) || 0 %> notes - <%= Tag.contributors(tag.name).count %> people <br></a>" data-html="true" title="<%= tag.name %>">
<% if tag.name[0..4] != "oauth" %>
<%= tag.name %>
<% else %>
<%= tag.name[0..5] + tag.name.split(':')[1] %>
<% end %>

It says span with id as tag_+tag.id. Is tag.id not same as usertag.id?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can you check it locally? Maybe also look for the total count of items like span.label to be sure they're appearing at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I am trying to debug this. I am trying my level best to write these test asap. It is giving errors.

On localhost everything is working fine. Also in production things are working fine. Just trying to debug the tests.

end

test 'Oauth tags are in form of oauth:provider for twitter' do
UserSession.create(users(:jeff))
user = users(:jeff)
auth = { "provider" => "twitter", "uid" => "123456789"}
uid = user.id
identity = UserTag.create_with_omniauth(auth, uid)
get :profile
assert_response :redirect
assert_redirected_to '/profile/jeff'
s = "span#tag_"+identity.id.to_s
assert_select s, 'oauth:twitter'
end

test 'Oauth tags are in form of oauth:provider for google' do
UserSession.create(users(:jeff))
user = users(:jeff)
auth = { "provider" => "google_oauth2", "uid" => "123456789"}
uid = user.id
identity = UserTag.create_with_omniauth(auth, uid)
get :profile
assert_response :redirect
assert_redirected_to '/profile/jeff'
s = "span#tag_"+identity.id.to_s
assert_select s, 'oauth:google_oauth2'
end

test 'Oauth tags are in form of oauth:provider for facebook' do
UserSession.create(users(:jeff))
user = users(:jeff)
auth = { "provider" => "facebook", "uid" => "123456789"}
uid = user.id
identity = UserTag.create_with_omniauth(auth, uid)
get :profile
assert_response :redirect
assert_redirected_to '/profile/jeff'
s = "div#tag_"+identity.id.to_s
assert_select s, 'oauth:facebook'
end

end