save_and_open_page
have_button(locator)| // Promise.all is good for executing many promises at once | |
| Promise.all([ | |
| promise1, | |
| promise2 | |
| ]); | |
| // Promise.resolve is good for wrapping synchronous code | |
| Promise.resolve().then(function () { | |
| if (somethingIsNotRight()) { | |
| throw new Error("I will be rejected asynchronously!"); |
| def choose_autocomplete_result(item_text, input_selector = 'input[data-autocomplete]') | |
| page.execute_script %{ $('#{input_selector}').trigger("focus") } | |
| page.execute_script %{ $('#{input_selector}').trigger("keydown") } | |
| item_selector = "ul.ui-autocomplete li.ui-menu-item:contains('#{item_text}')" | |
| expect(page).to have_selector('ul.ui-autocomplete li.ui-menu-item', text: item_text) | |
| page.execute_script %{ $("#{item_selector}").trigger("mouseenter").trigger("click"); } | |
| end |
| // create an index with an analyzer "myindex" | |
| curl -X PUT localhost:9200/myindex -d ' | |
| { | |
| "settings" : {` | |
| "index":{ | |
| "number_of_replicas":0, | |
| "number_of_shards":1, | |
| "analysis":{ | |
| "analyzer":{ | |
| "first":{ |
| # Thanks to http://stackoverflow.com/a/927275/1041467 | |
| def debug_msg(msg, title = 'DEBUG') | |
| Rails.logger.debug "\e[5;1;34m#{title}:\e[0m #{msg}" | |
| end |
| preload_app! | |
| min_threads = Integer(ENV['MIN_THREADS'] || 0) | |
| max_threads = Integer(ENV['MAX_THREADS'] || 5) | |
| threads min_threads, max_threads | |
| workers Integer(ENV['WORKER_COUNT'] || 3 ) | |
| on_worker_boot do | |
| ActiveSupport.on_load(:active_record) do |
| class ApplicationController < ActionController::Base | |
| before_filter :enable_http_auth, if: :use_http_auth? | |
| private | |
| def use_http_auth? | |
| Rails.env.production? | |
| end | |
| def enable_http_auth |
| uk: | |
| errors: | |
| messages: | |
| expired: "прострочено, створіть новий" | |
| not_found: "не знайдено" | |
| already_confirmed: "вже було підтверджено, спробуйте увійти" | |
| not_locked: "не було заблоковано" | |
| not_saved: | |
| one: "Виникла помилка, через яку неможливо зберегти зміни:" | |
| other: "Виникли помилки (загалом - %{count}), через які неможливо зберегти зміни:" |
| def screenshot | |
| require 'capybara/util/save_and_open_page' | |
| now = Time.now | |
| p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
| Capybara.save_page body, "#{p}.html" | |
| path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
| page.driver.render path | |
| Launchy.open path | |
| end |
| class CreateRoles < ActiveRecord::Migration | |
| def change | |
| create_table :roles do |t| | |
| t.string :activities, array: true, length: 30, using: 'gin', default: '{}' | |
| t.timestamps | |
| end | |
| end | |
| end | |
| ## |