From 5f96c276e9c7eec6dd8b1ccf526a6fa08a5a0960 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 23 Jul 2014 14:55:06 +0200 Subject: [PATCH] Rework the Sign Up/Sign In views Use Capybaras save_page when feature tests go wrong --- app/assets/images/facebook.png | Bin 1431 -> 0 bytes app/assets/images/google.png | Bin 1615 -> 0 bytes app/assets/images/novell.png | Bin 413 -> 0 bytes app/assets/images/suse.svg | 104 ++++++++++++++++++ app/assets/stylesheets/application.css | 1 + app/assets/stylesheets/fonts/suse-icons.eot | Bin 0 -> 1780 bytes app/assets/stylesheets/fonts/suse-icons.svg | 11 ++ app/assets/stylesheets/fonts/suse-icons.ttf | Bin 0 -> 1608 bytes app/assets/stylesheets/fonts/suse-icons.woff | Bin 0 -> 1192 bytes app/assets/stylesheets/osem-fonts.css | 47 ++++++++ .../stylesheets/{osem.css => osem.css.scss} | 2 +- app/helpers/application_helper.rb | 12 ++ app/models/user.rb | 2 +- app/views/devise/registrations/edit.html.haml | 3 +- app/views/devise/registrations/new.html.haml | 51 +++++---- app/views/devise/sessions/new.html.haml | 54 +++++---- app/views/devise/shared/_links.html.haml | 12 +- app/views/devise/shared/_openid.html.haml | 14 +-- app/views/layouts/_navigation.html.haml | 45 ++++---- config/initializers/devise.rb | 6 +- config/secrets.yml.example | 7 +- spec/features/omniauth_spec.rb | 35 ++++-- spec/support/omniauth_macros.rb | 2 +- spec/support/save_feature_failures.rb | 18 +++ 24 files changed, 326 insertions(+), 100 deletions(-) delete mode 100644 app/assets/images/facebook.png delete mode 100644 app/assets/images/google.png delete mode 100644 app/assets/images/novell.png create mode 100644 app/assets/images/suse.svg create mode 100644 app/assets/stylesheets/fonts/suse-icons.eot create mode 100644 app/assets/stylesheets/fonts/suse-icons.svg create mode 100644 app/assets/stylesheets/fonts/suse-icons.ttf create mode 100644 app/assets/stylesheets/fonts/suse-icons.woff create mode 100644 app/assets/stylesheets/osem-fonts.css rename app/assets/stylesheets/{osem.css => osem.css.scss} (99%) create mode 100644 spec/support/save_feature_failures.rb diff --git a/app/assets/images/facebook.png b/app/assets/images/facebook.png deleted file mode 100644 index e8bca65fd18e68bc9986f89138e9d26f46c928ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1431 zcmV;I1!($-P)O)mmvrv;GCO9>_SpXy|k1<1Cm1M_hbhP zl0&lD=KKzqfI1=k5;;=QAw$=k~oI-NGCj)bTbKS!G#6ahLB#(4lifHMpr#L3;+S`QA0+d07t=rar@%YUe=|x1q&RdWG>wk}R+J*;Y~~>w!U3rUoV{{tn;jRsan4L< z6Jm1_|MTZBx3Vl*leUW$$Yg3N_0;z$KzL8@T(g;(Znv+XX%UmIwK8@glJ(u~pBB+q z1$~x~V=S~yAE&a~Jlbjewf@~ZQ8wQ zK~#9!mVSaIA|e!R!IoP5D#joQpiPJxY7C7D!NjNpF-l@8 zi1DY2NsWn#7!t$;1BekdAhv0w)F>aJ(w2_~X`x38y|#DI_If+x?9Sfa?)9z^ewjGw z+jn;Moqe8pKW65D|9c~M`R;BSzax;AmX_Q_ix$<3?zFm(enng70IKHaVfVYs9Cke` zAA{C+1)Oss;zLA2a306vJdRB`f@dSquh(7;T~A41@7}%nwY9Z}RaJfPt*`#VzT>?h zlo%ijW@TZ|rbm(Ka~Zag&UOUWt^j8eRkx7@WZxKvd*yW9_WhmkrF)R(b;Fb9#_+fXkBg#m&U863HxK+q0PNCvC@vLLQG`%X zl}ar{Cr?OBjMe5(qhxsJ@YpdJv;?S)fEtNJX6T)xfA_;HfV~E|OK6wT|L)H|gvO%Q z1mCLXLDRjUUXLY;#|6c$3Q`IbRj~*WDhXZAyl1f;*G>S8F(V{Y7%F0tq7b;mM^s(J z>PMp-EnPP(dv{qSh*&*wxujNOqJZe2x)@70y`X4}pt0W#9!c^hf{&3JXJFde_=d(o4wqQ@uJq-iMa52H9ZiscuE zQ4}1v(QsCNN&;)EXW^$a{kS#~G3Uy9e_~#a@qRFP4X*`TaOmYyjOdlgG-1M|)}m<5 zcLPxk+p2O=bvcAL+xoHOa(EJsBLqLR{$ut1UKO9OE5m(x>DFfRVpTC#mKR`X;ufAd z*@$loRgAbP;&F=YMDbAQe{F?6)U7JUtIG?}m#(DtK*P>I(9|8p$Lp71W{wYq*=g9d zVKMrK#*Ccs3(>)6|ME75BVoB>W7W(Ak3I9a#7K$1BPHoLvbqR3dp$V;JzHBl2C!^v z6Us#;l!(fJ}G<232uotwFht;59nK^Zpbty!A*Ve zM4w~Q#>NoBUKp|=XkMUbty_qvQafRC*|Q@JF^l8T${1% z@OvhZCbeewj6L?r88|%f<>nf+?RXBaJUs_X3eJG_ZUnnf19plS!UJ0!lWX!9;{Am$ z#KB|LVD|#&PA?>EL=FNK_s;;24uPF62k#OWkp3M&s5xHdSGR#(tTk+`a4dK>zH&n} z8@SyQ$uC9@0v>w9&)Nk*__RE&xp`{GM1Kx`4}Px3nv?C$K#6ZgLj3Lh)b5`|AT#vE z0~lEODrljcep(blubI%E90w(4F z=Sfb?WM!DQMx2)=GTzJvm`Fkh@s%5MntD&#Vy`*FkhmAzZXYlP9y%Z{d|C1$shJW@ z=o9h2XroNR=Fd!EbHy4@vI*G$GCV~o35<@@E5u(8T5$>_f1T3b&R&Z~N{9=iDztaY8;@6P`C#`qK7Vn6RW!jS8~bu` z_shnm;j5@Wv|YyDsw^JwC%QZKJf>YFd%Ejsceq`Q+!ANbguE_N;-Zv#gkjbr)z$MG z8XDG=m6cTs17er%Yhm)uiB__!{YN4{N^G@F%wHh!y5WRa{aZsPkJF=peYAJ9Q`ih~ z#>N@v5t}QFrV1dx81#z)HzmX+#uRnGZX zkdUy9GS1i?{Wdgc8UI10f^p3y33JVRtGu{z`8!FHaU2Byz4osF0|3bfn|->$iJkxe N002ovPDHLkV1hOX`1Sw* diff --git a/app/assets/images/novell.png b/app/assets/images/novell.png deleted file mode 100644 index a33e55e2e23d64f0bcee51a445f2ffa1a1a8efdb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 413 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyO9OmDT>ra<{RaXD@&7?d{~4J7 zGw}RZwfKMN`2U9P|Cwd~KYse(J@x;>mH*3||G#|opF!Y1i`4%|PyQRa{J(hhzo6Rx z-3R~w{PkbY;s2(c|7R@vpOE)|)yDslI{%C6{$IcS-^%AdgV_Ju_x>}8{GT-Yzq#lC zKY#vk#1_kS*h{~W^q zSw#Pft5hEQXbE&MV@Z%-FoVOh8)+a;lDE4HLkFv@2av;A;1OBOz`!jG!i)^F=12eq z*-JcqUD@xkvGAC4zv4B$02C_pba4!^IKB1KMy>-20?Yx$v3!MDvR?le{r_Lgx-mg? z^3k*@?RQ+ABLtKqIWIlGbN4+TgD%4Z<_@kcirw}yMUH6c)I$ztaD0e F0sy;#xo7|Y diff --git a/app/assets/images/suse.svg b/app/assets/images/suse.svg new file mode 100644 index 00000000..ab3061dc --- /dev/null +++ b/app/assets/images/suse.svg @@ -0,0 +1,104 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 50504034..dac9aa07 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,6 +10,7 @@ *= require osem-schedule *= require osem-schedule-print *= require osem-dashboard + *= require osem-fonts *= require font-awesome *= require bootstrap-markdown.min */ diff --git a/app/assets/stylesheets/fonts/suse-icons.eot b/app/assets/stylesheets/fonts/suse-icons.eot new file mode 100644 index 0000000000000000000000000000000000000000..ffed3026fcb0cc97a1d743e8b9d5d36b04c91ea3 GIT binary patch literal 1780 zcmdT^J8TnK6utM&$BsQAHnL}ouwXFA;b%LUBr^yh$nFLQK_Vi7B9Qovg7cAx9mPR{ zX0=EtT{fw4I?_Uh`rwJvuAGt{K(=rtad6s|FcY* z24fkKg@9qxAeCtVyf4j1NG{w6t};iJmK0U_U@VIp;T*+HGVaT}3=TckSkE_RagpL`n|v{Cv&7%CV#W zA@&m8orgoUgoaoK_MZ90l^a+LYw*aIv*CPe_f}Ug_Z|5_$?!d%wSIn$I0d6Y2Di8cGafw` zQsG~E${`vk7cGOdn9APbb*z`&KOX`F%85b2{!etc(~c!=!PVqzmw8^g?mibz+`t?ckUm z)BDTpxiNFd@m$Y6#_ot)lj98chdVc{E zGN#3?^{4CWPk*1>YFajnRN9imkNNb;%Feh@SrMw(y{|CM+$+uu6%S}Ewk7oVzy|ZE zvG)gU|5~9CPbUpF)2U=qm?^HweCr>7N--BKt1m5hmzDcl&GyDbT`gdubgsF0yh zk#0p;1?PT*HA>R!2&;qeVWv@sTy`mE + + +Generated by Fontastic.me + + + + + + + diff --git a/app/assets/stylesheets/fonts/suse-icons.ttf b/app/assets/stylesheets/fonts/suse-icons.ttf new file mode 100644 index 0000000000000000000000000000000000000000..ef1de507623b002a83b416a9cab53e96b4b25b6c GIT binary patch literal 1608 zcmdT^O>7fa5dLQW?ARM(BYW4V7A&T6C}2C;klhMZkhZ~*fCwb2sFi486`UW5*ijrL zdZ}8e;zq-%haQkx^-%THd)1#qRkd8W^w0wbxFR7qmqJ*2bMhzp?o)y_5{9dp^p$A8 zy0)=>gNt!3`HptsT5mbRXGGA|`niqh#wO0;3jMFs_PWtVr!{`(0AL&^_w{D4zm2nM zee+NHk3j8>a_jq>H!n}T@eFy51aNQg(Zd(ohAjgb(9R-p$8%z)nGnP()9zu!jDh#n z>2Rn(iMcsta)<`G4HH>8Co8lUQvD43@Tr<$j>U0t>iL{Xp1a7*-sprzDCa7 z+<(QY&i}_ych2J3CO0F)o8e#qi?~F-WYy}&13wc6?taNw8EdjBVUTfV{4fZEQxePu zbw#(NDU*)tgu!e`ROfT3Y?bSiR=MP!)ckU(HtTW@!zXK;P;y)u?A+bix%=hfUdQ!B zD->O&-l`VQv<_r7Lv+p14!u@e5*gPn&eV^ZqV3CB*{RzibN1mk%_FyJwQMnOi&HG* z^O{qTj>@<5{Oy8B&2=Y=njCa1-x}rdjF#2MOwG_8k)xt{dT1E?b&);oT-K~sH!JX7=JLuI{)~Y6dR2BCdDRK{XNAN`N!zvI;F!3*0GEpy0p;0-tRQl zmwR2}U3AK{bQ4 z-rq~p@cl;E@TaC3_p+q_sB?*RY%y#-uFhk2RS}jtTmAK3*PCwA_}3((Mv?q+$@fWc r@>U&Mb%puZ6m|wSEaE*Bc54o0$6ts2W7HAiJoi5M^|=bz-ADfdMESoq literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/fonts/suse-icons.woff b/app/assets/stylesheets/fonts/suse-icons.woff new file mode 100644 index 0000000000000000000000000000000000000000..4ebb0dc1a24edad86e2666b825c9606ab6508448 GIT binary patch literal 1192 zcmZXSdoWyA9LLW-?6O`! zCdiH&8^cV*YrUF8Td`}{(?5DOoe0m#3AFh+wH5D>ZA)6D+aVpoL-Xb zrgq=yq-1f%%k{0tBdc##Yp+!Wvo3m_6fPU+318Fpj?8B{Pp~+hDXH()LeR)Mk0|M4+DAu2H?K| zj)!~vNJN67gJ}11Pia4jF6dNuIruoV(CKtWW1<5JEOGkkK1qRG0pi2+;idnvkI6P$ zytV%wa>2;mR*lNT1ASj@_$R*afuD&O6IcYY0HZYOPB$QEQ-=w6jEze(>w5S1yRA{x zz8YtPi4OEJwGejv@N|!&Da+V9>$jenDcK zlAC!Lam`I6xwy1Axy1{Sy7$!|*)=47$j$M)H(a-;$-XK2~>GDUgI*3Wrzx8z&NW?0Y1?t>9@ab9|gZG-zrqcD0pq4fLhr>!-9 zGggzid+EdS@M4qOeAVvUI?DHNswgiXSL6w5pVcSljTEW&3k_fSFdx64ACquhD+UJ6 H2WtNS$^Y3~ literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/osem-fonts.css b/app/assets/stylesheets/osem-fonts.css new file mode 100644 index 00000000..0864ce30 --- /dev/null +++ b/app/assets/stylesheets/osem-fonts.css @@ -0,0 +1,47 @@ +/* Generated with http://fontastic.me/ and app/assets/images/suse.svg */ +@charset "UTF-8"; + +@font-face { + font-family: "suse-icons"; + src:url("fonts/suse-icons.eot"); + src:url("fonts/suse-icons.eot?#iefix") format("embedded-opentype"), + url("fonts/suse-icons.woff") format("woff"), + url("fonts/suse-icons.ttf") format("truetype"), + url("fonts/suse-icons.svg#suse-icons") format("svg"); + font-weight: normal; + font-style: normal; + +} + +[data-icon]:before { + font-family: "suse-icons" !important; + content: attr(data-icon); + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* We have to repeat this for every symbol that extends font awesome. So if + you add fa-rutzelfuz you need to copy and paste these two... +*/ +[class^="fa-suse"]:before, +[class*=" fa-suse"]:before { + font-family: "suse-icons" !important; + font-style: normal !important; + font-weight: normal !important; + font-variant: normal !important; + text-transform: none !important; + speak: none; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.fa-suse:before { + content: "a"; +} diff --git a/app/assets/stylesheets/osem.css b/app/assets/stylesheets/osem.css.scss similarity index 99% rename from app/assets/stylesheets/osem.css rename to app/assets/stylesheets/osem.css.scss index 7ad9dba9..d64a4776 100644 --- a/app/assets/stylesheets/osem.css +++ b/app/assets/stylesheets/osem.css.scss @@ -120,4 +120,4 @@ body { .pad{ padding-top: 35px; padding-bottom: 35px; -} +} \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7ca2a022..04ac8a88 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -210,4 +210,16 @@ module ApplicationHelper def markdown_hint(text="") markdown("#{text} Please look at #{link_to '**Markdown Syntax**', 'https://daringfireball.net/projects/markdown/syntax', target: '_blank'} to format your text") end + + def omniauth_configured + providers = [] + Devise.omniauth_providers.each do |provider| + provider_key = "#{provider}_key" + provider_secret = "#{provider}_secret" + unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank? + providers << provider + end + end + return providers + end end diff --git a/app/models/user.rb b/app/models/user.rb index c86c773e..afcce0b4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,7 +7,7 @@ class User < ActiveRecord::Base # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, - :omniauthable, omniauth_providers: [:novell, :google, :facebook] + :omniauthable, omniauth_providers: [:suse, :google, :facebook] has_and_belongs_to_many :roles has_many :openids diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index c2b89f82..b7714d18 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -23,7 +23,8 @@ %h4 To add an openID with a different email address to your account, sign in with your openID while logged in to OSEM - = render 'devise/shared/openid' + #openidlinks + = render 'devise/shared/openid' = f.inputs name: 'Account' do = f.input :email, required: false, input_html: {autocomplete: "off"} diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 8c4af033..233d62f2 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,21 +1,32 @@ .row - .page-header - %h1.text-center Sign Up - .col-md-5.col-md-offset-1 - .well - = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| - = f.input :email - = f.input :name, required: true - = f.input :password - = f.input :password_confirmation - = f.action :submit, as: :button, label: 'Sign Up', button_html: {class: 'btn btn-primary'} - %br - %br - %h4 Already have an account? - = render 'devise/shared/links' - - if resource_class.omniauth_providers.present? - .col-md-4 - .well - %h4 Or use your openID - - = render 'devise/shared/openid' + .col-md-6.col-md-offset-3 + .panel.panel-default + .panel-heading + %h3.panel-title + Sign Up + .panel-body + = semantic_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| + = f.input :email + = f.input :name, required: true + = f.input :password + = f.input :password_confirmation + %p.text-right + = f.action :submit, as: :button, label: 'Sign Up', button_html: {class: 'btn btn-success' } + - unless omniauth_configured.empty? + .row + .col-md-4 + %hr + .col-md-4 + %h4.text-center + or sign up using + .col-md-4 + %hr + .row + .col-md-12 + #openidlinks + = render 'devise/shared/openid' + %p.text-right + %a.small{"data-toggle" => "collapse", "data-target" => "#devise-help"} + Need Help? + #devise-help.collapse + = render 'devise/shared/links' diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 80d78201..11f55860 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,22 +1,34 @@ .row - .page-header - %h2.text-center Sign In - .col-md-5.col-md-offset-1 - .well - = semantic_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| - = f.input :email - = f.input :password - - if devise_mapping.rememberable? - = f.check_box :remember_me - = f.label 'Remember me' - %br - = f.action :submit, as: :button, label: 'Sign In', button_html: {class: 'btn btn-primary'} - %br - %br - = render "devise/shared/links" - - - if resource_class.omniauth_providers.present? - .col-md-4 - .well - %h4 Or use your openID - = render 'devise/shared/openid' + .col-md-6.col-md-offset-3 + .panel.panel-default + .panel-heading + %h3.panel-title + Sign In + .panel-body + = semantic_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| + = f.input :email + = f.input :password + - if devise_mapping.rememberable? + %p.text-right.small + = f.label 'Remember me' + = f.check_box :remember_me + %p.text-right + = f.action :submit, as: :button, label: 'Sign In', button_html: {class: 'btn btn-success'} + - unless omniauth_configured.empty? + .row + .col-md-4 + %hr + .col-md-4 + %h4.text-center + or sign in using + .col-md-4 + %hr + .row + .col-md-12 + #openidlinks + = render 'devise/shared/openid' + %p.text-right + %a.small{"data-toggle" => "collapse", "data-target" => "#devise-help"} + Need Help? + #devise-help.collapse + = render 'devise/shared/links' diff --git a/app/views/devise/shared/_links.html.haml b/app/views/devise/shared/_links.html.haml index feca9d4d..b320965b 100644 --- a/app/views/devise/shared/_links.html.haml +++ b/app/views/devise/shared/_links.html.haml @@ -1,16 +1,8 @@ -- if controller_name != 'sessions' - = link_to "Sign in", new_user_session_path - %br - -- if devise_mapping.registerable? && controller_name != 'registrations' - = link_to "Sign up", new_registration_path(resource_name) - %br - -- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' +- if devise_mapping.recoverable? && controller_name != 'passwords' = link_to "Forgot your password?", new_password_path(resource_name) %br -- if devise_mapping.confirmable? && controller_name != 'confirmations' +- if devise_mapping.confirmable? && controller_name != 'confirmations' && controller_name == 'passwords' = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %br diff --git a/app/views/devise/shared/_openid.html.haml b/app/views/devise/shared/_openid.html.haml index 5d1e6300..64f5f72a 100644 --- a/app/views/devise/shared/_openid.html.haml +++ b/app/views/devise/shared/_openid.html.haml @@ -1,7 +1,7 @@ -- if devise_mapping.omniauthable? - - resource_class.omniauth_providers.each do |provider| - - provider_key = "#{provider}_key" - - provider_secret = "#{provider}_secret" - - unless Rails.application.secrets.send(provider_key).blank? || Rails.application.secrets.send(provider_secret).blank? - = link_to image_tag("#{provider}.png", size: '32x32') + provider , omniauth_authorize_path(resource_name, provider) - %br +.btn-group.btn-group-lg + - omniauth_configured.each do |provider| + = link_to user_omniauth_authorize_path(provider), + class: "btn btn-success btn-lg", + id: "omniauth-#{provider}", + title: "Your #{provider} login" do + %i{:class => "fa fa-#{provider}"} \ No newline at end of file diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 31065a46..3b200e11 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -36,26 +36,29 @@ = link_to(new_registration_path('user')) do %span.glyphicon.glyphicon-heart Sign Up - %li.dropdown.visible-desktop - %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"} - %span.glyphicon.glyphicon-user - Sign In - %span.caret - .dropdown-menu{:style => "padding: 17px;"} - = form_tag user_session_path do - = text_field_tag 'user[email]', nil, id: 'user_email_dd' - = password_field_tag 'user[password]', nil, id: 'user_password_dd' - %p.text-right - %small - Remember me - = check_box_tag 'user[remember_me]' - %button.btn.btn-success.btn-block Sign in - %p - %small - %ul.list-unstyled - %li - = link_to "Forgot your password?", new_password_path('user') - %li - = link_to 'Sign in with openID', new_user_session_path + %li.dropdown.visible-desktop + %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"} + %span.glyphicon.glyphicon-user + Sign In + %span.caret + .dropdown-menu{:style => "padding: 17px;"} + = form_tag user_session_path do + = text_field_tag 'user[email]', nil, id: 'user_email_dd' + = password_field_tag 'user[password]', nil, id: 'user_password_dd' + %p.text-right + %small + Remember me + = check_box_tag 'user[remember_me]' + %button.btn.btn-success.btn-block Sign in + - unless omniauth_configured.empty? + .divider + %h6.text-center + or + = render 'devise/shared/openid' + %p.text-right + %a.small{"data-toggle" => "collapse", "data-target" => "#navbar-devise-help"} + Need Help? + #navbar-devise-help.collapse + = link_to "Forgot your password?", new_password_path(User.new) %li.hidden-lg = link_to('Sign In', new_user_session_path) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 99546161..1caa0d05 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -9,10 +9,10 @@ Devise.setup do |config| # Define the available openID providers that can be used to log in # Pass each provider to User model in :omniauth_providers (for open_id providers use their name) - config.omniauth :open_id, name: 'novell', identifier: 'http://www.opensuse.org/openid/user' - config.omniauth :google_oauth2, Rails.application.secrets.google_key, Rails.application.secrets.google_secret, + config.omniauth :open_id, name: 'suse', identifier: 'http://www.opensuse.org/openid/user' + config.omniauth :google_oauth2, Rails.application.secrets.google_key, Rails.application.secrets.google_secret, name: 'google', - scope: 'email' + scope: 'email' config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret # ==> Mailer Configuration diff --git a/config/secrets.yml.example b/config/secrets.yml.example index 0671fb71..068526b6 100644 --- a/config/secrets.yml.example +++ b/config/secrets.yml.example @@ -23,11 +23,10 @@ defaults: &defaults facebook_key: '' facebook_secret: '' - # Developers do not need to register their application for novell account to work. + # Developers do not need to register their application for suse account to work. # You must, however, leave the sample data there, for the login option to appear. - - novell_key: 'sample data' - novell_secret: 'sample data' + suse_key: 'sample data' + suse_secret: 'sample data' # If you add more providers that do not require a key, you still have to create the 2 variables with sample data diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 89ef91c6..41cbb76e 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -8,8 +8,8 @@ feature Openid do scenario 'has option to log in with Google account' do visit '/accounts/sign_in' - expect(page.has_content?('Or use your openID')).to be true - expect(page.has_content?('google')).to be true + expect(page.has_content?('or sign in using')).to be true + expect(page.has_link?('omniauth-google')).to be true end scenario 'signs in *new* user with Google account' do @@ -18,7 +18,9 @@ feature Openid do visit '/accounts/sign_in' mock_auth_new_user - click_link 'google' + within("#openidlinks") do + click_link 'omniauth-google' + end expect(flash).to eq('test-1@gmail.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) @@ -31,7 +33,9 @@ feature Openid do visit '/accounts/sign_in' mock_auth_existing_user_participant - click_link 'google' + within("#openidlinks") do + click_link 'omniauth-google' + end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) @@ -40,8 +44,11 @@ feature Openid do scenario 'can handle authentication error' do OmniAuth.config.mock_auth[:google] = :invalid_credentials visit '/accounts/sign_in' - expect(page.has_content?('Or use your openID')).to be true - click_link 'google' + expect(page.has_content?('or sign in using')).to be true + within("#openidlinks") do + click_link 'omniauth-google' + end + expect(flash).to eq("Could not authenticate you from Google because \"Invalid credentials\".") end @@ -56,7 +63,9 @@ feature Openid do visit '/accounts/edit' mock_auth_new_user - click_link 'google' + within("#openidlinks") do + click_link 'omniauth-google' + end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) @@ -71,7 +80,9 @@ feature Openid do visit '/accounts/sign_in' mock_auth_existing_user_participant - click_link 'google' + within("#openidlinks") do + click_link 'omniauth-google' + end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) @@ -82,7 +93,9 @@ feature Openid do visit '/accounts/edit' mock_auth_new_user - click_link 'google' + within("#openidlinks") do + click_link 'omniauth-google' + end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) @@ -96,7 +109,9 @@ feature Openid do visit '/accounts/sign_in' mock_auth_new_user_fb - click_link 'facebook' + within("#openidlinks") do + click_link 'omniauth-facebook' + end expect(flash).to eq('test-participant-1@google.com signed in successfully with facebook') expect(Openid.count).to eq(expected_count_openid) expect(User.count).to eq(expected_count_user) diff --git a/spec/support/omniauth_macros.rb b/spec/support/omniauth_macros.rb index 64196bc2..76351686 100644 --- a/spec/support/omniauth_macros.rb +++ b/spec/support/omniauth_macros.rb @@ -26,7 +26,7 @@ module OmniauthMacros def mock_auth_new_user_fb OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new( - provider: 'google', + provider: 'facebook', uid: 'facebook-test-uid-1', info: { name: 'new user fb name', diff --git a/spec/support/save_feature_failures.rb b/spec/support/save_feature_failures.rb new file mode 100644 index 00000000..8ff680cd --- /dev/null +++ b/spec/support/save_feature_failures.rb @@ -0,0 +1,18 @@ +# Automatically save and open the page +# whenever an expectation is not met in a features spec +RSpec.configure do |config| + config.after(:each, type: :feature) do + ename = RSpec.current_example.full_description + ename = ename.gsub " ", "_" + ename.downcase! + ename = ename + ".html" + if RSpec.current_example.exception.present? + save_page(ename) + else + capfile = File.expand_path(ename, Capybara.save_and_open_page_path) + if File.exist?(capfile) + File.unlink(capfile) + end + end + end +end