Skip to content

Commit

Permalink
Merge pull request #1 from Sinetheta/solidus-compat
Browse files Browse the repository at this point in the history
Make compatible with Solidus master
  • Loading branch information
jhawthorn committed Apr 29, 2016
2 parents 61ed9fc + ad8bcc1 commit 5ff91b6
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sudo: false
language: ruby
rvm:
- 2.3.0
env:
matrix:
- SOLIDUS_BRANCH=v1.0
- SOLIDUS_BRANCH=v1.1
- SOLIDUS_BRANCH=v1.2
- SOLIDUS_BRANCH=v1.3
- SOLIDUS_BRANCH=master
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ source 'https://rubygems.org'
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem 'solidus', github: 'solidusio/solidus', branch: branch

gem 'solidus_auth_devise'

gemspec
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Solidus Comments
==============

[![Build Status](https://travis-ci.org/solidusio-contrib/solidus_comments.svg?branch=master)](https://travis-ci.org/solidusio-contrib/solidus_comments)

Solidus Comments is an extension for Solidus to allow commenting on different models via the
admin ui and currently supports Orders & Shipments.

Expand Down
12 changes: 9 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'spree/testing_support/extension_rake'
require 'spree/testing_support/common_rake'

RSpec::Core::RakeTask.new

task :default => [:spec]
task :default do
if Dir["spec/dummy"].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
end
Rake::Task[:spec].invoke
end

desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'solidus_comments'
Rake::Task['extension:test_app'].invoke
Rake::Task['common:test_app'].invoke("Spree::User")
end
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion app/views/spree/admin/shared/_comments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= hidden_field_tag 'comment[commentable_type]', commentable.class %>
<%= hidden_field_tag 'comment[user_id]', spree_current_user.id %>

<fieldset data-hook="admin_comment_form_fields" class="no-border-top">
<fieldset data-hook="admin_comment_form_fields" class="no-border-top fullwidth">
<fieldset class="index no-border-bottom">
<legend align="center"><%= Spree.t(:add_comment) %></legend>

Expand Down
6 changes: 6 additions & 0 deletions solidus_comments.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ Gem::Specification.new do |s|
s.add_dependency 'acts_as_commentable', '4.0.1'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'capybara'
s.add_development_dependency 'poltergeist'
s.add_development_dependency 'factory_girl'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'database_cleaner'
s.add_development_dependency 'pry-rails'
end
20 changes: 20 additions & 0 deletions spec/features/admin/order_comments_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

RSpec.feature 'Order Comments', :js do
let!(:order) { create(:completed_order_with_totals) }

before :each do
login_as_admin
end

it "adding comments" do
visit spree.comments_admin_order_path(order)
expect(page).to have_text('NO COMMENTS FOUND')

fill_in 'Comment', with: 'A test comment.'
click_button 'Add Comment'

expect(page).to have_text(/Comments \(1\)/i) # uppercase < v1.2, sentence case >= v1.3
expect(page).to have_text('A test comment.')
end
end
17 changes: 11 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
ENV["RAILS_ENV"] = "test"


require File.expand_path("../../../config/environment.rb", __FILE__)
begin
require File.expand_path('../dummy/config/environment', __FILE__)
rescue LoadError
fail 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
end


require 'rspec/rails'
require 'pry'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |file| require file }

RSpec.configure do |config|
# == Mock Framework
Expand All @@ -24,8 +29,8 @@
# 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
# because database cleaner
config.use_transactional_fixtures = false

config.include FeatureHelper, type: :feature
end
12 changes: 12 additions & 0 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'capybara/rspec'
require 'capybara/rails'
require 'capybara/poltergeist'

RSpec.configure do |config|
config.include Rack::Test::Methods, type: :requests

Capybara.javascript_driver = :poltergeist
Capybara.register_driver(:poltergeist) do |app|
Capybara::Poltergeist::Driver.new app, js_errors: true, timeout: 60
end
end
24 changes: 24 additions & 0 deletions spec/support/database_cleaner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'database_cleaner'

RSpec.configure do |config|

config.before(:suite) do
DatabaseCleaner.clean_with :truncation
end

config.before do
DatabaseCleaner.strategy = :transaction
end

config.before(:each, :js) do
DatabaseCleaner.strategy = :truncation
end

config.before do
DatabaseCleaner.start
end

config.after do
DatabaseCleaner.clean
end
end
8 changes: 8 additions & 0 deletions spec/support/factory_girl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'ffaker'
require 'factory_girl'

FactoryGirl.find_definitions

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end
10 changes: 10 additions & 0 deletions spec/support/feature_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module FeatureHelper
def login_as_admin
admin = create(:admin_user, password: 'test123', password_confirmation: 'test123')
visit spree.admin_path
fill_in 'Email', with: admin.email
fill_in 'Password', with: 'test123'
click_button 'Login'
admin
end
end
7 changes: 7 additions & 0 deletions spec/support/spree.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spree/testing_support/factories'
require 'spree/testing_support/url_helpers'
require 'spree/testing_support/capybara_ext'

RSpec.configure do |config|
config.include Spree::TestingSupport::UrlHelpers
end

0 comments on commit 5ff91b6

Please sign in to comment.