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

Fixes user update #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixes user update #12

wants to merge 2 commits into from

Conversation

rer7891
Copy link
Owner

@rer7891 rer7891 commented Jan 22, 2020

What functionality does this accomplish?

closes #

Description:

What did you struggle on to complete?

Current Test Suite:

Test Coverage Percentage: x%

  • No Tests have been changed
  • Some Tests have been changed
  • All of the Tests have been changed(Please describe what in the world happened):
  • New Tests added for new features

Checklist:

  • My code has no unused/commented out code
  • I have reviewed my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have fully tested my code
  • I have partially tested my code (please explain why):

Helpful Resources:

  • Resource link AND small description of info gathered/learned

Review Requests(optional):

Please include a gif of how you feel about this branch:

user.reload
expect(user.role).to eq("merchant_admin")
expect(user.role).to eq("user")
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

within "#user-#{user.id}" do
select "user", :from => "Role"
select("Vintage Vampire", from: "Merchant").select_option
click_on "Update"
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


within "#user-#{user.id}" do
select "user", :from => "Role"
select("Vintage Vampire", from: "Merchant").select_option
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


within "#user-#{user.id}" do
select "user", :from => "Role"
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.


visit admin_dash_users_path

expect(user.role).to eq("merchant_employee")
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

user.reload
expect(user.role).to eq("merchant_employee")
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -15,12 +15,36 @@

within "#user-#{user.id}" do
expect(page).to have_content('Role')
select "merchant_admin", :from => "Role"
select "merchant_employee", :from => "Role"
select("Vintage Vampire", from: "Merchant").select_option
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -15,12 +15,36 @@

within "#user-#{user.id}" do
expect(page).to have_content('Role')
select "merchant_admin", :from => "Role"
select "merchant_employee", :from => "Role"
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

if params[:user][:role] == "merchant_employee"
@user.merchant_id = @merchant.id
@user.save
elsif params[:user][:role] != "merchant_employee" && @user.merchant_id != nil
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Style/NonNilCheck: Prefer !expression.nil? over expression != nil.
Metrics/LineLength: Line is too long. [83/80]

@@ -1,6 +1,7 @@
class Admin::UsersController < Admin::BaseController
def index
@users = User.unscoped.all

Copy link

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body end.

expect(user.role).to eq("user")
expect(user.merchant_id).to eq(nil)
save_and_open_page
expect(page).to have_content("Please try again. You may need to choose a merchant.")
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [88/80]

user.reload
expect(user.role).to eq("user")
expect(user.merchant_id).to eq(nil)
save_and_open_page
Copy link

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.
Lint/Debugger: Remove debugger entry point save_and_open_page.

end

user.reload
expect(user.role).to eq("user")
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


within "#user-#{user.id}" do
select "merchant_employee", :from => "Role"
click_on "Update"
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

expect(user.role).to eq("user")

within "#user-#{user.id}" do
select "merchant_employee", :from => "Role"
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Style/HashSyntax: Use the new Ruby 1.9 hash syntax.

it "won't update if no merchant is given for a merchant employee" do
admin = create(:admin_user)
user = create(:random_user)
merchant = create(:ray_merchant)
Copy link

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - merchant.

redirect_to admin_dash_users_path
else
flash[:error] = "Please try again. You may need to choose a merchant."
redirect_to admin_dash_users_path
Copy link

Choose a reason for hiding this comment

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

Style/IdenticalConditionalBranches: Move redirect_to admin_dash_users_path out of the conditional.

flash[:success] = "The user role has been updated to #{@user.role}."
redirect_to admin_dash_users_path
else
flash[:error] = "Please try again. You may need to choose a merchant."
Copy link

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
if @user.update
flash[:success] = "The user role has been updated to #{@user.role}."
redirect_to admin_dash_users_path
Copy link

Choose a reason for hiding this comment

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

Style/IdenticalConditionalBranches: Move redirect_to admin_dash_users_path out of the conditional.

flash[:success] = "The user role has been updated to #{@user.role}."
redirect_to admin_dash_users_path
@merchant = Merchant.where(name: params[:user][:merchant]).first
if params[:user][:role] == "merchant_employee" && @merchant
Copy link

Choose a reason for hiding this comment

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

Layout/IndentationConsistency: Inconsistent indentation detected.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

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.

1 participant