voluntary 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/app/assets/javascripts/voluntary/application.js +5 -1
  4. data/app/assets/javascripts/voluntary/lib/moment.js +3195 -0
  5. data/app/assets/javascripts/voluntary/workflow/user/index.js.coffee +11 -0
  6. data/app/controllers/voluntary/api/v1/organizations_controller.rb +30 -0
  7. data/app/controllers/workflow/user/stories_controller.rb +15 -0
  8. data/app/controllers/workflow/user/tasks_controller.rb +18 -0
  9. data/app/controllers/workflow/user_controller.rb +3 -3
  10. data/app/models/story.rb +1 -1
  11. data/app/views/layouts/application.html.erb +1 -1
  12. data/app/views/workflow/user/index.html.erb +26 -9
  13. data/app/views/workflow/user/stories/index.html.erb +26 -0
  14. data/app/views/workflow/user/tasks/assigned.html.erb +26 -0
  15. data/config/routes/api.rb +3 -1
  16. data/config/routes/workflow.rb +2 -0
  17. data/db/migrate/20150818151512_create_or_alter_arguments.rb +1 -1
  18. data/lib/generators/voluntary/product_dummy/templates/features/support/user_cuke_helpers.rb +5 -5
  19. data/lib/voluntary/version.rb +1 -1
  20. metadata +10 -12
  21. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_behaviour_steps.rb +0 -17
  22. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_steps.rb +0 -11
  23. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_behaviour_steps.rb +0 -23
  24. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb +0 -25
  25. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/product_steps.rb +0 -15
  26. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/project_steps.rb +0 -23
  27. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb +0 -33
  28. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/task_steps.rb +0 -29
  29. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/wizards/story_steps.rb +0 -15
@@ -0,0 +1,11 @@
1
+ $(document).ready ->
2
+ $.get '/workflow/user/stories', (data) ->
3
+ $('#stories').html data
4
+
5
+ $('#workflow_user_tabs a').click (e) ->
6
+ e.preventDefault()
7
+
8
+ $.get $(this).data('url'), (data) =>
9
+ $($(this).attr('href')).html data
10
+
11
+ $(this).tab 'show'
@@ -0,0 +1,30 @@
1
+ module Voluntary
2
+ module Api
3
+ module V1
4
+ class OrganizationsController < ActionController::Base
5
+ include Voluntary::V1::BaseController
6
+
7
+ respond_to :json
8
+
9
+ def index
10
+ options = {}
11
+
12
+ collection = Organization.order('name')
13
+ collection = collection.where(user_id: params[:user_id]) if params[:user_id].present?
14
+ options[:json] = collection.paginate(page: params[:page], per_page: 100)
15
+
16
+ options[:meta] = {
17
+ pagination: {
18
+ total_pages: options[:json].total_pages, current_page: options[:json].current_page,
19
+ previous_page: options[:json].previous_page, next_page: options[:json].next_page
20
+ }
21
+ }
22
+
23
+ respond_with do |format|
24
+ format.json { render options }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ class Workflow::User::StoriesController < ApplicationController
2
+ def index
3
+ @stories = Story.where(state: 'active', :users_without_tasks_ids.ne => current_user.id).paginate(page: params[:page], per_page: 20)
4
+ projects = Project.where(id: @stories.map(&:project_id)).index_by(&:id)
5
+ products = Product.where(id: projects.values.map(&:product_id)).index_by(&:id)
6
+
7
+ @stories.map! do |story|
8
+ projects[story.project_id].product = products[projects[story.project_id].product_id]
9
+ story.project = projects[story.project_id]
10
+ story
11
+ end
12
+
13
+ render layout: false if request.xhr?
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class Workflow::User::TasksController < ApplicationController
2
+ before_action :authenticate_user!
3
+
4
+ def assigned
5
+ @tasks = Task.includes(:story).where(user_id: current_user.id, state: 'assigned')
6
+ projects = Project.where(id: @tasks.map{|t| t.story.project_id }).index_by(&:id)
7
+ products = Product.where(id: projects.values.map(&:product_id)).index_by(&:id)
8
+
9
+ @tasks.map! do |task|
10
+ project = projects[task.story.project_id]
11
+ project.product = products[project.product_id]
12
+ task.story.project = project
13
+ task
14
+ end
15
+
16
+ render layout: false if request.xhr?
17
+ end
18
+ end
@@ -1,7 +1,7 @@
1
1
  class Workflow::UserController < ApplicationController
2
+ before_action :authenticate_user!
3
+
2
4
  def index
3
- @assigned_tasks = Task.where(user_id: current_user.id, state: 'assigned')
4
- @completed_tasks = Task.complete.where(user_id: current_user.id)
5
- @sidenav_links_count = 1
5
+ @hide_sidebar = true
6
6
  end
7
7
  end
data/app/models/story.rb CHANGED
@@ -52,7 +52,7 @@ class Story
52
52
  def offeror=(value); self.offeror_id = value.id; end
53
53
 
54
54
  def project; project_id ? Project.find(project_id) : nil; end
55
- def project=(value); self.project_id = value.id; end
55
+ def project=(value); @project = value; self.project_id = value.id; end
56
56
 
57
57
  def next_task_for_user(user)
58
58
  return nil if (users_without_tasks_ids || []).include?(user.id)
@@ -28,7 +28,7 @@
28
28
  </div>
29
29
  <% end %>
30
30
  <div class="row">
31
- <% if sidenav(@sidenav_links_count).present? || content_for?(:search) || content_for?(:sidebar) %>
31
+ <% if (!@hide_sidebar && sidenav(@sidenav_links_count).present?) || content_for?(:search) || content_for?(:sidebar) %>
32
32
  <div class="col-md-9">
33
33
  <% if content_for?(:breadcrumbs) %>
34
34
  <div class="nav" style="padding-bottom:15px;">
@@ -1,14 +1,31 @@
1
+ <% content_for :javascript_includes do %>
2
+ <%= javascript_include_tag 'voluntary/workflow/user/index' %>
3
+ <% end %>
1
4
  <div class="container-fluid" style="padding-top:0px;">
2
5
  <div class="row">
3
- <div class="col-md-6">
4
- <h3><%= I18n.t('workflow.index.assigned_tasks') %></h3>
5
-
6
- <%= render 'tasks', collection: @assigned_tasks, columns: ['name', 'story_id'] %>
7
- </div>
8
- <div class="col-md-6">
9
- <h3><%= I18n.t('workflow.index.completed_tasks') %></h3>
10
-
11
- <%= render 'tasks', collection: @completed_tasks, columns: ['name', 'story_id'] %>
6
+ <div class="col-md-12">
7
+ <div>
8
+ <ul id="workflow_user_tabs" class="nav nav-tabs" role="tablist">
9
+ <li role="presentation" class="active">
10
+ <a href="#stories" aria-controls="stories" role="tab" data-toggle="tab" data-url="<%= stories_workflow_user_index_path %>">
11
+ <%= t('stories.index.title') %>
12
+ </a>
13
+ </li>
14
+ <li role="presentation">
15
+ <a href="#assigned_tasks" aria-controls="assigned_tasks" role="tab" data-toggle="tab" data-url="<%= assigned_tasks_workflow_user_index_path %>">
16
+ <%= t('workflow.index.assigned_tasks') %>
17
+ </a>
18
+ </li>
19
+ </ul>
20
+ <div class="tab-content">
21
+ <div role="tabpanel" class="tab-pane active" id="stories" style="padding-top:15px;">
22
+ Stories
23
+ </div>
24
+ <div role="tabpanel" class="tab-pane" id="assigned_tasks" style="padding-top:15px;">
25
+ Tasks
26
+ </div>
27
+ </div>
28
+ </div>
12
29
  </div>
13
30
  </div>
14
31
  </div>
@@ -0,0 +1,26 @@
1
+ <table class="table table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th><%= t('activerecord.models.story') %></th>
5
+ <th><%= t('activerecord.models.project') %></th>
6
+ <th><%= t('activerecord.models.product') %></th>
7
+ <th></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @stories.each do |story| %>
12
+ <tr>
13
+ <td><%= link_to story.name, story_path(story) %></td>
14
+ <td><%= link_to story.project.name, project_path(story.project) %></td>
15
+ <td>
16
+ <% if story.project.product %>
17
+ <%= link_to story.project.product.name, product_path(story.project.product) %>
18
+ <% else %>
19
+ -
20
+ <% end %>
21
+ </td>
22
+ <td><%= link_to t('workflow.user.next_task'), next_task_workflow_user_index_path(story) %></td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
@@ -0,0 +1,26 @@
1
+ <table class="table table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th><%= t('activerecord.models.task') %></th>
5
+ <th><%= t('activerecord.models.story') %></th>
6
+ <th><%= t('activerecord.models.project') %></th>
7
+ <th><%= t('activerecord.models.product') %></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% @tasks.each do |task| %>
12
+ <tr>
13
+ <td><%= link_to task.name, edit_task_workflow_user_index_path(task) %></td>
14
+ <td><%= link_to task.story.name, story_path(task.story) %></td>
15
+ <td><%= link_to task.story.project.name, project_path(task.story.project) %></td>
16
+ <td>
17
+ <% if task.story.project.product %>
18
+ <%= link_to task.story.project.product.name, product_path(task.story.project.product) %>
19
+ <% else %>
20
+ -
21
+ <% end %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
data/config/routes/api.rb CHANGED
@@ -14,6 +14,8 @@ namespace :voluntary, path: 'api', module: 'voluntary/api', defaults: {format: '
14
14
 
15
15
  get '/things/:left_thing_name/vs/:right_thing_name/arguments', to: 'things/arguments#comparison'
16
16
 
17
- resources :users
17
+ resources :users do
18
+ resources :organizations, only: [:index]
19
+ end
18
20
  end
19
21
  end
@@ -14,6 +14,8 @@ namespace 'workflow' do
14
14
 
15
15
  get 'projects/:id' => 'user/projects#show', as: :user_project
16
16
 
17
+ get 'stories' => 'user/stories#index', as: :stories
18
+ get 'tasks/assigned' => 'user/tasks#assigned', as: :assigned_tasks
17
19
  get 'stories/:story_id/tasks' => 'tasks#index', as: :tasks
18
20
  get 'stories/:story_id/tasks/next' => 'tasks#next', as: :next_task
19
21
  patch 'tasks/:id' => 'tasks#update', as: :update_task
@@ -4,7 +4,7 @@ class CreateOrAlterArguments < ActiveRecord::Migration
4
4
  add_column :arguments, :argumentable_type, :string
5
5
  add_column :arguments, :argumentable_id, :integer
6
6
 
7
- Argument.update_all 'argumentable_type = "Thing", argumentable_id = thing_id'
7
+ Argument.update_all "argumentable_type = 'Thing', argumentable_id = thing_id"
8
8
 
9
9
  remove_column :arguments, :thing_id
10
10
  add_index :arguments, [:topic_id, :argumentable_id, :argumentable_type], name: 'arguments_index_on_argumentable_topic', unique: true
@@ -4,7 +4,7 @@ module UserCukeHelpers
4
4
  # and the given override attributes, adds the standard aspects to it
5
5
  # and returns it
6
6
  def create_user(overrides={})
7
- Factory(
7
+ FactoryGirl.create(
8
8
  :user, {
9
9
  password: 'password',
10
10
  password_confirmation: 'password'
@@ -16,13 +16,13 @@ module UserCukeHelpers
16
16
  def login_as(user)
17
17
  fill_in 'Email', with: "#{user}@volontari.at"
18
18
  fill_in 'Password', with: 'password'
19
- click_button :submit
19
+ click_button 'Log in'
20
20
  end
21
21
 
22
22
  # create a new @me user, if not present, and log in using the
23
23
  # integration_sessions controller (automatic)
24
24
  def automatic_login
25
- @me ||= Factory(:user)
25
+ @me ||= FactoryGirl.create(:user)
26
26
  page.driver.visit(new_integration_sessions_path(user_id: @me.slug))
27
27
  click_button "Login"
28
28
  end
@@ -31,7 +31,7 @@ module UserCukeHelpers
31
31
  def manual_login
32
32
  visit login_page
33
33
  login_as @me.name
34
- visit user_confirmation_path(confirmation_token: @me.confirmation_token)
34
+ #visit user_confirmation_path(confirmation_token: @me.confirmation_token)
35
35
  end
36
36
 
37
37
  # checks the page content to see, if the login was successful
@@ -75,4 +75,4 @@ module UserCukeHelpers
75
75
 
76
76
  end
77
77
 
78
- World(UserCukeHelpers)
78
+ World(UserCukeHelpers)
@@ -1,3 +1,3 @@
1
1
  module Voluntary
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voluntary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Gawlista
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-23 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1130,7 +1130,7 @@ dependencies:
1130
1130
  - - "~>"
1131
1131
  - !ruby/object:Gem::Version
1132
1132
  version: 2.2.0
1133
- description: "#Crowdsourcing management system for #RubyOnRails: http://bit.ly/voluntary-0-5-1"
1133
+ description: "#Crowdsourcing management system for #RubyOnRails: http://bit.ly/voluntary-0-5-2"
1134
1134
  email:
1135
1135
  - gawlista@gmail.com
1136
1136
  executables: []
@@ -1147,9 +1147,11 @@ files:
1147
1147
  - app/assets/javascripts/voluntary/functions.js
1148
1148
  - app/assets/javascripts/voluntary/lib/jquery-competitive_list.js
1149
1149
  - app/assets/javascripts/voluntary/lib/jquery.multisortable.js
1150
+ - app/assets/javascripts/voluntary/lib/moment.js
1150
1151
  - app/assets/javascripts/voluntary/lib/sugar.js
1151
1152
  - app/assets/javascripts/voluntary/likes/list.js.coffee
1152
1153
  - app/assets/javascripts/voluntary/users.js.coffee
1154
+ - app/assets/javascripts/voluntary/workflow/user/index.js.coffee
1153
1155
  - app/assets/stylesheets/voluntary/application.css
1154
1156
  - app/assets/stylesheets/voluntary/base.css.sass
1155
1157
  - app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.sass
@@ -1173,6 +1175,7 @@ files:
1173
1175
  - app/controllers/voluntary/api/v1/argument_topics_controller.rb
1174
1176
  - app/controllers/voluntary/api/v1/arguments_controller.rb
1175
1177
  - app/controllers/voluntary/api/v1/base_controller.rb
1178
+ - app/controllers/voluntary/api/v1/organizations_controller.rb
1176
1179
  - app/controllers/voluntary/api/v1/tasks_controller.rb
1177
1180
  - app/controllers/voluntary/api/v1/things/arguments_controller.rb
1178
1181
  - app/controllers/voluntary/api/v1/users_controller.rb
@@ -1183,6 +1186,8 @@ files:
1183
1186
  - app/controllers/workflow/tasks_controller.rb
1184
1187
  - app/controllers/workflow/user/product/areas_controller.rb
1185
1188
  - app/controllers/workflow/user/projects_controller.rb
1189
+ - app/controllers/workflow/user/stories_controller.rb
1190
+ - app/controllers/workflow/user/tasks_controller.rb
1186
1191
  - app/controllers/workflow/user_controller.rb
1187
1192
  - app/controllers/workflow_controller.rb
1188
1193
  - app/helpers/voluntary/application_helper.rb
@@ -1334,6 +1339,8 @@ files:
1334
1339
  - app/views/workflow/user/index.html.erb
1335
1340
  - app/views/workflow/user/product/areas/show.html.erb
1336
1341
  - app/views/workflow/user/projects/show.html.erb
1342
+ - app/views/workflow/user/stories/index.html.erb
1343
+ - app/views/workflow/user/tasks/assigned.html.erb
1337
1344
  - config/initializers/1_initialize_app_config.rb
1338
1345
  - config/initializers/active_model_serializer.rb
1339
1346
  - config/initializers/assets.rb
@@ -1462,24 +1469,15 @@ files:
1462
1469
  - lib/generators/voluntary/product_dummy/templates/dummy/config/initializers/secret_token.rb
1463
1470
  - lib/generators/voluntary/product_dummy/templates/dummy/spec/factories.rb
1464
1471
  - lib/generators/voluntary/product_dummy/templates/dummy/spec/spec_helper.rb
1465
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_behaviour_steps.rb
1466
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_steps.rb
1467
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_behaviour_steps.rb
1468
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb
1469
1472
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/custom_web_steps.rb
1470
1473
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/email_steps.rb
1471
1474
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/factory_steps.rb
1472
1475
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/javascript_steps.rb
1473
1476
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/navigation_steps.rb
1474
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/product_steps.rb
1475
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/project_steps.rb
1476
1477
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/resources_steps.rb
1477
1478
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/session_steps.rb
1478
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb
1479
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/task_steps.rb
1480
1479
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/user_steps.rb
1481
1480
  - lib/generators/voluntary/product_dummy/templates/features/step_definitions/web_steps.rb
1482
- - lib/generators/voluntary/product_dummy/templates/features/step_definitions/wizards/story_steps.rb
1483
1481
  - lib/generators/voluntary/product_dummy/templates/features/support/database_cleaner_patches.rb
1484
1482
  - lib/generators/voluntary/product_dummy/templates/features/support/env.rb
1485
1483
  - lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb
@@ -1,17 +0,0 @@
1
- Then /^I can't edit areas$/ do
2
- steps %{
3
- Given an area named "area 1"
4
- When I go to the edit area page
5
- Then I should see "Access denied"
6
- }
7
- end
8
-
9
- Then /^I can't delete areas$/ do
10
- steps %{
11
- Given an area named "area 1"
12
- When I am on the area page
13
- Then I should not see "Actions"
14
- }
15
- end
16
-
17
-
@@ -1,11 +0,0 @@
1
- Given /^an area named "([^\"]*)"$/ do |name|
2
- # WORKAROUND: get rid of area query. Don't know why it doesn't work without (e.g. /roles/2_users/projects.feature)
3
- @area = Area.where(name: name).first || Factory(:area, name: name)
4
- @area.reload
5
- end
6
-
7
- Then /^I should see the following areas:$/ do |expected_table|
8
- rows = find("table").all('tr')
9
- table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
10
- expected_table.diff!(table)
11
- end
@@ -1,23 +0,0 @@
1
- When /^I fill out a comment form$/ do
2
- fill_in 'Subject', with: 'Comment 1'
3
- fill_in 'Text', with: 'Dummy 1'
4
- end
5
-
6
- When /^I fill out a comment's comment form$/ do
7
- fill_in 'Subject', with: 'Comment 2'
8
- fill_in 'Text', with: 'Dummy 2'
9
- end
10
-
11
- Then /^I should see the comment$/ do
12
- steps %{
13
- Then I should see "Comment 1"
14
- And I should see "Dummy 1"
15
- }
16
- end
17
-
18
- Then /^I should see the comment's comment$/ do
19
- page.should have_xpath(
20
- '//div[@class="nested_comments"]//div[@class="comment"]//div[@class="content"]//p',
21
- text: 'Dummy 2'
22
- )
23
- end
@@ -1,25 +0,0 @@
1
- Given /^a comment$/ do
2
- attributes = { commentable: @project }
3
- attributes[:user_id] ||= @me.id if @me
4
- @comment = Factory(:comment, attributes)
5
- @comment.reload
6
- end
7
-
8
- When /^I reply the (\d+)(?:st|nd|rd|th) comment$/ do |pos|
9
- find(:xpath, "//a[@class='new_comment'][#{pos.to_i}]").click
10
- end
11
-
12
- When /^I edit the (\d+)(?:st|nd|rd|th) comment$/ do |pos|
13
- find(:xpath, "//a[@class='edit_comment'][#{pos.to_i}]").click
14
- end
15
-
16
- When /^I delete the (\d+)(?:st|nd|rd|th) comment$/ do |pos|
17
- page.execute_script 'window.confirm = function () { return true }'
18
- find(:xpath, "//a[@class='destroy_comment'][#{pos.to_i}]").click
19
- end
20
-
21
- Then /^I should see the following comments:$/ do |expected_table|
22
- expected_table.hashes.each do |hash|
23
- steps %{Then I should see "#{hash['Name']}"}
24
- end
25
- end