Merge pull request #7362 from opf/feature/csv_export_on_time_entry_index_only
Feature/csv export on time entry index only [ci skip]pull/7377/head
commit
5a7ac87ac0
@ -1,49 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
collection @projects => "projects" |
||||
|
||||
# This is a bit verbose as Project.level_list produces an array of hashes with the form: |
||||
# [ |
||||
# { :project => <Project object>, |
||||
# :level => <hierarchy level> } |
||||
# ] |
||||
|
||||
node(:id) { |p| p[:project].id } |
||||
node(:name) { |p| p[:project].name } |
||||
node(:identifier) { |p| p[:project].identifier } |
||||
node(:has_children) { |p| !p[:project].leaf? } |
||||
node(:level) { |p| p[:level] } |
||||
|
||||
node(:created_on, if: lambda { |p| p[:project].created_on }) do |p| |
||||
p[:project].created_on.utc |
||||
end |
||||
|
||||
node(:updated_on, if: lambda { |p| p[:project].updated_on }) do |p| |
||||
p[:project].updated_on.utc |
||||
end |
@ -1,90 +0,0 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License version 3. |
||||
|
||||
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
Copyright (C) 2010-2013 the ChiliProject Team |
||||
|
||||
This program is free software; you can redistribute it and/or |
||||
modify it under the terms of the GNU General Public License |
||||
as published by the Free Software Foundation; either version 2 |
||||
of the License, or (at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program; if not, write to the Free Software |
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
|
||||
See docs/COPYRIGHT.rdoc for more details. |
||||
|
||||
++#%> |
||||
|
||||
<div class="generic-table--container"> |
||||
<div class="generic-table--results-container"> |
||||
<table class="generic-table"> |
||||
<colgroup> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col highlight-col> |
||||
<col> |
||||
</colgroup> |
||||
<thead> |
||||
<tr> |
||||
<%= sort_header_tag("spent_on", caption: TimeEntry.human_attribute_name(:spent_on)) %> |
||||
<%= sort_header_tag("user", caption: TimeEntry.human_attribute_name(:user)) %> |
||||
<%= sort_header_tag("activity", caption: TimeEntry.human_attribute_name(:activity)) %> |
||||
<%= sort_header_tag("project", caption: TimeEntry.human_attribute_name(:project)) %> |
||||
<%= sort_header_tag("work_package", caption: TimeEntry.human_attribute_name(:issue)) %> |
||||
<%= sort_header_tag("comments", caption: TimeEntry.human_attribute_name(:comments)) %> |
||||
<%= sort_header_tag("hours", caption: TimeEntry.human_attribute_name(:hours)) %> |
||||
<th> |
||||
<div class="generic-table--empty-header"></div> |
||||
</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<% entries.each do |entry| -%> |
||||
<tr class="time-entry"> |
||||
<td class="spent_on"><%= format_date(entry.spent_on) %></td> |
||||
<td class="user"><%= link_to_user(entry.user) %></td> |
||||
<td class="activity"><%= h entry.activity %></td> |
||||
<td class="project"><%= link_to_project(entry.project) %></td> |
||||
<td class="subject"> |
||||
<% if entry.work_package -%> |
||||
<%= entry.work_package.visible? ? link_to_work_package(entry.work_package, truncate: 50) : "##{entry.work_package.id}" -%> |
||||
<% end -%> |
||||
</td> |
||||
<td class="comments"><%= h entry.comments %></td> |
||||
<td class="hours"><%= html_hours("%.2f" % entry.hours) %></td> |
||||
<td align="center"> |
||||
<% if entry.editable_by?(current_user) -%> |
||||
<%= link_to icon_wrapper('icon-context icon-edit', t(:button_edit)), |
||||
edit_time_entry_path(entry), |
||||
class: 'no-decoration-on-hover', |
||||
title: t(:button_edit) %> |
||||
<%= link_to icon_wrapper('icon-context icon-delete', t(:button_delete)), |
||||
time_entry_path(entry), |
||||
confirm: t(:text_are_you_sure), |
||||
class: 'no-decoration-on-hover', |
||||
method: :delete, |
||||
title: t(:button_delete) %> |
||||
<% end -%> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
@ -1,30 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
collection @entries => "timeEntries" |
||||
extends 'timelog/show' |
@ -1,57 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
object @entry => "timeEntry" |
||||
attributes :id, |
||||
:spent_on, |
||||
:comments, |
||||
:hours |
||||
|
||||
node :user do |e| |
||||
partial('users/show', object: e.user) |
||||
end |
||||
|
||||
child :activity => :activity do |
||||
attributes :name |
||||
end |
||||
|
||||
child :project do |
||||
attributes :id, :name |
||||
end |
||||
|
||||
child :work_package do |
||||
attributes :id, :subject |
||||
|
||||
node :isVisible do |w| |
||||
w.visible? |
||||
end |
||||
end |
||||
|
||||
node :isEditable do |e| |
||||
e.editable_by?(User.current) |
||||
end |
@ -1,34 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
object @user |
||||
attributes :id, |
||||
:name, |
||||
:firstname, |
||||
:lastname |
||||
|
@ -1,58 +0,0 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
## |
||||
# Hack against rabl 0.13.0 which applies config.include_child_root to |
||||
# #collection as well as to #child calls as you would expect. |
||||
# |
||||
module Rabl |
||||
class Engine |
||||
def to_hash_with_hack(options = {}) |
||||
if is_collection?(@_data_object) |
||||
options[:building_collection] = true |
||||
end |
||||
to_hash_without_hack(options) |
||||
end |
||||
|
||||
alias_method :to_hash_without_hack, :to_hash |
||||
alias_method :to_hash, :to_hash_with_hack |
||||
end |
||||
|
||||
class Builder |
||||
def to_hash_with_hack(object = nil, settings = nil, options = nil) |
||||
if @options[:building_collection] && !@options[:child_root] |
||||
@options[:root_name] = false |
||||
end |
||||
to_hash_without_hack(object, settings, options) |
||||
end |
||||
|
||||
alias_method :to_hash_without_hack, :to_hash |
||||
alias_method :to_hash, :to_hash_with_hack |
||||
end |
||||
end |
@ -1,53 +0,0 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
Rabl.configure do |config| |
||||
config.json_engine = ::Oj # Class with #dump class method (defaults JSON) |
||||
config.include_json_root = true |
||||
config.include_xml_root = false |
||||
config.include_child_root = false |
||||
config.xml_options = { dasherize: false, skip_types: false } |
||||
|
||||
# Commented as these are defaults |
||||
# config.cache_all_output = false |
||||
# config.cache_sources = Rails.env != 'development' # Defaults to false |
||||
# config.cache_engine = Rabl::CacheEngine.new # Defaults to Rails cache |
||||
# config.perform_caching = false |
||||
# config.escape_all_output = false |
||||
# config.msgpack_engine = nil # Defaults to ::MessagePack |
||||
# config.bson_engine = nil # Defaults to ::BSON |
||||
# config.plist_engine = nil # Defaults to ::Plist::Emit |
||||
# config.include_msgpack_root = true |
||||
# config.include_bson_root = true |
||||
# config.include_plist_root = true |
||||
# config.enable_json_callbacks = false |
||||
# config.view_paths = [] |
||||
# config.raise_on_missing_attribute = true # Defaults to false |
||||
# config.replace_nil_values_with_empty_strings = true # Defaults to false |
||||
end |
@ -1,52 +0,0 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module ActionView |
||||
class Resolver |
||||
def find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = []) |
||||
cached(key, [name, prefix, partial], details, locals) do |
||||
if details[:formats] & [:xml, :json] |
||||
details = details.dup |
||||
details[:formats] = details[:formats].dup + [:api] |
||||
end |
||||
find_templates(name, prefix, partial, details) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
module ActionController |
||||
module MimeResponds |
||||
class Collector |
||||
def api(&block) |
||||
any(:xml, :json, &block) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -1,84 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require "spec_helper" |
||||
|
||||
describe "/time_entries", type: :feature do |
||||
let(:user) { FactoryBot.create :admin } |
||||
|
||||
describe "sorting time entries", js: true do |
||||
let(:projects) { FactoryBot.create_list :project, 3 } |
||||
let(:comments) { ["TE 2", "TE 1", "TE 3"] } |
||||
let(:hours) { [2, 5, 1] } |
||||
|
||||
let!(:time_entries) do |
||||
comments.zip(projects).zip(hours).map do |comment_and_project, hours| |
||||
comment, project = comment_and_project |
||||
work_package = FactoryBot.create :work_package, project: project |
||||
|
||||
FactoryBot.create :time_entry, |
||||
comments: comment, |
||||
work_package: work_package, |
||||
project: project, |
||||
hours: hours |
||||
end |
||||
end |
||||
|
||||
def shown_comments |
||||
page.all("td.comments").map(&:text) |
||||
end |
||||
|
||||
def shown_hours |
||||
page.all("td.hours").map(&:text).map(&:to_i) |
||||
end |
||||
|
||||
before do |
||||
login_as user |
||||
visit time_entries_path |
||||
end |
||||
|
||||
it "should allow sorting the time entries" do |
||||
expect(page).to have_selector('td.comments', text: "TE 2") |
||||
expect(page).to have_selector('td.comments', text: "TE 1") |
||||
expect(page).to have_selector('td.comments', text: "TE 3") |
||||
|
||||
|
||||
click_on "Comment" |
||||
expect(page).to have_selector('td.comments', count: 3) |
||||
expect(shown_comments).to eq comments.sort |
||||
|
||||
click_on "Hours" |
||||
expect(page).to have_selector('td.comments', count: 3) |
||||
expect(shown_hours).to eq hours.sort |
||||
|
||||
click_on "Hours" |
||||
expect(page).to have_selector('td.comments', count: 3) |
||||
expect(shown_hours).to eq hours.sort.reverse |
||||
end |
||||
end |
||||
end |
@ -1,83 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe '/projects/level_list.api.rabl', type: :view do |
||||
before do |
||||
params[:format] = 'json' |
||||
end |
||||
|
||||
subject { rendered } |
||||
describe 'with no project available' do |
||||
it 'renders an empty projects document' do |
||||
assign(:projects, []) |
||||
|
||||
render |
||||
|
||||
is_expected.to have_json_size(0).at_path('projects') |
||||
end |
||||
end |
||||
|
||||
describe 'with some projects available' do |
||||
let(:projects) do |
||||
p1 = FactoryBot.build(:project, name: 'P1') |
||||
|
||||
# a result from Project.project_level_list |
||||
[{ project: p1, |
||||
level: 0 }, |
||||
{ project: FactoryBot.build(:project, name: 'P2', parent: p1), |
||||
level: 1 }, |
||||
{ project: FactoryBot.build(:project, name: 'P3'), |
||||
level: 0 }] |
||||
end |
||||
|
||||
before do |
||||
assign(:projects, projects) |
||||
render |
||||
end |
||||
|
||||
subject { rendered } |
||||
|
||||
it 'renders a projects document with the size of 3 of type array' do |
||||
is_expected.to have_json_size(3).at_path('projects') |
||||
end |
||||
|
||||
it 'renders all three projects' do |
||||
is_expected.to be_json_eql('P1'.to_json).at_path('projects/0/name') |
||||
is_expected.to be_json_eql('P2'.to_json).at_path('projects/1/name') |
||||
is_expected.to be_json_eql('P3'.to_json).at_path('projects/2/name') |
||||
end |
||||
|
||||
it 'renders the project levels' do |
||||
is_expected.to be_json_eql(0.to_json).at_path('projects/0/level') |
||||
is_expected.to be_json_eql(1.to_json).at_path('projects/1/level') |
||||
is_expected.to be_json_eql(0.to_json).at_path('projects/2/level') |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue