Merge pull request #28 from iloveitaly/additional-tests
Additional Tests
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -11,6 +11,6 @@ group :test do
|
||||
end
|
||||
end
|
||||
|
||||
gem 'spree', '~> 1.1.2'
|
||||
gem 'spree', '~> 1.1.3'
|
||||
|
||||
gemspec
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div>
|
||||
<div>
|
||||
<%= form_for(:digital, :url => { :controller => 'digitals', :action => 'create' }, :html => { :multipart => true }) do |f| %>
|
||||
<%= form_for(:digital, :url => admin_product_digitals_path(@product), :method => :create, :multipart => true ) do |f| %>
|
||||
<fieldset>
|
||||
<legend><%= Spree::Variant.model_name.human %> "<%= variant.options_text %>"</legend>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<% variant.digitals.each do |digital| %>
|
||||
<li>
|
||||
<%= render digital %>
|
||||
<%= link_to t("delete_file"), admin_product_digital_url(:id => variant.digitals.first.id), :confirm => t('delete_file_cofirmation', :filename => variant.digitals.first.attachment_file_name), :method => :delete %>
|
||||
<%= link_to t("delete_file"), admin_product_digital_url(@product, digital), :confirm => t('delete_file_cofirmation', :filename => digital.attachment_file_name), :method => :delete %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
<% else %>
|
||||
This product has no variants.
|
||||
|
||||
<% if @product.master.digital? %>
|
||||
<% if @product.master.digital? %>
|
||||
A digital version of this product currently exists:
|
||||
<%= render @product.master.digital %>
|
||||
<%= render @product.master.digitals %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'form', :variant => @product.master %>
|
||||
|
||||
@@ -12,5 +12,6 @@ en:
|
||||
mp3: Audio MP3
|
||||
mobi: Kindle eBook
|
||||
epub: ePub eBook
|
||||
pdf: pdf eBook
|
||||
spree_digital:
|
||||
upload: Upload
|
||||
43
spec/controllers/digitals_controller_spec.rb
Normal file
43
spec/controllers/digitals_controller_spec.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Admin::DigitalsController do
|
||||
before do
|
||||
@product = FactoryGirl.create :product
|
||||
|
||||
controller.stub :authorize! => true
|
||||
end
|
||||
|
||||
let(:product) { @product }
|
||||
|
||||
context "with variants" do
|
||||
before do
|
||||
# TODO add variants with digital
|
||||
end
|
||||
|
||||
it "should display an empty page when no digitals exist" do
|
||||
|
||||
end
|
||||
|
||||
it "should display list of digitals when they exist" do
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context "without variants" do
|
||||
render_views
|
||||
|
||||
it "should display an empty page when no digitals exist" do
|
||||
spree_get :index, "product_id" => product.permalink
|
||||
response.code.should == "200"
|
||||
response.body.should include("This product has no variants")
|
||||
end
|
||||
|
||||
it "should display list of digitals when they exist" do
|
||||
@digital = FactoryGirl.create :digital, :variant => product.master
|
||||
spree_get :index, :product_id => product.permalink
|
||||
response.code.should == "200"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Digital do
|
||||
|
||||
@@ -12,13 +12,13 @@ describe Spree::Digital do
|
||||
end
|
||||
|
||||
context "#destroy" do
|
||||
#it "should destroy associated digital_links" do
|
||||
# digital = FactoryGirl.create(:digital)
|
||||
# 3.times { digital.digital_links.create! :order => FactoryGirl.create(:order) }
|
||||
# DigitalLink.count.should == 3
|
||||
# digital.destroy
|
||||
# DigitalLink.count.should == 0
|
||||
#end
|
||||
it "should destroy associated digital_links" do
|
||||
digital = FactoryGirl.create(:digital)
|
||||
3.times { digital.digital_links.create!({ :line_item => FactoryGirl.create(:line_item) }, :without_protection => true) }
|
||||
Spree::DigitalLink.count.should == 3
|
||||
digital.destroy
|
||||
Spree::DigitalLink.count.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -81,7 +81,6 @@ describe Spree::Order do
|
||||
|
||||
order.rate_hash.count.should == 1
|
||||
order.rate_hash.first.shipping_method.calculator.class.should_not == Spree::Calculator::DigitalDelivery
|
||||
puts "SHIPP #{order.rate_hash.first}"
|
||||
order.rate_hash.first.cost.should == 10.0
|
||||
end
|
||||
end
|
||||
|
||||
18
spec/models/variant_spec.rb
Normal file
18
spec/models/variant_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Spree::Variant do
|
||||
before do
|
||||
@product = FactoryGirl.create :product
|
||||
@digital = FactoryGirl.create :digital, :variant => @product.master
|
||||
end
|
||||
|
||||
let(:variant) { @product.master }
|
||||
|
||||
it "should delete all digitals on variant#destroy" do
|
||||
digital_id = variant.digitals.first.id
|
||||
Spree::Digital.find(digital_id).should_not be_nil
|
||||
variant.digitals.count.should == 1
|
||||
variant.destroy
|
||||
expect { Spree::Digital.find(digital_id) }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
@@ -1,34 +1,24 @@
|
||||
# Configure Rails Environment
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
|
||||
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
||||
|
||||
require 'rspec/rails'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
|
||||
|
||||
# Requires factories defined in spree_core
|
||||
require 'spree/core/testing_support/factories'
|
||||
require 'spree/core/testing_support/env'
|
||||
require 'spree/core/testing_support/controller_requests'
|
||||
require 'spree/core/url_helpers'
|
||||
|
||||
RSpec.configure do |config|
|
||||
# == Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
config.include Spree::Core::UrlHelpers
|
||||
config.include Spree::Core::TestingSupport::ControllerRequests
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
end
|
||||
|
||||
Dir[File.join(File.dirname(__FILE__), "factories/*.rb")].each {|f| require f }
|
||||
|
||||
Reference in New Issue
Block a user