dorsale 3.14.3 → 3.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Rakefile +2 -0
- data/app/pdfs/dorsale/application_pdf.rb +11 -1
- data/app/pdfs/dorsale/expense_gun/expense_pdf.rb +75 -0
- data/app/views/dorsale/expense_gun/expenses/_show_actions.html.slim +2 -0
- data/app/views/dorsale/expense_gun/expenses/show.pdf.ruby +3 -0
- data/lib/dorsale/version.rb +1 -1
- metadata +125 -358
- data/features/access.feature +0 -17
- data/features/billing_machine_invoices.feature +0 -261
- data/features/billing_machine_multiple_vat.feature +0 -53
- data/features/billing_machine_payment_terms.feature +0 -19
- data/features/billing_machine_quotations.feature +0 -193
- data/features/customer_vault_activity_types.feature +0 -19
- data/features/customer_vault_corporations.feature +0 -95
- data/features/customer_vault_filters.feature +0 -14
- data/features/customer_vault_individuals.feature +0 -35
- data/features/customer_vault_invoices.feature +0 -10
- data/features/customer_vault_links.feature +0 -54
- data/features/customer_vault_origins.feature +0 -19
- data/features/customer_vault_people.feature +0 -25
- data/features/customer_vault_search.feature +0 -22
- data/features/customer_vault_tasks.feature +0 -35
- data/features/expense_gun_categories.feature +0 -19
- data/features/expense_gun_expenses.feature +0 -60
- data/features/flyboy_task_comments.feature +0 -21
- data/features/flyboy_tasks.feature +0 -122
- data/features/flyboy_tasks_summary.feature +0 -22
- data/features/step_definitions/access_steps.rb +0 -15
- data/features/step_definitions/alexandrie_steps.rb +0 -25
- data/features/step_definitions/billing_machine_invoices_steps.rb +0 -377
- data/features/step_definitions/billing_machine_multiple_vat.rb +0 -19
- data/features/step_definitions/billing_machine_payment_terms_steps.rb +0 -42
- data/features/step_definitions/billing_machine_quotations_steps.rb +0 -248
- data/features/step_definitions/common_steps.rb +0 -91
- data/features/step_definitions/customer_vault_activity_types_steps.rb +0 -42
- data/features/step_definitions/customer_vault_corporations_steps.rb +0 -218
- data/features/step_definitions/customer_vault_filters_steps.rb +0 -37
- data/features/step_definitions/customer_vault_individuals_steps.rb +0 -67
- data/features/step_definitions/customer_vault_invoices_steps.rb +0 -7
- data/features/step_definitions/customer_vault_links_steps.rb +0 -73
- data/features/step_definitions/customer_vault_origins_steps.rb +0 -42
- data/features/step_definitions/customer_vault_people_steps.rb +0 -26
- data/features/step_definitions/customer_vault_search_steps.rb +0 -48
- data/features/step_definitions/customer_vault_tasks_steps.rb +0 -34
- data/features/step_definitions/expense_gun_categories_steps.rb +0 -50
- data/features/step_definitions/expense_gun_expenses_steps.rb +0 -135
- data/features/step_definitions/flyboy_task_comments_steps.rb +0 -10
- data/features/step_definitions/flyboy_tasks_steps.rb +0 -196
- data/features/step_definitions/tasks_summary_steps.rb +0 -30
- data/features/step_definitions/users_management_step.rb +0 -29
- data/features/support/env.rb +0 -8
- data/features/users_management.feature +0 -18
- data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +0 -145
- data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +0 -153
- data/spec/controllers/dorsale/billing_machine/quotations_controller_spec.rb +0 -24
- data/spec/controllers/dorsale/comments_controller_spec.rb +0 -50
- data/spec/controllers/dorsale/customer_vault/events_controller_spec.rb +0 -42
- data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +0 -129
- data/spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb +0 -45
- data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +0 -40
- data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +0 -349
- data/spec/factories/alexandrie_attachment_types.rb +0 -5
- data/spec/factories/alexandrie_attachments.rb +0 -16
- data/spec/factories/billing_machine_invoice_lines.rb +0 -9
- data/spec/factories/billing_machine_invoices.rb +0 -9
- data/spec/factories/billing_machine_payment_terms.rb +0 -5
- data/spec/factories/billing_machine_quotation_lines.rb +0 -9
- data/spec/factories/billing_machine_quotations.rb +0 -9
- data/spec/factories/customer_vault_activity_types.rb +0 -5
- data/spec/factories/customer_vault_corporations.rb +0 -13
- data/spec/factories/customer_vault_event.rb +0 -13
- data/spec/factories/customer_vault_individuals.rb +0 -17
- data/spec/factories/customer_vault_links.rb +0 -7
- data/spec/factories/customer_vault_origins.rb +0 -5
- data/spec/factories/dorsale_addresses.rb +0 -9
- data/spec/factories/dorsale_comments.rb +0 -7
- data/spec/factories/expense_gun_categories.rb +0 -7
- data/spec/factories/expense_gun_expense_lines.rb +0 -10
- data/spec/factories/expense_gun_expenses.rb +0 -13
- data/spec/factories/flyboy_task_comments.rb +0 -9
- data/spec/factories/flyboy_tasks.rb +0 -8
- data/spec/files/avatar.png +0 -0
- data/spec/files/pdf.pdf +0 -0
- data/spec/mailers/user_mailer_spec.rb +0 -21
- data/spec/models/dorsale/address_spec.rb +0 -46
- data/spec/models/dorsale/alexandrie/attachment_spec.rb +0 -36
- data/spec/models/dorsale/alexandrie/attachment_type_spec.rb +0 -11
- data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +0 -52
- data/spec/models/dorsale/billing_machine/invoice_spec.rb +0 -258
- data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +0 -51
- data/spec/models/dorsale/billing_machine/quotation_spec.rb +0 -213
- data/spec/models/dorsale/billing_machine_spec.rb +0 -57
- data/spec/models/dorsale/comment_spec.rb +0 -24
- data/spec/models/dorsale/customer_vault/activity_type_spec.rb +0 -10
- data/spec/models/dorsale/customer_vault/corporation_spec.rb +0 -33
- data/spec/models/dorsale/customer_vault/event_spec.rb +0 -22
- data/spec/models/dorsale/customer_vault/individual_spec.rb +0 -44
- data/spec/models/dorsale/customer_vault/link_spec.rb +0 -14
- data/spec/models/dorsale/customer_vault/origin_spec.rb +0 -8
- data/spec/models/dorsale/customer_vault/person_spec.rb +0 -112
- data/spec/models/dorsale/email_spec.rb +0 -39
- data/spec/models/dorsale/expense_gun/category_spec.rb +0 -9
- data/spec/models/dorsale/expense_gun/expense_line_spec.rb +0 -59
- data/spec/models/dorsale/expense_gun/expense_spec.rb +0 -176
- data/spec/models/dorsale/flyboy/task_comment_spec.rb +0 -54
- data/spec/models/dorsale/flyboy/task_spec.rb +0 -254
- data/spec/models/dorsale/i18n_spec.rb +0 -30
- data/spec/models/dorsale/users_spec.rb +0 -65
- data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +0 -42
- data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +0 -42
- data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +0 -42
- data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +0 -55
- data/spec/rails_helper.rb +0 -55
- data/spec/routing/dorsale/alexandrie/attachments_routing_spec.rb +0 -32
- data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +0 -67
- data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +0 -67
- data/spec/routing/dorsale/comments_routing_spec.rb +0 -23
- data/spec/routing/dorsale/customer_vault/activity_types_routing_spec.rb +0 -40
- data/spec/routing/dorsale/customer_vault/events_routing_spec.rb +0 -12
- data/spec/routing/dorsale/customer_vault/origins_routing_spec.rb +0 -40
- data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +0 -109
- data/spec/routing/dorsale/expense_gun/expenses_routing_spec.rb +0 -62
- data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +0 -11
- data/spec/routing/dorsale/flyboy/tasks_routing_spec.rb +0 -51
- data/spec/routing/dorsale/users_routing_spec.rb +0 -38
- data/spec/services/dorsale/billing_machine/quotation/copy_spec.rb +0 -55
- data/spec/services/dorsale/billing_machine/quotation/statistics.rb +0 -23
- data/spec/services/dorsale/billing_machine/quotation/to_invoice_spec.rb +0 -46
- data/spec/services/dorsale/expense_gun/expense/copy_spec.rb +0 -83
- data/spec/services/dorsale/flyboy/task/copy_spec.rb +0 -24
- data/spec/services/dorsale/flyboy/task/snoozer_spec.rb +0 -117
- data/spec/spec_helper.rb +0 -86
- data/spec/support/devise.rb +0 -3
- data/spec/support/message_delivery.rb +0 -5
@@ -1,24 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Dorsale::BillingMachine::QuotationsController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
before(:each) { sign_in(user) }
|
8
|
-
|
9
|
-
describe "#preview" do
|
10
|
-
render_views
|
11
|
-
|
12
|
-
it "should render show" do
|
13
|
-
post :preview
|
14
|
-
expect(response).to render_template(:show)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should not save" do
|
18
|
-
post :preview
|
19
|
-
@quotation = assigns(:quotation)
|
20
|
-
expect(@quotation).to be_valid
|
21
|
-
expect(@quotation).to_not be_persisted
|
22
|
-
end
|
23
|
-
end # describe "#preview" do
|
24
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Dorsale::CommentsController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
|
8
|
-
before(:each) { sign_in(user) }
|
9
|
-
|
10
|
-
let(:commentable) { create(:customer_vault_corporation) }
|
11
|
-
let(:valid_params) {
|
12
|
-
{
|
13
|
-
:comment => {
|
14
|
-
:commentable_id => commentable.id,
|
15
|
-
:commentable_type => commentable.class.to_s,
|
16
|
-
:text => "Hello",
|
17
|
-
},
|
18
|
-
:back_url => "/",
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
describe "create" do
|
23
|
-
it "should create comment" do
|
24
|
-
post :create, params: valid_params
|
25
|
-
expect(assigns(:comment)).to be_persisted
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should redirect to back_url" do
|
29
|
-
post :create, params: valid_params
|
30
|
-
expect(response).to redirect_to("/")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "update" do
|
35
|
-
it "should update comment text" do
|
36
|
-
comment = create(:dorsale_comment)
|
37
|
-
patch :update, params: {id: comment, comment: {text: "New-comment-text"}, back_url: "/"}
|
38
|
-
expect(response).to redirect_to("/")
|
39
|
-
expect(comment.reload.text).to eq "New-comment-text"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "destroy" do
|
44
|
-
it "should destroy comment" do
|
45
|
-
comment = create(:dorsale_comment)
|
46
|
-
delete :destroy, params: {id: comment, back_url: "/"}
|
47
|
-
expect(response).to redirect_to("/")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe ::Dorsale::CustomerVault::EventsController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
|
8
|
-
before(:each) { sign_in(user) }
|
9
|
-
|
10
|
-
describe "#filters" do
|
11
|
-
before do
|
12
|
-
@event1 = create(:customer_vault_event, action: "create")
|
13
|
-
@event2 = create(:customer_vault_event, action: "update")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should filter by event_action" do
|
17
|
-
cookies[:filters] = {event_action: "create"}.to_json
|
18
|
-
get :index
|
19
|
-
expect(assigns(:events)).to eq [@event1]
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should filter by multiple event_action" do
|
23
|
-
cookies[:filters] = {event_action: "create update"}.to_json
|
24
|
-
get :index
|
25
|
-
expect(assigns(:events)).to contain_exactly(@event1, @event2)
|
26
|
-
end
|
27
|
-
end # describe "#filters"
|
28
|
-
|
29
|
-
describe "#index" do
|
30
|
-
before do
|
31
|
-
@corporation1 = create(:customer_vault_corporation)
|
32
|
-
@corporation2 = create(:customer_vault_corporation)
|
33
|
-
@event1 = create(:customer_vault_event, person: @corporation1, created_at: "2012-02-15")
|
34
|
-
@event2 = create(:customer_vault_event, person: @corporation2, created_at: "2012-03-15")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should assigns all events ordered by created_at DESC" do
|
38
|
-
get :index
|
39
|
-
expect(assigns(:events)).to eq [@event2, @event1]
|
40
|
-
end
|
41
|
-
end # describe "#index"
|
42
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
RSpec.describe ::Dorsale::CustomerVault::PeopleController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
|
8
|
-
before(:each) { sign_in(user) }
|
9
|
-
|
10
|
-
describe "#corporations" do
|
11
|
-
render_views
|
12
|
-
|
13
|
-
it "should return corporations only" do
|
14
|
-
corporation = create(:customer_vault_corporation)
|
15
|
-
individual = create(:customer_vault_individual)
|
16
|
-
get :corporations
|
17
|
-
expect(assigns :people).to eq [corporation]
|
18
|
-
end
|
19
|
-
end # describe "#corporations"
|
20
|
-
|
21
|
-
describe "#individuals" do
|
22
|
-
render_views
|
23
|
-
|
24
|
-
it "should return individuals only" do
|
25
|
-
corporation = create(:customer_vault_corporation)
|
26
|
-
individual = create(:customer_vault_individual)
|
27
|
-
get :individuals
|
28
|
-
expect(assigns :people).to eq [individual]
|
29
|
-
end
|
30
|
-
end # describe "#individuals"
|
31
|
-
|
32
|
-
describe "#list" do
|
33
|
-
describe "sorting" do
|
34
|
-
it "should sort people by name by default" do
|
35
|
-
abc = create(:customer_vault_corporation, name: "Abc Corp")
|
36
|
-
bob = create(:customer_vault_individual, last_name: "Bob")
|
37
|
-
alice = create(:customer_vault_individual, last_name: "Alice")
|
38
|
-
zorg = create(:customer_vault_corporation, name: "Zorg Corp")
|
39
|
-
|
40
|
-
get :index
|
41
|
-
|
42
|
-
expect(assigns(:people)).to eq([abc, alice, bob, zorg])
|
43
|
-
end
|
44
|
-
end # describe "sorting"
|
45
|
-
|
46
|
-
describe "filters" do
|
47
|
-
it "should filter by person type" do
|
48
|
-
individual = create(:customer_vault_individual)
|
49
|
-
corporation = create(:customer_vault_corporation)
|
50
|
-
|
51
|
-
cookies[:filters] = {person_type: "Dorsale::CustomerVault::Individual"}.to_json
|
52
|
-
|
53
|
-
get :index
|
54
|
-
|
55
|
-
expect(assigns(:people)).to eq [individual]
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should filter by person origin" do
|
59
|
-
origin = create(:customer_vault_origin)
|
60
|
-
individual1 = create(:customer_vault_individual, origin: origin)
|
61
|
-
individual2 = create(:customer_vault_individual)
|
62
|
-
|
63
|
-
cookies[:filters] = {person_origin: origin.id}.to_json
|
64
|
-
get :index
|
65
|
-
|
66
|
-
expect(assigns(:people)).to eq [individual1]
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should filter by person activity_type" do
|
70
|
-
activity_type = create(:customer_vault_activity_type)
|
71
|
-
corporation1 = create(:customer_vault_corporation, activity_type: activity_type)
|
72
|
-
corporation2 = create(:customer_vault_corporation)
|
73
|
-
|
74
|
-
cookies[:filters] = {person_activity: activity_type.id}.to_json
|
75
|
-
get :index
|
76
|
-
|
77
|
-
expect(assigns(:people)).to eq [corporation1]
|
78
|
-
end
|
79
|
-
end # describe "filters"
|
80
|
-
|
81
|
-
describe "search" do
|
82
|
-
it "search should ignore filters" do
|
83
|
-
corporation1 = create(:customer_vault_corporation, tag_list: "abc", name: "aaa")
|
84
|
-
corporation2 = create(:customer_vault_corporation, tag_list: "xyz", name: "bbb")
|
85
|
-
@request.cookies["filters"] = {tags: ["abc"]}.to_json
|
86
|
-
get :index, params: {q: "bbb"}
|
87
|
-
expect(assigns(:people)).to eq [corporation2]
|
88
|
-
end
|
89
|
-
end # describe "search"
|
90
|
-
end # describe "#list"
|
91
|
-
|
92
|
-
describe "#create" do
|
93
|
-
before do
|
94
|
-
allow_any_instance_of(Dorsale::CustomerVault::PeopleController).to \
|
95
|
-
receive(:model) { Dorsale::CustomerVault::Corporation }
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should generate an event" do
|
99
|
-
expect {
|
100
|
-
post :create, params: {person: {corporation_name: "agilidée"}}
|
101
|
-
}.to change(Dorsale::CustomerVault::Event, :count).by(1)
|
102
|
-
|
103
|
-
event = Dorsale::CustomerVault::Event.last_created
|
104
|
-
expect(event.author).to eq user
|
105
|
-
expect(event.person).to eq Dorsale::CustomerVault::Person.last_created
|
106
|
-
expect(event.action).to eq "create"
|
107
|
-
end
|
108
|
-
end # describe "#create"
|
109
|
-
|
110
|
-
describe "#update" do
|
111
|
-
before do
|
112
|
-
allow_any_instance_of(Dorsale::CustomerVault::PeopleController).to \
|
113
|
-
receive(:model) { Dorsale::CustomerVault::Corporation }
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should generate an event" do
|
117
|
-
corporation = create(:customer_vault_corporation)
|
118
|
-
|
119
|
-
expect {
|
120
|
-
patch :update, params: {id: corporation, person: {corporation_name: "agilidée"}}
|
121
|
-
}.to change(Dorsale::CustomerVault::Event, :count).by(1)
|
122
|
-
|
123
|
-
event = Dorsale::CustomerVault::Event.last_created
|
124
|
-
expect(event.author).to eq user
|
125
|
-
expect(event.person).to eq corporation
|
126
|
-
expect(event.action).to eq "update"
|
127
|
-
end
|
128
|
-
end # describe "#update"
|
129
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
RSpec.describe ::Dorsale::ExpenseGun::ExpensesController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
let(:user) { create(:user) }
|
6
|
-
before(:each) { sign_in(user) }
|
7
|
-
|
8
|
-
describe "#index" do
|
9
|
-
describe "filters" do
|
10
|
-
render_views
|
11
|
-
|
12
|
-
it "should filter by state" do
|
13
|
-
expense1 = create(:expense_gun_expense, state: "accepted")
|
14
|
-
expense2 = create(:expense_gun_expense, state: "refused")
|
15
|
-
|
16
|
-
cookies[:filters] = {expense_state: "accepted"}.to_json
|
17
|
-
get :index
|
18
|
-
|
19
|
-
expect(assigns :expenses).to eq [expense1]
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should filter by user" do
|
23
|
-
user1 = create(:user)
|
24
|
-
user2 = create(:user)
|
25
|
-
expense1 = create(:expense_gun_expense, user: user1)
|
26
|
-
expense2 = create(:expense_gun_expense, user: user2)
|
27
|
-
|
28
|
-
cookies[:filters] = {expense_user_id: user1.id}.to_json
|
29
|
-
get :index
|
30
|
-
|
31
|
-
expect(assigns :expenses).to eq [expense1]
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should assigns only users having expenses" do
|
35
|
-
user1 = create(:user)
|
36
|
-
user2 = create(:user)
|
37
|
-
expense2 = create(:expense_gun_expense, user: user2)
|
38
|
-
|
39
|
-
get :index
|
40
|
-
|
41
|
-
expect(assigns :users).to eq [user2]
|
42
|
-
end
|
43
|
-
end # describe "filters"
|
44
|
-
end # describe "#index"
|
45
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Dorsale::Flyboy::TaskCommentsController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
|
8
|
-
before(:each) { sign_in(user) }
|
9
|
-
|
10
|
-
let(:task) { create(:flyboy_task) }
|
11
|
-
let(:task_comment) { create(:flyboy_task_comment, task: task) }
|
12
|
-
|
13
|
-
describe "#create" do
|
14
|
-
let(:valid_params) { {task_id: task.id, task_comment: task_comment.attributes} }
|
15
|
-
|
16
|
-
it "should create the task_comment" do
|
17
|
-
post :create, params: valid_params
|
18
|
-
expect(assigns(:task_comment).persisted?).to be true
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should redirect to referrer if referrer is task" do
|
22
|
-
url = flyboy_task_path(task) + "?sort=xxx"
|
23
|
-
request.env["HTTP_REFERER"] = url
|
24
|
-
post :create, params: valid_params
|
25
|
-
expect(response).to redirect_to url
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should redirect to task if referrer is not task" do
|
29
|
-
url = "/anywhere"
|
30
|
-
request.env["HTTP_REFERER"] = url
|
31
|
-
post :create, params: valid_params
|
32
|
-
expect(response).to redirect_to flyboy_task_path(task)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should redirect to task if referrer is missing" do
|
36
|
-
post :create, params: valid_params
|
37
|
-
expect(response).to redirect_to flyboy_task_path(task)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,349 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Dorsale::Flyboy::TasksController, type: :controller do
|
4
|
-
routes { Dorsale::Engine.routes }
|
5
|
-
|
6
|
-
let(:user) { create(:user) }
|
7
|
-
|
8
|
-
before(:each) { sign_in(user) }
|
9
|
-
|
10
|
-
let!(:task) {
|
11
|
-
create(:flyboy_task, done: false)
|
12
|
-
}
|
13
|
-
|
14
|
-
let(:valid_attributes) {
|
15
|
-
{
|
16
|
-
:name => "New Task",
|
17
|
-
:term => Date.current,
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
describe "#complete" do
|
22
|
-
before(:each) do
|
23
|
-
request.env["HTTP_REFERER"] = "where_i_came_from"
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should mark the task as done" do
|
27
|
-
patch :complete, params: {id: task.id}
|
28
|
-
expect(task.reload.done).to be true
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should set progress to 100" do
|
32
|
-
patch :complete, params: {id: task.id}
|
33
|
-
expect(task.reload.progress).to eq(100)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should add a task_comment" do
|
37
|
-
count = task.comments.count
|
38
|
-
patch :complete, params: {id: task.id}
|
39
|
-
expect(task.reload.comments.count).to eq(count+1)
|
40
|
-
expect(task.comments.last.progress).to eq(100)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should redirect to the referer page" do
|
44
|
-
patch :complete, params: {id: task.id}
|
45
|
-
expect(response).to redirect_to "where_i_came_from"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "GET index" do
|
50
|
-
context "when applying filter" do
|
51
|
-
before do
|
52
|
-
Dorsale::Flyboy::Task.destroy_all
|
53
|
-
@task1 = create(:flyboy_task, done: true)
|
54
|
-
@task2 = create(:flyboy_task, done: false)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should display both when not filtered" do
|
58
|
-
get :index
|
59
|
-
expect(assigns(:tasks).to_a.sort).to eq [@task1, @task2].sort
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should filter by status closed" do
|
63
|
-
cookies["filters"] = {"fb_state" => "done"}.to_json
|
64
|
-
get :index
|
65
|
-
expect(assigns(:tasks).to_a).to eq [@task1]
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should filter by status opened" do
|
69
|
-
cookies["filters"] = {"fb_state" => "undone"}.to_json
|
70
|
-
get :index
|
71
|
-
expect(assigns(:tasks).to_a).to eq [@task2]
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should filter by tags" do
|
75
|
-
task1 = create(:flyboy_task, tag_list: "abc")
|
76
|
-
task2 = create(:flyboy_task, tag_list: "xyz")
|
77
|
-
cookies["filters"] = {fb_tags: ["abc"]}.to_json
|
78
|
-
get :index
|
79
|
-
expect(assigns(:tasks)).to eq [task1]
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "when sorting" do
|
84
|
-
before do
|
85
|
-
Dorsale::Flyboy::Task.destroy_all
|
86
|
-
@corporation1 = create(:customer_vault_corporation, name: "Abc")
|
87
|
-
@corporation2 = create(:customer_vault_corporation, name: "dEF")
|
88
|
-
@corporation3 = create(:customer_vault_corporation, name: "xyz")
|
89
|
-
|
90
|
-
@task1 = create(:flyboy_task,
|
91
|
-
:taskable => @corporation1,
|
92
|
-
:name => "Abc",
|
93
|
-
:progress => 100,
|
94
|
-
:term => "21/12/2012",
|
95
|
-
:reminder_type => "custom",
|
96
|
-
:reminder_date => "21/12/2012",
|
97
|
-
:tag_list => "aaa",
|
98
|
-
)
|
99
|
-
|
100
|
-
@task2 = create(:flyboy_task,
|
101
|
-
:taskable => @corporation2,
|
102
|
-
:name => "dEF",
|
103
|
-
:progress => 0,
|
104
|
-
:term => "23/12/2012",
|
105
|
-
:reminder_type => "custom",
|
106
|
-
:reminder_date => "23/12/2012",
|
107
|
-
:tag_list => "bbb",
|
108
|
-
)
|
109
|
-
|
110
|
-
@task3 = create(:flyboy_task,
|
111
|
-
:taskable => @corporation3,
|
112
|
-
:name => "xyz",
|
113
|
-
:progress => 35,
|
114
|
-
:term => "22/12/2012",
|
115
|
-
:reminder_type => "custom",
|
116
|
-
:reminder_date => "22/12/2012",
|
117
|
-
:tag_list => "",
|
118
|
-
)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "sorting by taskable asc" do
|
122
|
-
get :index, params: {sort: "taskable"}
|
123
|
-
expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3]
|
124
|
-
end
|
125
|
-
|
126
|
-
it "sorting by taskable desc" do
|
127
|
-
get :index, params: {sort: "-taskable"}
|
128
|
-
expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1]
|
129
|
-
end
|
130
|
-
|
131
|
-
it "sorting by name asc" do
|
132
|
-
get :index, params: {sort: "name"}
|
133
|
-
expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3]
|
134
|
-
end
|
135
|
-
|
136
|
-
it "sorting by name desc" do
|
137
|
-
get :index, params: {sort: "-name"}
|
138
|
-
expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1]
|
139
|
-
end
|
140
|
-
|
141
|
-
it "sorting by progress asc" do
|
142
|
-
get :index, params: {sort: "progress"}
|
143
|
-
expect(assigns(:tasks).to_a).to eq [@task2, @task3, @task1]
|
144
|
-
end
|
145
|
-
|
146
|
-
it "sorting by progress desc" do
|
147
|
-
get :index, params: {sort: "-progress"}
|
148
|
-
expect(assigns(:tasks).to_a).to eq [@task1, @task3, @task2]
|
149
|
-
end
|
150
|
-
|
151
|
-
it "sorting by term asc" do
|
152
|
-
get :index, params: {sort: "term"}
|
153
|
-
expect(assigns(:tasks).to_a).to eq [@task1, @task3, @task2]
|
154
|
-
end
|
155
|
-
|
156
|
-
it "sorting by term desc" do
|
157
|
-
get :index, params: {sort: "-term"}
|
158
|
-
expect(assigns(:tasks).to_a).to eq [@task2, @task3, @task1]
|
159
|
-
end
|
160
|
-
|
161
|
-
it "sorting by tags asc" do
|
162
|
-
get :index, params: {sort: "tags"}
|
163
|
-
expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3]
|
164
|
-
end
|
165
|
-
|
166
|
-
it "sorting by tags desc" do
|
167
|
-
get :index, params: {sort: "-tags"}
|
168
|
-
expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1]
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe "GET show" do
|
174
|
-
it "assigns the requested task as @task" do
|
175
|
-
get :show, params: {:id => task.to_param}
|
176
|
-
expect(assigns(:task)).to eq(task)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "GET edit" do
|
181
|
-
it "assigns the requested task as @task" do
|
182
|
-
get :edit, params: {:id => task.to_param}
|
183
|
-
expect(assigns(:task)).to eq(task)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "POST create" do
|
188
|
-
describe "with valid params" do
|
189
|
-
it "creates a new Task" do
|
190
|
-
expect {
|
191
|
-
post :create, params: {:task => valid_attributes}
|
192
|
-
}.to change(Dorsale::Flyboy::Task, :count).by(1)
|
193
|
-
end
|
194
|
-
|
195
|
-
it "assigns a newly created task as @task" do
|
196
|
-
post :create, params: {:task => valid_attributes}
|
197
|
-
expect(assigns(:task)).to be_a(Dorsale::Flyboy::Task)
|
198
|
-
expect(assigns(:task)).to be_persisted
|
199
|
-
end
|
200
|
-
|
201
|
-
it "redirects to the created task" do
|
202
|
-
post :create, params: {:task => valid_attributes}
|
203
|
-
expect(response).to redirect_to Dorsale::Flyboy::Task.last_created
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should send a mail to the owner" do
|
207
|
-
owner = create(:user)
|
208
|
-
ActionMailer::Base.deliveries.clear
|
209
|
-
post :create, params: {:task => valid_attributes.merge(owner_id: owner.id)}
|
210
|
-
expect(ActionMailer::Base.deliveries.count).to eq 1
|
211
|
-
email = ActionMailer::Base.deliveries.last
|
212
|
-
expect(email.to).to include owner.email
|
213
|
-
expect(email.subject).to include "New Task"
|
214
|
-
expect(email.body).to include @user.to_s
|
215
|
-
expect(email.body).to include "http://"
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should not send a mail if there is no owner" do
|
219
|
-
ActionMailer::Base.deliveries.clear
|
220
|
-
post :create, params: {:task => valid_attributes}
|
221
|
-
expect(ActionMailer::Base.deliveries.count).to eq 0
|
222
|
-
end
|
223
|
-
|
224
|
-
it "should not send a mail if the author is the owner" do
|
225
|
-
ActionMailer::Base.deliveries.clear
|
226
|
-
post :create, params: {:task => valid_attributes}
|
227
|
-
expect(ActionMailer::Base.deliveries.count).to eq 0
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "PUT update" do
|
233
|
-
let!(:task) { create(:flyboy_task) }
|
234
|
-
|
235
|
-
describe "with valid params" do
|
236
|
-
it "assigns the requested task as @task" do
|
237
|
-
patch :update, params: {id: task, task: valid_attributes}
|
238
|
-
expect(assigns(:task)).to eq(task)
|
239
|
-
end
|
240
|
-
|
241
|
-
it "redirects to the task" do
|
242
|
-
patch :update, params: {id: task, task: valid_attributes}
|
243
|
-
expect(response).to redirect_to(task)
|
244
|
-
end
|
245
|
-
|
246
|
-
it "should create term changed comment" do
|
247
|
-
valid_attributes[:term] = task.term - 3.days
|
248
|
-
|
249
|
-
expect {
|
250
|
-
patch :update, params: {id: task, task: valid_attributes}
|
251
|
-
}.to change(Dorsale::Flyboy::TaskComment, :count).by(1)
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "with invalid params" do
|
256
|
-
it "assigns the task as @task" do
|
257
|
-
patch :update, params: {id: task, task: {name: nil}}
|
258
|
-
expect(assigns(:task)).to eq(task)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "DELETE destroy" do
|
264
|
-
it "destroys the requested task" do
|
265
|
-
task = create(:flyboy_task)
|
266
|
-
expect {
|
267
|
-
delete :destroy, params: {:id => task.to_param}
|
268
|
-
}.to change(Dorsale::Flyboy::Task, :count).by(-1)
|
269
|
-
end
|
270
|
-
|
271
|
-
it "redirects to the tasks list" do
|
272
|
-
task = create(:flyboy_task)
|
273
|
-
delete :destroy, params: {:id => task.to_param}
|
274
|
-
expect(response).to redirect_to(flyboy_tasks_path)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "snooze" do
|
279
|
-
it "should redirect to the task list to refresh it" do
|
280
|
-
task = create(:flyboy_task, term: 3.days.ago)
|
281
|
-
patch :snooze, params: {:id => task.to_param}
|
282
|
-
expect(response).to redirect_to(task)
|
283
|
-
end
|
284
|
-
|
285
|
-
it "is expected to create a task comment" do
|
286
|
-
task = create(:flyboy_task, term: 3.days.ago)
|
287
|
-
expect {
|
288
|
-
patch :snooze, params: {:id => task.to_param}
|
289
|
-
}.to change(Dorsale::Flyboy::TaskComment, :count).by(1)
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe "summary" do
|
294
|
-
let(:summary_user) { create :user }
|
295
|
-
|
296
|
-
before(:each) do
|
297
|
-
Dorsale::Flyboy::Task.destroy_all
|
298
|
-
sign_in summary_user
|
299
|
-
|
300
|
-
Timecop.freeze "2016-03-09 15:00:00"
|
301
|
-
@delayed_task = create(:flyboy_task, term: Date.yesterday) # tuesday
|
302
|
-
@today_task = create(:flyboy_task, term: Date.current) # thursday - today
|
303
|
-
@tomorrow_task = create(:flyboy_task, term: Date.tomorrow) # wednesday
|
304
|
-
@this_week_task = create(:flyboy_task, term: Date.parse("2016-03-12")) # sunday
|
305
|
-
@next_week_task = create(:flyboy_task, term: Date.parse("2016-03-14")) # monday next week
|
306
|
-
@next_next_week_task = create(:flyboy_task, term: Date.parse("2016-03-22")) # tuesday 2 weeks
|
307
|
-
end
|
308
|
-
|
309
|
-
it "should not assign tasks when owner is an other person" do
|
310
|
-
other_user = create(:user)
|
311
|
-
Dorsale::Flyboy::Task.update_all(owner_id: other_user.id)
|
312
|
-
|
313
|
-
Timecop.freeze "2016-03-09 15:00:00"
|
314
|
-
controller.setup_tasks_summary
|
315
|
-
expect(assigns(:delayed_tasks)).to eq []
|
316
|
-
expect(assigns(:today_tasks)).to eq []
|
317
|
-
expect(assigns(:tomorrow_tasks)).to eq []
|
318
|
-
expect(assigns(:this_week_tasks)).to eq []
|
319
|
-
expect(assigns(:next_week_tasks)).to eq []
|
320
|
-
expect(assigns(:next_next_week_tasks)).to eq []
|
321
|
-
end
|
322
|
-
|
323
|
-
it "should assign tasks when owner is nil" do
|
324
|
-
Dorsale::Flyboy::Task.update_all(owner_id: nil)
|
325
|
-
|
326
|
-
Timecop.freeze "2016-03-09 15:00:00"
|
327
|
-
controller.setup_tasks_summary
|
328
|
-
expect(assigns(:delayed_tasks)).to eq [@delayed_task]
|
329
|
-
expect(assigns(:today_tasks)).to eq [@today_task]
|
330
|
-
expect(assigns(:tomorrow_tasks)).to eq [@tomorrow_task]
|
331
|
-
expect(assigns(:this_week_tasks)).to eq [@this_week_task]
|
332
|
-
expect(assigns(:next_week_tasks)).to eq [@next_week_task]
|
333
|
-
expect(assigns(:next_next_week_tasks)).to eq [@next_next_week_task]
|
334
|
-
end
|
335
|
-
|
336
|
-
it "should assign tasks when owner is me" do
|
337
|
-
Dorsale::Flyboy::Task.update_all(owner_id: summary_user.id)
|
338
|
-
|
339
|
-
Timecop.freeze "2016-03-09 15:00:00"
|
340
|
-
controller.setup_tasks_summary
|
341
|
-
expect(assigns(:delayed_tasks)).to eq [@delayed_task]
|
342
|
-
expect(assigns(:today_tasks)).to eq [@today_task]
|
343
|
-
expect(assigns(:tomorrow_tasks)).to eq [@tomorrow_task]
|
344
|
-
expect(assigns(:this_week_tasks)).to eq [@this_week_task]
|
345
|
-
expect(assigns(:next_week_tasks)).to eq [@next_week_task]
|
346
|
-
expect(assigns(:next_next_week_tasks)).to eq [@next_next_week_task]
|
347
|
-
end
|
348
|
-
end # describe summary
|
349
|
-
end
|