-
Notifications
You must be signed in to change notification settings - Fork 57
[1643] Hide Unavailable Equipment Items #1668
base: master
Are you sure you want to change the base?
Conversation
9ff6aa1
to
11439c2
Compare
app/views/catalog/index.html.erb
Outdated
<%# 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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Ready for review! |
There was a problem hiding this 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.
app/views/catalog/index.html.erb
Outdated
} else { | ||
$("#toggle_unavailable").text("Hide unavailable"); | ||
} | ||
$(".col-md-4").each(function() { |
There was a problem hiding this comment.
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) :)
spec/features/reservations_spec.rb
Outdated
page.reset! | ||
end | ||
|
||
it 'shows all items by default' do |
There was a problem hiding this comment.
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
spec/features/reservations_spec.rb
Outdated
end | ||
|
||
it 'reshows all items when clicked again' do | ||
click_button "toggle_unavailable" |
There was a problem hiding this comment.
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.
Also, I think style check is causing the build to fail -- |
9037e95
to
1bc2785
Compare
6966e9b
to
91aedd4
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these checks are nice!
Resolves #1643