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

Remove state from profile #435

Closed
wants to merge 4 commits into from
Closed

Conversation

m-an
Copy link
Contributor

@m-an m-an commented Apr 30, 2018

closes #445
closes #443
closes #442

@m-an m-an added the PR: WIP label Apr 30, 2018
@m-an m-an force-pushed the feature/remove_state_from_profile branch 3 times, most recently from 5040816 to c77ad31 Compare May 3, 2018 18:21
@m-an m-an changed the title Remove state from profile [WIP] Remove state from profile May 3, 2018
@m-an m-an force-pushed the feature/remove_state_from_profile branch 2 times, most recently from 22382e8 to 157cdc0 Compare May 8, 2018 13:11
@m-an m-an requested a review from rxx May 8, 2018 13:35

private

def create_or_update_document_label
Copy link

Choose a reason for hiding this comment

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

I can't understand why do you duplicate label logic in model and controller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we add label 'document:verified' on document upload if there's no label 'document:verified'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is not duplicating any logic,
correct me, please, if I'm wrong

def send_document_review_notification
if value == 'verified'
ProfileReviewMailer.approved(account).deliver_now
EventAPI.notify('system.document.verified', account_uid: account.uid)
Copy link

Choose a reason for hiding this comment

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

add TODO: Need to update specs/event_api.md if you don't add it in current request. Specs are important for users of Events API

@@ -4,7 +4,7 @@
# Class Phone
#
class Phone < ApplicationRecord
belongs_to :account
belongs_to :account, optional: true
Copy link

Choose a reason for hiding this comment

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

Why optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, sorry, accidentaly added it from another branch

<div class="dropdown show">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<%= @profile.state.upcase_first %>
<%= @profile.account.labels.find_by(key: 'document', scope: 'private')&.value %>
Copy link

Choose a reason for hiding this comment

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

Never do any ActiveRecord find, where in a view

<% Profile::STATES.each do |state|%>
<%= link_to(state.upcase_first, change_state_admin_profile_path(@profile, state: state), method: :put, class: 'dropdown-item') unless @profile.state == state%>
<% Document::STATES.each do |state|%>
<%= link_to(state.upcase_first, document_label_admin_profile_path(@profile, state: state), method: :put, class: 'dropdown-item') unless @profile.account.labels.find_by(key: :document).value == state%>
Copy link

Choose a reason for hiding this comment

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

same as above. And use short string. It's hard to read


it 'does not add new label' do
create_document
expect(current_account.labels.count).to eq 1
Copy link

Choose a reason for hiding this comment

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

same as above


it 'remains value verified' do
create_document
expect(current_account.labels.first.value).to eq 'verified'
Copy link

Choose a reason for hiding this comment

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

same as above


context 'document label changes' do
let!(:account) { create(:account) }
let(:mailer_deliveries) { ActionMailer::Base.deliveries }
Copy link

Choose a reason for hiding this comment

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

why not let(:last_mailer_delivery) { ActionMailer::Base.deliveries.last }


context 'can be created with different scopes' do
it 'account has both labels' do
expect(account.labels.first).to eq label_public
Copy link

Choose a reason for hiding this comment

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

expect(account.labels).to eq [label_public, label_private]

end
end

context 'with public labels duplicating levels' do
Copy link

Choose a reason for hiding this comment

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

Wrong name. It's not implicit reason for spec.
I suggest when account has all required label for level 4 but in public scope

@m-an m-an force-pushed the feature/remove_state_from_profile branch from 157cdc0 to 404aeb3 Compare May 11, 2018 13:51
@rxx rxx force-pushed the feature/remove_state_from_profile branch from 031d752 to 32eab69 Compare May 15, 2018 11:43
@rxx
Copy link

rxx commented May 15, 2018

already merged with #460 branch

@rxx rxx closed this May 15, 2018
@ec ec deleted the feature/remove_state_from_profile branch October 24, 2018 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants