Skip to content

Commit

Permalink
Simplify the decorator for hashes. This allows nested hashes to be ou…
Browse files Browse the repository at this point in the history
…tput correctly.
  • Loading branch information
Thomas Lapinski committed Jul 20, 2015
1 parent 123d579 commit 8749551
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 35 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,40 @@
}
end
end
describe 'gitlab_rails with hash value' do
let(:params) { {:gitlab_rails => {
'ldap_enabled' => true,
'ldap_servers' => {
'main' => {
'label' => 'LDAP',
'host' => '_your_ldap_server',
'port' => 389,
'uid' => 'sAMAccountName',
'method' => 'plain',
'bind_dn' => '_the_full_dn_of_the_user_you_will_bind_with',
'password' => '_the_password_of_the_bind_user',
'active_directory' => true,
'allow_username_or_email_login' => false,
'block_auto_created_users' => false,
'base' => '',
'user_filter' => '',
}
},
'omniauth_providers' => [
{
'name' => 'google_oauth2',
'app_id' => 'YOUR APP ID',
'app_secret' => 'YOUR APP SECRET',
'args' => { 'access_type' => 'offline', 'approval_prompt' => '' }
}
]
}}}

it { is_expected.to contain_file('/etc/gitlab/gitlab.rb') \
.with_content(/^\s*gitlab_rails\['ldap_enabled'\] = true$/)
.with_content(/^\s*gitlab_rails\['ldap_servers'\] = {"main"=>{"label"=>"LDAP", "host"=>"_your_ldap_server", "port"=>"389", "uid"=>"sAMAccountName", "method"=>"plain", "bind_dn"=>"_the_full_dn_of_the_user_you_will_bind_with", "password"=>"_the_password_of_the_bind_user", "active_directory"=>true, "allow_username_or_email_login"=>false, "block_auto_created_users"=>false, "base"=>"", "user_filter"=>""}}$/)
.with_content(/^\s*gitlab_rails\['omniauth_providers'\] = \["{"name"=>"google_oauth2", "app_id"=>"YOUR APP ID", "app_secret"=>"YOUR APP SECRET", "args"=>{"access_type"=>"offline", "approval_prompt"=>""}}"\]$/)
}
end
end
end
3 changes: 1 addition & 2 deletions templates/gitlab.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
vedit = v.map { |s| "\"#{s}\"" }
return "[#{vedit.join(',')}]"
elsif v.is_a?(Hash)
vedit = v.map { |k,s| "\"#{k}\" => \"#{s}\"" }
return "{#{vedit.join(',')}}"
return v.inspect
else
return v
end
Expand Down

0 comments on commit 8749551

Please sign in to comment.