Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace not working symbols to strings #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/redmine_oauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class RedmineOauthController < AccountController
include Helpers::MailHelper
include Helpers::Checker
def oauth_google
if Setting.plugin_redmine_omniauth_google[:oauth_authentification]
if Setting.plugin_redmine_omniauth_google['oauth_authentification']
session[:back_url] = params[:back_url]
redirect_to oauth_client.auth_code.authorize_url(:redirect_uri => oauth_google_callback_url, :scope => scopes)
else
Expand Down Expand Up @@ -83,7 +83,7 @@ def try_to_login info
end

def oauth_client
@client ||= OAuth2::Client.new(settings[:client_id], settings[:client_secret],
@client ||= OAuth2::Client.new(settings['client_id'], settings['client_secret'],
:site => 'https://accounts.google.com',
:authorize_url => '/o/oauth2/auth',
:token_url => '/o/oauth2/token')
Expand Down
2 changes: 1 addition & 1 deletion app/views/hooks/_view_account_login_bottom.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= stylesheet_link_tag 'buttons', :plugin => 'redmine_omniauth_google' %>

<% if Setting.plugin_redmine_omniauth_google[:oauth_authentification] %>
<% if Setting.plugin_redmine_omniauth_google['oauth_authentification'] %>
<%= link_to oauth_google_path(:back_url => back_url) do %>
<%= button_tag :class => 'button-login' do %>
<%= image_tag('/plugin_assets/redmine_omniauth_google/images/google_login_icon.png', :class => 'button-login-icon', :alt => l(:login_via_google)) %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/settings/_google_settings.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<p>
<label>Client ID:</label>
<%= text_field_tag 'settings[client_id]', @settings[:client_id] %>
<%= text_field_tag 'settings[client_id]', @settings['client_id'] %>
</p>
<p>
<label>Client Secret:</label>
<%= text_field_tag 'settings[client_secret]', @settings[:client_secret] %>
<%= text_field_tag 'settings[client_secret]', @settings['client_secret'] %>
</p>
<p>
<label>Available domains</label>
<%= text_area_tag "settings[allowed_domains]", @settings[:allowed_domains], :rows => 5 %>
<%= text_area_tag "settings[allowed_domains]", @settings['allowed_domains'], :rows => 5 %>
</p>
<p>
<label>Oauth authentification:</label>
<%= check_box_tag "settings[oauth_authentification]", true, @settings[:oauth_authentification] %>
<%= check_box_tag "settings[oauth_authentification]", true, @settings['oauth_authentification'] %>
</p>
4 changes: 2 additions & 2 deletions lib/helpers/checker.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Helpers
module Checker
def allowed_domain_for? email
allowed_domains = Setting.plugin_redmine_omniauth_google[:allowed_domains]
allowed_domains = Setting.plugin_redmine_omniauth_google['allowed_domains']
return unless allowed_domains
allowed_domains = allowed_domains.split
return true if allowed_domains.empty?
allowed_domains.index(parse_email(email)[:domain])
end
end
end
end
6 changes: 3 additions & 3 deletions test/functional/redmine_oauth_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def set_response_body_stub options = {}
end

def test_oauth_google_with_enabled_oauth_authentification
Setting.plugin_redmine_omniauth_google[:oauth_authentification] = nil
Setting.plugin_redmine_omniauth_google['oauth_authentification'] = nil
get :oauth_google
assert_response 404
end
Expand Down Expand Up @@ -100,15 +100,15 @@ def test_oauth_google_callback_with_new_user_created_with_manual_activation
end

def test_oauth_google_callback_with_not_allowed_email_domain
Setting.plugin_redmine_omniauth_google[:allowed_domains] = "twinslash.com"
Setting.plugin_redmine_omniauth_google['allowed_domains'] = "twinslash.com"
set_response_body_stub
get :oauth_google_callback
assert_redirected_to :signin
end

def test_oauth_google_callback_with_allowed_email_domain
Setting.self_registration = '3'
Setting.plugin_redmine_omniauth_google[:allowed_domains] = parse_email(@default_response_body[:email])[:domain]
Setting.plugin_redmine_omniauth_google['allowed_domains'] = parse_email(@default_response_body[:email])[:domain]
set_response_body_stub
get :oauth_google_callback
assert_redirected_to :controller => 'my', :action => 'account'
Expand Down