save_and_open_page
have_button(locator)| 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 |
| 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 | |
| ## |
| require 'spec_helper' | |
| describe PersonPolicy do | |
| subject { PersonPolicy } | |
| let(:person) { create(:person) } | |
| let(:user) { create(:valid_user) } | |
| context 'given user\'s role activities' do |
| class ApplicationController < ActionController::Base | |
| # Includes Authorization mechanism | |
| include Pundit | |
| # Prevent CSRF attacks by raising an exception. | |
| # For APIs, you may want to use :null_session instead. | |
| protect_from_forgery with: :exception | |
| # Globally rescue Authorization Errors in controller. |
| <% flash.each do |type, message| %> | |
| <div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
| <button class="close" data-dismiss="alert">×</button> | |
| <%= message %> | |
| </div> | |
| <% end %> |
| // layout file | |
| <body> | |
| <div class="container"> | |
| <%= flash_messages %> | |
| <%= yield %> | |
| </div><!-- /container --> | |
| </body> |
| #Navigating | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| #Clicking links and buttons | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |