This file contains 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 VariantDatasheet do | |
describe "Importing Data" do | |
it "should parse file contents and return a result" do | |
variant_datasheet = VariantDatasheet.new | |
file_path = 'spec/support/toughbook_19_variants.csv' |
This file contains 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
Failures: | |
1) VariantDatasheet Importing Data should parse file contents and return a result | |
Failure/Error: variant_datasheet.import_data(file_path).should eq(result) | |
expected [["TYPE", "FAMILY", "SKU", "DESCRIPTION", " SRP ", "STATUS", "CPU", "SCREEN", "RAM", "BASE SKU", "HDD", "WLAN/WWLAN", "DRIVE", "OS", "WIRELESS CARRIER", "OTHER", "LAST MODIFIED", "COMMENT", "Effective Date"], ["CPU", "CF-19", "CF-19BTUDX1M", "No Wireless, Win7, Intel Core i5-2520M 2.50GHz, No vPro, 10.1\" TF+XGA Touch, 320GB(7200rpm), 4GB, No WLAN, TPM, No Bluetooth, Dual Pass (Upper:WWAN/Lower:None), Smartcard, No Absolute BIOS, No Drive, Toughbook Preferred", "3859", "CURRENT", "Intel Core i5-2520M 2.50GHz", "10.1 TF+XGA Touch", "4GB", "F", "320GB(7200rpm)", "No WLAN", "No Drive", "Win7", "No WLAN", "No Bluetooth, Dual Pass (Upper:WWAN/Lower:None), Smartcard", "8/26/11 17:33", nil, nil]] | |
got [["TYPE", "FAMILY", "SKU", "DESCRIPTION", " SRP ", "STATUS", "CPU", "SCREEN", "RAM", "BASE SKU", "HDD", "WLAN/W |
This file contains 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 VariantDatasheet < ActiveRecord::Base | |
require 'csv' | |
has_attached_file :csv, :path => ":rails_root/uploads/variant_datasheets/:id/:basename.:extension" | |
validates_attachment_presence :csv | |
def import_data | |
variants = self.get_variants |
This file contains 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 'csv' | |
require 'ruby_regex' | |
class Cleaner | |
def initialize | |
@rejects = get_reject_csvs | |
@role_addresses = CSV.read('./role_addresses.csv') | |
end | |
# Removes rows from CSV containing problematic emails |
This file contains 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 'net/telnet' | |
# Returns the highest priority MX record server for a domain or nil. | |
# | |
# get_mail_server('mydomain.com') # => 'smtp.mydomain.com' | |
def get_mail_server(domain) | |
require 'resolv' | |
mx = nil | |
Resolv::DNS.open do |dns| | |
mail_servers = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) |
This file contains 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 DomainsController do | |
render_views | |
context "#show" do | |
it "should have the correct domain name on the page" do | |
domain = Domain.create!(:name => "Example Dossmain") | |
visit domain_path(domain) |
This file contains 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 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
# Loading more in this block will cause your tests to run faster. However, | |
# if you change any configuration or code from libraries loaded here, you'll | |
# need to restart spork for it take effect. | |
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) |
This file contains 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
# Finds the product that the variant is for | |
# | |
# variant_attr - a hash of attributes for the variant | |
# | |
# Returns an instance of Product | |
def get_variant_product(variant_attr) | |
product_id = variant_attr["product_id"].to_i | |
product = Product.find(product_id) | |
product |
This file contains 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
Given /^the custom taxons and custom products exist$/ do | |
taxonomy = Taxonomy.find_by_name('Categories') | |
root = taxonomy.root | |
clothing_taxon = taxonomy.taxons.create(:name => 'Clothing', :parent_id => root.id) | |
bags_taxon = taxonomy.taxons.create(:name => 'Bags', :parent_id => root.id) | |
mugs_taxon = taxonomy.taxons.create(:name => 'Mugs', :parent_id => root.id) | |
taxonomy = Taxonomy.find_by_name('Brand') | |
root = taxonomy.root |
This file contains 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
Given /^the custom taxons and custom products exist$/ do | |
taxonomy = Taxonomy.find_by_name('Categories') | |
root = taxonomy.root | |
clothing_taxon = taxonomy.taxons.create(:name => 'Clothing', :parent_id => root.id) | |
bags_taxon = taxonomy.taxons.create(:name => 'Bags', :parent_id => root.id) | |
mugs_taxon = taxonomy.taxons.create(:name => 'Mugs', :parent_id => root.id) | |
taxonomy = Taxonomy.find_by_name('Brand') | |
root = taxonomy.root |