Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes admin authentication methods pages + specs
- Let :provider, :api_key, :api_secret be required fields. Also cleanup partials and add small starter spec for the extended engine classes. Conflicts: spec/integration/sign_in_spec.rb spec/spec_helper.rb spree_social.gemspec
- Loading branch information
Showing
13 changed files
with
157 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ nbproject | |
spec/dummy | ||
.rvmrc | ||
.bundle | ||
coverage | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
guard "rspec", cmd: "bundle exec rspec", all_on_start: false, all_after_pass: false do | ||
watch("spec/spec_helper.rb") { "spec" } | ||
watch("config/routes.rb") { "spec/controllers" } | ||
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"} | ||
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^app/(.*)(\.erb)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//= require spree/backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* | ||
*= require spree/backend | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
app/views/spree/admin/authentication_methods/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
spec/features/spree/admin/authentication_methods_configuration_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
require 'spec_helper' | ||
|
||
feature 'Admin Authentication Methods', js: true do | ||
stub_authorization! | ||
|
||
context 'elements' do | ||
scenario 'has configuration tab' do | ||
visit spree.admin_path | ||
click_link 'Configuration' | ||
expect(page).to have_text 'SOCIAL AUTHENTICATION METHODS' | ||
end | ||
end | ||
|
||
context 'when no auth methods exists' do | ||
background do | ||
visit spree.admin_path | ||
click_link 'Configuration' | ||
click_link 'Social Authentication Methods' | ||
end | ||
|
||
scenario 'can create new' do | ||
expect(page).to have_text 'NO AUTHENTICATION METHODS FOUND, ADD ONE!' | ||
|
||
click_link 'New Authentication Method' | ||
expect(page).to have_text 'BACK TO AUTHENTICATION METHODS LIST' | ||
|
||
select2 'Test', from: 'Environment' | ||
select2 'Github', from: 'Social Provider' | ||
fill_in 'API Key', with: 'KEY123' | ||
fill_in 'API Secret', with: 'SEC123' | ||
|
||
click_button 'Create' | ||
expect(page).to have_text 'successfully created!' | ||
end | ||
|
||
scenario 'does not save with empty fields' do | ||
click_link 'New Authentication Method' | ||
click_button 'Create' | ||
expect(page).to have_text 'errors prohibited this record from being saved' | ||
end | ||
end | ||
|
||
context 'when auth method exists' do | ||
given!(:authentication_method) do | ||
Spree::AuthenticationMethod.create!( | ||
provider: 'facebook', | ||
api_key: 'fake', | ||
api_secret: 'fake', | ||
environment: Rails.env, | ||
active: true) | ||
end | ||
|
||
background do | ||
visit spree.admin_path | ||
click_link 'Configuration' | ||
click_link 'Social Authentication Methods' | ||
end | ||
|
||
scenario 'can be updated' do | ||
within_row(1) do | ||
click_icon :edit | ||
end | ||
|
||
fill_in 'API Key', with: 'fake' | ||
fill_in 'API Secret', with: 'fake' | ||
|
||
click_button 'Update' | ||
expect(page).to have_text 'successfully updated!' | ||
end | ||
|
||
scenario 'can be deleted' do | ||
within_row(1) do | ||
click_icon :trash | ||
end | ||
|
||
page.driver.browser.switch_to.alert.accept unless Capybara.javascript_driver == :poltergeist | ||
|
||
expect(page).to have_text 'successfully removed!' | ||
expect(page).not_to have_text authentication_method.provider | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'spec_helper' | ||
|
||
describe SpreeSocial do | ||
context 'constants' do | ||
it { should be_const_defined(:OAUTH_PROVIDERS) } | ||
|
||
it 'contain all providers' do | ||
oauth_providers = [ | ||
['Facebook', 'facebook'], | ||
['Twitter', 'twitter'], | ||
['Github', 'github'], | ||
['Google', 'google_oauth2']] | ||
expect(described_class::OAUTH_PROVIDERS).to match_array oauth_providers | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters