agilibox 1.0.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +321 -2
- data/Rakefile +4 -0
- data/app/assets/javascripts/agilibox/autocomplete.coffee +2 -0
- data/app/assets/javascripts/agilibox/checkboxes_dropdown.coffee +9 -0
- data/app/assets/javascripts/agilibox/modals.coffee +81 -55
- data/app/assets/stylesheets/agilibox/actions.sass +2 -0
- data/app/assets/stylesheets/agilibox/all.sass +5 -0
- data/app/assets/stylesheets/agilibox/buttons.sass +11 -0
- data/app/assets/stylesheets/agilibox/filters.sass +13 -3
- data/app/assets/stylesheets/agilibox/forms.sass +49 -0
- data/app/assets/stylesheets/agilibox/icons.sass +5 -0
- data/app/assets/stylesheets/agilibox/modals.sass +15 -7
- data/app/assets/stylesheets/agilibox/pagination.sass +7 -0
- data/app/assets/stylesheets/agilibox/print.sass +10 -0
- data/app/assets/stylesheets/agilibox/tables.sass +26 -0
- data/app/controllers/agilibox/application_controller.rb +2 -4
- data/app/controllers/agilibox/small_data/filters_controller.rb +8 -6
- data/app/controllers/concerns/agilibox/api_controller_concern.rb +69 -0
- data/app/controllers/concerns/agilibox/back_url_concern.rb +13 -5
- data/app/emails/agilibox/email.rb +113 -0
- data/app/filters/agilibox/small_data/filter.rb +19 -1
- data/app/filters/agilibox/small_data/filter_strategy.rb +1 -1
- data/app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb +3 -2
- data/app/filters/agilibox/small_data/filter_strategy_by_date_end.rb +3 -2
- data/app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb +56 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_date_period.rb +5 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb +5 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_key_value.rb +14 -3
- data/app/filters/agilibox/small_data/filter_strategy_by_key_values.rb +13 -0
- data/app/filters/agilibox/small_data/filter_strategy_by_tags.rb +1 -1
- data/app/forms/agilibox/mini_form_object.rb +29 -0
- data/app/helpers/agilibox/all_helpers.rb +2 -0
- data/app/helpers/agilibox/bootstrap_helper.rb +62 -3
- data/app/helpers/agilibox/button_helper.rb +22 -13
- data/app/helpers/agilibox/filters_helper.rb +7 -8
- data/app/helpers/agilibox/font_awesome_helper.rb +67 -0
- data/app/helpers/agilibox/form_helper.rb +37 -14
- data/app/helpers/agilibox/i18n_helper.rb +5 -0
- data/app/helpers/agilibox/link_helper.rb +1 -1
- data/app/helpers/agilibox/pagination_helper.rb +18 -2
- data/app/helpers/agilibox/routes_helper.rb +6 -2
- data/app/helpers/agilibox/sorting_helper.rb +9 -4
- data/app/helpers/agilibox/text_helper.rb +51 -26
- data/app/helpers/h.rb +3 -0
- data/app/jobs/concerns/agilibox/setup_job_concern.rb +35 -0
- data/app/libs/agilibox/collection_update.rb +32 -0
- data/app/libs/agilibox/fcm/notifier.rb +28 -0
- data/app/libs/agilibox/fcm/request.rb +48 -0
- data/app/libs/agilibox/initialize_with.rb +20 -0
- data/app/libs/agilibox/mini_model_serializer/serialize.rb +30 -0
- data/app/libs/agilibox/mini_model_serializer/serializer.rb +23 -0
- data/app/libs/agilibox/monkey.rb +39 -0
- data/app/libs/agilibox/phone_number_sanitizer.rb +15 -0
- data/app/libs/agilibox/sortable_uuid_generator.rb +1 -1
- data/app/libs/agilibox/token_generator.rb +37 -0
- data/app/mailers/agilibox/application_mailer.rb +2 -0
- data/app/mailers/agilibox/generic_mailer.rb +9 -0
- data/app/models/concerns/agilibox/active_record_uuid_concern.rb +4 -2
- data/app/models/concerns/agilibox/default_values_concern.rb +4 -3
- data/app/models/concerns/agilibox/model_i18n.rb +37 -6
- data/app/models/concerns/agilibox/pluck_distinct.rb +13 -0
- data/app/models/concerns/agilibox/pluck_to_hash.rb +9 -0
- data/app/models/concerns/agilibox/polymorphic_id.rb +5 -2
- data/app/models/concerns/agilibox/search.rb +11 -13
- data/app/models/concerns/agilibox/timestamp_helpers.rb +17 -0
- data/app/serializers/agilibox/serializers/base.rb +47 -1
- data/app/serializers/agilibox/serializers/xlsx.rb +25 -23
- data/app/services/agilibox/service.rb +17 -0
- data/app/sms/agilibox/sms/application_sms.rb +42 -0
- data/app/sms/agilibox/sms/message.rb +25 -0
- data/app/sms/agilibox/sms/strategies/amazon_sns.rb +48 -0
- data/app/sms/agilibox/sms/strategies/base.rb +15 -0
- data/app/sms/agilibox/sms/strategies/test.rb +10 -0
- data/app/sms/agilibox/sms.rb +35 -0
- data/app/sorters/agilibox/sorter.rb +26 -0
- data/app/views/agilibox/_flash.html.slim +9 -0
- data/app/views/agilibox/forms/_checkboxes_dropdown.html.slim +14 -0
- data/app/views/agilibox/search/_form.html.slim +1 -6
- data/app/views/agilibox/search/_form_bs3.html.slim +13 -0
- data/app/views/agilibox/search/_form_bs4.html.slim +9 -0
- data/app/views/agilibox/search/_form_bs5.html.slim +8 -0
- data/app/views/kaminari/bootstrap4/_first_page.html.slim +2 -0
- data/app/views/kaminari/bootstrap4/_gap.html.slim +2 -0
- data/app/views/kaminari/bootstrap4/_last_page.html.slim +2 -0
- data/app/views/kaminari/bootstrap4/_next_page.html.slim +2 -0
- data/app/views/kaminari/bootstrap4/_page.html.slim +6 -0
- data/app/views/kaminari/bootstrap4/_paginator.html.slim +12 -0
- data/app/views/kaminari/bootstrap4/_prev_page.html.slim +2 -0
- data/config/cucumber.yml +9 -0
- data/config/locales/actions.en.yml +76 -0
- data/config/locales/actions.fr.yml +76 -0
- data/config/locales/attributes.en.yml +108 -0
- data/config/locales/attributes.fr.yml +108 -0
- data/config/locales/common.en.yml +0 -160
- data/config/locales/common.fr.yml +0 -171
- data/config/locales/dates.fr.yml +8 -0
- data/config/locales/errors.en.yml +5 -0
- data/config/locales/errors.fr.yml +5 -0
- data/db/migrate/20000101000000_enable_agilibox_extensions.rb +7 -0
- data/lib/agilibox/active_model_custom_error_messages.rb +23 -0
- data/lib/agilibox/active_model_type_cast.rb +52 -0
- data/lib/agilibox/config.rb +19 -0
- data/lib/agilibox/core_and_rails_ext.rb +2 -1
- data/lib/agilibox/cucumber_config.rb +53 -0
- data/lib/agilibox/cucumber_helpers/agilibox.rb +2 -0
- data/lib/agilibox/cucumber_helpers/ajax.rb +18 -0
- data/lib/agilibox/cucumber_helpers/apparition.rb +18 -0
- data/lib/agilibox/cucumber_helpers/capybara.rb +12 -0
- data/lib/agilibox/cucumber_helpers/capybara_selectors.rb +7 -0
- data/lib/agilibox/cucumber_helpers/chrome_headless.rb +16 -0
- data/lib/agilibox/cucumber_helpers/common_steps.rb +139 -0
- data/lib/agilibox/cucumber_helpers/cuprite.rb +20 -0
- data/lib/agilibox/cucumber_helpers/database_cleaner.rb +8 -0
- data/lib/agilibox/cucumber_helpers/factory_bot.rb +1 -0
- data/lib/agilibox/cucumber_helpers/rails.rb +1 -0
- data/lib/agilibox/cucumber_helpers/rspec.rb +6 -0
- data/lib/agilibox/cucumber_helpers/screenshots.rb +3 -0
- data/lib/agilibox/cucumber_helpers/select2.rb +23 -0
- data/lib/agilibox/cucumber_helpers/sign_in.rb +17 -0
- data/lib/agilibox/cucumber_helpers/simplecov.rb +1 -0
- data/lib/agilibox/cucumber_helpers/timecop.rb +3 -0
- data/lib/agilibox/cucumber_helpers/turbolinks.rb +34 -0
- data/lib/agilibox/cucumber_helpers/zonebie.rb +4 -0
- data/lib/agilibox/engine.rb +15 -0
- data/lib/agilibox/engine_file.rb +10 -0
- data/lib/agilibox/errors_middleware.rb +50 -0
- data/lib/agilibox/form_back_url.rb +4 -4
- data/lib/agilibox/rspec.rb +29 -0
- data/lib/agilibox/test_helpers.rb +13 -0
- data/lib/agilibox/version.rb +1 -1
- data/lib/tasks/cucumber.rake +76 -0
- metadata +165 -9
- data/app/filters/agilibox/small_data/filter_strategy_by_time_period.rb +0 -37
- data/lib/agilibox/active_record_comma_type_cast.rb +0 -12
@@ -0,0 +1,139 @@
|
|
1
|
+
# Clicks / Keyboard
|
2
|
+
|
3
|
+
When("I click on {string}") do |text|
|
4
|
+
find(:agilibox_clickable, text).click
|
5
|
+
end
|
6
|
+
|
7
|
+
When("I click on first {string}") do |text|
|
8
|
+
expect(page).to have_content(text)
|
9
|
+
all(:agilibox_clickable, text).first.click
|
10
|
+
end
|
11
|
+
|
12
|
+
When("I click on last {string}") do |text|
|
13
|
+
expect(page).to have_content(text)
|
14
|
+
all(:agilibox_clickable, text).last.click
|
15
|
+
end
|
16
|
+
|
17
|
+
When("I click on {string} element") do |selector|
|
18
|
+
find(selector).click
|
19
|
+
end
|
20
|
+
|
21
|
+
When("I click on first {string} element") do |selector|
|
22
|
+
expect(page).to have_selector(selector)
|
23
|
+
all(selector).first.click
|
24
|
+
end
|
25
|
+
|
26
|
+
When("I click on last {string} element") do |selector|
|
27
|
+
expect(page).to have_selector(selector)
|
28
|
+
all(selector).last.click
|
29
|
+
end
|
30
|
+
|
31
|
+
When("I press key {string}") do |key|
|
32
|
+
find("body").send_keys(key.length == 1 ? key : key.to_sym)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Routes
|
36
|
+
|
37
|
+
When("I go on the {string} page") do |route_name|
|
38
|
+
path = main_app.public_send("#{route_name}_path")
|
39
|
+
visit path
|
40
|
+
end
|
41
|
+
|
42
|
+
Then("I am on the {string} page") do |route_name|
|
43
|
+
path = main_app.public_send("#{route_name}_path")
|
44
|
+
wait_for { current_path }.to eq path
|
45
|
+
end
|
46
|
+
|
47
|
+
# Contents
|
48
|
+
|
49
|
+
Then("I see {string}") do |text|
|
50
|
+
expect(page).to have_content(text)
|
51
|
+
end
|
52
|
+
|
53
|
+
Then("I do not see {string}") do |text|
|
54
|
+
expect(page).to have_no_content(text)
|
55
|
+
end
|
56
|
+
|
57
|
+
Then("I see {string} element") do |selector|
|
58
|
+
expect(page).to have_selector(selector)
|
59
|
+
end
|
60
|
+
|
61
|
+
Then("I do not see {string} element") do |selector|
|
62
|
+
expect(page).to have_no_selector(selector)
|
63
|
+
end
|
64
|
+
|
65
|
+
Then("I see {int} times {string} element") do |count, selector|
|
66
|
+
expect(page).to have_selector(selector, count: count)
|
67
|
+
end
|
68
|
+
|
69
|
+
Then("I see {string} in modal") do |text|
|
70
|
+
expect(find("#modal")).to have_content(text)
|
71
|
+
end
|
72
|
+
|
73
|
+
Then("I see {string} element in modal") do |selector|
|
74
|
+
expect(find("#modal")).to have_selector(selector)
|
75
|
+
end
|
76
|
+
|
77
|
+
Then("I see {string} out of modal") do |text|
|
78
|
+
expect(page).to have_no_selector("#modal")
|
79
|
+
expect(page).to have_content(text)
|
80
|
+
end
|
81
|
+
|
82
|
+
Then("I see {string} element out of modal") do |selector|
|
83
|
+
expect(page).to have_no_selector("#modal")
|
84
|
+
expect(page).to have_selector(selector)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Forms
|
88
|
+
|
89
|
+
When("I fill in {string} with {string}") do |id, value|
|
90
|
+
fill_in id, with: value
|
91
|
+
end
|
92
|
+
|
93
|
+
When("I select {string}") do |value|
|
94
|
+
select value
|
95
|
+
end
|
96
|
+
|
97
|
+
When("I select {string} from {string}") do |value, from|
|
98
|
+
select value, from: from
|
99
|
+
end
|
100
|
+
|
101
|
+
When(/^I select2 "([^"]*)" from "([^"]*)"$/) do |value, selector|
|
102
|
+
select2(selector, value)
|
103
|
+
end
|
104
|
+
|
105
|
+
When("I fill in {string} with {string} file") do |id, file|
|
106
|
+
expect(page).to have_selector(".form-group.file", visible: :all)
|
107
|
+
|
108
|
+
execute_script %(
|
109
|
+
$(".form-group.file").css("display", "block")
|
110
|
+
)
|
111
|
+
|
112
|
+
attach_file id, Rails.root.join("spec", "fixtures", file)
|
113
|
+
end
|
114
|
+
|
115
|
+
When("I search {string}") do |q|
|
116
|
+
fill_in :q, with: q
|
117
|
+
find(".search-submit").click
|
118
|
+
end
|
119
|
+
|
120
|
+
# Emails
|
121
|
+
|
122
|
+
Given("I clean my mailbox") do
|
123
|
+
email_deliveries.clear
|
124
|
+
end
|
125
|
+
|
126
|
+
Then(/I have (\d+) emails?/) do |count|
|
127
|
+
expect(email_deliveries.count).to eq count
|
128
|
+
end
|
129
|
+
|
130
|
+
# Factories
|
131
|
+
|
132
|
+
Given("an existing {string}") do |factory|
|
133
|
+
instance_variable_set "@#{factory}", create(factory)
|
134
|
+
end
|
135
|
+
|
136
|
+
Given("I am a signed in {string}") do |factory|
|
137
|
+
@user = create(factory) # rubocop:disable Rails/SaveBang
|
138
|
+
sign_in @user
|
139
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "capybara/cuprite"
|
2
|
+
|
3
|
+
Capybara.register_driver :agilibox_cuprite do |app|
|
4
|
+
Capybara::Cuprite::Driver.new(app,
|
5
|
+
:browser_options => {
|
6
|
+
:"disable-gpu" => true,
|
7
|
+
:"no-sandbox" => nil,
|
8
|
+
},
|
9
|
+
:headless => (ENV["CHROME_HEADLESS"].to_s != "false"),
|
10
|
+
:inspector => true,
|
11
|
+
:js_errors => true,
|
12
|
+
:process_timeout => Agilibox::CucumberConfig.cuprite_process_timeout,
|
13
|
+
:timeout => Agilibox::CucumberConfig.cuprite_timeout,
|
14
|
+
:window_size => Agilibox::CucumberConfig.window_size,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
Capybara.default_driver = :agilibox_cuprite
|
19
|
+
Capybara.current_driver = :agilibox_cuprite
|
20
|
+
Capybara.javascript_driver = :agilibox_cuprite
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require "database_cleaner"
|
2
|
+
|
3
|
+
Cucumber::Rails::Database.autorun_database_cleaner = false
|
4
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation
|
5
|
+
|
6
|
+
After do |_scenario, _block|
|
7
|
+
DatabaseCleaner.clean_with(:truncation, except: Agilibox::CucumberConfig.databasecleaner_tables)
|
8
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
World(FactoryBot::Syntax::Methods)
|
@@ -0,0 +1 @@
|
|
1
|
+
ActionController::Base.allow_rescue = false
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CapybaraSelect2
|
2
|
+
def select2_search(id, query)
|
3
|
+
find("##{id} + .select2-container").click
|
4
|
+
find(".select2-search__field").set(query.to_s)
|
5
|
+
end
|
6
|
+
|
7
|
+
def select2(id, query, label = query)
|
8
|
+
select2_search(id, query)
|
9
|
+
find(".select2-results li", text: label.to_s).click
|
10
|
+
end
|
11
|
+
|
12
|
+
def select2_expect_have_result(id, query, label = query)
|
13
|
+
select2_search(id, query)
|
14
|
+
expect(page).to have_selector(".select2-results li", text: label.to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
def select2_expect_have_no_result(id, query, label = query)
|
18
|
+
select2_search(id, query)
|
19
|
+
expect(page).to have_no_selector(".select2-results li", text: label.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
World(CapybaraSelect2)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CapybaraSignIn
|
2
|
+
include ::Warden::Test::Helpers if defined?(Warden)
|
3
|
+
|
4
|
+
def sign_out
|
5
|
+
logout
|
6
|
+
end
|
7
|
+
|
8
|
+
def sign_in(user)
|
9
|
+
sign_out
|
10
|
+
visit(new_user_session_path)
|
11
|
+
fill_in "user_email", with: user.email
|
12
|
+
fill_in "user_password", with: user.password
|
13
|
+
find("[type=submit]").click
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
World(CapybaraSignIn)
|
@@ -0,0 +1 @@
|
|
1
|
+
require "simplecov"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module CapybaraWaitTurbolinksRequests
|
2
|
+
def wait_turbolinks_requests(timeout = Capybara.default_max_wait_time)
|
3
|
+
Timeout.timeout(timeout) do
|
4
|
+
sleep 0.1 until all_turbolinks_requests_finished?
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def all_turbolinks_requests_finished?
|
9
|
+
have_no_selector("html.turbolinks-load")
|
10
|
+
end
|
11
|
+
|
12
|
+
def turbolinks_defined?
|
13
|
+
page.evaluate_script("typeof Turbolinks") != "undefined"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
World(CapybaraWaitTurbolinksRequests)
|
18
|
+
|
19
|
+
# Auto wait turbolinks requests between steps
|
20
|
+
AfterStep do |_scenario|
|
21
|
+
if turbolinks_defined?
|
22
|
+
execute_script %(
|
23
|
+
$(document).on("turbolinks:before-visit", function(){
|
24
|
+
$("html").addClass("turbolinks-load")
|
25
|
+
})
|
26
|
+
|
27
|
+
$(document).on("turbolinks:load", function(){
|
28
|
+
$("html").removeClass("turbolinks-load")
|
29
|
+
})
|
30
|
+
)
|
31
|
+
|
32
|
+
wait_turbolinks_requests
|
33
|
+
end
|
34
|
+
end
|
data/lib/agilibox/engine.rb
CHANGED
@@ -1,9 +1,24 @@
|
|
1
|
+
require "awesome_print"
|
2
|
+
require "pry-rails"
|
1
3
|
require "rails-i18n"
|
4
|
+
require "nilify_blanks"
|
5
|
+
require "tapenade"
|
2
6
|
|
3
7
|
module Agilibox
|
4
8
|
class Engine < ::Rails::Engine
|
5
9
|
isolate_namespace Agilibox
|
10
|
+
|
11
|
+
initializer "agilibox_mime_types" do
|
12
|
+
Mime::Type.register "application/vnd.ms-excel", :xls
|
13
|
+
Mime::Type.register "application/vnd.ms-excel", :xlsx
|
14
|
+
end
|
15
|
+
|
16
|
+
# initializer "agilibox_errors_middleware" do
|
17
|
+
# require "agilibox/errors_middleware"
|
18
|
+
# end
|
6
19
|
end
|
7
20
|
end
|
8
21
|
|
22
|
+
require_relative "config"
|
23
|
+
require_relative "engine_file"
|
9
24
|
require_relative "core_and_rails_ext"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Kernel
|
2
|
+
def engine_file(engine)
|
3
|
+
app_file = caller(1..1).first.split(":").first
|
4
|
+
app_root = ::Rails.application.root.to_s
|
5
|
+
relative_file = app_file.sub(app_root, "")
|
6
|
+
engine_root = engine::Engine.root.to_s
|
7
|
+
|
8
|
+
::File.join(engine_root, relative_file)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Agilibox::ErrorsMiddleware
|
2
|
+
MAINTENANCE_ERRORS = [
|
3
|
+
"ActiveRecord::ConnectionTimeoutError",
|
4
|
+
"connections on port 5432",
|
5
|
+
"PG::UnableToSend",
|
6
|
+
]
|
7
|
+
|
8
|
+
NOT_ACCEPTABLE_ERRORS = [
|
9
|
+
"ActionController::BadRequest",
|
10
|
+
"ActionController::UnknownFormat",
|
11
|
+
"ActionController::UnknownHttpMethod",
|
12
|
+
"ActionDispatch::Cookies::CookieOverflow",
|
13
|
+
"ActionDispatch::Http::MimeNegotiation::InvalidType",
|
14
|
+
"ActionView::MissingTemplate",
|
15
|
+
"Mime::Type::InvalidMimeType",
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(app)
|
19
|
+
@app = app
|
20
|
+
end
|
21
|
+
|
22
|
+
def call(env)
|
23
|
+
@app.call(env)
|
24
|
+
rescue StandardError => e
|
25
|
+
error = "#{e.class} : #{e.message}"
|
26
|
+
|
27
|
+
if MAINTENANCE_ERRORS.any? { |pattern| error.match?(pattern) }
|
28
|
+
return respond_with 503, "Maintenance en cours."
|
29
|
+
end
|
30
|
+
|
31
|
+
if NOT_ACCEPTABLE_ERRORS.any? { |pattern| error.match?(pattern) }
|
32
|
+
return respond_with 406, "Not acceptable."
|
33
|
+
end
|
34
|
+
|
35
|
+
raise e
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def respond_with(status, body)
|
41
|
+
[status, {"Content-Type" => "text/plain; charset=UTF-8"}, [body]]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
stack = Rails.configuration.middleware
|
46
|
+
mw = Agilibox::ErrorsMiddleware
|
47
|
+
stack.unshift(mw)
|
48
|
+
stack.insert_after(ActionDispatch::DebugExceptions, mw) if defined?(ActionDispatch::DebugExceptions)
|
49
|
+
stack.insert_after(Bugsnag::Rack, mw) if defined?(Bugsnag::Rack)
|
50
|
+
stack.use(mw)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Agilibox::FormBackUrl
|
2
2
|
def back_url_tag
|
3
3
|
tag(:input,
|
4
|
-
:type
|
5
|
-
:name
|
6
|
-
:value => (params[:back_url] || request.referer),
|
4
|
+
:type => "hidden",
|
5
|
+
:name => "back_url",
|
6
|
+
:value => (params[:back_url].presence || request.referer),
|
7
7
|
)
|
8
8
|
end
|
9
9
|
|
@@ -15,4 +15,4 @@ module Agilibox::FormBackUrl
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
ActionView::Helpers::FormTagHelper.
|
18
|
+
ActionView::Helpers::FormTagHelper.prepend(Agilibox::FormBackUrl)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "test_helpers"
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.include Agilibox::TestHelpers
|
5
|
+
|
6
|
+
if defined?(FactoryBot)
|
7
|
+
config.include FactoryBot::Syntax::Methods
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(FactoryGirl)
|
11
|
+
warn "Please replace FactoryGirl by FactoryBot"
|
12
|
+
config.include FactoryGirl::Syntax::Methods
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(Devise)
|
16
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
17
|
+
end
|
18
|
+
|
19
|
+
config.after(:each) { Timecop.return }
|
20
|
+
end
|
21
|
+
|
22
|
+
Shoulda::Matchers.configure do |config|
|
23
|
+
config.integrate do |with|
|
24
|
+
with.test_framework :rspec
|
25
|
+
with.library :rails
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Zonebie.set_random_timezone
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Agilibox::TestHelpers
|
2
|
+
def json_response
|
3
|
+
@json_response ||= JSON.parse(response.body).with_indifferent_access
|
4
|
+
end
|
5
|
+
|
6
|
+
def email_deliveries
|
7
|
+
ActionMailer::Base.deliveries
|
8
|
+
end
|
9
|
+
|
10
|
+
def sms_deliveries
|
11
|
+
Agilibox::SMS::Strategies::Test.deliveries
|
12
|
+
end
|
13
|
+
end
|
data/lib/agilibox/version.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
42
|
+
end
|
43
|
+
|
44
|
+
task :annotations_setup do
|
45
|
+
Rails.application.configure do
|
46
|
+
if config.respond_to?(:annotations)
|
47
|
+
config.annotations.directories << 'features'
|
48
|
+
config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
desc 'Alias for cucumber:ok'
|
54
|
+
task :cucumber => 'cucumber:ok'
|
55
|
+
|
56
|
+
task :default => :cucumber
|
57
|
+
|
58
|
+
task :features => :cucumber do
|
59
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
60
|
+
end
|
61
|
+
|
62
|
+
# In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon.
|
63
|
+
task 'test:prepare' do
|
64
|
+
end
|
65
|
+
|
66
|
+
task :stats => 'cucumber:statsetup'
|
67
|
+
|
68
|
+
task :notes => 'cucumber:annotations_setup'
|
69
|
+
rescue LoadError
|
70
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
71
|
+
task :cucumber do
|
72
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|