Skip to content

Instantly share code, notes, and snippets.

test "SHOULD create note AND redirect to Notes#index(SINCE null folder_id) WHEN only body is provided IF logged in as account:owner" do
sign_in @user
assert_difference('@user.account.notes.count') do
post notes_url(@user.account.hash_id), params: { note: { body: @note_by_user_no_folder.body } }
end
assert_redirected_to notes_url(@user.account.hash_id, anchor: Note.last.id)
end
def sanitize_username(self, s):
"""Takes a string and returns it with only allowed characters."""
# http://stackoverflow.com/questions/12756156/with-python-what-is-the-most-efficient-way-to-remove-all-char-from-string-excep#comment17236154_12756156
# a-z, A-Z, 0-9, _, -, .
keep_set = set(string.ascii_letters + string.digits + '_-.')
return filter(keep_set.__contains__, s)
sanitize_username('chrickso') returns <filter object at 0x10c53aa58>