Skip to content

Commit

Permalink
Merge pull request #29 from aitbw/aitbw/test_suite_maintenance
Browse files Browse the repository at this point in the history
Test suite maintenance
  • Loading branch information
kennyadsl authored Dec 28, 2018
2 parents bed1f94 + 1e4934d commit c9fc314
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 65 deletions.
15 changes: 12 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch
gem 'solidus', git: 'https://github.com/solidusio/solidus.git', branch: branch
gem 'solidus_auth_devise'
gem 'deface'

Expand All @@ -13,8 +13,17 @@ else
gem "rails", "~> 4.2.7"
end

gem 'pg', '~> 0.21'
gem 'mysql2', '~> 0.4.10'
if branch < 'v2.5'
gem 'factory_bot', '4.10.0'
else
gem 'factory_bot', '> 4.10.0'
end

if ENV['DB'] == 'mysql'
gem 'mysql2', '~> 0.4.10'
else
gem 'pg', '~> 0.21'
end

group :development, :test do
gem "pry-rails"
Expand Down
2 changes: 1 addition & 1 deletion app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def count_of(variant)
end

def assembly_cannot_be_part
errors.add(:can_be_part, Spree.t(:assembly_cannot_be_part)) if can_be_part
errors.add(:can_be_part, I18n.t('spree.assembly_cannot_be_part')) if can_be_part
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/models/spree/stock/availability_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def validate(line_item)
display_name = %Q{#{variant.name}}
display_name += %Q{ (#{variant.options_text})} unless variant.options_text.blank?

line_item.errors[:quantity] << Spree.t(
:selected_quantity_not_available,
line_item.errors[:quantity] << I18n.t(
'spree.selected_quantity_not_available',
item: display_name.inspect
)
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/spree/stock/inventory_validator_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ def validate(line_item)
total_quantity = line_item.quantity_by_variant.values.sum

if line_item.inventory_units.count != total_quantity
line_item.errors[:inventory] << Spree.t(
:inventory_not_available,
line_item.errors[:inventory] << I18n.t(
'spree.inventory_not_available',
item: line_item.variant.name
)
end
Expand Down
10 changes: 5 additions & 5 deletions app/views/spree/admin/orders/_assemblies.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if order.line_items.assemblies.any? %>
<fieldset class="no-border-bottom">
<legend align="center" class="" data-hook="">
<%= Spree.t(:product_bundles) %>
<%= I18n.t('spree.product_bundles') %>
</legend>
</fieldset>

Expand Down Expand Up @@ -43,10 +43,10 @@
<td class="line-item-total align-center"><%= line_item_shipment_price(item, item.quantity) %></td>
<td class="cart-line-item-delete actions" data-hook="cart_line_item_delete">
<% if can? :update, item %>
<%= link_to '', '#', :class => 'save-line-item fa fa-ok no-text with-tip', :title => Spree.t('actions.save') %>
<%= link_to '', '#', :class => 'cancel-line-item fa fa-cancel no-text with-tip', :title => Spree.t('actions.cancel') %>
<%= link_to '', '#', :class => 'edit-line-item fa fa-edit no-text with-tip', :title => Spree.t('actions.edit') %>
<%= link_to '', '#', :class => 'delete-line-item fa fa-trash no-text with-tip', :title => Spree.t('actions.delete') %>
<%= link_to '', '#', :class => 'save-line-item fa fa-ok no-text with-tip', :title => I18n.t('spree.actions.save') %>
<%= link_to '', '#', :class => 'cancel-line-item fa fa-cancel no-text with-tip', :title => I18n.t('spree.actions.cancel') %>
<%= link_to '', '#', :class => 'edit-line-item fa fa-edit no-text with-tip', :title => I18n.t('spree.actions.edit') %>
<%= link_to '', '#', :class => 'delete-line-item fa fa-trash no-text with-tip', :title => I18n.t('spree.actions.delete') %>
<% end %>
</td>
<% end %>
Expand Down
22 changes: 11 additions & 11 deletions app/views/spree/admin/orders/_stock_contents.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<tr class="edit-method hidden total">
<td colspan="5">
<div class="field alpha five columns">
<%= label_tag 'selected_shipping_rate_id', Spree.t(:shipping_method) %>
<%= label_tag 'selected_shipping_rate_id', I18n.t('spree.shipping_method') %>
<%= select_tag :selected_shipping_rate_id,
options_for_select(shipment.shipping_rates.map {|sr| ["#{sr.name} #{sr.display_price}", sr.id] }, shipment.selected_shipping_rate_id),
{:class => 'select2 fullwidth', :data => {'shipment-number' => shipment.number } } %>
Expand All @@ -13,9 +13,9 @@
<td class="actions">
<% if can? :update, shipment %>
<%= link_to '', '#', :class => 'save-method fa fa-ok no-text with-tip',
:data => {'shipment-number' => shipment.number, :action => 'save'}, title: Spree.t('actions.save') %>
:data => {'shipment-number' => shipment.number, :action => 'save'}, title: I18n.t('spree.actions.save') %>
<%= link_to '', '#', :class => 'cancel-method fa fa-cancel no-text with-tip',
:data => {:action => 'cancel'}, :title => Spree.t('actions.cancel') %>
:data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel') %>
<% end %>
</td>
</tr>
Expand All @@ -30,40 +30,40 @@
<span><%= shipment.display_cost %></span>
</td>
<% else %>
<td colspan='5'><%= Spree.t(:no_shipping_method_selected) %></td>
<td colspan='5'><%= I18n.t('spree.no_shipping_method_selected') %></td>
<% end %>

<td class="actions">
<% if can? :update, shipment %>
<%= link_to '', '#', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %>
<%= link_to '', '#', :class => 'edit-method fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %>
<% end %>
</td>
</tr>

<tr class="edit-tracking hidden total">
<td colspan="5">
<label><%= Spree.t(:tracking_number) %>:</label>
<label><%= I18n.t('spree.tracking_number') %>:</label>
<%= text_field_tag :tracking, shipment.tracking %>
</td>
<td class="actions">
<% if can? :update, shipment %>
<%= link_to '', '#', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => Spree.t('actions.save') %>
<%= link_to '', '#', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel') %>
<%= link_to '', '#', :class => 'save-tracking fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, :action => 'save'}, :title => I18n.t('spree.actions.save') %>
<%= link_to '', '#', :class => 'cancel-tracking fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel') %>
<% end %>
</td>
</tr>

<tr class="show-tracking total">
<td colspan="5">
<% if shipment.tracking.present? %>
<strong><%= Spree.t(:tracking) %>:</strong> <%= shipment.tracking %>
<strong><%= I18n.t('spree.tracking') %>:</strong> <%= shipment.tracking %>
<% else %>
<%= Spree.t(:no_tracking_present) %>
<%= I18n.t('spree.no_tracking_present') %>
<% end %>
</td>
<td class="actions">
<% if can? :update, shipment %>
<%= link_to '', '#', :class => 'edit-tracking fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %>
<%= link_to '', '#', :class => 'edit-tracking fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %>
<% end %>
</td>
</tr>
12 changes: 6 additions & 6 deletions app/views/spree/admin/orders/_stock_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<td class="item-name">
<%= item.variant.product.name %><br><%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %>
<% if item.part && item.line_item %>
<i><%= Spree.t(:part_of_bundle, sku: item.product.sku) %></i>
<i><%= I18n.t('spree.part_of_bundle', sku: item.product.sku) %></i>
<% end %>
</td>
<td class="item-price align-center">
Expand Down Expand Up @@ -34,11 +34,11 @@
<td class="cart-item-delete actions" data-hook="cart_item_delete">
<% if !shipment.shipped? && !item.part %>
<% if can? :update, item %>
<%= link_to '', '#', :class => 'save-item fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => Spree.t('actions.save'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => Spree.t('actions.cancel'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'edit-item fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => Spree.t('edit') %>
<%= link_to '', '#', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => Spree.t('split') %>
<%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => Spree.t('actions.delete') %>
<%= link_to '', '#', :class => 'save-item fa fa-ok no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'save'}, :title => I18n.t('spree.actions.save'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'cancel-item fa fa-cancel no-text with-tip', :data => {:action => 'cancel'}, :title => I18n.t('spree.actions.cancel'), :style => 'display: none' %>
<%= link_to '', '#', :class => 'edit-item fa fa-edit no-text with-tip', :data => {:action => 'edit'}, :title => I18n.t('spree.actions.edit') %>
<%= link_to '', '#', :class => 'split-item fa fa-arrows-h no-text with-tip', :data => {:action => 'split', 'variant-id' => item.variant.id}, :title => I18n.t('spree.actions.split') %>
<%= link_to '', '#', :class => 'delete-item fa fa-trash no-text with-tip', :data => {'shipment-number' => shipment.number, 'variant-id' => item.variant.id, :action => 'remove'}, :title => I18n.t('spree.actions.delete') %>
<% end %>
<% end %>
</td>
Expand Down
14 changes: 7 additions & 7 deletions app/views/spree/admin/parts/_parts_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<table class="index">
<thead>
<tr>
<th><%= Spree.t(:sku) %></th>
<th><%= Spree.t(:name) %></th>
<th><%= Spree.t(:options) %></th>
<th><%= Spree.t(:qty) %></th>
<th><%= I18n.t('spree.sku') %></th>
<th><%= I18n.t('spree.name') %></th>
<th><%= I18n.t('spree.options') %></th>
<th><%= I18n.t('spree.qty') %></th>
</tr>
</thead>
<tbody>
Expand All @@ -17,20 +17,20 @@
<td class="actions">
<%= link_to_with_icon(
'edit',
Spree.t('actions.edit'),
I18n.t('spree.actions.edit'),
set_count_admin_product_part_url(@product, part),
:class => "set_count_admin_product_part_link save-line-item") %>

<%= link_to_with_icon(
'delete',
Spree.t('actions.delete'),
I18n.t('spree.actions.delete'),
remove_admin_product_part_url(@product, part),
class: "remove_admin_product_part_link delete-line-item") %>
</td>
</tr>
<% end %>
<% if parts.empty? %>
<tr><td colspan="5"><%= Spree.t(:none) %>.</td></tr>
<tr><td colspan="5"><%= I18n.t('spree.none') %>.</td></tr>
<% end %>
</tbody>
</table>
Expand Down
14 changes: 7 additions & 7 deletions app/views/spree/admin/parts/available.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
}
</script>

<h4><%= Spree.t(:available_parts) %></h4>
<h4><%= I18n.t('spree.available_parts') %></h4>
<table class="index">
<thead>
<tr>
<th><%= Spree.t(:name) %></th>
<th><%= Spree.t(:options) %></th>
<th><%= Spree.t(:qty) %></th>
<th><%= I18n.t('spree.name') %></th>
<th><%= I18n.t('spree.options') %></th>
<th><%= I18n.t('spree.qty') %></th>
<th></th>
</tr>
</thead>
Expand All @@ -27,19 +27,19 @@
options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %>
<% else %>
<%= hidden_field_tag "part[id]", product.master.id %>
<%= Spree.t(:no_variants) %>
<%= I18n.t(:no_variants) %>
<% end %>
</td>
<td><%= text_field_tag "part[count]", 1 %></td>
<td class="actions">
<%= link_to(Spree.t(:select),
<%= link_to(I18n.t('spree.select'),
admin_product_parts_path(@product),
:class => "add_product_part_link btn btn-primary") %>
</td>
</tr>
<% end %>
<% if @available_products.empty? %>
<tr><td colspan="3"><%= Spree.t(:no_match_found) %>.</td></tr>
<tr><td colspan="3"><%= I18n.t('spree.no_match_found') %>.</td></tr>
<% end %>
</tbody>
</table>
Expand Down
14 changes: 7 additions & 7 deletions app/views/spree/admin/parts/available.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
else row.style.display = '';
}
</script>
<h4><%= Spree.t(:available_parts) %></h4>
<h4><%= I18n.t('spree.available_parts') %></h4>
<table class="index">
<thead>
<tr>
<th><%= Spree.t(:name) %></th>
<th><%= Spree.t(:options) %></th>
<th><%= Spree.t(:qty) %></th>
<th><%= I18n.t('spree.name') %></th>
<th><%= I18n.t('spree.options') %></th>
<th><%= I18n.t('spree.qty') %></th>
<th></th>
</tr>
</thead>
Expand All @@ -26,19 +26,19 @@
options_for_select(product.variants.map { |v| [variant_options(v), v.id] }) %>
<% else %>
<%= hidden_field_tag "part[id]", product.master.id %>
<%= Spree.t(:no_variants) %>
<%= I18n.t('spree.no_variants') %>
<% end %>
</td>
<td><%= text_field_tag "part[count]", 1 %></td>
<td class="actions">
<%= link_to(icon('add') + ' ' + Spree.t(:select),
<%= link_to(icon('add') + ' ' + I18n.t('spree.select'),
admin_product_parts_path(@product),
:class => "add_product_part_link") %>
</td>
</tr>
<% end %>
<% if @available_products.empty? %>
<tr><td colspan="3"><%= Spree.t(:no_match_found) %>.</td></tr>
<tr><td colspan="3"><%= I18n.t('spree.no_match_found') %>.</td></tr>
<% end %>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/admin/parts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<%= form_tag('#') do %>
<label><%= Spree.t(:search) %>:</label>
<label><%= I18n.t('spree.search') %>:</label>
<input id="searchtext" size="25">
<button id="search_parts_button" class="fa fa-search button" name="button">Search</button>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="left six columns alpha">
<div class="field">
<%= f.label :can_be_part, Spree.t(:can_be_part)%>
<%= f.label :can_be_part, I18n.t('spree.can_be_part')%>
<%= f.check_box(:can_be_part) %>
</div>
</div>
<div class="right six columns omega">
<div class="field">
<%= f.label :individual_sale, Spree.t(:individual_sale)%>
<%= f.label :individual_sale, I18n.t('spree.individual_sale')%>
<%= f.check_box(:individual_sale) %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<li<%= ' class="active"' if current == "Parts" %>>
<%= link_to_with_icon 'sitemap', Spree.t(:parts), admin_product_parts_url(@product) %>
<%= link_to_with_icon 'sitemap', I18n.t('spree.parts'), admin_product_parts_url(@product) %>
</li>
18 changes: 9 additions & 9 deletions db/migrate/20091029165620_add_parts_fields_to_products.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
class AddPartsFieldsToProducts < SolidusSupport::Migration[4.2]
def self.up
table = if table_exists?(:products)
table = if data_source_exists?(:products)
'products'
elsif table_exists?(:spree_products)
elsif data_source_exists?(:spree_products)
'spree_products'
end
end

change_table(table) do |t|
t.column :can_be_part, :boolean, :default => false, :null => false
t.column :individual_sale, :boolean, :default => true, :null => false
end
end
end

def self.down
table = if table_exists?(:products)
table = if data_source_exists?(:products)
'products'
elsif table_exists?(:spree_products)
elsif data_source_exists?(:spree_products)
'spree_products'
end
end

change_table(table) do |t|
t.remove :can_be_part
t.remove :individual_sale
Expand Down
1 change: 0 additions & 1 deletion solidus_product_assembly.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rspec-rails', '~> 3.4'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'factory_bot', '~> 4.4'
s.add_development_dependency 'capybara', '~> 2.7'
s.add_development_dependency 'poltergeist', '~> 1.9'
s.add_development_dependency 'database_cleaner', '~> 1.3'
Expand Down

0 comments on commit c9fc314

Please sign in to comment.