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

Commit

Permalink
Dont override channel and don't add query strings to image urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dutil authored and Jeff Dutil committed Sep 29, 2014
1 parent 0654dbd commit ecddad9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/serializers/spree/wombat/image_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ImageSerializer < ActiveModel::Serializer
attributes :url, :position, :title, :type, :dimensions

def url
add_host_prefix(object.attachment.url(:original))
add_host_prefix(object.attachment.url(:original)).gsub(/\?.*/, '')
end

def title
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/spree/wombat/order_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def status
end

def channel
'spree'
object.channel || 'spree'
end

def updated_at
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/spree/wombat/shipment_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def email
end

def channel
'spree'
object.order.channel || 'spree'
end

def cost
Expand Down
11 changes: 9 additions & 2 deletions spec/serializers/spree/wombat/order_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ module Wombat
expect(serialized_order["status"]).to eql order.state
end

it "sets the channel to spree" do
expect(serialized_order["channel"]).to eql "spree"
context '#channel' do
it "sets the channel to spree if unset" do
expect(serialized_order["channel"]).to eql "spree"
end

it "sets the channel to existing value other than spree" do
order.update_column :channel, 'wombat'
expect(serialized_order["channel"]).to eql "wombat"
end
end

it "set's the placed_on to completed_at date in ISO format" do
Expand Down
11 changes: 9 additions & 2 deletions spec/serializers/spree/wombat/shipment_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ module Wombat
expect(serialized_shipment["status"]).to eql shipment.state
end

it "sets the channel to spree" do
expect(serialized_shipment["channel"]).to eql "spree"
context '#channel' do
it "sets the channel to spree if unset" do
expect(serialized_shipment["channel"]).to eql "spree"
end

it "sets the channel to existing value other than spree" do
shipment.order.update_column :channel, 'wombat'
expect(serialized_shipment["channel"]).to eql "wombat"
end
end

it "serializes the stock_location.name as stock_location" do
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/spree/wombat/variant_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Wombat
expect(serialized_variant["images"].count).to be 3
dimension_hash = {"height" => 490, "width" => 489}
3.times.each_with_index do |i|
expect(serialized_variant["images"][i]["url"]).to match /http:\/\/myapp.dev\/spree\/products\/\d*\/original\/thinking-cat.jpg\?\d*/
expect(serialized_variant["images"][i]["url"]).to match /http:\/\/myapp.dev\/spree\/products\/\d*\/original\/thinking-cat.jpg\z/
expect(serialized_variant["images"][i]["position"]).to eql i
expect(serialized_variant["images"][i]["title"]).to eql "variant image #{i}"
expect(serialized_variant["images"][i]["type"]).to eql "original"
Expand Down

0 comments on commit ecddad9

Please sign in to comment.