solidus_newsletter 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -0
- data/.gitignore +2 -2
- data/.rubocop.yml +23 -0
- data/.ruby-version +1 -1
- data/Gemfile +41 -14
- data/README.md +4 -3
- data/Rakefile +4 -19
- data/app/controllers/spree/admin/newsletters_controller.rb +5 -3
- data/app/controllers/spree/newsletters_controller.rb +12 -6
- data/app/models/spree/newsletter.rb +3 -1
- data/app/overrides/spree/admin/configurations/index/add_newsletter_to_admin_configurations_menu.html.erb.deface +3 -3
- data/app/overrides/spree/admin/shared/_configuration_menu/add_newsletter_to_admin_configurations_sidebar_menu.html.erb.deface +1 -1
- data/app/views/spree/admin/newsletters/_form.html.erb +4 -4
- data/app/views/spree/admin/newsletters/edit.html.erb +8 -2
- data/app/views/spree/shared/_newsletter.html.erb +14 -7
- data/config/locales/en.yml +2 -1
- data/config/locales/es-MX.yml +8 -6
- data/config/routes.rb +2 -0
- data/db/migrate/20180209175720_add_spree_newsletters_table.rb +1 -1
- data/lib/solidus_newsletter/configuration.rb +2 -0
- data/lib/solidus_newsletter/engine.rb +12 -10
- data/lib/solidus_newsletter/testing_support/factories.rb +8 -0
- data/lib/solidus_newsletter/version.rb +3 -1
- data/lib/solidus_newsletter.rb +8 -0
- data/solidus_newsletter.gemspec +22 -20
- data/spec/controllers/spree/admin/newsletters_controller_spec.rb +4 -2
- data/spec/controllers/spree/newsletters_controller_spec.rb +38 -7
- data/spec/models/spree/newsletter_spec.rb +3 -1
- data/spec/spec_helper.rb +21 -35
- metadata +44 -136
- data/.travis.yml +0 -29
- data/Gemfile.lock +0 -410
- data/lib/solidus_newsletter/factories.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41468f6f1439adf05a6b7dae4b31fe167caab4dc5514d8d47c601a405df8be21
|
4
|
+
data.tar.gz: 53101a190127763f6c958aa3dda6d0d5019186740a9d0340ac7ca600a71788e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6084ba67e4124a99a74478519f47715aa25e93bd87e5af7dd65af73efd87eef880c2e03e9152e2fe53e44ed44af6d249fb7bba9a18a18b6caed1f46a7bb40031
|
7
|
+
data.tar.gz: 1b3c91d263292366da9112d0546a6d66c70fc2ad3cc21c7d9ac57a9799704fa736e4c39522945abdc6f02849b3fe939aef8998ab2a7d3b4d8c4be2b8f039d6cd
|
@@ -0,0 +1,35 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
# Always take the latest version of the orb, this allows us to
|
5
|
+
# run specs against Solidus supported versions only without the need
|
6
|
+
# to change this configuration every time a Solidus version is released
|
7
|
+
# or goes EOL.
|
8
|
+
solidusio_extensions: solidusio/extensions@volatile
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
run-specs-with-postgres:
|
12
|
+
executor: solidusio_extensions/postgres
|
13
|
+
steps:
|
14
|
+
- solidusio_extensions/run-tests
|
15
|
+
run-specs-with-mysql:
|
16
|
+
executor: solidusio_extensions/mysql
|
17
|
+
steps:
|
18
|
+
- solidusio_extensions/run-tests
|
19
|
+
|
20
|
+
workflows:
|
21
|
+
"Run specs on supported Solidus versions":
|
22
|
+
jobs:
|
23
|
+
- run-specs-with-postgres
|
24
|
+
- run-specs-with-mysql
|
25
|
+
"Weekly run specs against master":
|
26
|
+
triggers:
|
27
|
+
- schedule:
|
28
|
+
cron: "0 0 * * 4" # every Thursday
|
29
|
+
filters:
|
30
|
+
branches:
|
31
|
+
only:
|
32
|
+
- master
|
33
|
+
jobs:
|
34
|
+
- run-specs-with-postgres
|
35
|
+
- run-specs-with-mysql
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require:
|
2
|
+
- solidus_dev_support/rubocop
|
3
|
+
|
4
|
+
inherit_gem:
|
5
|
+
solidus_dev_support: .rubocop.yml
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
Exclude:
|
9
|
+
- spec/dummy/**/*
|
10
|
+
- vendor/**/*
|
11
|
+
|
12
|
+
Rails/SkipsModelValidations:
|
13
|
+
Exclude:
|
14
|
+
- db/migrate/**/*
|
15
|
+
|
16
|
+
Gemspec/OrderedDependencies:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/RegexpLiteral:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/MissingRespondToMissing:
|
23
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/Gemfile
CHANGED
@@ -1,25 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
2
5
|
|
3
6
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
|
9
|
+
%w[solidusio/solidus solidusio/solidus_frontend]
|
10
|
+
else
|
11
|
+
%w[solidusio/solidus] * 2
|
12
|
+
end
|
13
|
+
|
14
|
+
gem 'solidus', github: solidus_git, branch: branch
|
15
|
+
gem 'solidus_api', github: solidus_git, branch: branch
|
16
|
+
gem 'solidus_backend', github: solidus_git, branch: branch
|
17
|
+
gem 'solidus_core', github: solidus_git, branch: branch
|
18
|
+
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
|
19
|
+
gem 'solidus_sample', github: solidus_git, branch: branch
|
20
|
+
|
21
|
+
# Needed to help Bundler figure out how to resolve dependencies,
|
22
|
+
# otherwise it takes forever to resolve them.
|
23
|
+
# See https://github.com/bundler/bundler/issues/6677
|
24
|
+
gem 'rails', ENV.fetch('RAILS_VERSION', nil)
|
25
|
+
|
26
|
+
# Provides basic authentication functionality for testing parts of your engine
|
27
|
+
gem 'solidus_auth_devise'
|
28
|
+
|
29
|
+
case ENV.fetch('DB', nil)
|
30
|
+
when 'mysql'
|
31
|
+
gem 'mysql2'
|
32
|
+
when 'postgresql'
|
33
|
+
gem 'pg'
|
12
34
|
else
|
13
|
-
gem '
|
14
|
-
gem 'rails_test_params_backport', group: :test
|
35
|
+
gem 'sqlite3'
|
15
36
|
end
|
16
37
|
|
17
|
-
|
18
|
-
gem '
|
19
|
-
gem '
|
38
|
+
group :test do
|
39
|
+
gem 'rails-controller-testing'
|
40
|
+
gem 'rspec-activemodel-mocks'
|
41
|
+
end
|
20
42
|
|
21
43
|
group :development, :test do
|
22
|
-
gem '
|
44
|
+
gem 'factory_bot', '> 4.10.0'
|
45
|
+
gem 'pry-rails'
|
23
46
|
end
|
24
47
|
|
25
48
|
gemspec
|
49
|
+
|
50
|
+
# Use a local Gemfile to include development dependencies that might not be
|
51
|
+
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
|
52
|
+
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
SolidusNewsletter
|
2
|
+
=================
|
3
|
+
[![CircleCI](https://circleci.com/gh/jtapia/solidus_newsletter.svg?style=shield)](https://circleci.com/gh/jtapia/solidus_newsletter)
|
3
4
|
|
4
5
|
Basic Overview
|
5
6
|
-----
|
@@ -26,4 +27,4 @@ Using the newsletter form
|
|
26
27
|
|
27
28
|
```ruby
|
28
29
|
<%= render partial: 'spree/shared/newsletter' %>
|
29
|
-
```
|
30
|
+
```
|
data/Rakefile
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
|
2
|
-
Bundler::GemHelper.install_tasks
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require '
|
5
|
-
|
3
|
+
require 'solidus_dev_support/rake_tasks'
|
4
|
+
SolidusDevSupport::RakeTasks.install
|
6
5
|
|
7
|
-
|
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_newsletter'
|
20
|
-
Rake::Task['extension:test_app'].invoke
|
21
|
-
end
|
6
|
+
task default: 'extension:specs'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spree
|
2
4
|
module Admin
|
3
5
|
class NewslettersController < Spree::Admin::BaseController
|
@@ -7,9 +9,9 @@ module Spree
|
|
7
9
|
|
8
10
|
if (title == newsletter_params[:title] && text == newsletter_params[:text]) &&
|
9
11
|
(newsletter_params[:title].present? && newsletter_params[:text])
|
10
|
-
flash[:success] =
|
12
|
+
flash[:success] = I18n.t('spree.newsletter.admin.success')
|
11
13
|
else
|
12
|
-
flash[:error] =
|
14
|
+
flash[:error] = I18n.t('spree.newsletter.admin.error')
|
13
15
|
end
|
14
16
|
|
15
17
|
redirect_to admin_newsletters_edit_path
|
@@ -30,4 +32,4 @@ module Spree
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
|
-
end
|
35
|
+
end
|
@@ -1,15 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Spree
|
2
4
|
class NewslettersController < StoreController
|
3
5
|
def create
|
4
|
-
@newsletter = Spree::Newsletter.
|
6
|
+
@newsletter = Spree::Newsletter.find_or_initialize_by(newsletter_params)
|
5
7
|
|
6
|
-
if @newsletter.
|
7
|
-
flash[:
|
8
|
+
if @newsletter.persisted?
|
9
|
+
flash[:notice] = I18n.t('spree.newsletter.controller.already_subscribed')
|
8
10
|
else
|
9
|
-
|
11
|
+
if @newsletter.save
|
12
|
+
flash[:success] = I18n.t('spree.newsletter.controller.success')
|
13
|
+
else
|
14
|
+
flash[:error] = I18n.t('spree.newsletter.controller.error')
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
|
-
redirect_to
|
18
|
+
redirect_to root_path
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
@@ -18,4 +24,4 @@ module Spree
|
|
18
24
|
params.require(:newsletters).permit(:name, :email)
|
19
25
|
end
|
20
26
|
end
|
21
|
-
end
|
27
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<!-- insert_bottom "[data-hook='admin_configurations_menu']" -->
|
2
2
|
|
3
3
|
<tr>
|
4
|
-
<td><%= link_to
|
5
|
-
<td><%=
|
6
|
-
</tr>
|
4
|
+
<td><%= link_to I18n.t('spree.newsletter.config_name'), admin_newsletters_edit_path %></td>
|
5
|
+
<td><%= I18n.t('spree.newsletter.config_description') %></td>
|
6
|
+
</tr>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<fieldset class='no-border-bottom'>
|
4
4
|
<div class='field'>
|
5
5
|
<%= f.field_container :title do %>
|
6
|
-
<%= f.label
|
6
|
+
<%= f.label I18n.t('spree.newsletter.title') %>
|
7
7
|
<%= f.text_field :title, class: 'fullwidth', value: SolidusNewsletter::Config[:title] %>
|
8
8
|
<%= f.error_message_on :title %>
|
9
9
|
<% end %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
<div class='field'>
|
13
13
|
<%= f.field_container :text do %>
|
14
|
-
<%= f.label
|
14
|
+
<%= f.label I18n.t('spree.newsletter.form.text') %>
|
15
15
|
<%= f.text_field :text, class: 'fullwidth', value: SolidusNewsletter::Config[:text] %>
|
16
16
|
<%= f.error_message_on :text %>
|
17
17
|
<% end %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<fieldset class='currency no-border-bottom'>
|
25
25
|
<div class='field'>
|
26
26
|
<%= f.field_container :title do %>
|
27
|
-
<%= f.label
|
27
|
+
<%= f.label I18n.t('spree.newsletter.form.title') %>
|
28
28
|
<%= f.text_field :title, class: 'fullwidth', value: SolidusNewsletter::Config[:title] %>
|
29
29
|
<%= f.error_message_on :title %>
|
30
30
|
<% end %>
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<fieldset class='currency no-border-bottom'>
|
37
37
|
<div class='field'>
|
38
38
|
<%= f.field_container :text do %>
|
39
|
-
<%= f.label
|
39
|
+
<%= f.label I18n.t('spree.newsletter.form.text') %>
|
40
40
|
<%= f.text_field :text, class: 'fullwidth', value: SolidusNewsletter::Config[:text] %>
|
41
41
|
<%= f.error_message_on :text %>
|
42
42
|
<% end %>
|
@@ -1,11 +1,17 @@
|
|
1
1
|
<%= render 'spree/admin/shared/general_tabs' %>
|
2
2
|
|
3
|
-
<% admin_breadcrumb(
|
3
|
+
<% admin_breadcrumb(
|
4
|
+
link_to(
|
5
|
+
I18n.t('spree.newsletter.admin_breadcrumb'),
|
6
|
+
edit_admin_general_settings_path
|
7
|
+
)
|
8
|
+
) %>
|
4
9
|
|
5
10
|
<%= form_for :newsletters, url: admin_newsletters_update_path, method: :put do |f| %>
|
6
11
|
<fieldset class='no-border-top'>
|
7
12
|
<%= render 'form', f: f %>
|
8
|
-
<%= render 'spree/admin/shared/edit_resource_links',
|
13
|
+
<%= render 'spree/admin/shared/edit_resource_links',
|
14
|
+
collection_url: edit_admin_general_settings_url %>
|
9
15
|
</fieldset>
|
10
16
|
<% end %>
|
11
17
|
|
@@ -1,23 +1,30 @@
|
|
1
1
|
<section class='newsletter-section'>
|
2
|
-
<h2 class='newsletter-section__title'
|
2
|
+
<h2 class='newsletter-section__title'>
|
3
|
+
<%= SolidusNewsletter::Config[:title].html_safe %>
|
4
|
+
</h2>
|
3
5
|
|
4
6
|
<div class='newsletter-section__content row'>
|
5
|
-
<%= form_for :
|
7
|
+
<%= form_for :newsletters, url: newsletters_path, method: :post do |f| %>
|
6
8
|
<div class='field text col-md-3 col-sm-12 text-center'>
|
7
|
-
<p><%= SolidusNewsletter::Config[:text] %></p>
|
9
|
+
<p><%= SolidusNewsletter::Config[:text].html_safe %></p>
|
8
10
|
</div>
|
9
11
|
|
10
12
|
<div class='field col-md-3 col-sm-6' id=<%= 'name' %>>
|
11
|
-
<%= f.text_field :name,
|
13
|
+
<%= f.text_field :name,
|
14
|
+
class: 'required fullwidth',
|
15
|
+
placeholder: I18n.t('spree.newsletter.form.name') %>
|
12
16
|
</div>
|
13
17
|
|
14
18
|
<div class='field col-md-3 col-sm-6' id=<%= 'email' %>>
|
15
|
-
<%= f.email_field :email,
|
19
|
+
<%= f.email_field :email,
|
20
|
+
class: 'required fullwidth',
|
21
|
+
placeholder: I18n.t('spree.newsletter.form.email') %>
|
16
22
|
</div>
|
17
23
|
|
18
24
|
<div class='col-md-3 col-sm-6 form-buttons'>
|
19
|
-
<%= f.submit
|
25
|
+
<%= f.submit I18n.t('spree.newsletter.form.button'),
|
26
|
+
class: 'newsletter-btn border-rounded small-text' %>
|
20
27
|
</div>
|
21
28
|
<% end %>
|
22
29
|
</div>
|
23
|
-
</section>
|
30
|
+
</section>
|
data/config/locales/en.yml
CHANGED
@@ -13,8 +13,9 @@ en:
|
|
13
13
|
spree:
|
14
14
|
newsletter:
|
15
15
|
controller:
|
16
|
-
|
16
|
+
success: Thank you to subscribe to our newsletter
|
17
17
|
error: Something went wrong, please try again
|
18
|
+
already_subscribed: You're already registered
|
18
19
|
admin:
|
19
20
|
success: The newsletter was updated successfuly!
|
20
21
|
error: Something went wrong, please try again
|
data/config/locales/es-MX.yml
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
es-MX:
|
2
2
|
activerecord:
|
3
3
|
attributes:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
spree/newsletter:
|
5
|
+
name: Nombre
|
6
|
+
email: Email
|
7
|
+
text: Texto
|
7
8
|
models:
|
8
9
|
spree/newsletter:
|
9
10
|
one: Newsletter
|
@@ -12,8 +13,9 @@ es-MX:
|
|
12
13
|
spree:
|
13
14
|
newsletter:
|
14
15
|
controller:
|
15
|
-
|
16
|
-
error: Hubo un
|
16
|
+
success: Gracias por suscribirte a nuestro newsletter
|
17
|
+
error: Hubo un problema, por favor intenta otra vez
|
18
|
+
already_subscribed: Ya estas actualmente registrado
|
17
19
|
admin:
|
18
20
|
success: El texto del newsletter a sido actualizado correctamente
|
19
21
|
error: El texto del newsletter no se a podido actualizar, intente más tarde
|
@@ -21,7 +23,7 @@ es-MX:
|
|
21
23
|
title: Titulo
|
22
24
|
text: Texto
|
23
25
|
name: Nombre
|
24
|
-
email: Correo
|
26
|
+
email: Correo Electrónico
|
25
27
|
button: Enviar
|
26
28
|
admin_breadcrumb: Newsletter
|
27
29
|
config_name: Newsletter
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SolidusNewsletter
|
2
4
|
class Engine < Rails::Engine
|
3
|
-
|
4
|
-
isolate_namespace Spree
|
5
|
-
engine_name 'solidus_newsletter'
|
5
|
+
include SolidusSupport::EngineExtensions
|
6
6
|
|
7
|
-
|
7
|
+
isolate_namespace ::Spree
|
8
|
+
|
9
|
+
engine_name 'solidus_newsletter'
|
8
10
|
|
9
11
|
# use rspec for tests
|
10
12
|
config.generators do |g|
|
@@ -15,12 +17,12 @@ module SolidusNewsletter
|
|
15
17
|
SolidusNewsletter::Config = SolidusNewsletter::Configuration.new
|
16
18
|
end
|
17
19
|
|
18
|
-
def self.activate
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
20
|
+
# def self.activate
|
21
|
+
# Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
22
|
+
# Rails.configuration.cache_classes ? require(c) : load(c)
|
23
|
+
# end
|
24
|
+
# end
|
23
25
|
|
24
|
-
config.to_prepare &method(:activate).to_proc
|
26
|
+
# config.to_prepare &method(:activate).to_proc
|
25
27
|
end
|
26
28
|
end
|
data/lib/solidus_newsletter.rb
CHANGED
data/solidus_newsletter.gemspec
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
#
|
2
|
-
$:.push File.expand_path('../lib', __FILE__)
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
require 'solidus_newsletter/version'
|
3
|
+
require_relative 'lib/solidus_newsletter/version'
|
6
4
|
|
7
|
-
# Describe your gem and declare its dependencies:
|
8
5
|
Gem::Specification.new do |s|
|
9
6
|
s.name = 'solidus_newsletter'
|
10
7
|
s.version = SolidusNewsletter::VERSION
|
@@ -14,24 +11,29 @@ Gem::Specification.new do |s|
|
|
14
11
|
s.summary = 'Solidus Newsletter extension'
|
15
12
|
s.description = 'Adds a newsletter form to the homepage'
|
16
13
|
|
17
|
-
# s.files = Dir['{app,config,models,db,lib}/**/*'] + %w(MIT-LICENSE Rakefile README.md)
|
18
14
|
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
19
16
|
s.require_path = 'lib'
|
20
17
|
s.requirements << 'none'
|
21
18
|
|
22
|
-
|
19
|
+
if s.respond_to?(:metadata)
|
20
|
+
s.metadata['homepage_uri'] = s.homepage
|
21
|
+
s.metadata['source_code_uri'] = 'https://github.com/jtapia/solidus_newsletter'
|
22
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
23
|
+
end
|
24
|
+
|
25
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.5')
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
30
|
+
|
31
|
+
solidus_version = ['>= 2.5', '< 4']
|
32
|
+
|
23
33
|
s.add_dependency 'solidus_core', solidus_version
|
24
|
-
s.add_dependency '
|
25
|
-
s.add_dependency 'solidus_api', solidus_version
|
26
|
-
s.add_dependency 'solidus_support'
|
27
|
-
|
28
|
-
s.add_development_dependency 'database_cleaner', '~> 1.6'
|
29
|
-
s.add_development_dependency 'factory_bot', '~> 4.4'
|
30
|
-
s.add_development_dependency 'ffaker'
|
31
|
-
s.add_development_dependency 'rspec-rails', '~> 3.3'
|
32
|
-
s.add_development_dependency 'simplecov', '~> 0.14'
|
33
|
-
s.add_development_dependency 'rspec-activemodel-mocks'
|
34
|
-
s.add_development_dependency 'webmock'
|
35
|
-
s.add_development_dependency 'byebug'
|
36
|
-
end
|
34
|
+
s.add_dependency 'solidus_support', '~> 0.5'
|
37
35
|
|
36
|
+
s.add_development_dependency 'solidus_backend', solidus_version
|
37
|
+
s.add_development_dependency 'solidus_dev_support', '~> 2.5'
|
38
|
+
s.add_development_dependency 'solidus_frontend', solidus_version
|
39
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Spree::Admin::NewslettersController, type: :controller do
|
5
|
+
RSpec.describe Spree::Admin::NewslettersController, type: :controller do
|
4
6
|
stub_authorization!
|
5
7
|
|
6
8
|
before do
|
@@ -24,4 +26,4 @@ describe Spree::Admin::NewslettersController, type: :controller do
|
|
24
26
|
expect(flash[:error]).to include('Something went wrong, please try again')
|
25
27
|
end
|
26
28
|
end
|
27
|
-
end
|
29
|
+
end
|
@@ -1,19 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
|
-
describe Spree::NewslettersController, type: :controller do
|
5
|
+
RSpec.describe Spree::NewslettersController, type: :controller do
|
6
|
+
let(:newsletter) { create(:newsletter) }
|
7
|
+
|
4
8
|
context '#create' do
|
5
|
-
it 'returns true' do
|
6
|
-
post :create,
|
9
|
+
it 'returns true new object' do
|
10
|
+
post :create,
|
11
|
+
params: {
|
12
|
+
newsletters: {
|
13
|
+
name: 'User Test',
|
14
|
+
email: 'user@test.com'
|
15
|
+
}
|
16
|
+
}
|
7
17
|
|
8
18
|
expect(response.status).to eq(302)
|
9
|
-
expect(flash[:success])
|
19
|
+
expect(flash[:success])
|
20
|
+
.to include(I18n.t('spree.newsletter.controller.success'))
|
10
21
|
end
|
11
22
|
|
12
23
|
it 'returns false' do
|
13
|
-
post :create,
|
24
|
+
post :create,
|
25
|
+
params: {
|
26
|
+
newsletters: {
|
27
|
+
name: '',
|
28
|
+
email: ''
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
expect(response.status).to eq(302)
|
33
|
+
expect(flash[:error]).to include(I18n.t('spree.newsletter.controller.error'))
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns already added' do
|
37
|
+
post :create,
|
38
|
+
params: {
|
39
|
+
newsletters: {
|
40
|
+
name: newsletter.name,
|
41
|
+
email: newsletter.email
|
42
|
+
}
|
43
|
+
}
|
14
44
|
|
15
45
|
expect(response.status).to eq(302)
|
16
|
-
expect(flash[:
|
46
|
+
expect(flash[:notice])
|
47
|
+
.to include(I18n.t('spree.newsletter.controller.already_subscribed'))
|
17
48
|
end
|
18
49
|
end
|
19
|
-
end
|
50
|
+
end
|