Skip to content

Commit

Permalink
Update for Spree 2.1x and Rails 4
Browse files Browse the repository at this point in the history
  • Loading branch information
futhr committed Apr 12, 2014
1 parent 3e034cf commit ede6f4f
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: '2-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'

gemspec
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spree Frequently Asked Question

[![Build Status](https://travis-ci.org/futhr/spree-faq.png?branch=2-0-stable)](https://travis-ci.org/futhr/spree-faq)
[![Coverage Status](https://coveralls.io/repos/futhr/spree-faq/badge.png?branch=2-0-stable)](https://coveralls.io/r/futhr/spree-faq)
[![Build Status](https://travis-ci.org/futhr/spree-faq.png?branch=2-1-stable)](https://travis-ci.org/futhr/spree-faq)
[![Coverage Status](https://coveralls.io/repos/futhr/spree-faq/badge.png?branch=2-1-stable)](https://coveralls.io/r/futhr/spree-faq)
[![Code Climate](https://codeclimate.com/github/futhr/spree-faq.png)](https://codeclimate.com/github/futhr/spree-faq)
[![Gem Version](https://badge.fury.io/rb/spree-faq.png)](http://badge.fury.io/rb/spree-faq)

Expand All @@ -12,7 +12,7 @@ An Spree Commerce extension for managing FAQs.
Add to your `Gemfile`:

```ruby
gem 'spree_faq', '~> 2.0.0'
gem 'spree_faq', '~> 2.1.0'
```

Then run from the command line:
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/spree/admin/question_categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class QuestionCategoriesController < ResourceController
def question_category
@question_category ||= @object
end

def question_category_params
params.require(:question_category).permit(:questions_attributes, :question, :answer,
question: [:question_category_id, :question, :answer])
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/spree/faqs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class FaqsController < StoreController
helper 'spree/products'

def index
@categories = QuestionCategory.all(include: :questions)
@categories = QuestionCategory.includes(:questions).load
end

def default_title
Expand Down
1 change: 0 additions & 1 deletion app/models/spree/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ class Spree::Question < ActiveRecord::Base

belongs_to :question_category, class_name: 'Spree::QuestionCategory'
validates :question_category_id, :question, :answer, presence: true
attr_accessible :question, :answer, :question_category_id, :question_category
end
1 change: 0 additions & 1 deletion app/models/spree/question_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ class Spree::QuestionCategory < ActiveRecord::Base
validates :name, presence: true
validates :name, uniqueness: { case_sensitive: false }
accepts_nested_attributes_for :questions, allow_destroy: true
attr_accessible :name, :questions_attributes, :question, :answer
end
File renamed without changes.
13 changes: 13 additions & 0 deletions spec/controllers/admin/question_categories_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,17 @@
expect { spree_delete :destroy }.to raise_error
end
end

context 'permitted attributes' do
let(:permitted_attributes) do
[:questions_attributes, :question, :answer,
question: [:question_category_id, :question, :answer]]
end

specify do
controller.params = { question_category: attributes }
controller.params.require(:question_category).should_receive(:permit).with(*permitted_attributes)
controller.send :question_category_params
end
end
end
6 changes: 0 additions & 6 deletions spec/models/question_category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
it { should accept_nested_attributes_for(:questions) }
end

context 'mass assignment' do
%w(name questions_attributes question answer).each do |column|
it { should allow_mass_assignment_of(column.to_sym) }
end
end

context 'acts as list' do

subject { create(:question_category) }
Expand Down
6 changes: 0 additions & 6 deletions spec/models/question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@
end
end

context 'mass assignment' do
%w(question answer question_category_id question_category).each do |column|
it { should allow_mass_assignment_of(column.to_sym) }
end
end

context 'acts as list' do

before do
Expand Down
6 changes: 3 additions & 3 deletions spree_faq.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|

s.has_rdoc = false

s.add_runtime_dependency 'spree_core', '~> 2.0.0'
s.add_runtime_dependency 'spree_core', '~> 2.1.0'

s.add_development_dependency 'rspec-rails', '~> 2.14'
s.add_development_dependency 'capybara', '~> 2.2.1'
Expand All @@ -35,8 +35,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'simplecov', '~> 0.7.1'
s.add_development_dependency 'database_cleaner', '~> 1.2.0'
s.add_development_dependency 'i18n-spec', '~> 0.4.1'
s.add_development_dependency 'coffee-rails', '~> 3.2.2'
s.add_development_dependency 'sass-rails', '~> 3.2.6'
s.add_development_dependency 'coffee-rails', '~> 4.0.0'
s.add_development_dependency 'sass-rails', '~> 4.0.0'
s.add_development_dependency 'ffaker', '>= 1.24.0'
s.add_development_dependency 'guard-rspec', '>= 4.2.0'
s.add_development_dependency 'launchy', '>= 2.4.0'
Expand Down

0 comments on commit ede6f4f

Please sign in to comment.