# Models
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
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
Then /^I swipe to delete all cells in "([^\"]*)"$/ do |orientation| | |
total_rows = query("tableView index:0",numberOfRowsInSection:0) #this returns an array | |
end_of_range = total_rows[0] - 1 | |
(0..end_of_range).each do | |
scroll_to_row "tableView index:0", 0 | |
sleep(STEP_PAUSE) | |
macro %Q[I swipe on cell number 1 in "#{orientation}"] #requires this custom step definition: https://gist.github.com/3298026 | |
sleep(STEP_PAUSE) | |
touch "TableViewCellDeleteConfirmationControl" | |
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
Then /^I swipe on cell number (\d+) in "([^\"]*)"$/ do |index, orientation| | |
index = index.to_i | |
screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0) | |
if orientation == "landscape" | |
swipe("up", {:query => "tableViewCell index:#{index-1}"}) | |
elsif orientation == "portrait" | |
swipe("right", {:query => "tableViewCell index:#{index-1}"}) | |
end | |
sleep(STEP_PAUSE) | |
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
def check_cell(prefix) | |
if @final_count[0] == 1 | |
final_cell = query "TableViewCell index:0" | |
if final_cell.first["class"] == "UITableViewCell" | |
sleep(STEP_PAUSE) | |
else | |
screenshot_and_raise "#{prefix} of the cells were deleted!" | |
end | |
else | |
screenshot_and_raise "#{prefix} of the cells were deleted!" |
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
urls = ["http://brigade.codeforamerica.org/index.html", "brigade.codeforamerica.org", "http://codeforamerica.org", "codeforamerica.org/index.html", "brigade.codeforamerica.org/index.html"] | |
urls.each do |url| | |
# clean up the URLs so they all start off with the same format | |
if url.include?("http://") | |
url.gsub!("http://","") | |
end | |
# we're only interested in the part that comes before the first slash, | |
# so we split the string into the part before the slash, and the part after the slash | |
a = url.split("/") |
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
== Welcome to Rails | |
Rails is a web-application framework that includes everything needed to create | |
database-backed web applications according to the Model-View-Control pattern. | |
This pattern splits the view (also called the presentation) into "dumb" | |
templates that are primarily responsible for inserting pre-built data in between | |
HTML tags. The model contains the "smart" domain objects (such as Account, | |
Product, Person, Post) that holds all the business logic and knows how to | |
persist themselves to a database. The controller handles the incoming requests |
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
recipes: | |
- setup | |
- readme | |
- gems | |
- testing | |
- controllers | |
- routes | |
- extras | |
prefs: |
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
# app/models/user.rb | |
class User | |
include Mongoid::Document | |
embeds_many :api_applications | |
... | |
end | |
# app/models/api_application.rb | |
class ApiApplication | |
include Mongoid::Document |
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
while getopts ":a:o:" opt; do | |
case $opt in | |
a) | |
echo "Getting ready to set environment variables for $2" | |
echo "Setting CANONICAL_URL" | |
heroku config:set CANONICAL_URL=$2.herokuapp.com --app $2 | |
echo "Setting DOMAIN_NAME" | |
heroku config:set DOMAIN_NAME=herokuapp.com --app $2 |
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 update | |
# reset attempt count if user is no longer locked out | |
unless resource.otp_time_lockout? || resource.second_factor_locked_at.nil? | |
resource.update(second_factor_attempts_count: 0, second_factor_locked_at: nil) | |
end | |
if resource.authenticate_otp(params[:code].strip) | |
warden.session(resource_name)['need_two_factor_authentication'] = false | |
sign_in resource_name, resource, bypass: true | |
set_flash_message :notice, :success |
OlderNewer