Skip to content

Comments

Feature/coach login with GitHub & admin login with username/password#50

Merged
tansaku merged 40 commits intoAgileVentures:developfrom
junyu-w:feature/login-with-github
Oct 26, 2016
Merged

Feature/coach login with GitHub & admin login with username/password#50
tansaku merged 40 commits intoAgileVentures:developfrom
junyu-w:feature/login-with-github

Conversation

@junyu-w
Copy link
Contributor

@junyu-w junyu-w commented Oct 21, 2016

feature: user login with github (no whitelist check in this PR)
pivotal tracker story:
https://www.pivotaltracker.com/story/show/132353109

feature:

  1. migration to create root user
  2. coach login with github account

@junyu-w junyu-w closed this Oct 21, 2016
@tansaku
Copy link
Contributor

tansaku commented Oct 21, 2016

okay, let me know when you want me to do a more detailed review :-)

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 21, 2016

image
@tansaku those are the only two failed tests right now and the first one depends on the whitelist feature being developed by one of my teammates
However, I don't quite understand how the 2nd failed test works... seems like it ran the resample rake task but how is the updated value decided? Can you help me take a look at this one?
Thanks!

@tansaku
Copy link
Contributor

tansaku commented Oct 23, 2016

@DrakeW we are having some inconsistency with that second test: cucumber features/view_metrics_with_secrets.feature:39 - it is supposed to be completely sandboxed, but it does seem to fail intermittently. We can get around that by deleting the cached network connections for it - see https://github.com/AgileVentures/projectscope/blob/develop/features/support/fixtures/cassettes/View_A_Projects_Metrics_with_Secrets/update_metrics_for_projects.yml
re running and checking that in, but a value of 0 there suggests a more serious issue.

I note the same test is failing in the other open PR:

#51

which is relying on a change to one of the gems - perhaps that needs to be pulled in first ...?

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 23, 2016

@tansaku #51 relies on changes to all metric gems we are using, and there's no dependency between our two branches so the order doesn't matter regarding dependency?

but it makes sense to pull in those small PRs first since otherwise they might need to merge my changes (a lot of files) first before they can be merged....

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 24, 2016

@tansaku failed view_metrics_with_secrets has been fixed with newest upstream changes, and the other failed test will be fixed by the whitelist feature. It's good for a detailed review

@armandofox
Copy link
Contributor

armandofox commented Oct 25, 2016

the moral of the story here is make each PR small enough to review independently, even if there's a string of related ones....

welcome to real life software development on an existing product with an existing team :-)

@tansaku
Copy link
Contributor

tansaku commented Oct 25, 2016

@DrakeW going to try and get some things sorted tonight - I think credentials for all gems should return array of symbols ... gonna try and impose that as I think it's the right thing to do

@tansaku tansaku closed this Oct 25, 2016
@tansaku tansaku reopened this Oct 25, 2016
@@ -0,0 +1,28 @@
class Users::UnlocksController < Devise::UnlocksController
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need all these devise controllers filled with only comments - could we just delete the ones we're not actually customizing?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned that having lots of files filled with comments makes the whole projects more burdensome to navigate - if we really must have these files for devise to operate that's one thing, but these should all exist in the gem - can't we add them individually as needed?

before_action :authenticate_user!

http_basic_authenticate_with name: "cs169", password: ENV['PROJECTSCOPE_PASSWORD']
# http_basic_authenticate_with name: "cs169", password: ENV['PROJECTSCOPE_PASSWORD']
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this if not being used any more - we should avoid commenting old code - old code is kept in git history

@tansaku
Copy link
Contributor

tansaku commented Oct 25, 2016

@DrakeW thanks for this.

So this test is failing (as you mentioned):

Scenario: unauthrozied user login
    Given I am on the login page
    When I sign in as coach with github email "test-coach-not-exist@test.com"
    Then I should be on the login page
    And I should see "You are not authroized."

I note that unauthrozied should be unauthorised- perhaps we could fix that typo :-)

Also, if this test doesn't work, shouldn't we remove it and put it in a separate PR that builds on the whitelist work of your colleague?

It's important to keep every commit on non-feature branches green to support operations like git bisect and the ability to safely role production code back to any instance.

The set of cucumber tests with the PR indicate the new functionality that's being added right? The two authorised logins (coach and admin) are passing - let's merge those in, and keep the exclusion of unauthorised users to a later PR? Isn't the current functionality excluding people who don't have github logins? so you could just rewrite the step definition to fail the github oauth for the particular user you don't want to be able to log in here, e.g.

Scenario: non github user cannot log in
    Given I am on the login page
    When I sign in with a non github email
    Then I should be on the login page
    And I should see "You are not unauthorised."

See https://github.com/omniauth/omniauth/wiki/Integration-Testing#mocking-failure for how to mock the github oauth fail.

Does that make sense? I think it's really important to write your code as self contained and not having failing tests that will pass once other code is in place. The feature you have here excludes non-github users right? So the sad path here is non-github users can't log in. The whitelist feature is separate and should be addressed in a separate PR no?

Let's make this PR address https://www.pivotaltracker.com/story/show/132353109 and we can address https://www.pivotaltracker.com/story/show/132353501 in another and both can be green and clean :-)

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 25, 2016

@tansaku thanks for the review and I'll make changes accordingly.
Also as a side not we had a short meeting with @armandofox today and decided to dump the code for username/password login (so only github login is allowed).

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 26, 2016

@tansaku so after I added @omniauth tag to all tests that require login, some tests began failing randomly
one error is
image
the other one is
image

The first one happened randomly at any test that tries to add data into the db like And the following projects exist...
The second one only happened in the add_projecst_with_config test and I was thinking if that was caused by some conflict between the @omniatuh and @javascript?

Any thoughts?

@junyu-w
Copy link
Contributor Author

junyu-w commented Oct 26, 2016

@tansaku found out the issue was caused by the Given I am logged in step, that step is a declarative one and contains several substeps as shown in https://github.com/DrakeW/projectscope/blob/feature/login-with-github/features/step_definitions/project_steps.rb#L58

And the problem is that cucumber proceeded to the next step before all the substeps actually finishes, which caused

  1. db lock problem by possibly trying to create user & projects at the same time
  2. the Unable to find link "New Project" problem because the login was not actually finished.

It's all fixed now

ADMIN = "admin"
COACH = "coach"

def self.from_omniauth(auth)
Copy link
Contributor

Choose a reason for hiding this comment

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

this method is a bit long - I'll still pull in but it would be good to refactor to make it easier to see what the components are doing

def self.from_omniauth(auth)
email = auth.info.email.nil? ? auth.extra.raw_info.email : auth.info.email
login = auth.extra.raw_info.login
if !login.nil? and !email.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

this block of code is ripe for pulling out as a separate method - we could also rewrite as unless login.nil or email.nil?

ah, I guess the method is not so huge because it's just block syntax on that first_or_create, but we could extract that as a separate method and self document like so:

unless login.nil or email.nil?
find_or_create_user_from(login, email, auth)
end

just some thoughts ...

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<!-- <div class="field">
Copy link
Contributor

Choose a reason for hiding this comment

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

delete these comments?

@tansaku tansaku merged commit 9aee541 into AgileVentures:develop Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants