solidus_reviews 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +322 -0
  3. data/.travis.yml +27 -14
  4. data/Gemfile +23 -8
  5. data/LICENSE.md +2 -2
  6. data/README.md +9 -11
  7. data/Rakefile +2 -0
  8. data/app/controllers/spree/admin/feedback_reviews_controller.rb +3 -1
  9. data/app/controllers/spree/admin/review_settings_controller.rb +3 -1
  10. data/app/controllers/spree/admin/reviews_controller.rb +9 -6
  11. data/app/controllers/spree/feedback_reviews_controller.rb +25 -19
  12. data/app/controllers/spree/products_controller_decorator.rb +2 -0
  13. data/app/controllers/spree/reviews_controller.rb +11 -7
  14. data/app/helpers/spree/api/api_helpers_decorator.rb +12 -0
  15. data/app/helpers/spree/reviews_helper.rb +15 -5
  16. data/app/models/spree/feedback_review.rb +5 -4
  17. data/app/models/spree/product_decorator.rb +5 -4
  18. data/app/models/spree/review.rb +28 -10
  19. data/app/models/spree/reviews_ability.rb +17 -3
  20. data/app/models/spree/reviews_configuration.rb +16 -8
  21. data/app/models/spree/user_decorator.rb +3 -0
  22. data/app/overrides/add_reviews_after_product_properties.rb +7 -5
  23. data/app/overrides/add_reviews_tab_to_admin.rb +12 -4
  24. data/app/overrides/add_reviews_to_admin_configuration_sidebar.rb +13 -5
  25. data/app/views/spree/admin/feedback_reviews/index.html.erb +9 -9
  26. data/app/views/spree/admin/review_settings/edit.html.erb +64 -35
  27. data/app/views/spree/admin/reviews/_form.html.erb +26 -5
  28. data/app/views/spree/admin/reviews/edit.html.erb +2 -2
  29. data/app/views/spree/admin/reviews/index.html.erb +100 -88
  30. data/app/views/spree/api/reviews/_review.json.jbuilder +8 -0
  31. data/app/views/spree/api/reviews/index.json.jbuilder +6 -0
  32. data/app/views/spree/api/reviews/show.json.jbuilder +3 -0
  33. data/app/views/spree/feedback_reviews/_form.html.erb +5 -5
  34. data/app/views/spree/feedback_reviews/_summary.html.erb +3 -3
  35. data/app/views/spree/feedback_reviews/create.js.erb +2 -2
  36. data/app/views/spree/reviews/_form.html.erb +15 -10
  37. data/app/views/spree/reviews/new.html.erb +2 -2
  38. data/app/views/spree/shared/_rating.html.erb +3 -3
  39. data/app/views/spree/shared/_review.html.erb +29 -19
  40. data/app/views/spree/shared/_review_summary.html.erb +3 -3
  41. data/app/views/spree/shared/_reviews.html.erb +6 -6
  42. data/app/views/spree/shared/_shortrating.html.erb +2 -2
  43. data/bin/rails +4 -2
  44. data/config/initializers/constants.rb +2 -0
  45. data/config/initializers/load_preferences.rb +2 -0
  46. data/config/locales/de-CH.yml +14 -1
  47. data/config/locales/de.yml +14 -1
  48. data/config/locales/en-GB.yml +14 -2
  49. data/config/locales/en.yml +14 -1
  50. data/config/locales/es.yml +14 -2
  51. data/config/locales/fr.yml +14 -2
  52. data/config/locales/it.yml +79 -0
  53. data/config/locales/pl.yml +14 -2
  54. data/config/locales/pt-BR.yml +14 -2
  55. data/config/locales/pt.yml +14 -2
  56. data/config/locales/ro.yml +15 -3
  57. data/config/locales/ru.yml +14 -2
  58. data/config/locales/sv.yml +14 -1
  59. data/config/locales/tr.yml +14 -2
  60. data/config/locales/uk.yml +14 -1
  61. data/config/locales/zh-CN.yml +14 -1
  62. data/config/locales/zh-TW.yml +14 -1
  63. data/config/routes.rb +18 -1
  64. data/db/migrate/20081020220724_create_reviews.rb +4 -2
  65. data/db/migrate/20101222083309_create_feedback_reviews.rb +5 -3
  66. data/db/migrate/20110406083603_add_rating_to_products.rb +7 -5
  67. data/db/migrate/20110606150524_add_user_to_reviews.rb +4 -2
  68. data/db/migrate/20110806093221_add_ip_address_to_reviews.rb +3 -1
  69. data/db/migrate/20120110172331_namespace_tables.rb +3 -1
  70. data/db/migrate/20120123141326_recalculate_ratings.rb +6 -5
  71. data/db/migrate/20120712182514_add_locale_to_reviews.rb +4 -2
  72. data/db/migrate/20120712182627_add_locale_to_feedback_reviews.rb +4 -2
  73. data/db/migrate/20140703200946_add_show_identifier_to_reviews.rb +3 -1
  74. data/db/migrate/20190613165528_add_verified_purchaser_to_reviews.rb +5 -0
  75. data/lib/controllers/spree/api/reviews_controller.rb +111 -0
  76. data/lib/generators/solidus_reviews/install/install_generator.rb +5 -4
  77. data/lib/solidus_reviews.rb +3 -1
  78. data/lib/solidus_reviews/factories.rb +3 -1
  79. data/lib/solidus_reviews/factories/feedback_review_factory.rb +6 -5
  80. data/lib/solidus_reviews/factories/review_factory.rb +19 -9
  81. data/lib/spree_reviews/engine.rb +7 -0
  82. data/solidus_reviews.gemspec +20 -18
  83. data/spec/controllers/admin/feedback_reviews_controller_spec.rb +9 -7
  84. data/spec/controllers/admin/review_settings_controller_spec.rb +18 -16
  85. data/spec/controllers/admin/reviews_controller_spec.rb +18 -16
  86. data/spec/controllers/feedback_reviews_controller_spec.rb +29 -25
  87. data/spec/controllers/products_controller_spec.rb +4 -2
  88. data/spec/controllers/reviews_controller_spec.rb +67 -40
  89. data/spec/controllers/spree/api/reviews_controller_spec.rb +233 -0
  90. data/spec/features/admin_spec.rb +3 -0
  91. data/spec/features/reviews_spec.rb +27 -11
  92. data/spec/helpers/review_helper_spec.rb +3 -2
  93. data/spec/models/feedback_review_spec.rb +19 -17
  94. data/spec/models/product_spec.rb +41 -19
  95. data/spec/models/review_spec.rb +100 -42
  96. data/spec/models/reviews_ability_spec.rb +10 -8
  97. data/spec/models/reviews_configuration_spec.rb +28 -19
  98. data/spec/spec_helper.rb +21 -35
  99. data/vendor/assets/javascripts/jquery.rating.js +389 -376
  100. metadata +108 -59
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusReviews
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
4
-
5
- class_option :auto_run_migrations, :type => :boolean, :default => false
6
+ class_option :auto_run_migrations, type: :boolean, default: false
6
7
 
7
8
  def add_javascripts
8
9
  append_file "vendor/assets/javascripts/spree/frontend/all.js", "//= require spree/frontend/solidus_reviews\n"
@@ -10,7 +11,7 @@ module SolidusReviews
10
11
  end
11
12
 
12
13
  def add_stylesheets
13
- inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require spree/frontend/solidus_reviews\n", :before => /\*\//, :verbose => true
14
+ inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require spree/frontend/solidus_reviews\n", before: /\*\//, verbose: true
14
15
  end
15
16
 
16
17
  def add_migrations
@@ -18,7 +19,7 @@ module SolidusReviews
18
19
  end
19
20
 
20
21
  def run_migrations
21
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
22
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
22
23
  if run_migrations
23
24
  run 'bundle exec rake db:migrate'
24
25
  else
@@ -1,5 +1,7 @@
1
- require 'sass/rails'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'solidus'
4
+ require 'sass/rails'
3
5
  require 'deface'
4
6
  require 'solidus_auth_devise'
5
7
  require 'spree_reviews/engine'
@@ -1,4 +1,6 @@
1
- require "factory_girl"
1
+ # frozen_string_literal: true
2
+
3
+ require "factory_bot"
2
4
 
3
5
  Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
4
6
  require File.expand_path(f)
@@ -1,8 +1,9 @@
1
- FactoryGirl.define do
2
- factory :feedback_review, :class => Spree::FeedbackReview do |f|
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :feedback_review, class: Spree::FeedbackReview do |_f|
3
5
  user
4
6
  review
5
- comment { generate(:random_description) }
6
- rating { rand(1..5) }
7
+ rating { rand(1..5) }
7
8
  end
8
- end
9
+ end
@@ -1,20 +1,30 @@
1
- FactoryGirl.define do
2
- factory :review, :class => Spree::Review do |f|
3
- name { generate(:random_email) }
4
- title { generate(:random_string) }
5
- review { generate(:random_description) }
1
+ # frozen_string_literal: true
2
+
3
+ FactoryBot.define do
4
+ factory :review, class: Spree::Review do |_f|
5
+ sequence(:name) { |i| "User #{i}" }
6
+ title { FFaker::Book.title }
7
+ review { 'This product is ok!' }
6
8
  rating { rand(1..5) }
7
- approved false
8
- show_identifier true
9
+ approved { false }
10
+ show_identifier { true }
9
11
  user
10
12
  product
11
13
 
12
14
  trait :approved do
13
- approved true
15
+ approved { true }
14
16
  end
15
17
 
16
18
  trait :hide_identifier do
17
- show_identifier false
19
+ show_identifier { false }
20
+ end
21
+
22
+ trait :with_image do
23
+ images {
24
+ [
25
+ FactoryBot.create(:image)
26
+ ]
27
+ }
18
28
  end
19
29
  end
20
30
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SpreeReviews
2
4
  class Engine < Rails::Engine
3
5
  require 'spree/core'
@@ -12,6 +14,11 @@ module SpreeReviews
12
14
  end
13
15
  Spree::Ability.register_ability(Spree::ReviewsAbility)
14
16
  end
17
+
18
+ if SolidusSupport.api_available?
19
+ paths["app/controllers"] << "lib/controllers"
20
+ end
21
+
15
22
  config.to_prepare &method(:activate).to_proc
16
23
  end
17
24
  end
@@ -1,15 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.platform = Gem::Platform::RUBY
3
5
  s.name = 'solidus_reviews'
4
- s.version = '1.0.0'
5
- s.summary = 'Basic review and ratings facility for Spree'
6
- s.authors = ['Paul Callaghan']
6
+ s.version = '1.1.0'
7
+ s.summary = 'Basic review and ratings facility for Solidus'
8
+ s.authors = ['Solidus Contrib']
7
9
  s.description = s.summary
8
10
  s.required_ruby_version = '>= 1.9.3'
9
11
 
10
- s.authors = ['Paul Callaghan', 'Alex Blackie']
11
- s.email = 'paulcc.two@gmail.com'
12
- s.homepage = 'https://github.com/solidusio-contrib/solidus-reviews/'
12
+ s.homepage = 'https://github.com/solidusio-contrib/solidus_reviews/'
13
13
  s.license = 'BSD-3'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
@@ -17,19 +17,21 @@ Gem::Specification.new do |s|
17
17
  s.require_path = 'lib'
18
18
  s.requirements << 'none'
19
19
 
20
- s.add_dependency 'solidus', '~> 1.0'
21
- s.add_dependency 'deface', '~> 1.0'
22
- s.add_dependency 'solidus_auth_devise', '~> 1.0'
20
+ s.add_dependency 'deface', '~> 1'
21
+ s.add_dependency 'solidus', ['>= 1.4', '< 3']
22
+ s.add_dependency 'solidus_auth_devise', ['>= 1.0', '< 3']
23
+ s.add_dependency 'solidus_support', '~> 0.1'
23
24
 
25
+ s.add_development_dependency 'capybara'
26
+ s.add_development_dependency 'capybara-screenshot'
27
+ s.add_development_dependency 'coffee-rails'
28
+ s.add_development_dependency 'database_cleaner'
24
29
  s.add_development_dependency 'ffaker'
25
- s.add_development_dependency 'capybara', '~> 2.7'
26
- s.add_development_dependency 'database_cleaner', '1.2.0'
27
- s.add_development_dependency 'poltergeist', '~> 1.10.0'
28
- s.add_development_dependency 'rspec-rails', '~> 3'
29
- s.add_development_dependency 'factory_girl', '~> 4.4'
30
- s.add_development_dependency 'sqlite3'
31
- s.add_development_dependency 'simplecov', '~> 0.7.1'
32
- s.add_development_dependency 'coffee-rails', '~> 4.0.0'
33
- s.add_development_dependency 'sass-rails', '~> 5.0'
30
+ s.add_development_dependency 'poltergeist'
34
31
  s.add_development_dependency 'pry'
32
+ s.add_development_dependency 'rspec-rails'
33
+ s.add_development_dependency 'rubocop', '~> 0.53.0'
34
+ s.add_development_dependency 'sass-rails'
35
+ s.add_development_dependency 'simplecov'
36
+ s.add_development_dependency 'sqlite3', '~> 1.3.6'
35
37
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Spree::Admin::FeedbackReviewsController do
@@ -5,11 +7,11 @@ describe Spree::Admin::FeedbackReviewsController do
5
7
 
6
8
  before do
7
9
  user = create(:admin_user)
8
- controller.stub(:try_spree_current_user => user)
10
+ allow(controller).to receive(:spree_current_user).and_return(user)
9
11
  end
10
12
 
11
13
  context '#index' do
12
- let!(:review) { create(:review)}
14
+ let!(:review) { create(:review) }
13
15
  let!(:other_review) { create(:review) }
14
16
 
15
17
  let!(:feedback_review_1) { create(:feedback_review, created_at: 10.days.ago, review: review) }
@@ -20,10 +22,10 @@ describe Spree::Admin::FeedbackReviewsController do
20
22
  let!(:other_feedback_review_2) { create(:feedback_review, created_at: 2.days.ago, review: other_review) }
21
23
 
22
24
  it 'looks up feedback reviews for the specified review and renders the template' do
23
- spree_get :index, review_id: review.id
24
- response.status.should eq(200)
25
- response.should render_template(:index)
26
- assigns(:collection).should eq([feedback_review_2, feedback_review_3, feedback_review_1])
25
+ get :index, params: { review_id: review.id }
26
+ expect(response.status).to eq(200)
27
+ expect(response).to render_template(:index)
28
+ expect(assigns(:collection)).to eq([feedback_review_2, feedback_review_3, feedback_review_1])
27
29
  end
28
30
  end
29
- end
31
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Spree::Admin::ReviewSettingsController do
@@ -5,13 +7,13 @@ describe Spree::Admin::ReviewSettingsController do
5
7
 
6
8
  before do
7
9
  user = create(:admin_user)
8
- controller.stub(:try_spree_current_user => user)
10
+ allow(controller).to receive(:spree_current_user).and_return(user)
9
11
  end
10
12
 
11
13
  context '#update' do
12
14
  it 'redirects to edit-review-settings page' do
13
- spree_put :update, preferences: { preview_size: 4 }
14
- response.should redirect_to spree.edit_admin_review_settings_path
15
+ put :update, params: { preferences: { preview_size: 4 } }
16
+ expect(response).to redirect_to spree.edit_admin_review_settings_path
15
17
  end
16
18
 
17
19
  context 'For parameters:
@@ -22,36 +24,36 @@ describe Spree::Admin::ReviewSettingsController do
22
24
  track_locale: true' do
23
25
 
24
26
  it 'sets preferred_preview_size to 4' do
25
- spree_put :update, preferences: { preview_size: 4 }
26
- Spree::Reviews::Config.preferred_preview_size.should eq 4
27
+ put :update, params: { preferences: { preview_size: 4 } }
28
+ expect(Spree::Reviews::Config.preferred_preview_size).to eq 4
27
29
  end
28
30
 
29
31
  it 'sets preferred_show_email to false' do
30
- spree_put :update, preferences: { show_email: false }
31
- Spree::Reviews::Config.preferred_show_email.should be false
32
+ put :update, params: { preferences: { show_email: false } }
33
+ expect(Spree::Reviews::Config.preferred_show_email).to be false
32
34
  end
33
35
 
34
36
  it 'sets preferred_feedback_rating to false' do
35
- spree_put :update, preferences: { feedback_rating: false }
36
- Spree::Reviews::Config.preferred_feedback_rating.should be false
37
+ put :update, params: { preferences: { feedback_rating: false } }
38
+ expect(Spree::Reviews::Config.preferred_feedback_rating).to be false
37
39
  end
38
40
 
39
41
  it 'sets preferred_require_login to true' do
40
- spree_put :update, preferences: { require_login: true }
41
- Spree::Reviews::Config.preferred_require_login.should be true
42
+ put :update, params: { preferences: { require_login: true } }
43
+ expect(Spree::Reviews::Config.preferred_require_login).to be true
42
44
  end
43
45
 
44
46
  it 'sets preferred_track_locale to true' do
45
- spree_put :update, preferences: { track_locale: true }
46
- Spree::Reviews::Config.preferred_track_locale.should be true
47
+ put :update, params: { preferences: { track_locale: true } }
48
+ expect(Spree::Reviews::Config.preferred_track_locale).to be true
47
49
  end
48
50
  end
49
51
  end
50
52
 
51
53
  context '#edit' do
52
54
  it 'should render the edit template' do
53
- spree_get :edit
54
- response.should render_template(:edit)
55
+ get :edit
56
+ expect(response).to render_template(:edit)
55
57
  end
56
58
  end
57
- end
59
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Spree::Admin::ReviewsController do
@@ -8,7 +10,7 @@ describe Spree::Admin::ReviewsController do
8
10
 
9
11
  before do
10
12
  user = create(:admin_user)
11
- controller.stub(try_spree_current_user: user)
13
+ allow(controller).to receive(:spree_current_user).and_return(user)
12
14
  end
13
15
 
14
16
  context '#index' do
@@ -17,30 +19,30 @@ describe Spree::Admin::ReviewsController do
17
19
  create(:review, product: product),
18
20
  create(:review, product: product)
19
21
  ]
20
- spree_get :index, product_id: product.slug
21
- assigns[:reviews].should =~ reviews
22
+ get :index, params: { product_id: product.slug }
23
+ expect(assigns[:reviews]).to match_array reviews
22
24
  end
23
25
  end
24
26
 
25
27
  context '#approve' do
26
28
  it 'show notice message when approved' do
27
29
  review.update_attribute(:approved, true)
28
- spree_get :approve, id: review.id
29
- response.should redirect_to spree.admin_reviews_path
30
- flash[:notice].should eq Spree.t(:info_approve_review)
30
+ get :approve, params: { id: review.id }
31
+ expect(response).to redirect_to spree.admin_reviews_path
32
+ expect(flash[:success]).to eq I18n.t('spree.info_approve_review')
31
33
  end
32
34
 
33
35
  it 'show error message when not approved' do
34
- Spree::Review.any_instance.stub(:update_attribute).and_return(false)
35
- spree_get :approve, id: review.id
36
- flash[:error].should eq Spree.t(:error_approve_review)
36
+ expect_any_instance_of(Spree::Review).to receive(:save).and_return(false)
37
+ get :approve, params: { id: review.id }
38
+ expect(flash[:error]).to eq I18n.t('spree.error_approve_review')
37
39
  end
38
40
  end
39
41
 
40
42
  context '#edit' do
41
43
  specify do
42
- spree_get :edit, id: review.id
43
- response.status.should eq(200)
44
+ get :edit, params: { id: review.id }
45
+ expect(response.status).to eq(200)
44
46
  end
45
47
 
46
48
  context 'when product is nil' do
@@ -50,14 +52,14 @@ describe Spree::Admin::ReviewsController do
50
52
  end
51
53
 
52
54
  it 'flash error' do
53
- spree_get :edit, id: review.id
54
- flash[:error].should eq Spree.t(:error_no_product)
55
+ get :edit, params: { id: review.id }
56
+ expect(flash[:error]).to eq I18n.t('spree.error_no_product')
55
57
  end
56
58
 
57
59
  it 'redirect to admin-reviews page' do
58
- spree_get :edit, id: review.id
59
- response.should redirect_to spree.admin_reviews_path
60
+ get :edit, params: { id: review.id }
61
+ expect(response).to redirect_to spree.admin_reviews_path
60
62
  end
61
63
  end
62
64
  end
63
- end
65
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Spree::FeedbackReviewsController do
@@ -10,62 +12,64 @@ describe Spree::FeedbackReviewsController do
10
12
  feedback_review: {
11
13
  rating: '4 stars',
12
14
  comment: 'some comment'
13
- }}
15
+ } }
14
16
  end
15
17
 
16
18
  before do
17
- controller.stub spree_current_user: user
18
- controller.stub spree_user_signed_in?: true
19
+ allow(controller).to receive(:spree_current_user).and_return(user)
20
+ allow(controller).to receive(:spree_user_signed_in?).and_return(true)
19
21
  request.env['HTTP_REFERER'] = '/'
20
22
  end
21
23
 
22
24
  describe '#create' do
23
25
  it 'creates a new feedback review' do
24
26
  rating = 4
25
- comment = FFaker::Lorem.paragraphs(3).join("\n")
27
+ comment = ['Thanks for your review!', 'Cheers'].join("\n")
26
28
  expect {
27
- spree_post :create, { review_id: review.id,
28
- feedback_review: { comment: comment,
29
- rating: rating },
30
- format: :js }
31
- response.status.should eq(200)
32
- response.should render_template(:create)
29
+ post :create, params: { review_id: review.id,
30
+ feedback_review: {
31
+ comment: comment,
32
+ rating: rating
33
+ },
34
+ format: :js }
35
+ expect(response.status).to eq(200)
36
+ expect(response).to render_template(:create)
33
37
  }.to change(Spree::Review, :count).by(1)
34
38
  feedback_review = Spree::FeedbackReview.last
35
- feedback_review.comment.should eq(comment)
36
- feedback_review.review.should eq(review)
37
- feedback_review.rating.should eq(rating)
38
- feedback_review.user.should eq(user)
39
-
39
+ expect(feedback_review.comment).to eq(comment)
40
+ expect(feedback_review.review).to eq(review)
41
+ expect(feedback_review.rating).to eq(rating)
42
+ expect(feedback_review.user).to eq(user)
40
43
  end
41
44
 
42
45
  it 'redirects back to the calling page' do
43
- spree_post :create, valid_attributes
44
- response.should redirect_to '/'
46
+ post :create, params: valid_attributes
47
+ expect(response).to redirect_to '/'
45
48
  end
46
49
 
47
50
  it 'sets locale on feedback-review if required by config' do
48
51
  Spree::Reviews::Config.preferred_track_locale = true
49
- spree_post :create, valid_attributes
50
- assigns[:review].locale.should eq I18n.locale.to_s
52
+ post :create, params: valid_attributes
53
+ expect(assigns[:review].locale).to eq I18n.locale.to_s
51
54
  end
52
55
 
53
56
  it 'fails when user is not authorized' do
54
- controller.stub(:authorize!) { raise }
57
+ allow(controller).to receive(:authorize!).and_raise(RuntimeError)
58
+
55
59
  expect {
56
- spree_post :create, valid_attributes
60
+ post :create, params: valid_attributes
57
61
  }.to raise_error
58
62
  end
59
63
 
60
64
  it 'removes all non-numbers from ratings parameter' do
61
- spree_post :create, valid_attributes
62
- controller.params[:feedback_review][:rating].should eq '4'
65
+ post :create, params: valid_attributes
66
+ expect(controller.params[:feedback_review][:rating]).to eq '4'
63
67
  end
64
68
 
65
69
  it 'do not create feedback-review if review doesnt exist' do
66
70
  expect {
67
- spree_post :create, valid_attributes.merge!({review_id: nil})
68
- }.to raise_error
71
+ post :create, params: valid_attributes.merge!({ review_id: nil })
72
+ }.to raise_error ActionController::UrlGenerationError
69
73
  end
70
74
  end
71
75
  end