css = ""
css << ".hidden { display: none !important }"
- css << ".hide_unless_logged_in { display: none !important }" unless @user
- css << ".hide_if_logged_in { display: none !important }" if @user
- css << ".hide_if_user_#{@user.id} { display: none !important }" if @user
- css << ".show_if_user_#{@user.id} { display: inline !important }" if @user
- css << ".hide_unless_administrator { display: none !important }" unless @user && @user.administrator?
- css << ".hide_unless_moderator { display: none !important }" unless @user && @user.moderator?
+ css << ".hide_unless_logged_in { display: none !important }" unless current_user
+ css << ".hide_if_logged_in { display: none !important }" if current_user
+ css << ".hide_if_user_#{current_user.id} { display: none !important }" if current_user
+ css << ".show_if_user_#{current_user.id} { display: inline !important }" if current_user
+ css << ".hide_unless_administrator { display: none !important }" unless current_user && current_user.administrator?
+ css << ".hide_unless_moderator { display: none !important }" unless current_user && current_user.moderator?
content_tag(:style, css, :type => "text/css")
end
:preferred_editor => preferred_editor
}
- if @user
- data[:user] = @user.id.to_json
+ if current_user
+ data[:user] = current_user.id.to_json
- unless @user.home_lon.nil? || @user.home_lat.nil?
- data[:user_home] = { :lat => @user.home_lat, :lon => @user.home_lon }
+ unless current_user.home_lon.nil? || current_user.home_lat.nil?
+ data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon }
end
end
require "test_helper"
class ApplicationHelperTest < ActionView::TestCase
+ attr_accessor :current_user
+
def setup
I18n.locale = "en"
end
end
def test_style_rules
- @user = nil
+ self.current_user = nil
css = style_rules
assert_match /\.hidden /, css
assert_match /\.hide_unless_administrator /, css
assert_match /\.hide_unless_moderator /, css
- @user = create(:user)
+ self.current_user = create(:user)
css = style_rules
assert_match /\.hidden /, css
assert_no_match /\.hide_unless_logged_in /, css
assert_match /\.hide_if_logged_in /, css
- assert_match /\.hide_if_user_#{@user.id} /, css
- assert_match /\.show_if_user_#{@user.id} /, css
+ assert_match /\.hide_if_user_#{current_user.id} /, css
+ assert_match /\.show_if_user_#{current_user.id} /, css
assert_match /\.hide_unless_administrator /, css
assert_match /\.hide_unless_moderator /, css
- @user = create(:moderator_user)
+ self.current_user = create(:moderator_user)
css = style_rules
assert_match /\.hidden /, css
assert_no_match /\.hide_unless_logged_in /, css
assert_match /\.hide_if_logged_in /, css
- assert_match /\.hide_if_user_#{@user.id} /, css
- assert_match /\.show_if_user_#{@user.id} /, css
+ assert_match /\.hide_if_user_#{current_user.id} /, css
+ assert_match /\.show_if_user_#{current_user.id} /, css
assert_match /\.hide_unless_administrator /, css
assert_no_match /\.hide_unless_moderator /, css
- @user = create(:administrator_user)
+ self.current_user = create(:administrator_user)
css = style_rules
assert_match /\.hidden /, css
assert_no_match /\.hide_unless_logged_in /, css
assert_match /\.hide_if_logged_in /, css
- assert_match /\.hide_if_user_#{@user.id} /, css
- assert_match /\.show_if_user_#{@user.id} /, css
+ assert_match /\.hide_if_user_#{current_user.id} /, css
+ assert_match /\.show_if_user_#{current_user.id} /, css
assert_no_match /\.hide_unless_administrator /, css
assert_match /\.hide_unless_moderator /, css
end
require "test_helper"
class UserRolesHelperTest < ActionView::TestCase
+ attr_accessor :current_user
+
def test_role_icon_normal
- user = create(:user)
- @user = user
+ self.current_user = create(:user)
- icon = role_icon(user, "moderator")
+ icon = role_icon(current_user, "moderator")
assert_dom_equal "", icon
icon = role_icon(create(:moderator_user), "moderator")
end
def test_role_icon_administrator
- @user = create(:administrator_user)
+ self.current_user = create(:administrator_user)
user = create(:user)
icon = role_icon(user, "moderator")
end
def test_role_icons_normal
- user = create(:user)
- @user = user
+ self.current_user = create(:user)
- icons = role_icons(user)
+ icons = role_icons(current_user)
assert_dom_equal " ", icons
icons = role_icons(create(:moderator_user))
end
def test_role_icons_administrator
- @user = create(:administrator_user)
+ self.current_user = create(:administrator_user)
user = create(:user)
icons = role_icons(user)