This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ProductImageCollection | |
| def initialize(images) | |
| self.images = load_images(images) | |
| end | |
| def images_for(group: nil, color: nil, size: nil) | |
| processor = ProductImageCollectionProcessor.new(images.clone) | |
| processor.filter(group, color) | |
| processor.resize(size) if size.present? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| before(:each) { Rails.cache.clear } | |
| let(:magento_response) { "file in VCR"} | |
| subject(:inventory} {...] | |
| specify {expect(inventory.results).to eq magento_response } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filename = ARVG[0] | |
| content = File.read(filename) | |
| snippets = content.split("\n\n\n") | |
| snippets.each_with_index do |snippet, index| | |
| f = File.new("snippet_#{index}.js") | |
| f.write(snippet) | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Apibase | |
| class User | |
| def self.find_by_api_token(token) | |
| if token.present? | |
| users.find { |u| u['api_key'] == token } | |
| else | |
| nil | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec::Matchers.define :match_unordered_json_string do |json_string| | |
| match do |actual| | |
| sort_hash(JSON.parse(actual)).to_json == sort_hash(JSON.parse(json_string)).to_json | |
| end | |
| description do | |
| "be in the correct order" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class JsonTarget | |
| attr_accessor :votes_count, :votes_percentage, :position, :type, :media, :post | |
| def factory_hash | |
| { | |
| position: position, | |
| type: type, | |
| media: media, | |
| post: post | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sort_hash(hash) | |
| sorted_hash = {} | |
| hash.keys.sort.each do |k| | |
| if hash[k].is_a?(Hash) | |
| sorted_hash[k] = sort_hash(hash[k]) | |
| elsif hash[k].is_a?(Array) && hash[k].first.is_a?(Hash) | |
| sorted_hash[k] = hash[k].collect{ |h| sort_hash(h) } | |
| else | |
| sorted_hash[k] = hash[k] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pending_subscription_creation_required? | |
| updated_pending_subscription_required? || new_pending_subscription_required? | |
| end | |
| def updated_pending_subscription_required? | |
| @account.pending_subscription.present? | |
| end | |
| def new_pending_subscription_required? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def recordings | |
| super do |recordings| | |
| recordings = recordings.with_rejected_readings if self.with_rejected_readings.present? | |
| recordings | |
| end | |
| end | |
| def accepted_rejected_pie_chart_data | |
| readings = FoodReadings.where(food_recording_id: recordings.collect(&:id)) | |
| accepted = FoodReadings.where(food_recording_id: recordings.collect(&:id)).with_section(self.section_id).accepted.count } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe GSTCalculator do | |
| describe '#ex_gst_amount' do | |
| end | |
| describe '#gst_amount' do |