Browse Source

Merge branch 'feature/deface-in-test' into develop

* feature/deface-in-test:
  Configure travis to cache the bundle
  HoundCI formatting fixes
  Allow calls to codeclimate to go around webmock.
  Reload deface so our override is picked up.
  Clean up decorator.
tags/3.0.0^2
Bèr Kessels 6 years ago
parent
commit
d861ae1a79

+ 2
- 0
.travis.yml View File

@@ -5,3 +5,5 @@ rvm:
script:
- bundle exec rake test_app
- bundle exec rake spec
cache:
- bundler

+ 0
- 6
app/overrides/admin_configuration_decorator.rb View File

@@ -1,6 +0,0 @@
Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
:name => "add_sisow_settings_to_configurations_menu",
:insert_bottom => "[data-hook='admin_configurations_sidebar_menu']",
:partial => "spree/admin/shared/configurations_menu_sisow",
:original => '782d80d377c2a150800d0e78c4d2dcf015ebf14d',
:disabled => false)

+ 5
- 0
app/overrides/admin_decorator.rb View File

@@ -0,0 +1,5 @@
Deface::Override.new(
virtual_path: "spree/admin/shared/sub_menu/_configuration",
name: "add_sisow_settings",
insert_bottom: "[data-hook='admin_configurations_sidebar_menu']",
partial: "spree/admin/shared/configurations_menu_sisow")

+ 1
- 1
app/views/spree/admin/shared/_configurations_menu_sisow.html.erb View File

@@ -1 +1 @@
<%= configurations_sidebar_menu_item Spree.t(:sisow_configuration), edit_admin_sisow_path %>
<%= configurations_sidebar_menu_item Spree.t(:sisow_configuration), edit_admin_sisow_path %>

+ 27
- 25
spec/features/administer_spec.rb View File

@@ -1,45 +1,47 @@
require 'spec_helper'
require "spec_helper"

feature 'Administer' do
context 'as an admin' do
feature "Administer" do
context "as an admin" do
stub_authorization!

scenario 'I want to browse to the sisow settings page' do
scenario "I want to browse to the sisow settings page" do
# Reload Deface, else it won"t register our overrides.
Rails.application.config.deface.overrides.load_all Rails.application
visit spree.admin_path
click_link 'Sisow settings'
expect(page.find('h1')).to have_content 'Sisow configuration'
click_link "Sisow configuration"
expect(page.find("h1")).to have_content "Sisow configuration"
end

context 'when on the admin page' do
context "when on the admin page" do
before(:each) do
visit spree.edit_admin_sisow_path
end

scenario 'I want to provide the Sisow API-credentials' do
within_fieldset 'Identification settings' do
fill_in 'Merchant ID', with: 'ABC'
fill_in 'Merchant Key', with: 'DEF'
scenario "I want to provide the Sisow API-credentials" do
within_fieldset "Identification settings" do
fill_in "Merchant ID", with: "ABC"
fill_in "Merchant Key", with: "DEF"
end
click_button 'Update'
click_button "Update"

expect(page).to have_content 'Sisow settings updated'
expect(page).to have_field('Merchant ID', with: 'ABC')
expect(page).to have_field('Merchant Key', with: 'DEF')
expect(page).to have_content "Sisow settings updated"
expect(page).to have_field("Merchant ID", with: "ABC")
expect(page).to have_field("Merchant Key", with: "DEF")
end

scenario 'I want to change environment' do
expect(page).to have_checked_field 'Test mode'
expect(page).to have_unchecked_field 'Debug mode'
scenario "I want to change environment" do
expect(page).to have_checked_field "Test mode"
expect(page).to have_unchecked_field "Debug mode"

within_fieldset 'Environment settings' do
uncheck 'Test mode'
check 'Debug mode'
within_fieldset "Environment settings" do
uncheck "Test mode"
check "Debug mode"
end
click_button 'Update'
click_button "Update"

expect(page).to have_content 'Sisow settings updated'
expect(page).to have_unchecked_field 'Test mode'
expect(page).to have_checked_field 'Debug mode'
expect(page).to have_content "Sisow settings updated"
expect(page).to have_unchecked_field "Test mode"
expect(page).to have_checked_field "Debug mode"
end
end
end

+ 9
- 0
spec/spec_helper.rb View File

@@ -29,6 +29,13 @@ require 'spree/testing_support/preferences'
# Requires factories defined in lib/spree_billing_sisow/factories.rb
require 'spree_billing_sisow/factories'

# Override autogenerated spec/dummy/config/environments/test.rb
# We need to disable caching of classes, because otherwise
# the loading of the menu-item Deface::Override won't apply.
Dummy::Application.configure do
config.cache_classes = false
end

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods

@@ -69,6 +76,8 @@ RSpec.configure do |config|
config.before :suite do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with :truncation

WebMock.disable_net_connect!(allow: "codeclimate.com")
end

# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.

Loading…
Cancel
Save