Permalink
Browse files

Merge branch 'master' of github.com:nebulab/spree-subscriptions

  • Loading branch information...
2 parents 80a9eed + 5a893f7 commit 3faa48cd06777849fec315ba2458c5affafb4fad @kennyadsl kennyadsl committed Jun 6, 2012
@@ -1,6 +1,6 @@
module Spree
module Admin
- module Variants
+ module Products
class IssuesController < Spree::Admin::BaseController
before_filter :load_magazine
before_filter :load_issue, :only => [:show, :edit, :update]
@@ -37,16 +37,16 @@ def create
private
def load_magazine
- @magazine = Variant.find(params[:magazine_id])
- @product = @magazine.product # useful to display product_tab menu
+ @magazine = Product.find_by_permalink(params[:magazine_id])
+ @product = @magazine # useful to display product_tab menu
end
def load_issue
@issue = Issue.find(params[:id])
end
def load_products
- @products = Variant.unsubscribable.map { |variant| [variant.product.name, variant.id] }
+ @products = Product.unsubscribable.map { |product| [product.name, product.id] }
end
end
end
@@ -33,7 +33,7 @@ def update
protected
def load_data
- @variants = Variant.subscribable.all.map { |variant| [variant.product.name, variant.id] }
+ @products = Product.subscribable.all.map { |product| [product.name, product.id] }
end
end
end
@@ -6,4 +6,4 @@
Deface::Override.new(:virtual_path => "spree/admin/products/_form",
:name => "adds_subscribable_to_product",
:insert_bottom => "[data-hook='admin_product_form_right']",
- :partial => "spree/admin/variants/subscription_fields")
+ :partial => "spree/admin/products/subscription_fields")
@@ -1,5 +1,5 @@
<% if @product.subscribable? %>
<li<%== ' class="active"' if current == "Issues" %>>
- <%= link_to t("issues"), admin_magazine_issues_url(@product.master) %>
+ <%= link_to t("issues"), admin_magazine_issues_url(@product) %>
</li>
<% end %>
@@ -4,5 +4,5 @@
<% end %>
<% if @product.subscribable? %>
- <%= render :partial => 'spree/admin/product/subscription_fields', :locals => "f" => f %>
+ <%= render :partial => 'spree/admin/variants/subscription_fields', :locals => { :f => f } %>
<% end %>
View
@@ -3,8 +3,8 @@
resources :subscriptions do
resource :customer, :controller => "subscriptions/customer_details"
end
- resources :variants, :as => :magazines do
- resources :issues, :controller => "variants/issues"
+ resources :products, :as => :magazines do
+ resources :issues, :controller => "products/issues"
end
end
end
@@ -1,7 +1,7 @@
FactoryGirl.define do
factory :subscribable_variant, :parent => :variant do
# associations:
- product :subscribable_product
+ product { |p| p.association(:subscribable_product) }
issues_number 4
end
end
@@ -3,6 +3,7 @@
describe Spree::Product do
before(:each) do
@product = Factory(:simple_product, :subscribable => true)
+ @simple_product = Factory(:simple_product)
end
it "should respond to subscribable method" do
@@ -20,4 +21,8 @@
it "should respond to subscribable? with true" do
@product.subscribable?.should be_true
end
+
+ it "should have subscribable to false by default" do
+ @simple_product.subscribable?.should be false
+ end
end
@@ -23,7 +23,7 @@
context "subscribable products" do
before(:each) do
- @magazine = create(:simple_product, :subscribable => true).master
+ @magazine = create(:subscribable_product)
click_link "Products"
within('table.index tr:nth-child(2)') { click_link "Edit" }
end
@@ -45,7 +45,7 @@
context "managing an issue" do
before do
- @magazine = create(:simple_product, :subscribable => true).master
+ @magazine = create(:subscribable_product)
click_link "Products"
within('table.index tr:nth-child(2)') { click_link "Edit" }
end
@@ -36,26 +36,26 @@
it "should have the correct fields" do
within('#new_subscription') do
- page.should have_content('Variant')
+ page.should have_content('Product')
page.should have_content('Remaining Issues')
end
end
- it "should let choose only subscribable variant" do
+ it "should let choose only subscribable product" do
# this is an hack. The following line does not work!!
- # page.has_select?('Variant', :with_options => ['the book'])
+ # page.has_select?('Product', :with_options => ['the book'])
page.should have_xpath("//*[@id='subscription_magazine_id']/option", :count => 2)
end
it "should be created correctly" do
- select "web magazine", :from => "Variant"
+ select "web magazine", :from => "Product"
click_button "Create"
page.should have_content("successfully created!")
# within('table#listing_subscriptions tbody tr:nth-child(1)') { click_link("Edit") }
within('.sidebar') { click_link("Subscription Details") }
# hack. The following line does not work
- # page.has_select?('Variant', :selected => "web magazine")
- find_field('Variant').find('option[selected]').text.should == "web magazine"
+ # page.has_select?('Product', :selected => "web magazine")
+ find_field('Product').find('option[selected]').text.should == "web magazine"
end
end
@@ -69,10 +69,10 @@
it "should be edited correctly" do
within('table#listing_subscriptions tbody tr:nth-child(1)') { click_link("Edit") }
- select "web magazine", :from => "Variant"
+ select "web magazine", :from => "Product"
click_button "Update"
page.should have_content("successfully updated!")
- find_field('Variant').find('option[selected]').text.should == "web magazine"
+ find_field('Product').find('option[selected]').text.should == "web magazine"
end
context "editing customer details" do
@@ -96,7 +96,7 @@
end
click_button "Update"
page.should have_content("The customer's details have been updated")
- page.should have_content("Variant")
+ page.should have_content("Product")
within('.sidebar') { click_link("Customer Details") }
find_field("subscription_email").value.should == "johnnyrocket@stardustcompany.com"
within('#shipping') do
@@ -1,25 +0,0 @@
-require 'spec_helper'
-
-describe "Variants" do
- context "setting a variant as subscribabale" do
- before do
- user = create(:admin_user, :email => "test@example.com")
- sign_in_as!(user)
- end
-
- it "should be markable as subscribable by admin users" do
- product = create(:product_with_option_types, :subscribable => true)
-
- product.options.each do |option|
- create(:option_value, :option_type => option.option_type)
- end
-
- visit spree.admin_path
- click_link "Products"
- within('table.index tr:nth-child(2)') { click_link "Edit" }
- click_link "Variants"
- click_on "New Variant"
- page.has_checked_field?('variant_subscribable').should == true
- end
- end
-end

0 comments on commit 3faa48c

Please sign in to comment.