This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login_admin(admin) | |
visit admin_page | |
fill :email => admin.email | |
fill :password => admin.password | |
click_button "Login" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
Dir[Rails.root.join("spec/support/*.rb")].each {|f| require f} | |
DatabaseCleaner.strategy = :truncation | |
DatabaseCleaner.clean_with(:truncation) | |
RSpec.configure do |config| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Euro2012 antyspam | |
// @author pan_sarin | |
// @description Script for replacing euro2012 facebook content into not so annoying content | |
// @version 0.0.3 | |
// @include http://www.facebook.com/* | |
// @include https://www.facebook.com/* | |
// @todo user definied content ( links / images ) or more random dummy content from some rss | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.wrappers :my_default , :class => :input, | |
:hint_class => :field_with_hint, :error_class => :field_with_errors, | |
:label_class => "control-inline-label" do |b| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= simple_form_for [:admin, @user], remote: true, html: { novalidate: 'true'} do |f| | |
.tab-content | |
#basic.tab-pane.active | |
= f.input :login | |
= f.simple_fields_for :password_attributes do |pass| | |
= pass.input :password, label: 'Hasło' | |
= pass.input :password_confirmation, label: "Potwierdzenie hasła" | |
= pass.input :user_id, as: :hidden, input_html: {value: @user.id }, wrapper: :default | |
#personal.tab-pane | |
= f.simple_fields_for (@user.persisted? ? :personal : :personal_attributes), @user.personal do |p| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_fcbk | |
@users = User.where("active = true and (first_name like '%#{params[:q]}%' OR last_name like '%#{params[:q]}%')") | |
@users = @users.map { |r| {value: r.id, key: "#{r.first_name} #{r.last_name} "} } | |
render json: @users | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
if user.role?('admin') | |
can :manage, :all | |
end | |
if user.role?('user_manager') | |
can :manage, User |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
$(window).on 'mercury:ready', -> | |
document_container = $('.document_container') | |
Mercury.saveUrl = document_container.data('save-url') | |
Mercury.saveMethod = document_container.data('save-method') | |
console.debug Mercury.saveMethod | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require_relative 'controller_helper' | |
describe DocumentsController do | |
actions = rest_actions.reject{|a| a[:action] == :update} | |
actions << {method: :post, action: :mercury_save, params: {}} | |
actions << {method: :get, action: :upload, params: {}} | |
actions.each do |action| | |
{ admin: true, user: false, documents_manager: true}.each do |role, result| | |
it "#{role} should #{result ? '' : 'not'} have access to #{action[:method]} ##{action[:action]}" do | |
Document.stub(:find).and_return(Document.new) if action[:params].include?(:id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sign_in(role) | |
user = create :user, role | |
controller.stub!(:current_user).and_return(user) | |
end | |
def check_privilages(action, role, result) | |
sign_in(role) | |
send(action[:method], action[:action], action[:params]) | |
if result | |
response.should_not redirect_to(controller: :home, action: :access_denied) |
OlderNewer