This file contains hidden or 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
| Then /^"([^"]*)" from "([^"]*)" within "([^"]*)" should be disabled$/ do |option_name, type_label, selector| | |
| with_scope(selector) do | |
| x=page.find(:xpath, '//body').all(:xpath, XPath.generate { |x| x.descendant(:select).descendant(:option)[x.attr(:disabled) == 'disabled'] }) | |
| x.collect(&:text).should include(option_text) | |
| end | |
| end |
This file contains hidden or 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
| #date_convert.rb | |
| require 'date' | |
| require 'active_support/core_ext' | |
| Date::DATE_FORMATS.merge!({british: "%d/%m/%Y"}) | |
| class DateConvert | |
| # usage: | |
| # date_of_next( day_name, date) where day_name is a string or symbol representation of a full weekday name, e.g. :saturday | |
| # and date is either a valid Date object or a string representation of a date |
This file contains hidden or 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
| Date::DATE_FORMATS[:british] = "%d/%m/%Y" | |
| Date::DATE_FORMATS[:british_long] = "%d %B, %Y" | |
| Date::DATE_FORMATS[:british_long_ordinal] = lambda { |date| date.strftime("#{ActiveSupport::Inflector.ordinalize(date.day)} %B, %Y") } # => "25th April, 2007" |
This file contains hidden or 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
| polaris:~ martin$ rvm debug | |
| ruby-1.8.7-p302: | |
| rvm 1.0.14 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/] | |
| ruby-1.8.7-p302: |
This file contains hidden or 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
| describe "when authorised as admin" do | |
| describe "POST 'create'" do | |
| before(:each) do | |
| login_as_admin | |
| end | |
| after(:each) do | |
| logout | |
| end | |
| describe "with valid params" do | |
| it "should set password and password_confirmation to the same 10 digit value" do |
This file contains hidden or 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 initialize(user) | |
| user ||= User.new # Guest user | |
| if user.role? :admin | |
| can [:index, :show, :new, :edit, :create, :update, :destroy], [User, CommonContents, Logo] | |
| else | |
| can [:show, :edit, :update], User | |
| cannot [:index, :show, :new, :edit, :create, :update, :destroy], [CommonContents, Logo] | |
| end | |
| end |