From d7a4e3a89627b16ad9b7ba8242d3f527794b8ca2 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 15:53:16 +0100
Subject: [PATCH 01/13] Add taxonomies controller from spree_backend
---
.../spree/admin/taxonomies_controller.rb | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 app/controllers/spree/admin/taxonomies_controller.rb
diff --git a/app/controllers/spree/admin/taxonomies_controller.rb b/app/controllers/spree/admin/taxonomies_controller.rb
new file mode 100644
index 00000000000..3010db2a52a
--- /dev/null
+++ b/app/controllers/spree/admin/taxonomies_controller.rb
@@ -0,0 +1,21 @@
+module Spree
+ module Admin
+ class TaxonomiesController < ResourceController
+ respond_to :json, :only => [:get_children]
+
+ def get_children
+ @taxons = Taxon.find(params[:parent_id]).children
+ end
+
+ private
+
+ def location_after_save
+ if @taxonomy.created_at == @taxonomy.updated_at
+ edit_admin_taxonomy_url(@taxonomy)
+ else
+ admin_taxonomies_url
+ end
+ end
+ end
+ end
+end
From 8378dce7526c193fe837dc98fe7d41ff0f792a22 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 16:02:37 +0100
Subject: [PATCH 02/13] Bring taxons config controller that is overriden in ofn
to ofn so we can merge them with their decorator in a second step
---
.../spree/admin/taxons_controller.rb | 112 ++++++++++++++++++
1 file changed, 112 insertions(+)
create mode 100644 app/controllers/spree/admin/taxons_controller.rb
diff --git a/app/controllers/spree/admin/taxons_controller.rb b/app/controllers/spree/admin/taxons_controller.rb
new file mode 100644
index 00000000000..d852bc8ed00
--- /dev/null
+++ b/app/controllers/spree/admin/taxons_controller.rb
@@ -0,0 +1,112 @@
+module Spree
+ module Admin
+ class TaxonsController < Spree::Admin::BaseController
+
+ respond_to :html, :json, :js
+
+ def search
+ if params[:ids]
+ @taxons = Spree::Taxon.where(:id => params[:ids].split(','))
+ else
+ @taxons = Spree::Taxon.limit(20).search(:name_cont => params[:q]).result
+ end
+ end
+
+ def create
+ @taxonomy = Taxonomy.find(params[:taxonomy_id])
+ @taxon = @taxonomy.taxons.build(params[:taxon])
+ if @taxon.save
+ respond_with(@taxon) do |format|
+ format.json {render :json => @taxon.to_json }
+ end
+ else
+ flash[:error] = Spree.t('errors.messages.could_not_create_taxon')
+ respond_with(@taxon) do |format|
+ format.html { redirect_to @taxonomy ? edit_admin_taxonomy_url(@taxonomy) : admin_taxonomies_url }
+ end
+ end
+ end
+
+ def edit
+ @taxonomy = Taxonomy.find(params[:taxonomy_id])
+ @taxon = @taxonomy.taxons.find(params[:id])
+ @permalink_part = @taxon.permalink.split("/").last
+ end
+
+ def update
+ @taxonomy = Taxonomy.find(params[:taxonomy_id])
+ @taxon = @taxonomy.taxons.find(params[:id])
+ parent_id = params[:taxon][:parent_id]
+ new_position = params[:taxon][:position]
+
+ if parent_id || new_position #taxon is being moved
+ new_parent = parent_id.nil? ? @taxon.parent : Taxon.find(parent_id.to_i)
+ new_position = new_position.nil? ? -1 : new_position.to_i
+
+ # Bellow is a very complicated way of finding where in nested set we
+ # should actually move the taxon to achieve sane results,
+ # JS is giving us the desired position, which was awesome for previous setup,
+ # but now it's quite complicated to find where we should put it as we have
+ # to differenciate between moving to the same branch, up down and into
+ # first position.
+ new_siblings = new_parent.children
+ if new_position <= 0 && new_siblings.empty?
+ @taxon.move_to_child_of(new_parent)
+ elsif new_parent.id != @taxon.parent_id
+ if new_position == 0
+ @taxon.move_to_left_of(new_siblings.first)
+ else
+ @taxon.move_to_right_of(new_siblings[new_position-1])
+ end
+ elsif new_position < new_siblings.index(@taxon)
+ @taxon.move_to_left_of(new_siblings[new_position]) # we move up
+ else
+ @taxon.move_to_right_of(new_siblings[new_position-1]) # we move down
+ end
+ # Reset legacy position, if any extensions still rely on it
+ new_parent.children.reload.each{|t| t.update_column(:position, t.position)}
+
+ if parent_id
+ @taxon.reload
+ @taxon.set_permalink
+ @taxon.save!
+ @update_children = true
+ end
+ end
+
+ if params.key? "permalink_part"
+ parent_permalink = @taxon.permalink.split("/")[0...-1].join("/")
+ parent_permalink += "/" unless parent_permalink.blank?
+ params[:taxon][:permalink] = parent_permalink + params[:permalink_part]
+ end
+ #check if we need to rename child taxons if parent name or permalink changes
+ @update_children = true if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
+
+ if @taxon.update_attributes(params[:taxon])
+ flash[:success] = flash_message_for(@taxon, :successfully_updated)
+ end
+
+ #rename child taxons
+ if @update_children
+ @taxon.descendants.each do |taxon|
+ taxon.reload
+ taxon.set_permalink
+ taxon.save!
+ end
+ end
+
+ respond_with(@taxon) do |format|
+ format.html {redirect_to edit_admin_taxonomy_url(@taxonomy) }
+ format.json {render :json => @taxon.to_json }
+ end
+ end
+
+ def destroy
+ @taxon = Taxon.find(params[:id])
+ @taxon.destroy
+ respond_with(@taxon) { |format| format.json { render :json => '' } }
+ end
+
+ end
+ end
+end
From 20f965731dfdd83b97b8cad5a9714234771eb575 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 16:12:25 +0100
Subject: [PATCH 03/13] Fix basic rubocop issues in recently added controller
from spree_backend
---
.../spree/admin/taxons_controller.rb | 42 +++++++++++--------
1 file changed, 24 insertions(+), 18 deletions(-)
diff --git a/app/controllers/spree/admin/taxons_controller.rb b/app/controllers/spree/admin/taxons_controller.rb
index d852bc8ed00..57ae146d2a6 100644
--- a/app/controllers/spree/admin/taxons_controller.rb
+++ b/app/controllers/spree/admin/taxons_controller.rb
@@ -1,14 +1,13 @@
module Spree
module Admin
class TaxonsController < Spree::Admin::BaseController
-
respond_to :html, :json, :js
def search
if params[:ids]
- @taxons = Spree::Taxon.where(:id => params[:ids].split(','))
+ @taxons = Spree::Taxon.where(id: params[:ids].split(','))
else
- @taxons = Spree::Taxon.limit(20).search(:name_cont => params[:q]).result
+ @taxons = Spree::Taxon.limit(20).search(name_cont: params[:q]).result
end
end
@@ -17,12 +16,18 @@ def create
@taxon = @taxonomy.taxons.build(params[:taxon])
if @taxon.save
respond_with(@taxon) do |format|
- format.json {render :json => @taxon.to_json }
+ format.json { render json: @taxon.to_json }
end
else
flash[:error] = Spree.t('errors.messages.could_not_create_taxon')
respond_with(@taxon) do |format|
- format.html { redirect_to @taxonomy ? edit_admin_taxonomy_url(@taxonomy) : admin_taxonomies_url }
+ format.html do
+ if redirect_to @taxonomy
+ edit_admin_taxonomy_url(@taxonomy)
+ else
+ admin_taxonomies_url
+ end
+ end
end
end
end
@@ -39,7 +44,7 @@ def update
parent_id = params[:taxon][:parent_id]
new_position = params[:taxon][:position]
- if parent_id || new_position #taxon is being moved
+ if parent_id || new_position # taxon is being moved
new_parent = parent_id.nil? ? @taxon.parent : Taxon.find(parent_id.to_i)
new_position = new_position.nil? ? -1 : new_position.to_i
@@ -53,18 +58,18 @@ def update
if new_position <= 0 && new_siblings.empty?
@taxon.move_to_child_of(new_parent)
elsif new_parent.id != @taxon.parent_id
- if new_position == 0
+ if new_position.zero?
@taxon.move_to_left_of(new_siblings.first)
else
- @taxon.move_to_right_of(new_siblings[new_position-1])
+ @taxon.move_to_right_of(new_siblings[new_position - 1])
end
elsif new_position < new_siblings.index(@taxon)
@taxon.move_to_left_of(new_siblings[new_position]) # we move up
else
- @taxon.move_to_right_of(new_siblings[new_position-1]) # we move down
+ @taxon.move_to_right_of(new_siblings[new_position - 1]) # we move down
end
# Reset legacy position, if any extensions still rely on it
- new_parent.children.reload.each{|t| t.update_column(:position, t.position)}
+ new_parent.children.reload.each{ |t| t.update_column(:position, t.position) }
if parent_id
@taxon.reload
@@ -76,17 +81,19 @@ def update
if params.key? "permalink_part"
parent_permalink = @taxon.permalink.split("/")[0...-1].join("/")
- parent_permalink += "/" unless parent_permalink.blank?
+ parent_permalink += "/" if parent_permalink.present?
params[:taxon][:permalink] = parent_permalink + params[:permalink_part]
end
- #check if we need to rename child taxons if parent name or permalink changes
- @update_children = true if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
+ # check if we need to rename child taxons if parent name or permalink changes
+ if params[:taxon][:name] != @taxon.name || params[:taxon][:permalink] != @taxon.permalink
+ @update_children = true
+ end
if @taxon.update_attributes(params[:taxon])
flash[:success] = flash_message_for(@taxon, :successfully_updated)
end
- #rename child taxons
+ # rename child taxons
if @update_children
@taxon.descendants.each do |taxon|
taxon.reload
@@ -96,17 +103,16 @@ def update
end
respond_with(@taxon) do |format|
- format.html {redirect_to edit_admin_taxonomy_url(@taxonomy) }
- format.json {render :json => @taxon.to_json }
+ format.html { redirect_to edit_admin_taxonomy_url(@taxonomy) }
+ format.json { render json: @taxon.to_json }
end
end
def destroy
@taxon = Taxon.find(params[:id])
@taxon.destroy
- respond_with(@taxon) { |format| format.json { render :json => '' } }
+ respond_with(@taxon) { |format| format.json { render json: '' } }
end
-
end
end
end
From 2ce56aef2cfad9a35d33e05030b179abf0fa77dc Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 16:23:39 +0100
Subject: [PATCH 04/13] Add spree_backend views related to admin/configuration
taxonomies that are missing in ofn
---
.../spree/admin/taxonomies/_form.html.erb | 7 ++++
.../spree/admin/taxonomies/_js_head.html.erb | 13 ++++++
.../spree/admin/taxonomies/_list.html.erb | 26 ++++++++++++
.../spree/admin/taxonomies/_taxon.html.erb | 12 ++++++
app/views/spree/admin/taxonomies/edit.erb | 42 +++++++++++++++++++
.../spree/admin/taxonomies/index.html.erb | 15 +++++++
app/views/spree/admin/taxonomies/new.html.erb | 22 ++++++++++
.../spree/admin/taxons/_taxon_table.html.erb | 23 ++++++++++
app/views/spree/admin/taxons/edit.html.erb | 23 ++++++++++
app/views/spree/admin/taxons/search.rabl | 5 +++
10 files changed, 188 insertions(+)
create mode 100644 app/views/spree/admin/taxonomies/_form.html.erb
create mode 100755 app/views/spree/admin/taxonomies/_js_head.html.erb
create mode 100644 app/views/spree/admin/taxonomies/_list.html.erb
create mode 100644 app/views/spree/admin/taxonomies/_taxon.html.erb
create mode 100755 app/views/spree/admin/taxonomies/edit.erb
create mode 100644 app/views/spree/admin/taxonomies/index.html.erb
create mode 100644 app/views/spree/admin/taxonomies/new.html.erb
create mode 100644 app/views/spree/admin/taxons/_taxon_table.html.erb
create mode 100644 app/views/spree/admin/taxons/edit.html.erb
create mode 100644 app/views/spree/admin/taxons/search.rabl
diff --git a/app/views/spree/admin/taxonomies/_form.html.erb b/app/views/spree/admin/taxonomies/_form.html.erb
new file mode 100644
index 00000000000..1166e84a2e9
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_form.html.erb
@@ -0,0 +1,7 @@
+
+ <%= f.field_container :name do %>
+ <%= f.label :name, Spree.t(:name) %> *
+ <%= error_message_on :taxonomy, :name, :class => 'fullwidth title' %>
+ <%= text_field :taxonomy, :name %>
+ <% end %>
+
diff --git a/app/views/spree/admin/taxonomies/_js_head.html.erb b/app/views/spree/admin/taxonomies/_js_head.html.erb
new file mode 100755
index 00000000000..0b73bbbfb04
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_js_head.html.erb
@@ -0,0 +1,13 @@
+<% content_for :head do %>
+ <%= javascript_tag "var taxonomy_id = #{@taxonomy.id};
+ var loading = '#{escape_javascript Spree.t(:loading)}';
+ var new_taxon = '#{escape_javascript Spree.t(:new_taxon)}';
+ var server_error = '#{escape_javascript Spree.t(:server_error)}';
+ var taxonomy_tree_error = '#{escape_javascript Spree.t(:taxonomy_tree_error)}';
+
+ $(document).ready(function(){
+ setup_taxonomy_tree(taxonomy_id);
+ });
+ "
+ %>
+<% end %>
diff --git a/app/views/spree/admin/taxonomies/_list.html.erb b/app/views/spree/admin/taxonomies/_list.html.erb
new file mode 100644
index 00000000000..88a9ddc049f
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_list.html.erb
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+ <%= Spree.t(:name) %> |
+ |
+
+
+
+ <% @taxonomies.each do |taxonomy| %>
+
+
+
+ <%= taxonomy.name %>
+ |
+
+ <%= link_to_edit taxonomy.id, :no_text => true %>
+ <%= link_to_delete taxonomy, :no_text => true %>
+ |
+
+ <% end %>
+
+
diff --git a/app/views/spree/admin/taxonomies/_taxon.html.erb b/app/views/spree/admin/taxonomies/_taxon.html.erb
new file mode 100644
index 00000000000..d5eb39190cf
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_taxon.html.erb
@@ -0,0 +1,12 @@
+<% if taxon.children.length != 0 %>
+
+ <% taxon.children.each do |child| %>
+ -
+ <%= child.name %>
+ <% if child.children.length > 0 %>
+ <%= render :partial => 'taxon', :locals => { :taxon => child } %>
+ <% end %>
+
+ <% end %>
+
+<% end %>
diff --git a/app/views/spree/admin/taxonomies/edit.erb b/app/views/spree/admin/taxonomies/edit.erb
new file mode 100755
index 00000000000..e5f2dcc2b16
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/edit.erb
@@ -0,0 +1,42 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<%= render :partial => 'js_head' %>
+
+<% content_for :page_title do %>
+ <%= Spree.t(:taxonomy_edit) %>
+<% end %>
+
+<% content_for :page_actions do %>
+
+ <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
+
+<% end %>
+
+
+
+<%= form_for [:admin, @taxonomy] do |f| %>
+
+<% end %>
diff --git a/app/views/spree/admin/taxonomies/index.html.erb b/app/views/spree/admin/taxonomies/index.html.erb
new file mode 100644
index 00000000000..57c886272de
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/index.html.erb
@@ -0,0 +1,15 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<% content_for :page_title do %>
+ <%= Spree.t(:taxonomies) %>
+<% end %>
+
+<% content_for :page_actions do %>
+
+ <%= button_link_to Spree.t(:new_taxonomy), spree.new_admin_taxonomy_url, :icon => 'icon-plus', :id => 'admin_new_taxonomy_link' %>
+
+<% end %>
+
+
+ <%= render :partial => 'list' %>
+
diff --git a/app/views/spree/admin/taxonomies/new.html.erb b/app/views/spree/admin/taxonomies/new.html.erb
new file mode 100644
index 00000000000..a46166b9734
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/new.html.erb
@@ -0,0 +1,22 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<% content_for :page_title do %>
+ <%= Spree.t(:new_taxonomy) %>
+<% end %>
+
+<% content_for :page_actions do %>
+
+ <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
+
+<% end %>
+
+<%= form_for [:admin, @taxonomy] do |f| %>
+
+ <%= render :partial => 'form', :locals => { :f => f } %>
+
+<% end %>
diff --git a/app/views/spree/admin/taxons/_taxon_table.html.erb b/app/views/spree/admin/taxons/_taxon_table.html.erb
new file mode 100644
index 00000000000..1598bfb4702
--- /dev/null
+++ b/app/views/spree/admin/taxons/_taxon_table.html.erb
@@ -0,0 +1,23 @@
+
+
+
+ <%= Spree.t(:name) %> |
+ <%= Spree.t(:path) %> |
+ |
+
+
+
+ <% taxons.each do |taxon| %>
+
+ <%= taxon.name %> |
+ <%= taxon_path taxon %> |
+
+ <%= link_to_delete taxon, :url => remove_admin_product_taxon_url(@product, taxon), :name => icon('delete') + ' ' + Spree.t(:remove) %>
+ |
+
+ <% end %>
+ <% if taxons.empty? %>
+ <%= Spree.t(:none) %>. |
+ <% end %>
+
+
diff --git a/app/views/spree/admin/taxons/edit.html.erb b/app/views/spree/admin/taxons/edit.html.erb
new file mode 100644
index 00000000000..2335bee1c50
--- /dev/null
+++ b/app/views/spree/admin/taxons/edit.html.erb
@@ -0,0 +1,23 @@
+<%= render :partial => 'spree/admin/shared/configuration_menu' %>
+
+<% content_for :page_title do %>
+ <%= Spree.t(:taxon_edit) %>
+<% end %>
+
+<% content_for :page_actions do %>
+
+ <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
+
+<% end %>
+
+<% # Because otherwise the form would attempt to use to_param of @taxon %>
+<% form_url = admin_taxonomy_taxon_path(@taxonomy.id, @taxon.id) %>
+<%= form_for [:admin, @taxonomy, @taxon], :method => :put, :url => form_url, :html => { :multipart => true } do |f| %>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+
+
+ <%= button Spree.t('actions.update'), 'icon-refresh' %>
+ <%= Spree.t(:or) %>
+ <%= button_link_to Spree.t('actions.cancel'), edit_admin_taxonomy_url(@taxonomy), :icon => "icon-remove" %>
+
+<% end %>
diff --git a/app/views/spree/admin/taxons/search.rabl b/app/views/spree/admin/taxons/search.rabl
new file mode 100644
index 00000000000..ac5f36f9794
--- /dev/null
+++ b/app/views/spree/admin/taxons/search.rabl
@@ -0,0 +1,5 @@
+object false
+child(@taxons => :taxons) do
+ attributes :name, :pretty_name, :id
+end
+
From 2a68d34fb0332bb6a115e4a30debac189f655b4a Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 17:18:25 +0100
Subject: [PATCH 05/13] Convert spree/admin/taxonomies from erb to haml
---
.../spree/admin/taxonomies/_form.html.erb | 7 ----
.../spree/admin/taxonomies/_form.html.haml | 7 ++++
.../spree/admin/taxonomies/_js_head.html.erb | 8 ++--
.../spree/admin/taxonomies/_list.html.erb | 26 ------------
.../spree/admin/taxonomies/_list.html.haml | 19 +++++++++
.../spree/admin/taxonomies/_taxon.html.erb | 12 ------
.../spree/admin/taxonomies/_taxon.html.haml | 7 ++++
app/views/spree/admin/taxonomies/edit.erb | 42 -------------------
app/views/spree/admin/taxonomies/edit.haml | 32 ++++++++++++++
.../spree/admin/taxonomies/index.html.erb | 15 -------
.../spree/admin/taxonomies/index.html.haml | 11 +++++
app/views/spree/admin/taxonomies/new.html.erb | 22 ----------
.../spree/admin/taxonomies/new.html.haml | 15 +++++++
13 files changed, 95 insertions(+), 128 deletions(-)
delete mode 100644 app/views/spree/admin/taxonomies/_form.html.erb
create mode 100644 app/views/spree/admin/taxonomies/_form.html.haml
delete mode 100644 app/views/spree/admin/taxonomies/_list.html.erb
create mode 100644 app/views/spree/admin/taxonomies/_list.html.haml
delete mode 100644 app/views/spree/admin/taxonomies/_taxon.html.erb
create mode 100644 app/views/spree/admin/taxonomies/_taxon.html.haml
delete mode 100755 app/views/spree/admin/taxonomies/edit.erb
create mode 100755 app/views/spree/admin/taxonomies/edit.haml
delete mode 100644 app/views/spree/admin/taxonomies/index.html.erb
create mode 100644 app/views/spree/admin/taxonomies/index.html.haml
delete mode 100644 app/views/spree/admin/taxonomies/new.html.erb
create mode 100644 app/views/spree/admin/taxonomies/new.html.haml
diff --git a/app/views/spree/admin/taxonomies/_form.html.erb b/app/views/spree/admin/taxonomies/_form.html.erb
deleted file mode 100644
index 1166e84a2e9..00000000000
--- a/app/views/spree/admin/taxonomies/_form.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-
- <%= f.field_container :name do %>
- <%= f.label :name, Spree.t(:name) %> *
- <%= error_message_on :taxonomy, :name, :class => 'fullwidth title' %>
- <%= text_field :taxonomy, :name %>
- <% end %>
-
diff --git a/app/views/spree/admin/taxonomies/_form.html.haml b/app/views/spree/admin/taxonomies/_form.html.haml
new file mode 100644
index 00000000000..81927c7c1a7
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_form.html.haml
@@ -0,0 +1,7 @@
+.field.align-center
+ = f.field_container :name do
+ = f.label :name, t("spree.name")
+ %span.required *
+ %br/
+ = error_message_on :taxonomy, :name, class: 'fullwidth title'
+ = text_field :taxonomy, :name
diff --git a/app/views/spree/admin/taxonomies/_js_head.html.erb b/app/views/spree/admin/taxonomies/_js_head.html.erb
index 0b73bbbfb04..e95f4bdeff9 100755
--- a/app/views/spree/admin/taxonomies/_js_head.html.erb
+++ b/app/views/spree/admin/taxonomies/_js_head.html.erb
@@ -1,9 +1,9 @@
<% content_for :head do %>
<%= javascript_tag "var taxonomy_id = #{@taxonomy.id};
- var loading = '#{escape_javascript Spree.t(:loading)}';
- var new_taxon = '#{escape_javascript Spree.t(:new_taxon)}';
- var server_error = '#{escape_javascript Spree.t(:server_error)}';
- var taxonomy_tree_error = '#{escape_javascript Spree.t(:taxonomy_tree_error)}';
+ var loading = '#{escape_javascript t("spree.loading")}';
+ var new_taxon = '#{escape_javascript t("spree.new_taxon")}';
+ var server_error = '#{escape_javascript t("spree.server_error")}';
+ var taxonomy_tree_error = '#{escape_javascript t("spree.taxonomy_tree_error")}';
$(document).ready(function(){
setup_taxonomy_tree(taxonomy_id);
diff --git a/app/views/spree/admin/taxonomies/_list.html.erb b/app/views/spree/admin/taxonomies/_list.html.erb
deleted file mode 100644
index 88a9ddc049f..00000000000
--- a/app/views/spree/admin/taxonomies/_list.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
- <%= Spree.t(:name) %> |
- |
-
-
-
- <% @taxonomies.each do |taxonomy| %>
-
-
-
- <%= taxonomy.name %>
- |
-
- <%= link_to_edit taxonomy.id, :no_text => true %>
- <%= link_to_delete taxonomy, :no_text => true %>
- |
-
- <% end %>
-
-
diff --git a/app/views/spree/admin/taxonomies/_list.html.haml b/app/views/spree/admin/taxonomies/_list.html.haml
new file mode 100644
index 00000000000..1574e8b718f
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_list.html.haml
@@ -0,0 +1,19 @@
+%table#listing_taxonomies.index.sortable{"data-sortable-link" => update_positions_admin_taxonomies_url}
+ %colgroup
+ %col{style: "width: 85%"}/
+ %col{style: "width: 15%"}/
+ %thead
+ %tr
+ %th= t("spree.name")
+ %th.actions
+ %tbody
+ - @taxonomies.each do |taxonomy|
+ - tr_class = cycle('odd', 'even')
+ - tr_id = spree_dom_id(taxonomy)
+ %tr{class: tr_class, id: tr_id}
+ %td
+ %span.handle
+ = taxonomy.name
+ %td.actions
+ = link_to_edit taxonomy.id, no_text: true
+ = link_to_delete taxonomy, no_text: true
diff --git a/app/views/spree/admin/taxonomies/_taxon.html.erb b/app/views/spree/admin/taxonomies/_taxon.html.erb
deleted file mode 100644
index d5eb39190cf..00000000000
--- a/app/views/spree/admin/taxonomies/_taxon.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-<% if taxon.children.length != 0 %>
-
- <% taxon.children.each do |child| %>
- -
- <%= child.name %>
- <% if child.children.length > 0 %>
- <%= render :partial => 'taxon', :locals => { :taxon => child } %>
- <% end %>
-
- <% end %>
-
-<% end %>
diff --git a/app/views/spree/admin/taxonomies/_taxon.html.haml b/app/views/spree/admin/taxonomies/_taxon.html.haml
new file mode 100644
index 00000000000..6c5e5273b96
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/_taxon.html.haml
@@ -0,0 +1,7 @@
+- if taxon.children.length != 0
+ %ul
+ - taxon.children.each do |child|
+ %li{id: "#{child.id}", rel: "taxon"}
+ %a{href: "#", style: "background-image: url(#{child.icon.url});"}= child.name
+ - if child.children.length > 0
+ = render partial: 'taxon', locals: { taxon: child }
diff --git a/app/views/spree/admin/taxonomies/edit.erb b/app/views/spree/admin/taxonomies/edit.erb
deleted file mode 100755
index e5f2dcc2b16..00000000000
--- a/app/views/spree/admin/taxonomies/edit.erb
+++ /dev/null
@@ -1,42 +0,0 @@
-<%= render :partial => 'spree/admin/shared/configuration_menu' %>
-
-<%= render :partial => 'js_head' %>
-
-<% content_for :page_title do %>
- <%= Spree.t(:taxonomy_edit) %>
-<% end %>
-
-<% content_for :page_actions do %>
-
- <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
-
-<% end %>
-
-
-
-<%= form_for [:admin, @taxonomy] do |f| %>
-
-<% end %>
diff --git a/app/views/spree/admin/taxonomies/edit.haml b/app/views/spree/admin/taxonomies/edit.haml
new file mode 100755
index 00000000000..3deb3289992
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/edit.haml
@@ -0,0 +1,32 @@
+= render partial: 'spree/admin/shared/configuration_menu'
+
+= render partial: 'js_head'
+
+- content_for :page_title do
+ = t("spree.taxonomy_edit")
+
+- content_for :page_actions do
+ %li
+ = button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
+
+#ajax_error.errorExplanation{style: "display:none;"}
+= form_for [:admin, @taxonomy] do |f|
+ %fieldset.no-border-top
+ = render partial: 'form', locals: { f: f }
+ %div
+ = label_tag nil, t("spree.tree")
+ %br/
+ :javascript
+ Spree.routes.taxonomy_taxons_path = "#{spree.api_taxonomy_taxons_path(@taxonomy)}";
+ Spree.routes.admin_taxonomy_taxons_path = "#{spree.admin_taxonomy_taxons_path(@taxonomy)}";
+ #taxonomy_tree.tree
+ #progress{style: "display:none;"}
+ = image_tag 'select2-spinner.gif', title: 'Spinner', style: "vertical-align:bottom;"
+ = t("spree.updating")
+ \..
+ .info= t("spree.taxonomy_tree_instruction")
+ %br/
+ .filter-actions.actions
+ = button t('spree.actions.update'), 'icon-refresh'
+ %span.or= t("spree.or")
+ = button_link_to t('spree.actions.cancel'), admin_taxonomies_path, icon: 'icon-remove'
diff --git a/app/views/spree/admin/taxonomies/index.html.erb b/app/views/spree/admin/taxonomies/index.html.erb
deleted file mode 100644
index 57c886272de..00000000000
--- a/app/views/spree/admin/taxonomies/index.html.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-<%= render :partial => 'spree/admin/shared/configuration_menu' %>
-
-<% content_for :page_title do %>
- <%= Spree.t(:taxonomies) %>
-<% end %>
-
-<% content_for :page_actions do %>
-
- <%= button_link_to Spree.t(:new_taxonomy), spree.new_admin_taxonomy_url, :icon => 'icon-plus', :id => 'admin_new_taxonomy_link' %>
-
-<% end %>
-
-
- <%= render :partial => 'list' %>
-
diff --git a/app/views/spree/admin/taxonomies/index.html.haml b/app/views/spree/admin/taxonomies/index.html.haml
new file mode 100644
index 00000000000..63041138d12
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/index.html.haml
@@ -0,0 +1,11 @@
+= render partial: 'spree/admin/shared/configuration_menu'
+
+- content_for :page_title do
+ = t("spree.taxonomies")
+
+- content_for :page_actions do
+ %li
+ = button_link_to t("spree.new_taxonomy"), spree.new_admin_taxonomy_url, icon: 'icon-plus', id: 'admin_new_taxonomy_link'
+
+#list-taxonomies
+ = render partial: 'list'
diff --git a/app/views/spree/admin/taxonomies/new.html.erb b/app/views/spree/admin/taxonomies/new.html.erb
deleted file mode 100644
index a46166b9734..00000000000
--- a/app/views/spree/admin/taxonomies/new.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<%= render :partial => 'spree/admin/shared/configuration_menu' %>
-
-<% content_for :page_title do %>
- <%= Spree.t(:new_taxonomy) %>
-<% end %>
-
-<% content_for :page_actions do %>
-
- <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
-
-<% end %>
-
-<%= form_for [:admin, @taxonomy] do |f| %>
-
- <%= render :partial => 'form', :locals => { :f => f } %>
-
-<% end %>
diff --git a/app/views/spree/admin/taxonomies/new.html.haml b/app/views/spree/admin/taxonomies/new.html.haml
new file mode 100644
index 00000000000..a84338ddf13
--- /dev/null
+++ b/app/views/spree/admin/taxonomies/new.html.haml
@@ -0,0 +1,15 @@
+= render partial: 'spree/admin/shared/configuration_menu'
+
+- content_for :page_title do
+ = t("spree.new_taxonomy")
+
+- content_for :page_actions do
+ %li
+ = button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
+
+= form_for [:admin, @taxonomy] do |f|
+ = render partial: 'form', locals: { f: f }
+ %fieldset.no-border-top
+ %br/
+ .filter-actions.actions
+ = button t("spree.create"), 'icon-ok'
From def9ab7c47abbc57b1a8f54c04cbf2fa3db11c6e Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 17:22:30 +0100
Subject: [PATCH 06/13] Convert spree/admin/taxons from erb to haml
---
app/views/spree/admin/taxons/_form.html.haml | 14 +++++------
.../spree/admin/taxons/_taxon_table.html.erb | 23 -------------------
.../spree/admin/taxons/_taxon_table.html.haml | 20 ++++++++++++++++
app/views/spree/admin/taxons/edit.html.erb | 23 -------------------
app/views/spree/admin/taxons/edit.html.haml | 17 ++++++++++++++
app/views/spree/admin/taxons/search.rabl | 1 -
6 files changed, 44 insertions(+), 54 deletions(-)
delete mode 100644 app/views/spree/admin/taxons/_taxon_table.html.erb
create mode 100644 app/views/spree/admin/taxons/_taxon_table.html.haml
delete mode 100644 app/views/spree/admin/taxons/edit.html.erb
create mode 100644 app/views/spree/admin/taxons/edit.html.haml
diff --git a/app/views/spree/admin/taxons/_form.html.haml b/app/views/spree/admin/taxons/_form.html.haml
index 19a8af59368..72ba498a4dc 100644
--- a/app/views/spree/admin/taxons/_form.html.haml
+++ b/app/views/spree/admin/taxons/_form.html.haml
@@ -1,11 +1,11 @@
-.row{"data-hook" => "admin_inside_taxon_form"}
+.row
.alpha.five.columns
= f.field_container :name do
= f.label :name, t(:name)
%span.required *
%br/
- = error_message_on :taxon, :name, :class => 'fullwidth title'
- = text_field :taxon, :name, :class => 'fullwidth'
+ = error_message_on :taxon, :name, class: 'fullwidth title'
+ = text_field :taxon, :name, class: 'fullwidth'
= f.field_container :permalink_part do
= f.label :permalink_part, t(:permalink)
%span.required *
@@ -20,17 +20,17 @@
= f.field_container :meta_title do
= f.label :meta_title, t(:meta_title)
%br/
- = f.text_field :meta_title, :class => 'fullwidth', :rows => 6
+ = f.text_field :meta_title, class: 'fullwidth', rows: 6
= f.field_container :meta_description do
= f.label :meta_description, t(:meta_description)
%br/
- = f.text_field :meta_description, :class => 'fullwidth', :rows => 6
+ = f.text_field :meta_description, class: 'fullwidth', rows: 6
= f.field_container :meta_description do
= f.label :meta_keywords, t(:meta_keywords)
%br/
- = f.text_field :meta_keywords, :class => 'fullwidth', :rows => 6
+ = f.text_field :meta_keywords, class: 'fullwidth', rows: 6
.omega.seven.columns
= f.field_container :description do
= f.label :description, t(:description)
%br/
- = f.text_area :description, :class => 'fullwidth', :rows => 6
+ = f.text_area :description, class: 'fullwidth', rows: 6
diff --git a/app/views/spree/admin/taxons/_taxon_table.html.erb b/app/views/spree/admin/taxons/_taxon_table.html.erb
deleted file mode 100644
index 1598bfb4702..00000000000
--- a/app/views/spree/admin/taxons/_taxon_table.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- <%= Spree.t(:name) %> |
- <%= Spree.t(:path) %> |
- |
-
-
-
- <% taxons.each do |taxon| %>
-
- <%= taxon.name %> |
- <%= taxon_path taxon %> |
-
- <%= link_to_delete taxon, :url => remove_admin_product_taxon_url(@product, taxon), :name => icon('delete') + ' ' + Spree.t(:remove) %>
- |
-
- <% end %>
- <% if taxons.empty? %>
- <%= Spree.t(:none) %>. |
- <% end %>
-
-
diff --git a/app/views/spree/admin/taxons/_taxon_table.html.haml b/app/views/spree/admin/taxons/_taxon_table.html.haml
new file mode 100644
index 00000000000..7917db0c978
--- /dev/null
+++ b/app/views/spree/admin/taxons/_taxon_table.html.haml
@@ -0,0 +1,20 @@
+%table.index
+ %thead
+ %tr
+ %th= t("spree.name")
+ %th= t("spree.path")
+ %th
+ %tbody
+ - taxons.each do |taxon|
+ - tr_class = cycle('odd', 'even')
+ - tr_id = spree_dom_id(taxon)
+ %tr{class: tr_class, id: tr_id}
+ %td= taxon.name
+ %td= taxon_path taxon
+ %td.actions
+ = link_to_delete taxon, url: remove_admin_product_taxon_url(@product, taxon), name: icon('delete') + ' ' + t("spree.remove")
+ - if taxons.empty?
+ %tr
+ %td{colspan: "3"}
+ = t("spree.none")
+ \.
diff --git a/app/views/spree/admin/taxons/edit.html.erb b/app/views/spree/admin/taxons/edit.html.erb
deleted file mode 100644
index 2335bee1c50..00000000000
--- a/app/views/spree/admin/taxons/edit.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-<%= render :partial => 'spree/admin/shared/configuration_menu' %>
-
-<% content_for :page_title do %>
- <%= Spree.t(:taxon_edit) %>
-<% end %>
-
-<% content_for :page_actions do %>
-
- <%= button_link_to Spree.t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
-
-<% end %>
-
-<% # Because otherwise the form would attempt to use to_param of @taxon %>
-<% form_url = admin_taxonomy_taxon_path(@taxonomy.id, @taxon.id) %>
-<%= form_for [:admin, @taxonomy, @taxon], :method => :put, :url => form_url, :html => { :multipart => true } do |f| %>
- <%= render :partial => 'form', :locals => { :f => f } %>
-
-
- <%= button Spree.t('actions.update'), 'icon-refresh' %>
- <%= Spree.t(:or) %>
- <%= button_link_to Spree.t('actions.cancel'), edit_admin_taxonomy_url(@taxonomy), :icon => "icon-remove" %>
-
-<% end %>
diff --git a/app/views/spree/admin/taxons/edit.html.haml b/app/views/spree/admin/taxons/edit.html.haml
new file mode 100644
index 00000000000..7e1e0a45e4c
--- /dev/null
+++ b/app/views/spree/admin/taxons/edit.html.haml
@@ -0,0 +1,17 @@
+= render partial: 'spree/admin/shared/configuration_menu'
+
+- content_for :page_title do
+ = t("spree.taxon_edit")
+
+- content_for :page_actions do
+ %li
+ = button_link_to t("spree.back_to_taxonomies_list"), spree.admin_taxonomies_path, icon: 'icon-arrow-left'
+
+- # Because otherwise the form would attempt to use to_param of @taxon
+- form_url = admin_taxonomy_taxon_path(@taxonomy.id, @taxon.id)
+= form_for [:admin, @taxonomy, @taxon], method: :put, url: form_url, html: { multipart: true } do |f|
+ = render partial: 'form', locals: { f: f }
+ .form-buttons
+ = button t('spree.actions.update'), 'icon-refresh'
+ = t("spree.or")
+ = button_link_to t('spree.actions.cancel'), edit_admin_taxonomy_url(@taxonomy), icon: "icon-remove"
diff --git a/app/views/spree/admin/taxons/search.rabl b/app/views/spree/admin/taxons/search.rabl
index ac5f36f9794..5214337d12a 100644
--- a/app/views/spree/admin/taxons/search.rabl
+++ b/app/views/spree/admin/taxons/search.rabl
@@ -2,4 +2,3 @@ object false
child(@taxons => :taxons) do
attributes :name, :pretty_name, :id
end
-
From 4781ab93effe3e34678f2e1fb1fe9a88f8c25e70 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 17:45:30 +0100
Subject: [PATCH 07/13] Bring spree/admin configuration routes to ofn
---
config/routes/spree.rb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/config/routes/spree.rb b/config/routes/spree.rb
index 94da909f8b1..5bc162fc170 100644
--- a/config/routes/spree.rb
+++ b/config/routes/spree.rb
@@ -88,6 +88,23 @@
put :clear_api_key
end
end
+
+ # Configuration section
+ resources :taxonomies do
+ collection do
+ post :update_positions
+ end
+ member do
+ get :get_children
+ end
+ resources :taxons
+ end
+
+ resources :taxons, :only => [] do
+ collection do
+ get :search
+ end
+ end
end
resources :orders do
From 9291bf5c825c1671355134142cfaf7c3c5002586 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 17:51:26 +0100
Subject: [PATCH 08/13] Bring taxons_helper from spree
---
app/helpers/spree/admin/taxons_helper.rb | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 app/helpers/spree/admin/taxons_helper.rb
diff --git a/app/helpers/spree/admin/taxons_helper.rb b/app/helpers/spree/admin/taxons_helper.rb
new file mode 100644
index 00000000000..06b26d0b06a
--- /dev/null
+++ b/app/helpers/spree/admin/taxons_helper.rb
@@ -0,0 +1,9 @@
+module Spree
+ module Admin
+ module TaxonsHelper
+ def taxon_path(taxon)
+ taxon.ancestors.reverse.collect { |ancestor| ancestor.name }.join( " >> ")
+ end
+ end
+ end
+end
From c66579a22f9732bd3dbccacd747d512597d6eaf8 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 17:54:29 +0100
Subject: [PATCH 09/13] Fix simple rubocop issues in helper
---
app/helpers/spree/admin/taxons_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/spree/admin/taxons_helper.rb b/app/helpers/spree/admin/taxons_helper.rb
index 06b26d0b06a..87ee61dbd51 100644
--- a/app/helpers/spree/admin/taxons_helper.rb
+++ b/app/helpers/spree/admin/taxons_helper.rb
@@ -2,7 +2,7 @@ module Spree
module Admin
module TaxonsHelper
def taxon_path(taxon)
- taxon.ancestors.reverse.collect { |ancestor| ancestor.name }.join( " >> ")
+ taxon.ancestors.reverse.collect(&:name).join( " >> ")
end
end
end
From 845a7643206e4e5932040b2a9e9fed41933a6337 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 18:21:14 +0100
Subject: [PATCH 10/13] Bring taxonomies feature spec from spree_backend
---
.../admin/configuration/taxonomies_spec.rb | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100644 spec/features/admin/configuration/taxonomies_spec.rb
diff --git a/spec/features/admin/configuration/taxonomies_spec.rb b/spec/features/admin/configuration/taxonomies_spec.rb
new file mode 100644
index 00000000000..f6e260a31af
--- /dev/null
+++ b/spec/features/admin/configuration/taxonomies_spec.rb
@@ -0,0 +1,52 @@
+require 'spec_helper'
+
+describe "Taxonomies" do
+ stub_authorization!
+
+ before(:each) do
+ visit spree.admin_path
+ click_link "Configuration"
+ end
+
+ context "show" do
+ it "should display existing taxonomies" do
+ create(:taxonomy, :name => 'Brand')
+ create(:taxonomy, :name => 'Categories')
+ click_link "Taxonomies"
+ within_row(1) { page.should have_content("Brand") }
+ within_row(2) { page.should have_content("Categories") }
+ end
+ end
+
+ context "create" do
+ before(:each) do
+ click_link "Taxonomies"
+ click_link "admin_new_taxonomy_link"
+ end
+
+ it "should allow an admin to create a new taxonomy" do
+ page.should have_content("New Taxonomy")
+ fill_in "taxonomy_name", :with => "sports"
+ click_button "Create"
+ page.should have_content("successfully created!")
+ end
+
+ it "should display validation errors" do
+ fill_in "taxonomy_name", :with => ""
+ click_button "Create"
+ page.should have_content("can't be blank")
+ end
+ end
+
+ context "edit" do
+ it "should allow an admin to update an existing taxonomy" do
+ create(:taxonomy)
+ click_link "Taxonomies"
+ within_row(1) { click_icon :edit }
+ fill_in "taxonomy_name", :with => "sports 99"
+ click_button "Update"
+ page.should have_content("successfully updated!")
+ page.should have_content("sports 99")
+ end
+ end
+end
From 1d4aebd3f9f2ea84c3e795b0ddd75150000b35f0 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 18:51:10 +0100
Subject: [PATCH 11/13] Fix feature spec added from spree_backend
---
spec/features/admin/configuration/taxonomies_spec.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/spec/features/admin/configuration/taxonomies_spec.rb b/spec/features/admin/configuration/taxonomies_spec.rb
index f6e260a31af..a1b20355d69 100644
--- a/spec/features/admin/configuration/taxonomies_spec.rb
+++ b/spec/features/admin/configuration/taxonomies_spec.rb
@@ -1,9 +1,10 @@
require 'spec_helper'
describe "Taxonomies" do
- stub_authorization!
+ include AuthenticationWorkflow
before(:each) do
+ quick_login_as_admin
visit spree.admin_path
click_link "Configuration"
end
From 5b703a02cdc8e3fc4b9efd6b9c823379c3e84fe3 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 18:52:45 +0100
Subject: [PATCH 12/13] Transpec feature spec brought from spree_backend
---
.../admin/configuration/taxonomies_spec.rb | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/spec/features/admin/configuration/taxonomies_spec.rb b/spec/features/admin/configuration/taxonomies_spec.rb
index a1b20355d69..6a5b96fb3f9 100644
--- a/spec/features/admin/configuration/taxonomies_spec.rb
+++ b/spec/features/admin/configuration/taxonomies_spec.rb
@@ -14,8 +14,8 @@
create(:taxonomy, :name => 'Brand')
create(:taxonomy, :name => 'Categories')
click_link "Taxonomies"
- within_row(1) { page.should have_content("Brand") }
- within_row(2) { page.should have_content("Categories") }
+ within_row(1) { expect(page).to have_content("Brand") }
+ within_row(2) { expect(page).to have_content("Categories") }
end
end
@@ -26,16 +26,16 @@
end
it "should allow an admin to create a new taxonomy" do
- page.should have_content("New Taxonomy")
+ expect(page).to have_content("New Taxonomy")
fill_in "taxonomy_name", :with => "sports"
click_button "Create"
- page.should have_content("successfully created!")
+ expect(page).to have_content("successfully created!")
end
it "should display validation errors" do
fill_in "taxonomy_name", :with => ""
click_button "Create"
- page.should have_content("can't be blank")
+ expect(page).to have_content("can't be blank")
end
end
@@ -46,8 +46,8 @@
within_row(1) { click_icon :edit }
fill_in "taxonomy_name", :with => "sports 99"
click_button "Update"
- page.should have_content("successfully updated!")
- page.should have_content("sports 99")
+ expect(page).to have_content("successfully updated!")
+ expect(page).to have_content("sports 99")
end
end
end
From 3833cbbf73b7f4909421cd0b95f9b0e53d4b0211 Mon Sep 17 00:00:00 2001
From: luisramos0
Date: Tue, 17 Sep 2019 18:56:55 +0100
Subject: [PATCH 13/13] Fix rubocop issues in feature spec
---
spec/features/admin/configuration/taxonomies_spec.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/spec/features/admin/configuration/taxonomies_spec.rb b/spec/features/admin/configuration/taxonomies_spec.rb
index 6a5b96fb3f9..7eb592587fb 100644
--- a/spec/features/admin/configuration/taxonomies_spec.rb
+++ b/spec/features/admin/configuration/taxonomies_spec.rb
@@ -11,8 +11,8 @@
context "show" do
it "should display existing taxonomies" do
- create(:taxonomy, :name => 'Brand')
- create(:taxonomy, :name => 'Categories')
+ create(:taxonomy, name: 'Brand')
+ create(:taxonomy, name: 'Categories')
click_link "Taxonomies"
within_row(1) { expect(page).to have_content("Brand") }
within_row(2) { expect(page).to have_content("Categories") }
@@ -27,13 +27,13 @@
it "should allow an admin to create a new taxonomy" do
expect(page).to have_content("New Taxonomy")
- fill_in "taxonomy_name", :with => "sports"
+ fill_in "taxonomy_name", with: "sports"
click_button "Create"
expect(page).to have_content("successfully created!")
end
it "should display validation errors" do
- fill_in "taxonomy_name", :with => ""
+ fill_in "taxonomy_name", with: ""
click_button "Create"
expect(page).to have_content("can't be blank")
end
@@ -44,7 +44,7 @@
create(:taxonomy)
click_link "Taxonomies"
within_row(1) { click_icon :edit }
- fill_in "taxonomy_name", :with => "sports 99"
+ fill_in "taxonomy_name", with: "sports 99"
click_button "Update"
expect(page).to have_content("successfully updated!")
expect(page).to have_content("sports 99")