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
describe "PATCH /settings" do | |
context "as a partner" do | |
it "behaves like a user without access" do | |
user = create(:partner, company:) | |
params = { company: { website: "https://domain.suffix" } } | |
headers = { "Accept" => "text/vnd.turbo-stream.html" } | |
patch(settings_path, params: params, headers: headers) | |
expect(response).to be_unauthorized | |
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
require 'bundler/inline' | |
## | |
# Get dependencies | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'pg' | |
gem 'activerecord', require: 'active_record' | |
gem 'benchmark-ips' | |
gem 'pry' |
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
# frozen_string_literal: true | |
source "https://rubygems.org" | |
gem "activerecord", github: "bodacious/rails" | |
gem "sqlite3" |
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 "bundler/inline" | |
gemfile do | |
gem "benchmark-ips" | |
gem "jbuilder" | |
gem "activesupport", require: ["active_support"] | |
end | |
class User | |
attr_accessor :id, :name, :email, :password, :age, :username |
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 String | |
def palindrome? | |
clean_string = self.gsub(/[^\w]/, '').downcase | |
clean_string == clean_string.reverse | |
end | |
end | |
puts "madam".palindrome? # => true | |
puts "racecar".palindrome? # => true | |
puts "madam, . ".palindrome? # => true | |
puts "02/02/2020".palindrome? # => true |
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 Game | |
attr_accessor :doors | |
attr_reader :correct_door | |
def initialize(door_count: ) | |
chosen_door = (1..door_count).to_a.sample | |
@doors = door_count.times.map.with_index do |d, i| | |
Door.new(i+1 == chosen_door) | |
end | |
@correct_door = @doors.detect(&:correct?) | |
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
# Examples: | |
# | |
# @password = RandomPassword.password | |
# | |
class RandomPassword | |
class << self | |
delegate :password, to: new | |
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 AppDelegate | |
def window | |
@window ||= UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
end | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
window.rootViewController = UIViewController.alloc.init | |
window.makeKeyAndVisible | |
true |
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 AppDelegate | |
def hello_world_label | |
@hello_world_label ||= begin | |
frame = CGRectMake(20,200,280,40) | |
label = UILabel.alloc.initWithFrame(frame) | |
label.text = "Hello world" | |
label.textColor = UIColor.whiteColor | |
label.textAlignment = UITextAlignmentCenter | |
label |
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
# Since Sarah is the object of this sentence | |
"Sarah is a new member, why not send #{@sarah.object} a message?" |
NewerOlder