Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

[1643] Hide Unavailable Equipment Items #1668

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

Conversation

yongjie-lin
Copy link
Contributor

Resolves #1643

  • create button to hide/show unavailable items

@yongjie-lin yongjie-lin force-pushed the 1643_hide_unavailable_items branch from 9ff6aa1 to 11439c2 Compare March 3, 2017 20:16
<%# for kaminari pagination %>
<%= paginate @page_eq_models_by_category,
params: { controller: 'catalog', action: 'index' } %>
<%= form_tag update_user_per_cat_page_path,
<%= form_tag update_user_per_cat_page_path,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm aware my IDE did something strange to the whitespace - will follow up

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it just converted the spaces to tabs to match the rest of the file. To be honest, I think it's fine.

@yongjie-lin
Copy link
Contributor Author

Ready for review!

Copy link
Contributor

@AlanLiu96 AlanLiu96 left a comment

Choose a reason for hiding this comment

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

Overall amazing job. :) Really clear tests and efficient js. I left a few comments below, but they're mainly small changes.

} else {
$("#toggle_unavailable").text("Hide unavailable");
}
$(".col-md-4").each(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

While this works, could we use class/div tags and attach to those instead of the (".col-md-4") and (".col-md-3") css tags? (Ex. in the future we might make something else width 4, and wonder why it suddenly keeps disappearing) :)

page.reset!
end

it 'shows all items by default' do
Copy link
Contributor

Choose a reason for hiding this comment

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

awesome tests, really clear and easy to read

end

it 'reshows all items when clicked again' do
click_button "toggle_unavailable"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the last two tests depend on them executing in this order? I'm not sure if it's guaranteed that the tests won't be swapped.

@AlanLiu96
Copy link
Contributor

Also, I think style check is causing the build to fail -- rake check_style

@yongjie-lin yongjie-lin force-pushed the 1643_hide_unavailable_items branch from 6966e9b to 91aedd4 Compare April 1, 2017 21:25
Copy link
Collaborator

@esoterik esoterik left a comment

Choose a reason for hiding this comment

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

some comments on your test

empty_cart
Capybara.ignore_hidden_elements = false
@eq_model1 = FactoryGirl.create(:equipment_model, category: @category)
FactoryGirl.create(:equipment_item, equipment_model: @eq_model1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we have an equipment_model_with_item factory

context 'when hide unavailable button is clicked' do
before(:each) do
empty_cart
Capybara.ignore_hidden_elements = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this necessary?

Capybara.ignore_hidden_elements = false
@eq_model1 = FactoryGirl.create(:equipment_model, category: @category)
FactoryGirl.create(:equipment_item, equipment_model: @eq_model1)
@eq_model1[:overdue_count] = 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

you should actually create an overdue reservation for this because it's a feature spec

@eq_model1[:overdue_count] = 1
@eq_model1.save!
@eq_model1.reload
page.reset!
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this necessary? you haven't visited a page yet

@eq_model1.save!
@eq_model1.reload
page.reset!
visit root_path
Copy link
Collaborator

Choose a reason for hiding this comment

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

this belongs in the individual it blocks


after(:each) do
Capybara.ignore_hidden_elements = true
@eq_model1.destroy
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't necessary

after(:each) do
Capybara.ignore_hidden_elements = true
@eq_model1.destroy
page.reset!
Copy link
Collaborator

Choose a reason for hiding this comment

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

this also shouldn't be necessary


it 'shows all items by default' do
expect(page).to have_css('.availability-num', text: 1, visible: true)
expect(page).to have_css('.availability-num', text: 0, visible: true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

these checks are nice!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants