solidus_comments 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.travis.yml +21 -0
  4. data/Gemfile +18 -0
  5. data/LICENSE +26 -0
  6. data/README.md +38 -0
  7. data/Rakefile +21 -0
  8. data/app/assets/javascripts/spree/backend/solidus_comments.js +0 -0
  9. data/app/assets/javascripts/spree/frontend/solidus_comments.js +0 -0
  10. data/app/assets/stylesheets/spree/backend/solidus_comments.css +0 -0
  11. data/app/assets/stylesheets/spree/frontend/solidus_comments.css +0 -0
  12. data/app/controllers/spree/admin/comment_types_controller.rb +2 -0
  13. data/app/controllers/spree/admin/comments_controller.rb +7 -0
  14. data/app/controllers/spree/admin/orders_controller_decorator.rb +6 -0
  15. data/app/controllers/spree/admin/shipments_controller_decorator.rb +6 -0
  16. data/app/models/spree/comment.rb +16 -0
  17. data/app/models/spree/comment_type.rb +3 -0
  18. data/app/models/spree/order_decorator.rb +3 -0
  19. data/app/models/spree/shipment_decorator.rb +3 -0
  20. data/app/overrides/add_comment_configuration.rb +5 -0
  21. data/app/overrides/add_comment_to_admin_orders_tabs.rb +5 -0
  22. data/app/views/spree/admin/comment_types/_form.html.erb +15 -0
  23. data/app/views/spree/admin/comment_types/edit.html.erb +16 -0
  24. data/app/views/spree/admin/comment_types/index.html.erb +46 -0
  25. data/app/views/spree/admin/comment_types/new.html.erb +22 -0
  26. data/app/views/spree/admin/orders/_tab.html.erb +7 -0
  27. data/app/views/spree/admin/orders/comments.html.erb +2 -0
  28. data/app/views/spree/admin/shared/_comment_list.html.erb +26 -0
  29. data/app/views/spree/admin/shared/_comments.html.erb +42 -0
  30. data/app/views/spree/admin/shipments/comments.html.erb +7 -0
  31. data/config/locales/en.yml +17 -0
  32. data/config/locales/ru.yml +12 -0
  33. data/config/routes.rb +32 -0
  34. data/db/migrate/20091021182639_create_comments.rb +20 -0
  35. data/db/migrate/20100406085611_create_comment_types.rb +14 -0
  36. data/db/migrate/20100406100728_add_type_to_comments.rb +9 -0
  37. data/db/migrate/20111123200847_prefix_tables_with_spree.rb +6 -0
  38. data/lib/generators/solidus_comments/install/install_generator.rb +20 -0
  39. data/lib/solidus_comments/engine.rb +20 -0
  40. data/lib/solidus_comments.rb +5 -0
  41. data/script/rails +9 -0
  42. data/solidus_comments.gemspec +32 -0
  43. data/spec/features/admin/order_comments_spec.rb +20 -0
  44. data/spec/spec_helper.rb +36 -0
  45. data/spec/support/capybara.rb +12 -0
  46. data/spec/support/database_cleaner.rb +24 -0
  47. data/spec/support/factory_girl.rb +8 -0
  48. data/spec/support/feature_helper.rb +10 -0
  49. data/spec/support/spree.rb +7 -0
  50. metadata +299 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e02763169bbb7db1997e69b8b49e4b15752af3e9
4
+ data.tar.gz: 0d660f5af08b49819db3d26959ebd568fa591b7c
5
+ SHA512:
6
+ metadata.gz: 155cfb21d04f6e9aa6aa744e3926bd13f753b99b1d96f6ce2bac198b72747f0cad5e3758224c4c2cfa31b0009ed27e14a789cb618141d95a1cca3bf597817580
7
+ data.tar.gz: 9cd81be0a27ebce5ebdc5efc7d5e5614c0109f2236ec70d41f5bb49f147867680df7baccbfc3ba69bb1e1e2c0576e78be7ce67526318ba8b3e56a8f503e3f520
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.swp
2
+ spec/dummy
3
+ coverage
4
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.3.1
6
+ env:
7
+ matrix:
8
+ - SOLIDUS_BRANCH=v1.0 DB=postgres
9
+ - SOLIDUS_BRANCH=v1.1 DB=postgres
10
+ - SOLIDUS_BRANCH=v1.2 DB=postgres
11
+ - SOLIDUS_BRANCH=v1.3 DB=postgres
12
+ - SOLIDUS_BRANCH=v1.4 DB=postgres
13
+ - SOLIDUS_BRANCH=v2.0 DB=postgres
14
+ - SOLIDUS_BRANCH=master DB=postgres
15
+ - SOLIDUS_BRANCH=v1.0 DB=mysql
16
+ - SOLIDUS_BRANCH=v1.1 DB=mysql
17
+ - SOLIDUS_BRANCH=v1.2 DB=mysql
18
+ - SOLIDUS_BRANCH=v1.3 DB=mysql
19
+ - SOLIDUS_BRANCH=v1.4 DB=mysql
20
+ - SOLIDUS_BRANCH=v2.0 DB=mysql
21
+ - SOLIDUS_BRANCH=master DB=mysql
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "https://rubygems.org"
2
+
3
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
4
+ gem "solidus", github: "solidusio/solidus", branch: branch
5
+ gem "solidus_auth_devise"
6
+
7
+ if branch == 'master' || branch >= "v2.0"
8
+ gem "rails-controller-testing", group: :test
9
+ end
10
+
11
+ gem 'pg'
12
+ gem 'mysql2'
13
+
14
+ group :development, :test do
15
+ gem "pry-rails"
16
+ end
17
+
18
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2011 Rails Dog
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ Solidus Comments
2
+ ==============
3
+
4
+ [![Build Status](https://travis-ci.org/solidusio-contrib/solidus_comments.svg?branch=master)](https://travis-ci.org/solidusio-contrib/solidus_comments)
5
+
6
+ Solidus Comments is an extension for Solidus to allow commenting on different models via the
7
+ admin ui and currently supports Orders & Shipments.
8
+
9
+ Solidus Comments also supports optional comment Types which can be defined per comment-able
10
+ object (i.e. Order, Shipment, etc) via the admin Configuration tab.
11
+
12
+ This is based on a fork / rename of jderrett/spree-order-comments, and subsequently spree/spree-comments
13
+
14
+ Notes:
15
+
16
+ * Comments are create-only. You cannot edit or remove them from the Admin UI.
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Add the following to your Gemfile (or check Versionfile for Solidus versions requirements):
22
+
23
+ gem "solidus_comments"
24
+
25
+ Run:
26
+
27
+ ```shell
28
+ bundle install
29
+ bundle exec rails g solidus_comments:install
30
+ ```
31
+
32
+ Run the migrations if you did not during the installation generator:
33
+
34
+ bundle exec rake db:migrate
35
+
36
+ Start your server:
37
+
38
+ rails s
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'solidus_comments'
20
+ Rake::Task['common:test_app'].invoke("Spree::User")
21
+ end
@@ -0,0 +1,2 @@
1
+ class Spree::Admin::CommentTypesController < Spree::Admin::ResourceController
2
+ end
@@ -0,0 +1,7 @@
1
+ class Spree::Admin::CommentsController < Spree::Admin::ResourceController
2
+ private
3
+
4
+ def location_after_save
5
+ :back
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ Spree::Admin::OrdersController.class_eval do
2
+ def comments
3
+ load_order
4
+ @comment_types = Spree::CommentType.where(:applies_to => "Order")
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ Spree::Api::ShipmentsController.class_eval do
2
+ def comments
3
+ shipment
4
+ @comment_types = Spree::CommentType.where(:applies_to => "Shipment")
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ class Spree::Comment < ActiveRecord::Base
2
+ include ActsAsCommentable::Comment
3
+
4
+ belongs_to :commentable, :polymorphic => true
5
+ belongs_to :comment_type
6
+
7
+ default_scope { order('created_at ASC') }
8
+
9
+ # NOTE: install the acts_as_votable plugin if you
10
+ # want user to vote on the quality of comments.
11
+ #acts_as_voteable
12
+
13
+ # NOTE: Comments belong to a user
14
+ belongs_to :user
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ class Spree::CommentType < ActiveRecord::Base
2
+ has_many :comments
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::Order.class_eval do
2
+ acts_as_commentable
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::Shipment.class_eval do
2
+ acts_as_commentable
3
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
2
+ :name => "converted_admin_configurations_menu_468573024",
3
+ :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
4
+ :text => "<%= configurations_sidebar_menu_item Spree.t(:comment_types), admin_comment_types_path %>",
5
+ :disabled => false)
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(:virtual_path => "spree/admin/shared/_order_submenu",
2
+ :name => "converted_admin_order_tabs_472794197",
3
+ :insert_bottom => "[data-hook='admin_order_tabs'], #admin_order_tabs[data-hook]",
4
+ :partial => "spree/admin/orders/tab",
5
+ :disabled => false)
@@ -0,0 +1,15 @@
1
+ <div id="admin_comment_type_form_fields" data-hook>
2
+ <%= f.field_container :name do %>
3
+ <%= f.label :name, Spree.t(:name) %><br />
4
+ <%= f.text_field :name, :class => 'fullwidth title' %>
5
+ <%= error_message_on :comment_type, :name %>
6
+ <% end %>
7
+
8
+ <%= f.field_container :applies_to do %>
9
+ <%= f.label :applies_to, Spree.t(:applies_to) %><br />
10
+ <%= f.text_field :applies_to, :value => f.object.nil? ? 'Order' : f.object.applies_to, :class => 'fullwidth title' %>
11
+ <%= error_message_on :comment_type, :applies_to%>
12
+ <% end %>
13
+
14
+ </div>
15
+
@@ -0,0 +1,16 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <div id="admin_comment_type_edit_form_header" data-hook>
4
+ <h1><%= Spree.t(:editing_comment_type) %></h1>
5
+ <%= render 'spree/shared/error_messages', :target => @comment_type %>
6
+ </div>
7
+
8
+ <div id="admin_comment_type_edit_form" data-hook>
9
+ <%= form_for(@comment_type, :url => object_url, :html => { :method => :put }) do |f| %>
10
+ <%= render :partial => 'form', :locals => { :f => f } %>
11
+
12
+ <div id="admin_comment_type_edit_form_buttons" data-hook>
13
+ <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
14
+ </div>
15
+ <% end %>
16
+ </div>
@@ -0,0 +1,46 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:comment_types) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:new_comment_type), new_object_url, :icon => 'icon-plus', :id => 'admin_new_comment_type_link' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <% if @comment_types.any? %>
14
+ <table class="index" id='listing_comment_types'>
15
+ <colgroup>
16
+ <col style="width: 40%">
17
+ <col style="width: 45%">
18
+ <col style="width: 15%">
19
+ </colgroup>
20
+ <thead>
21
+ <tr data-hook="admin_comment_types_index_headers">
22
+ <th><%= Spree.t(:name) %></th>
23
+ <th><%= Spree.t(:applies_to) %></th>
24
+ <th data-hook="admin_comment_types_index_header_actions" class="actions"></th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <% @comment_types.each do |comment_type| %>
29
+ <tr id="<%= dom_id comment_type %>">
30
+ <tr id="<%= spree_dom_id comment_type %>" data-hook="admin_comment_types_index_rows" class="<%= cycle('odd', 'even')%>">
31
+ <td><%= comment_type.name %></td>
32
+ <td><%= comment_type.applies_to %></td>
33
+ <td data-hook="admin_comment_types_index_row_actions" class="actions">
34
+ <%= link_to_edit comment_type, :no_text => true %>
35
+ <%= link_to_delete comment_type, :no_text => true %>
36
+ </td>
37
+ </tr>
38
+ <% end %>
39
+ </tbody>
40
+ </table>
41
+ <% else %>
42
+ <div class="alpha twelve columns no-objects-found">
43
+ <%= Spree.t(:no_resource_found, resource: I18n.t(:comment_types, scope: 'spree')) %>,
44
+ <%= link_to Spree.t(:add_one), spree.new_admin_comment_type_path %>!
45
+ </div>
46
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:new_comment_type) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:back_to_comment_types_list), admin_comment_types_path, :icon => 'icon-arrow-left' %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @comment_type } %>
14
+
15
+ <%= form_for(:comment_type, :url => collection_url) do |f| %>
16
+ <fieldset class="no-border-top">
17
+ <%= render :partial => 'form', :locals => { :f => f } %>
18
+ <div data-hook="buttons" class="filter-actions actions">
19
+ <%= button Spree.t(:create), 'icon-ok' %>
20
+ </div>
21
+ </fieldset>
22
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <li <%== ' class="active"' if (defined? current and current == 'Comments') %>>
2
+ <% if @order.comments.any? %>
3
+ <%= link_to_with_icon 'comment-o', Spree.t(:comments_count, count: @order.comments.count), comments_admin_order_url(@order) %>
4
+ <% else %>
5
+ <%= link_to_with_icon 'comment-o', Spree.t(:comments), comments_admin_order_url(@order) %>
6
+ <% end %>
7
+ </li>
@@ -0,0 +1,2 @@
1
+ <%= render 'spree/admin/shared/order_tabs', :current => 'Comments' %>
2
+ <%= render 'spree/admin/shared/comments', :commentable => @order %>
@@ -0,0 +1,26 @@
1
+ <table class="index">
2
+ <colgroup>
3
+ <col style="width: 18%" />
4
+ <col style="width: 15%" />
5
+ <col style="width: 20%" />
6
+ <col style="width: 47%" />
7
+ </colgroup>
8
+ <thead>
9
+ <tr>
10
+ <th><%= "#{t('spree.date')}/#{t('spree.time')}" %></th>
11
+ <th><%= Spree.t(:type) %></th>
12
+ <th><%= Spree.t(:commenter) %></th>
13
+ <th><%= Spree.t(:comment) %></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% commentable.comments.reverse.each_with_index do |comment, index| %>
18
+ <tr class="<%= cycle('odd', 'even')%>">
19
+ <td class='align-center'><%= pretty_time(comment.created_at) %></td>
20
+ <td class='align-center'><%= comment.comment_type.try(:name) || Spree.t(:none) %></td>
21
+ <td class='align-center'><%= comment.user.try(:email) %></td>
22
+ <td><%= comment.comment.html_safe %></td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
@@ -0,0 +1,42 @@
1
+ <% if commentable.comments.any? %>
2
+ <%= render 'spree/admin/shared/comment_list', :commentable => commentable %>
3
+ <% else %>
4
+ <div class="alpha twelve columns no-objects-found">
5
+ <%= Spree.t(:no_resource_found, resource: I18n.t(:comments, scope: 'spree')) %>
6
+ </div>
7
+ <% end %>
8
+
9
+ <div class="order-add-comment">
10
+ <%= form_for(:comment, :url => admin_comments_url) do |f| %>
11
+ <%= hidden_field_tag 'comment[commentable_id]', commentable.id %>
12
+ <%= hidden_field_tag 'comment[commentable_type]', commentable.class %>
13
+ <%= hidden_field_tag 'comment[user_id]', spree_current_user.id %>
14
+
15
+ <fieldset data-hook="admin_comment_form_fields" class="no-border-top fullwidth">
16
+ <fieldset class="index no-border-bottom">
17
+ <legend align="center"><%= Spree.t(:add_comment) %></legend>
18
+
19
+ <div data-hook="comment_fields" class="row">
20
+ <div class="alpha twelve columns">
21
+ <% if @comment_types.present? %>
22
+ <div class="field">
23
+ <%= f.label :comment_type_id, Spree.t(:type) %>
24
+ <%= f.select :comment_type_id, @comment_types.map{|ct| [ct.name, ct.id]},{} ,:class => 'fullwidth' %>
25
+ </div>
26
+ <% end %>
27
+ <div class="field">
28
+ <%= f.label :comment, Spree.t(:comment) %>
29
+ <%= f.text_area :comment, :style => 'height:150px;', :class => 'fullwidth' %>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </fieldset>
34
+
35
+ <div class="clear"></div>
36
+
37
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
38
+ <%= button Spree.t(:add_comment), 'icon-arrow-right' %>
39
+ </div>
40
+ </fieldset>
41
+ <% end %>
42
+ </div>
@@ -0,0 +1,7 @@
1
+ <%= render 'spree/admin/shared/order_tabs', :current => 'Shipments' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <i class="icon-arrow-right"></i> <%= Spree.t(:shipments) %> <i class="icon-arrow-right"></i> #<%= @shipment.number%> (<%= Spree.t(@shipment.state.to_sym, :scope => :state_names, :default => @shipment.state.to_s.humanize) %>)
5
+ <% end %>
6
+
7
+ <%= render 'spree/admin/shared/comments', {:commentable => @shipment, :comments_for => "Shipment ##{@shipment.number}"} %>
@@ -0,0 +1,17 @@
1
+ ---
2
+ en:
3
+ spree:
4
+ said: said
5
+ for: for
6
+ none: None
7
+ comments: Comments
8
+ comments_count: Comments (%{count})
9
+ comment: Comment
10
+ add_comment: Add Comment
11
+ add_comment_type: Add Comment Type
12
+ comment_types: Comment Types
13
+ manage_comment_types: Manage comment types
14
+ applies_to: Applies To
15
+ new_comment_type: New Comment Type
16
+ editing_comment_type: Editing Comment Type
17
+ back_to_comment_types_list: Back to Comment Types List
@@ -0,0 +1,12 @@
1
+ ru:
2
+ said: сказал
3
+ for: для
4
+ comments: Комментарии
5
+ comment: Комментарий
6
+ add_comment: Добавить комментарий
7
+ add_comment_type: Добавить тип комментария
8
+ comment_types: Типы комментариев
9
+ manage_comment_types: Администрирование типов комментариев
10
+ applies_to: Применить к
11
+ new_comment_type: Новый тип комментария
12
+ editing_comment_type: Редактировать тип комментария
data/config/routes.rb ADDED
@@ -0,0 +1,32 @@
1
+
2
+ #map.namespace :admin do |admin|
3
+ # admin.resources :comments
4
+ # admin.resources :comment_types
5
+ #
6
+ # admin.resources :orders, :member => {:comments => :get} do |order|
7
+ # order.resources :shipments, :member => {:comments => :get}
8
+ # end
9
+ #end
10
+ #
11
+
12
+ Spree::Core::Engine.add_routes do
13
+ namespace :admin do
14
+ resources :comments
15
+ resources :comment_types
16
+
17
+ resources :orders do
18
+ member do
19
+ get :comments
20
+ end
21
+
22
+ resources :shipments do
23
+ member do
24
+ get :comments
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ #match '/admin/comments' => 'admin/comments', :via => [:get, :post]
31
+ # match '/admin/comment_types' => 'admin/comment_types', :via => [:get, :post]
32
+ end
@@ -0,0 +1,20 @@
1
+ class CreateComments < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :comments do |t|
4
+ t.string :title, :limit => 50
5
+ t.text :comment
6
+ t.references :commentable, :polymorphic => true
7
+ t.references :user
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :comments, :commentable_type
13
+ add_index :comments, :commentable_id
14
+ add_index :comments, :user_id
15
+ end
16
+
17
+ def self.down
18
+ drop_table :comments
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ class CreateCommentTypes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :comment_types do |t|
4
+ t.string :name
5
+ t.string :applies_to
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :comment_types
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddTypeToComments < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :comments, :comment_type_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :comments, :comment_type_id
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class PrefixTablesWithSpree < ActiveRecord::Migration
2
+ def change
3
+ rename_table :comments, :spree_comments
4
+ rename_table :comment_types, :spree_comment_types
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ module SolidusComments
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, :type => :boolean, :default => false
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=solidus_comments'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
12
+ if run_migrations
13
+ run 'bundle exec rake db:migrate'
14
+ else
15
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module SolidusComments
2
+ class Engine < Rails::Engine
3
+ engine_name 'solidus_comments'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ require 'spree_api'
2
+ require 'spree_backend'
3
+ require 'spree_core'
4
+ require 'acts_as_commentable'
5
+ require 'solidus_comments/engine'
data/script/rails ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+
5
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
6
+ APP_PATH = File.expand_path('../../../config/application', __FILE__)
7
+ require File.expand_path('../../../config/boot', __FILE__)
8
+ require 'rails/commands'
9
+
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'solidus_comments'
5
+ s.version = '1.0.0'
6
+ s.summary = 'Adds comments to the solidus admin'
7
+ s.required_ruby_version = '>= 2.1'
8
+
9
+ s.author = [ 'Rails Dog', 'Solidus Contrib' ]
10
+ s.email = 'contact+comments@solidus.io'
11
+ s.homepage = 'https://github.com/solidusio-contrib/solidus_comments'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.require_path = 'lib'
16
+ s.requirements << 'none'
17
+
18
+ solidus_version = ['>= 1.0', '< 3']
19
+ s.add_runtime_dependency 'solidus_core', solidus_version
20
+ s.add_runtime_dependency 'solidus_backend', solidus_version
21
+ s.add_runtime_dependency 'solidus_api', solidus_version
22
+ s.add_runtime_dependency 'deface'
23
+ s.add_dependency 'acts_as_commentable', '4.0.1'
24
+ s.add_development_dependency 'rspec-rails'
25
+ s.add_development_dependency 'sqlite3'
26
+ s.add_development_dependency 'capybara'
27
+ s.add_development_dependency 'poltergeist'
28
+ s.add_development_dependency 'factory_girl'
29
+ s.add_development_dependency 'ffaker'
30
+ s.add_development_dependency 'database_cleaner'
31
+ s.add_development_dependency 'pry-rails'
32
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.feature 'Order Comments', :js do
4
+ let!(:order) { create(:completed_order_with_totals) }
5
+
6
+ before :each do
7
+ login_as_admin
8
+ end
9
+
10
+ it "adding comments" do
11
+ visit spree.comments_admin_order_path(order)
12
+ expect(page).to have_text(/No Comments found/i)
13
+
14
+ fill_in 'Comment', with: 'A test comment.'
15
+ click_button 'Add Comment'
16
+
17
+ expect(page).to have_text(/Comments \(1\)/i) # uppercase < v1.2, sentence case >= v1.3
18
+ expect(page).to have_text('A test comment.')
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+
5
+ begin
6
+ require File.expand_path('../dummy/config/environment', __FILE__)
7
+ rescue LoadError
8
+ fail 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
9
+ end
10
+
11
+
12
+ require 'rspec/rails'
13
+ require 'pry'
14
+
15
+ # Requires supporting ruby files with custom matchers and macros, etc,
16
+ # in spec/support/ and its subdirectories.
17
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |file| require file }
18
+
19
+ RSpec.configure do |config|
20
+ # == Mock Framework
21
+ #
22
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
23
+ #
24
+ # config.mock_with :mocha
25
+ # config.mock_with :flexmock
26
+ # config.mock_with :rr
27
+ config.mock_with :rspec
28
+
29
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
30
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
31
+
32
+ # because database cleaner
33
+ config.use_transactional_fixtures = false
34
+
35
+ config.include FeatureHelper, type: :feature
36
+ end
@@ -0,0 +1,12 @@
1
+ require 'capybara/rspec'
2
+ require 'capybara/rails'
3
+ require 'capybara/poltergeist'
4
+
5
+ RSpec.configure do |config|
6
+ config.include Rack::Test::Methods, type: :requests
7
+
8
+ Capybara.javascript_driver = :poltergeist
9
+ Capybara.register_driver(:poltergeist) do |app|
10
+ Capybara::Poltergeist::Driver.new app, js_errors: true, timeout: 60
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ require 'database_cleaner'
2
+
3
+ RSpec.configure do |config|
4
+
5
+ config.before(:suite) do
6
+ DatabaseCleaner.clean_with :truncation
7
+ end
8
+
9
+ config.before do
10
+ DatabaseCleaner.strategy = :transaction
11
+ end
12
+
13
+ config.before(:each, :js) do
14
+ DatabaseCleaner.strategy = :truncation
15
+ end
16
+
17
+ config.before do
18
+ DatabaseCleaner.start
19
+ end
20
+
21
+ config.after do
22
+ DatabaseCleaner.clean
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ require 'ffaker'
2
+ require 'factory_girl'
3
+
4
+ FactoryGirl.find_definitions
5
+
6
+ RSpec.configure do |config|
7
+ config.include FactoryGirl::Syntax::Methods
8
+ end
@@ -0,0 +1,10 @@
1
+ module FeatureHelper
2
+ def login_as_admin
3
+ admin = create(:admin_user, password: 'test123', password_confirmation: 'test123')
4
+ visit spree.admin_path
5
+ fill_in 'Email', with: admin.email
6
+ fill_in 'Password', with: 'test123'
7
+ click_button 'Login'
8
+ admin
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'spree/testing_support/factories'
2
+ require 'spree/testing_support/url_helpers'
3
+ require 'spree/testing_support/capybara_ext'
4
+
5
+ RSpec.configure do |config|
6
+ config.include Spree::TestingSupport::UrlHelpers
7
+ end
metadata ADDED
@@ -0,0 +1,299 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_comments
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rails Dog
8
+ - Solidus Contrib
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-09-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: solidus_core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '3'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '1.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ - !ruby/object:Gem::Dependency
35
+ name: solidus_backend
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '3'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '1.0'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '3'
54
+ - !ruby/object:Gem::Dependency
55
+ name: solidus_api
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '3'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '1.0'
71
+ - - "<"
72
+ - !ruby/object:Gem::Version
73
+ version: '3'
74
+ - !ruby/object:Gem::Dependency
75
+ name: deface
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ type: :runtime
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: acts_as_commentable
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '='
93
+ - !ruby/object:Gem::Version
94
+ version: 4.0.1
95
+ type: :runtime
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '='
100
+ - !ruby/object:Gem::Version
101
+ version: 4.0.1
102
+ - !ruby/object:Gem::Dependency
103
+ name: rspec-rails
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ - !ruby/object:Gem::Dependency
117
+ name: sqlite3
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ - !ruby/object:Gem::Dependency
131
+ name: capybara
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ - !ruby/object:Gem::Dependency
145
+ name: poltergeist
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: factory_girl
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ - !ruby/object:Gem::Dependency
173
+ name: ffaker
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ type: :development
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ - !ruby/object:Gem::Dependency
187
+ name: database_cleaner
188
+ requirement: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ type: :development
194
+ prerelease: false
195
+ version_requirements: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ - !ruby/object:Gem::Dependency
201
+ name: pry-rails
202
+ requirement: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ type: :development
208
+ prerelease: false
209
+ version_requirements: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ description:
215
+ email: contact+comments@solidus.io
216
+ executables: []
217
+ extensions: []
218
+ extra_rdoc_files: []
219
+ files:
220
+ - ".gitignore"
221
+ - ".travis.yml"
222
+ - Gemfile
223
+ - LICENSE
224
+ - README.md
225
+ - Rakefile
226
+ - app/assets/javascripts/spree/backend/solidus_comments.js
227
+ - app/assets/javascripts/spree/frontend/solidus_comments.js
228
+ - app/assets/stylesheets/spree/backend/solidus_comments.css
229
+ - app/assets/stylesheets/spree/frontend/solidus_comments.css
230
+ - app/controllers/spree/admin/comment_types_controller.rb
231
+ - app/controllers/spree/admin/comments_controller.rb
232
+ - app/controllers/spree/admin/orders_controller_decorator.rb
233
+ - app/controllers/spree/admin/shipments_controller_decorator.rb
234
+ - app/models/spree/comment.rb
235
+ - app/models/spree/comment_type.rb
236
+ - app/models/spree/order_decorator.rb
237
+ - app/models/spree/shipment_decorator.rb
238
+ - app/overrides/add_comment_configuration.rb
239
+ - app/overrides/add_comment_to_admin_orders_tabs.rb
240
+ - app/views/spree/admin/comment_types/_form.html.erb
241
+ - app/views/spree/admin/comment_types/edit.html.erb
242
+ - app/views/spree/admin/comment_types/index.html.erb
243
+ - app/views/spree/admin/comment_types/new.html.erb
244
+ - app/views/spree/admin/orders/_tab.html.erb
245
+ - app/views/spree/admin/orders/comments.html.erb
246
+ - app/views/spree/admin/shared/_comment_list.html.erb
247
+ - app/views/spree/admin/shared/_comments.html.erb
248
+ - app/views/spree/admin/shipments/comments.html.erb
249
+ - config/locales/en.yml
250
+ - config/locales/ru.yml
251
+ - config/routes.rb
252
+ - db/migrate/20091021182639_create_comments.rb
253
+ - db/migrate/20100406085611_create_comment_types.rb
254
+ - db/migrate/20100406100728_add_type_to_comments.rb
255
+ - db/migrate/20111123200847_prefix_tables_with_spree.rb
256
+ - lib/generators/solidus_comments/install/install_generator.rb
257
+ - lib/solidus_comments.rb
258
+ - lib/solidus_comments/engine.rb
259
+ - script/rails
260
+ - solidus_comments.gemspec
261
+ - spec/features/admin/order_comments_spec.rb
262
+ - spec/spec_helper.rb
263
+ - spec/support/capybara.rb
264
+ - spec/support/database_cleaner.rb
265
+ - spec/support/factory_girl.rb
266
+ - spec/support/feature_helper.rb
267
+ - spec/support/spree.rb
268
+ homepage: https://github.com/solidusio-contrib/solidus_comments
269
+ licenses: []
270
+ metadata: {}
271
+ post_install_message:
272
+ rdoc_options: []
273
+ require_paths:
274
+ - lib
275
+ required_ruby_version: !ruby/object:Gem::Requirement
276
+ requirements:
277
+ - - ">="
278
+ - !ruby/object:Gem::Version
279
+ version: '2.1'
280
+ required_rubygems_version: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ version: '0'
285
+ requirements:
286
+ - none
287
+ rubyforge_project:
288
+ rubygems_version: 2.5.1
289
+ signing_key:
290
+ specification_version: 4
291
+ summary: Adds comments to the solidus admin
292
+ test_files:
293
+ - spec/features/admin/order_comments_spec.rb
294
+ - spec/spec_helper.rb
295
+ - spec/support/capybara.rb
296
+ - spec/support/database_cleaner.rb
297
+ - spec/support/factory_girl.rb
298
+ - spec/support/feature_helper.rb
299
+ - spec/support/spree.rb