voluntary 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/app/helpers/product_helper.rb +5 -3
  2. data/config/initializers/vendor_extensions.rb +1 -0
  3. data/lib/generators/voluntary/install/install_generator.rb +0 -17
  4. data/lib/generators/voluntary/product_dummy/product_dummy_generator.rb +105 -0
  5. data/lib/generators/voluntary/product_dummy/templates/app/controllers/application_controller.rb +3 -0
  6. data/lib/generators/voluntary/product_dummy/templates/app/controllers/home_controller.rb +4 -0
  7. data/lib/generators/voluntary/product_dummy/templates/app/models/ability.rb +49 -0
  8. data/lib/generators/voluntary/product_dummy/templates/app/models/app_config.rb +32 -0
  9. data/lib/generators/voluntary/product_dummy/templates/app/views/home/index.html.erb +0 -0
  10. data/lib/generators/voluntary/product_dummy/templates/app/views/layouts/application.html.erb +50 -0
  11. data/lib/generators/voluntary/product_dummy/templates/config/application.yml +147 -0
  12. data/lib/generators/voluntary/product_dummy/templates/config/cucumber.yml +8 -0
  13. data/lib/generators/voluntary/product_dummy/templates/config/database.example.yml +28 -0
  14. data/lib/generators/voluntary/product_dummy/templates/config/email.example.yml +9 -0
  15. data/lib/generators/voluntary/product_dummy/templates/config/locale_settings.yml +121 -0
  16. data/lib/generators/voluntary/product_dummy/templates/config/main_navigation.rb +262 -0
  17. data/lib/generators/voluntary/product_dummy/templates/config/mongoid.yml +78 -0
  18. data/lib/generators/voluntary/product_dummy/templates/config/routes.rb +3 -0
  19. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_behaviour_steps.rb +17 -0
  20. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_steps.rb +11 -0
  21. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb +34 -0
  22. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_behaviour_steps.rb +23 -0
  23. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb +25 -0
  24. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/email_steps.rb +89 -0
  25. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/factory_steps.rb +120 -0
  26. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/javascript_steps.rb +15 -0
  27. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/navigation_steps.rb +3 -0
  28. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/product_steps.rb +15 -0
  29. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/project_steps.rb +23 -0
  30. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/resources_steps.rb +8 -0
  31. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/session_steps.rb +35 -0
  32. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/state_machines/vacancy_steps.rb +7 -0
  33. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb +33 -0
  34. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/task_steps.rb +29 -0
  35. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/user_steps.rb +4 -0
  36. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb +32 -0
  37. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/web_steps.rb +271 -0
  38. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/wizards/story_steps.rb +15 -0
  39. data/lib/generators/voluntary/product_dummy/templates/features/support/database_cleaner_patches.rb +24 -0
  40. data/lib/generators/voluntary/product_dummy/templates/features/support/env.rb +86 -0
  41. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +32 -0
  42. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_form.html.erb +1 -0
  43. data/lib/generators/voluntary/product_dummy/templates/features/support/paths.rb +98 -0
  44. data/lib/generators/voluntary/product_dummy/templates/features/support/selectors.rb +44 -0
  45. data/lib/generators/voluntary/product_dummy/templates/features/support/spork_env +72 -0
  46. data/lib/generators/voluntary/product_dummy/templates/features/support/user_cuke_helpers.rb +78 -0
  47. data/lib/generators/voluntary/product_dummy/templates/spec/support/deferred_garbage_collector.rb +45 -0
  48. data/lib/generators/voluntary/product_dummy/templates/spec/support/devise.rb +3 -0
  49. data/lib/generators/voluntary/product_dummy/templates/spec/support/mongo_database_cleaner.rb +25 -0
  50. data/lib/voluntary/version.rb +1 -1
  51. metadata +212 -168
  52. data/app/views/products/types/text_creation/stories/_form.html.erb +0 -19
  53. data/app/views/products/types/text_creation/stories/_task_fields.html.erb +0 -7
  54. data/lib/vendors/active_model/naming.rb +0 -14
@@ -0,0 +1,98 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file is used by web_steps.rb, which you should also delete
4
+ #
5
+ # You have been warned
6
+ module NavigationHelpers
7
+ # Maps a name to a path. Used by the
8
+ #
9
+ # When /^I go to (.+)$/ do |page_name|
10
+ #
11
+ # step definition in web_steps.rb
12
+ #
13
+ def path_to(page_name)
14
+ case page_name
15
+
16
+ when /^the home\s?page$/
17
+ '/'
18
+
19
+ # authentication
20
+ when /^the sign in page$/
21
+ new_user_session_path
22
+
23
+ # areas
24
+ when /the areas page/
25
+ areas_path
26
+
27
+ when /the area page/
28
+ area_path(@area)
29
+
30
+ when /the edit area page/
31
+ edit_area_path(@area)
32
+
33
+ # product
34
+ when /the product page/
35
+ product_path(@product)
36
+
37
+ when /the edit product page/
38
+ edit_product_path(@product)
39
+
40
+ # projects
41
+ when /the project page/
42
+ project_path(@project)
43
+
44
+ when /the edit project page/
45
+ edit_project_path(@project)
46
+
47
+ # vacancies
48
+ when /the vacancy page/
49
+ vacancy_path(@vacancy)
50
+
51
+ when /the edit vacancy page/
52
+ edit_vacancy_path(@vacancy)
53
+
54
+ # candidatures
55
+ when /the candidature page/
56
+ candidature_path(@candidature)
57
+
58
+ when /the edit candidature page/
59
+ edit_candidature_path(@candidature)
60
+
61
+ # stories
62
+ when /the new project story page/
63
+ new_project_story_path(@project)
64
+
65
+ # workflow
66
+ when /the workflow page/
67
+ workflow_path
68
+
69
+ when /the edit workflow task page/
70
+ edit_task_workflow_user_index_path(@task || @story.tasks.last)
71
+
72
+ when /the project owner's workflow page/
73
+ workflow_project_owner_index_path
74
+
75
+ # Add more mappings here.
76
+ # Here is an example that pulls values out of the Regexp:
77
+ #
78
+ # when /^(.*)'s profile page$/i
79
+ # user_profile_path(User.find_by_login($1))
80
+
81
+ else
82
+ begin
83
+ page_name =~ /^the (.*) page$/
84
+ path_components = $1.split(/\s+/)
85
+ self.send(path_components.push('path').join('_').to_sym)
86
+ rescue NoMethodError, ArgumentError
87
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
88
+ "Now, go and add a mapping in #{__FILE__}"
89
+ end
90
+ end
91
+ end
92
+
93
+ def login_page
94
+ path_to "the new user session page"
95
+ end
96
+ end
97
+
98
+ World(NavigationHelpers)
@@ -0,0 +1,44 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file is used by web_steps.rb, which you should also delete
4
+ #
5
+ # You have been warned
6
+ module HtmlSelectorsHelpers
7
+ # Maps a name to a selector. Used primarily by the
8
+ #
9
+ # When /^(.+) within (.+)$/ do |step, scope|
10
+ #
11
+ # step definitions in web_steps.rb
12
+ #
13
+ def selector_for(locator)
14
+ case locator
15
+
16
+ when "the page"
17
+ "html > body"
18
+
19
+ # Add more mappings here.
20
+ # Here is an example that pulls values out of the Regexp:
21
+ #
22
+ # when /^the (notice|error|info) flash$/
23
+ # ".flash.#{$1}"
24
+
25
+ # You can also return an array to use a different selector
26
+ # type, like:
27
+ #
28
+ # when /the header/
29
+ # [:xpath, "//header"]
30
+
31
+ # This allows you to provide a quoted selector as the scope
32
+ # for "within" steps as was previously the default for the
33
+ # web steps:
34
+ when /^"(.+)"$/
35
+ $1
36
+
37
+ else
38
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
39
+ "Now, go and add a mapping in #{__FILE__}"
40
+ end
41
+ end
42
+ end
43
+
44
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ #uncomment the following line to use spork with the debugger
4
+ #require 'spork/ext/ruby-debug'
5
+
6
+ Spork.prefork do
7
+ require 'cucumber/rails'
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../../support/mongo_database_cleaner')
9
+ require File.join(File.dirname(__FILE__), "database_cleaner_patches")
10
+ require File.join(File.dirname(__FILE__), "integration_sessions_controller")
11
+
12
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
13
+ # order to ease the transition to Capybara we set the default here. If you'd
14
+ # prefer to use XPath just remove this line and adjust any selectors in your
15
+ # steps to use the XPath syntax.
16
+ Capybara.default_selector = :css
17
+
18
+ Capybara.javascript_driver = ENV['JAVASCRIPT_DRIVER'] ? ENV['JAVASCRIPT_DRIVER'].to_sym : :webkit
19
+
20
+ Capybara.add_selector(:row) do
21
+ xpath { |num| ".//tbody/tr[#{num}]" }
22
+ end
23
+
24
+ ActionController::Base.allow_rescue = false
25
+
26
+ DatabaseCleaner.strategy = :truncation
27
+ DatabaseCleaner.orm = "active_record"
28
+ Cucumber::Rails::World.use_transactional_fixtures = false
29
+
30
+ Cucumber::Rails::Database.javascript_strategy = :truncation
31
+ end
32
+
33
+ Spork.each_run do
34
+ Before do
35
+ DatabaseCleaner.clean
36
+
37
+ # TODO: find a better solution
38
+ begin
39
+ MongoDatabaseCleaner.clean
40
+ rescue
41
+ DatabaseCleaner.logger.error "Exception encountered by DatabaseCleaner in Cucumber After block: #{e}"
42
+ end
43
+
44
+ Devise.mailer.deliveries = []
45
+ end
46
+
47
+ After do
48
+ if Capybara.current_session.driver.respond_to?(:browser)
49
+ Capybara.reset_sessions!
50
+ # Capybara.current_session.driver.browser.manage.delete_all_cookies
51
+ end
52
+ end
53
+
54
+ Before('@localserver') do
55
+ CapybaraSettings.instance.save
56
+ Capybara.current_driver = :selenium
57
+ Capybara.run_server = false
58
+ end
59
+
60
+ After('@localserver') do
61
+ CapybaraSettings.instance.restore
62
+ end
63
+ end
64
+
65
+ # give firefox more time to complete requests
66
+ # http://ihswebdesign.com/knowledge-base/fixing-selenium-timeouterror/
67
+ After do |scenario|
68
+ if scenario.exception.is_a? Timeout::Error
69
+ # restart Selenium driver
70
+ Capybara.send(:session_pool).delete_if { |key, value| key =~ /selenium/i }
71
+ end
72
+ end
@@ -0,0 +1,78 @@
1
+ module UserCukeHelpers
2
+
3
+ # creates a new user object from the factory with some default attributes
4
+ # and the given override attributes, adds the standard aspects to it
5
+ # and returns it
6
+ def create_user(overrides={})
7
+ Factory(
8
+ :user, {
9
+ password: 'password',
10
+ password_confirmation: 'password'
11
+ }.merge(overrides)
12
+ )
13
+ end
14
+
15
+ # fill out the fields on the sign_in page and press submit
16
+ def login_as(user)
17
+ fill_in 'Email', with: "#{user}@volontari.at"
18
+ fill_in 'Password', with: 'password'
19
+ click_button :submit
20
+ end
21
+
22
+ # create a new @me user, if not present, and log in using the
23
+ # integration_sessions controller (automatic)
24
+ def automatic_login
25
+ @me ||= Factory(:user)
26
+ page.driver.visit(new_integration_sessions_path(user_id: @me.slug))
27
+ click_button "Login"
28
+ end
29
+
30
+ # use the @me user to perform a manual login via the sign_in page
31
+ def manual_login
32
+ visit login_page
33
+ login_as @me.name
34
+ visit user_confirmation_path(confirmation_token: @me.confirmation_token)
35
+ end
36
+
37
+ # checks the page content to see, if the login was successful
38
+ def confirm_login
39
+ wait_until { page.has_content?("Sign out") }
40
+ end
41
+
42
+ # delete all cookies, destroying the current session
43
+ def logout
44
+ $browser.delete_cookie('_session', 'path=/') if $browser
45
+ $browser.delete_all_visible_cookies if $browser
46
+ end
47
+
48
+ # fill change password section on the user edit page
49
+ def fill_change_password_section(cur_pass, new_pass, confirm_pass)
50
+ fill_in 'user_current_password', with: cur_pass
51
+ fill_in 'user_password', with: new_pass
52
+ fill_in 'user_password_confirmation', with: confirm_pass
53
+ end
54
+
55
+ # fill forgot password form to get reset password link
56
+ def fill_forgot_password_form(email)
57
+ fill_in 'user_email', with: email
58
+ end
59
+
60
+ # submit forgot password form to get reset password link
61
+ def submit_forgot_password_form
62
+ find("#new_user input.button").click
63
+ end
64
+
65
+ # fill the reset password form
66
+ def fill_reset_password_form(new_pass, confirm_pass)
67
+ fill_in 'user_password', with: new_pass
68
+ fill_in 'user_password_confirmation', with: confirm_pass
69
+ end
70
+
71
+ # submit reset password form
72
+ def submit_reset_password_form
73
+ find(".button").click
74
+ end
75
+
76
+ end
77
+
78
+ World(UserCukeHelpers)
@@ -0,0 +1,45 @@
1
+ # https://makandracards.com/makandra/950-speed-up-rspec-by-deferring-garbage-collection
2
+ class DeferredGarbageCollection
3
+
4
+ DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 10.0).to_f #used to be 10.0
5
+
6
+ @@last_gc_run = Time.now
7
+
8
+ def self.start
9
+ return if unsupported_enviroment
10
+ GC.disable if DEFERRED_GC_THRESHOLD > 0
11
+ end
12
+
13
+ def self.memory_threshold
14
+ @mem = %x(free 2>/dev/null).to_s.split(" ")
15
+ return nil if @mem.empty?
16
+ @mem[15].to_i / (@mem[7].to_i/100)
17
+ end
18
+
19
+ def self.reconsider
20
+ return if unsupported_enviroment
21
+
22
+ if (percent_used = self.memory_threshold)
23
+ running_out_of_memory = percent_used > 90
24
+
25
+ # just for info, as soon as we got some numbers remove it
26
+ swap_percent_used = @mem[19].to_i / (@mem[18].to_i/100) rescue 0
27
+ puts "percent memory used #{percent_used} (#{@mem[8]} of #{@mem[7]})"
28
+ puts "percent swap used #{swap_percent_used} (#{@mem[19]} of #{@mem[18]})"
29
+ else
30
+ running_out_of_memory = false
31
+ end
32
+
33
+ if( (DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD) || running_out_of_memory )
34
+ GC.enable
35
+ GC.start
36
+ GC.disable
37
+ @@last_gc_run = Time.now
38
+ end
39
+ end
40
+
41
+ def self.unsupported_enviroment
42
+ ENV['TRAVIS'] # TODO: enable for ruby 1.9.3 or more RAM
43
+ end
44
+
45
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include Devise::TestHelpers, :type => :controller
3
+ end
@@ -0,0 +1,25 @@
1
+ class MongoDatabaseCleaner
2
+ def self.clean
3
+ root = File.expand_path(File.dirname(__FILE__) + '/../../..')
4
+
5
+ Dir["#{root}/app/models/**/*.*"].each do |path_name|
6
+ path_name.gsub!("#{root}/app/models/", '')
7
+ path_name = path_name.split('/')
8
+ klass = path_name.pop.sub(/\.rb$/,'').camelize
9
+
10
+ unless path_name.none?
11
+ klass = [path_name.map(&:camelize).join('::'), klass].join('::')
12
+ end
13
+
14
+ begin
15
+ klass = klass.constantize
16
+ rescue
17
+ raise path_name
18
+ end
19
+
20
+ next if klass.respond_to?(:table_name) || !klass.respond_to?(:delete_all)
21
+
22
+ klass.delete_all
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Voluntary
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end