-
Notifications
You must be signed in to change notification settings - Fork 68
Admin organizations order #361
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
Changes from all commits
b0c872e
84505ec
dd2170f
898d6fe
761c7ff
1b8e97c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
language: ruby | ||
sudo: required | ||
cache: bundler | ||
bundler_args: '--without production development' | ||
rvm: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,14 @@ module ApplicationHelper | |
# from gravatar | ||
def avatar_url(user, size = 32) | ||
gravatar_id = Digest::MD5::hexdigest(user.email).downcase | ||
gravatar_options = Hash[set: "set1", | ||
gravatar: "hashed", | ||
size: "#{size}x#{size}"] | ||
"https://www.gravatar.com/avatar/#{gravatar_id}.png?" + | ||
"#{Rack::Utils.build_query(gravatar_options)}&d=identicon" | ||
gravatar_options = { | ||
set: "set1", | ||
gravatar: "hashed", | ||
size: "#{size}x#{size}", | ||
d: "identicon" | ||
} | ||
|
||
"https://www.gravatar.com/avatar/#{gravatar_id}.png?#{gravatar_options.to_param}" | ||
end | ||
|
||
def mdash | ||
|
@@ -38,7 +41,7 @@ def show_error_messages!(resource) | |
messages = resource.errors. | ||
full_messages.map { |msg| content_tag(:li, msg) }.join | ||
html = <<-HTML | ||
<div class="alert alert-error alert-block"> | ||
<div class="alert alert-danger"> | ||
<button type="button" class="close" data-dismiss="alert">x</button> | ||
<ul> | ||
#{messages} | ||
|
@@ -80,4 +83,15 @@ def get_body_css_class(controller) | |
|
||
"#{classes[controller]}" | ||
end | ||
|
||
def alert_class(alert) | ||
case alert | ||
when 'error', 'alert' | ||
'alert-danger' | ||
when 'notice' | ||
'alert-success' | ||
else | ||
'alert-info' | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
module UsersHelper | ||
private | ||
|
||
def edit_user_path(user) | ||
can_edit_user?(user) ? super : "" | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe ApplicationHelper do | ||
it 'avatar_url returns url to gravatar' do | ||
user = Fabricate(:user) | ||
gravatar_id = Digest::MD5::hexdigest(user.email).downcase | ||
expect(helper.avatar_url(user, 50)).to eq("https://www.gravatar.com/avatar/#{gravatar_id}.png?d=identicon&gravatar=hashed&set=set1&size=50x50") | ||
end | ||
|
||
describe 'seconds_to_hm' do | ||
it 'with 0 returns em dash' do | ||
expect(helper.seconds_to_hm(0)).to eq("—") | ||
end | ||
|
||
it 'with non-zero returns specific format' do | ||
expect(helper.seconds_to_hm(10)).to eq("0:00") | ||
expect(helper.seconds_to_hm(60)).to eq("0:01") | ||
expect(helper.seconds_to_hm(-60)).to eq("-0:01") | ||
expect(helper.seconds_to_hm(3600)).to eq("1:00") | ||
end | ||
end | ||
|
||
it 'alert_class returns specific error classes' do | ||
expect(helper.alert_class('error')).to eq('alert-danger') | ||
expect(helper.alert_class('alert')).to eq('alert-danger') | ||
expect(helper.alert_class('notice')).to eq('alert-success') | ||
expect(helper.alert_class('foo')).to eq('alert-info') | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe GlyphHelper do | ||
describe 'glyph helper' do | ||
it 'renders an span with glyphicon classes' do | ||
expect(helper.glyph('foo')).to match(/<span class=\"glyphicon glyphicon-foo\"><\/span>/) | ||
end | ||
|
||
it 'special mappings' do | ||
sample = GlyphHelper::GLYPHS.to_a.sample[0] | ||
expect(helper.glyph(sample)).to match(GlyphHelper::GLYPHS[sample]) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mean to do it now but these are the kind of things that I like to turn into a value object. And this will eventually reduce the amount of helpers. Just a thought worth sharing.