Initial Redmine tooling and local plugin forks
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
address_1:
|
||||
id: 1
|
||||
city: New York
|
||||
country_code: US
|
||||
region: NY
|
||||
street1: "1443A 5th Ave"
|
||||
postcode: 10035
|
||||
addressable_type: Contact
|
||||
addressable_id: 2
|
||||
|
||||
address_2:
|
||||
id: 2
|
||||
city: Moscow
|
||||
country_code: RU
|
||||
street1: "Bolshaya Yakimanka, 2"
|
||||
postcode: 103234
|
||||
addressable_type: Contact
|
||||
addressable_id: 3
|
||||
@@ -0,0 +1,47 @@
|
||||
contact_one:
|
||||
id: 1
|
||||
first_name: Ivan
|
||||
last_name: Ivanov
|
||||
middle_name: Ivanovich
|
||||
company: Domoway
|
||||
email: ivan@mail.com
|
||||
website: http://ivanov.com
|
||||
|
||||
contact_two:
|
||||
id: 2
|
||||
first_name: Marat
|
||||
last_name: Aminov
|
||||
middle_name: Ivanovich
|
||||
job_title: CEO
|
||||
company: Domoway
|
||||
email: "marat@mail.ru, marat@mail.com"
|
||||
skype_name: marat_aminov
|
||||
background: Marat is a famous writer an reader
|
||||
|
||||
contact_three:
|
||||
id: 3
|
||||
first_name: Domoway
|
||||
job_title: web project
|
||||
is_company: true
|
||||
email: "domoway@mail.ru"
|
||||
background: Realy cool project
|
||||
website: domoway.ru
|
||||
|
||||
contact_four:
|
||||
id: 4
|
||||
first_name: John
|
||||
last_name: Smith
|
||||
job_title: CEO
|
||||
is_company: false
|
||||
email: "jsmith@somenet.foo"
|
||||
background: "Contact with user realation\nUser id = 2"
|
||||
website: domoway.ru
|
||||
|
||||
contact_five:
|
||||
id: 5
|
||||
first_name: 'My company'
|
||||
job_title: web project
|
||||
is_company: true
|
||||
email: "company@mail.ru"
|
||||
background: Realy cool project
|
||||
website: company.ru
|
||||
@@ -0,0 +1,10 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
one:
|
||||
issue_id: 1
|
||||
contact_id: 1
|
||||
two:
|
||||
issue_id: 2
|
||||
contact_id: 2
|
||||
three:
|
||||
issue_id: 1
|
||||
contact_id: 2
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <contacts@somenet.foo>
|
||||
Subject: New note from forwarded html email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: multipart/alternative;
|
||||
boundary="Apple-Mail=_A369DB54-0A71-4F82-915A-340994835550"
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
|
||||
--Apple-Mail=_A369DB54-0A71-4F82-915A-340994835550
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/plain;
|
||||
charset=utf-8
|
||||
|
||||
|
||||
|
||||
Begin forwarded message:
|
||||
|
||||
> From: Marat Aminov <marat@mail.com>
|
||||
> Subject: Lorem ipsum dolor sit amet, consectetuer
|
||||
> Date: Wed, 5 Oct 2011 00:16:18
|
||||
> To: admin@somenet.foo
|
||||
>=20
|
||||
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas =
|
||||
imperdiet=20
|
||||
> turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus=20=
|
||||
|
||||
> blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent =
|
||||
taciti=20
|
||||
> sociosqu ad litora torquent per conubia nostra, per inceptos =
|
||||
himenaeos. In=20
|
||||
> in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in =
|
||||
dolor. Cras=20
|
||||
> sagittis odio eu lacus.=20
|
||||
>=20
|
||||
> Aliquam sem tortor, consequat sit amet, vestibulum id, iaculis at, =
|
||||
lectus.=20
|
||||
> Fusce tortor libero, congue ut, euismod nec, luctus=20
|
||||
>=20
|
||||
> eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, =
|
||||
tristique=20
|
||||
> sed, mauris. Pellentesque habitant morbi tristique senectus et netus =
|
||||
et=20
|
||||
> malesuada fames ac turpis egestas. Quisque sit amet libero. In hac =
|
||||
habitasse=20
|
||||
> platea dictumst.
|
||||
>=20
|
||||
> Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque=20=
|
||||
|
||||
> sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed =
|
||||
lorem.=20
|
||||
> Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum =
|
||||
et,=20
|
||||
> dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat =
|
||||
sed,=20
|
||||
> massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo=20=
|
||||
|
||||
> pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
|
||||
--Apple-Mail=_A369DB54-0A71-4F82-915A-340994835550
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-Type: text/html;
|
||||
charset=utf-8
|
||||
|
||||
<html><head></head><body style=3D"word-wrap: break-word; =
|
||||
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
|
||||
"><br><div><br><div>Begin forwarded message:</div><br =
|
||||
class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div =
|
||||
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
|
||||
margin-left: 0px;"><span style=3D"font-family:'Helvetica'; =
|
||||
font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>From: </b></span><span =
|
||||
style=3D"font-family:'Helvetica'; font-size:medium;">Marat Aminov <<a =
|
||||
href=3D"mailto:ivan@mail.com">marat@mail.com</a>><br></span></div><div =
|
||||
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
|
||||
margin-left: 0px;"><span style=3D"font-family:'Helvetica'; =
|
||||
font-size:medium; color:rgba(0, 0, 0, 1.0);"><b>Subject: =
|
||||
</b></span><span style=3D"font-family:'Helvetica'; =
|
||||
font-size:medium;"><b>Lorem ipsum dolor sit amet, =
|
||||
consectetuer</b><br></span></div><div style=3D"margin-top: 0px; =
|
||||
margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span =
|
||||
style=3D"font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, =
|
||||
1.0);"><b>Date: </b></span><span style=3D"font-family:'Helvetica'; =
|
||||
font-size:medium;">Wed, 5 Oct 2011 00:16:18<br></span></div><div style=3D"margin-top: =
|
||||
0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span =
|
||||
style=3D"font-family:'Helvetica'; font-size:medium; color:rgba(0, 0, 0, =
|
||||
1.0);"><b>To: </b></span><span style=3D"font-family:'Helvetica'; =
|
||||
font-size:medium;"><a =
|
||||
href=3D"mailto:admin@somenet.foo">admin@somenet.foo</a><br></span></div><b=
|
||||
r><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
|
||||
-webkit-line-break: after-white-space; "><div><b>Lorem</b> ipsum dolor =
|
||||
sit amet, consectetuer adipiscing elit. Maecenas =
|
||||
imperdiet </div><div>turpis et odio. Integer eget pede vel dolor =
|
||||
euismod varius. Phasellus </div><div>blandit eleifend augue. =
|
||||
<b>Nulla</b> facilisi. Duis id diam. Class aptent =
|
||||
taciti </div><div>sociosqu ad litora torquent per conubia nostra, =
|
||||
per inceptos himenaeos. In </div><div>in urna sed tellus aliquet =
|
||||
lobortis. Morbi scelerisque tortor in dolor. =
|
||||
Cras </div><div>sagittis odio eu =
|
||||
lacus. </div><div><br></div><div><ul =
|
||||
class=3D"MailOutline"><li>Aliquam sem tortor, consequat sit amet, =
|
||||
vestibulum id, iaculis at, lectus. </li><li>Fusce tortor =
|
||||
libero, congue ut, euismod nec, =
|
||||
luctus </li></ul><div><br></div></div><div>eget, eros. Pellentesque =
|
||||
tortor enim, feugiat in, dignissim eget, tristique </div><div>sed, =
|
||||
mauris. Pellentesque habitant morbi tristique senectus et netus =
|
||||
et </div><div>malesuada fames ac turpis egestas. Quisque sit amet =
|
||||
libero. In hac habitasse </div><div>platea =
|
||||
dictumst.</div><div><br></div><div>Nulla et nunc. Duis pede. Donec et =
|
||||
ipsum. Nam ut dui tincidunt neque </div><div>sollicitudin iaculis. =
|
||||
Duis vitae dolor. Vestibulum eget massa. Sed =
|
||||
lorem. </div><div>Nullam volutpat cursus erat. Cras felis dolor, =
|
||||
lacinia quis, rutrum et, </div><div>dictum et, ligula. Sed erat =
|
||||
nibh, gravida in, accumsan non, placerat sed, </div><div>massa. Sed =
|
||||
sodales, ante fermentum ultricies sollicitudin, massa =
|
||||
leo </div><div>pulvinar dui, a gravida orci mi eget odio. Nunc a =
|
||||
lacus.</div></div></blockquote></div><br></body></html>=
|
||||
|
||||
--Apple-Mail=_A369DB54-0A71-4F82-915A-340994835550--
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <redmine@somenet.foo>
|
||||
Subject: New note from forwarded email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
|
||||
---- Original message ----
|
||||
> From: "Marat Aminov" marat@mail.ru
|
||||
> To: "Ivan Ivanov" contacts@somenet.foo
|
||||
> Date: Sun, 26 Jun 2011 12:28:07 +0200
|
||||
> Subject: Test subject
|
||||
|
||||
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
> turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
> blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
> sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
> in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
> sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
> id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
> eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
> sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
> malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
> platea dictumst.
|
||||
>
|
||||
> Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
> sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
> Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
> dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
> massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
> pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
>
|
||||
> Project: onlinestore
|
||||
> Tracker: Feature Request
|
||||
> category: stock management
|
||||
> priority: URGENT
|
||||
>
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <contacts+d1@somenet.foo>
|
||||
Bcc: <contacts+c2@somenet.foo>
|
||||
Subject: New note from email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
@@ -0,0 +1,44 @@
|
||||
Return-Path: <rhill@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <rhill@somenet.foo>
|
||||
To: <ivan@mail.com>
|
||||
Bcc: <contacts@somenet.foo>
|
||||
Subject: New note from email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
Project: onlinestore
|
||||
Tracker: Feature Request
|
||||
category: stock management
|
||||
priority: URGENT
|
||||
@@ -0,0 +1,44 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <ivan@mail.com>
|
||||
Bcc: <contacts@somenet.foo>
|
||||
Subject: New note from email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
Project: onlinestore
|
||||
Tracker: Feature Request
|
||||
category: stock management
|
||||
priority: URGENT
|
||||
@@ -0,0 +1,43 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <contacts+c1@somenet.foo>
|
||||
Subject: New note from email
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
Project: onlinestore
|
||||
Tracker: Feature Request
|
||||
category: stock management
|
||||
priority: URGENT
|
||||
@@ -0,0 +1,44 @@
|
||||
Return-Path: <admin@somenet.foo>
|
||||
Received: from osiris ([127.0.0.1])
|
||||
by OSIRIS
|
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200
|
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris>
|
||||
From: "redMine Admin" <admin@somenet.foo>
|
||||
To: <invan@mail.com>
|
||||
Cc: <contacts+c1@somenet.foo>
|
||||
Subject: New note from email by id in cc
|
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain;
|
||||
format=flowed;
|
||||
charset="iso-8859-1";
|
||||
reply-type=original
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Priority: 3
|
||||
X-MSMail-Priority: Normal
|
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869
|
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet
|
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus
|
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti
|
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In
|
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras
|
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum
|
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus
|
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique
|
||||
sed, mauris. Pellentesque habitant morbi tristique senectus et netus et
|
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse
|
||||
platea dictumst.
|
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque
|
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem.
|
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et,
|
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed,
|
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo
|
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus.
|
||||
|
||||
Project: onlinestore
|
||||
Tracker: Feature Request
|
||||
category: stock management
|
||||
priority: URGENT
|
||||
@@ -0,0 +1,19 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
contact_project_one:
|
||||
project_id: 1
|
||||
contact_id: 1
|
||||
contact_project_two:
|
||||
project_id: 1
|
||||
contact_id: 2
|
||||
contact_project_three:
|
||||
project_id: 1
|
||||
contact_id: 3
|
||||
contact_project_0004:
|
||||
project_id: 2
|
||||
contact_id: 1
|
||||
contact_project_0005:
|
||||
project_id: 1
|
||||
contact_id: 4
|
||||
contact_project_0006:
|
||||
project_id: 1
|
||||
contact_id: 5
|
||||
@@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
contacts_setting_001:
|
||||
name: "redmine_contacts_string_setting"
|
||||
value: "String value"
|
||||
project_id: 1
|
||||
contacts_setting_002:
|
||||
name: "redmine_contacts_boolean_setting"
|
||||
value: 1
|
||||
project_id: 1
|
||||
contacts_setting_003:
|
||||
name: "redmine_contacts_float_setting"
|
||||
value: "10.3"
|
||||
project_id: 1
|
||||
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
one:
|
||||
id: 1
|
||||
name: Design
|
||||
project_id: 1
|
||||
two:
|
||||
id: 2
|
||||
name: Developing
|
||||
project_id: 1
|
||||
@@ -0,0 +1,27 @@
|
||||
deal_process_001:
|
||||
deal_id: 1
|
||||
old_value: 1
|
||||
value: 2
|
||||
author_id: 1
|
||||
created_at: "<%= (Time.now - 4.days).to_s(:db) %>"
|
||||
|
||||
deal_process_002:
|
||||
deal_id: 2
|
||||
old_value: 2
|
||||
value: 1
|
||||
author_id: 2
|
||||
created_at: "<%= (Time.now - 2.days).to_s(:db) %>"
|
||||
|
||||
deal_process_003:
|
||||
deal_id: 1
|
||||
old_value: 2
|
||||
value: 3
|
||||
author_id: 1
|
||||
created_at: "<%= (Time.now - 1.day).to_s(:db) %>"
|
||||
|
||||
deal_process_004:
|
||||
deal_id: 2
|
||||
old_value: 1
|
||||
value: 3
|
||||
author_id: 2
|
||||
created_at: "<%= Time.now.to_s(:db) %>"
|
||||
@@ -0,0 +1,34 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
new:
|
||||
id: 1
|
||||
name: Pending
|
||||
color: 11184810
|
||||
is_default: true
|
||||
status_type: 0
|
||||
position: 1
|
||||
won:
|
||||
id: 2
|
||||
name: Won
|
||||
color: 32768
|
||||
is_default: false
|
||||
status_type: 1
|
||||
lost:
|
||||
id: 3
|
||||
name: Lost
|
||||
color: 16711680
|
||||
is_default: false
|
||||
status_type: 2
|
||||
intermediate1:
|
||||
id: 4
|
||||
name: Intermediate 1
|
||||
color: 0
|
||||
is_default: false
|
||||
status_type: 0
|
||||
position: 2
|
||||
intermediate2:
|
||||
id: 5
|
||||
name: Intermediate 2
|
||||
color: 0
|
||||
is_default: false
|
||||
status_type: 0
|
||||
position: 3
|
||||
@@ -0,0 +1,24 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
deal_status_project_001:
|
||||
project_id: 1
|
||||
deal_status_id: 1
|
||||
|
||||
deal_status_project_002:
|
||||
project_id: 1
|
||||
deal_status_id: 2
|
||||
|
||||
deal_status_project_003:
|
||||
project_id: 1
|
||||
deal_status_id: 3
|
||||
|
||||
deal_status_project_004:
|
||||
project_id: 2
|
||||
deal_status_id: 1
|
||||
|
||||
deal_status_project_005:
|
||||
project_id: 2
|
||||
deal_status_id: 2
|
||||
|
||||
deal_status_project_006:
|
||||
project_id: 2
|
||||
deal_status_id: 3
|
||||
@@ -0,0 +1,59 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
deal_001:
|
||||
id: 1
|
||||
name: First deal with contacts
|
||||
contact_id: 1
|
||||
category_id: 1
|
||||
project_id: 1
|
||||
background: Test deal
|
||||
author_id: 1
|
||||
status_id: 1
|
||||
assigned_to_id: 1
|
||||
due_date: "<%= Time.now.to_s(:db) %>"
|
||||
price: 3000
|
||||
|
||||
deal_002:
|
||||
id: 2
|
||||
name: Second deal with contacts
|
||||
contact_id: 3
|
||||
project_id: 2
|
||||
background: Test deal two
|
||||
author_id: 2
|
||||
status_id: 3
|
||||
due_date: "<%= 3.days.from_now.to_s(:db) %>"
|
||||
price: 10000
|
||||
currency: "USD"
|
||||
|
||||
deal_003:
|
||||
id: 3
|
||||
name: Delevelop redmine plugin
|
||||
contact_id: 3
|
||||
project_id: 2
|
||||
background: Cross project deal
|
||||
author_id: 2
|
||||
status_id: 2
|
||||
due_date: "<%= 1.days.from_now.to_s(:db) %>"
|
||||
price: 5000
|
||||
currency: "USD"
|
||||
|
||||
deal_004:
|
||||
id: 4
|
||||
name: Deal without contact
|
||||
project_id: 2
|
||||
background: Deal without contact
|
||||
author_id: 2
|
||||
status_id: 1
|
||||
due_date: "<%= 2.days.from_now.to_s(:db) %>"
|
||||
price: 25500
|
||||
currency: "RUB"
|
||||
|
||||
deal_005:
|
||||
id: 5
|
||||
name: Closed deal
|
||||
contact_id: 3
|
||||
project_id: 2
|
||||
background: Closed deal
|
||||
author_id: 2
|
||||
status_id: 2
|
||||
price: 25500
|
||||
currency: "RUB"
|
||||
@@ -0,0 +1,10 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
di_001:
|
||||
issue_id: 1
|
||||
deal_id: 1
|
||||
di_002:
|
||||
issue_id: 2
|
||||
deal_id: 2
|
||||
di_003:
|
||||
issue_id: 3
|
||||
deal_id: 2
|
||||
@@ -0,0 +1,2 @@
|
||||
#,Is company,First Name,Middle Name,Last Name,Job title,Company,Phone,Email,Address,Skype,Website,Birthday,Tags,Background,License,Purchase date,Responsible,Postcode,City,Country code,LIST_FIELD
|
||||
25,0,Monica,,Smith,Realtor,"LLC ""Selection""",+1 650-253-0000,ivan@mail.com,,ivan.ivanov,,,"partner, realtor, smart, conference, do not call, PhD",,12345,2012-12-12,rhill,123456,Moscow,RU,"1, 3"
|
||||
|
@@ -0,0 +1,5 @@
|
||||
#;Is company;First Name;Middle Name;Last Name;Job title;Company;Phone;Email;Address;City;Country Code;Skype;Website;Birthday;Tags;Background;License;Purchase date
|
||||
46;0;Steven;Anthony;Ballmer;CEO;Microsoft;+1 (425) 706-8448;steveb@microsoft.com;;Seattle;US;;;24.03.1956;first, negative, partner;Steven Anthony 'Steve' Ballmer (born March 24, 1956)[4] is an American businessman and the chief executive of Microsoft, having held that post since January 2000.[4] As of 2011, his personal wealth is estimated at US$14.5 billion, ranking number 46 on the Forbes list of billionaires.[2];;
|
||||
12;0;Timothy;D.;Cook;CEO;Apple Inc.;+1 233 943 32 23;tim@apple.com;Cupertino , CA;Cupertino;GB;;;01.11.1960;conference;Independent Director , Nike, Inc. Beaverton , OR Sector: CONSUMER GOODS / Textile - Apparel Footwear & Accessories 50 Years Old Timothy D. Cook, Chief Operating Officer, joined the Company in March 1998. Mr. Cook also served as Executive Vice President, Worldwide Sales and Operations from 2002 to 2005. In 2004, his responsibilities were expanded to include the Company?s Macintosh hardware engineering. From 2000 to 2002, Mr. Cook served as Senior Vice President, Worldwide Operations, Sales, Service and Support. From 1998 to 2000, Mr. Cook served as Senior Vice President, Worldwide Operations. Prior to joining the Company, Mr. Cook was Vice President, Corporate Materials for Compaq Computer Corporation (Compaq). Prior to his work at Compaq, Mr. Cook was Chief Operating Officer of the Reseller Division at Intelligent Electronics. Mr. Cook also spent 12 years with International Business Machines Corporation (IBM), most recently as Director of North American Fulfillment. As CEO, Mr. Jobs will remain involved in major strategic decisions during this leave of absence, and Chief Operating Officer Tim Cook will be responsible for Apple's day to day operations.;;
|
||||
44;0;Билл;Генри;Гейтс;Chairman;Microsoft;+1 206-709-3100, +1 425-882-8080, +1 (408) 726-4390;billg@microsoft.com;Bill & Melinda Gates Foundation P.O. Box 23350 Seattle, WA 98102;;;;http://www.thegatesnotes.com/;28.10.1955;conference, IT;William Henry 'Bill' Gates III (born October 28, 1955)[3] is an American business magnate, investor, philanthropist, author, and former CEO and current chairman of Microsoft, the software company he founded with Paul Allen. He is consistently ranked among the world's wealthiest people[4] and was the wealthiest overall from 1995 to 2009, excluding 2008, when he was ranked third.[5] During his career at Microsoft, Gates held the positions of CEO and chief software architect, and remains the largest individual shareholder, with more than 8 percent of the common stock.[6] He has also authored or co-authored several books.;;
|
||||
13;0;Steven;Paul;Jobs;Chargé de communication;Apple Inc.;+1 344 563 93 33;jobs@apple.com;;;RU;;;24.02.1955;vip, IT;Steven Paul 'Steve' Jobs;;
|
||||
|
@@ -0,0 +1,2 @@
|
||||
#;Name;Background;Currency;Sum;Author;Assignee;Status;Contact;Category;Created;Updated,LIST_FIELD
|
||||
8;Сделка века;Кемска волость;JPY;100500;Redmine Admin;rhill;Won;Иван Грозный;Design;17.12.2012;17.12.2012;1, 3
|
||||
|
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,107 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
PRODID:-//Apple Inc.//Mac OS X 10.8.4//EN
|
||||
N:Безруков;Кирилл;;;
|
||||
FN:Кирилл Безруков
|
||||
EMAIL;type=INTERNET;type=pref:kirill@gmail.com
|
||||
TEL;type=CELL;type=VOICE;type=pref:+1 (234) 234-11-33
|
||||
ADR;type=WORK;type=pref:;;Миклухи Маклая\, 9 к 2\, корпус Б;Москва;;;
|
||||
NOTE:Текстовое описание на Русском
|
||||
BDAY:1981-05-12
|
||||
PHOTO;ENCODING=b;TYPE=JPEG:/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BS
|
||||
T0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dH
|
||||
B0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAAAABRiWFlaAAABuAAA
|
||||
ABRyVFJDAAABzAAAAEBnVFJDAAABzAAAAEBiVFJDAAABzAAAAEBkZXNjAAAAAAAAAANjMgAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAEZCAABYWVogAAAAAAAA9tYAAQAAAADTLV
|
||||
hZWiAAAAAAAAADFgAAAzMAAAKkWFlaIAAAAAAAAG+iAAA49QAAA5BYWVogAAAAAAAAYpkAALeF
|
||||
AAAY2lhZWiAAAAAAAAAkoAAAD4QAALbPY3VydgAAAAAAAAAaAAAAywHJA2MFkghrC/YQPxVRGz
|
||||
Qh8SmQMhg7kkYFUXdd7WtwegWJsZp8rGm/fdPD6TD////bAEMACAYGBwYFCAcHBwkJCAoMFA0M
|
||||
CwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDA
|
||||
sMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy
|
||||
MjIyMv/CABEIAJQAlAMAIgABEQECEQH/xAAbAAACAwEBAQAAAAAAAAAAAAADBAECBQAGB//EAB
|
||||
gBAAMBAQAAAAAAAAAAAAAAAAABAgME/8QAGAEAAwEBAAAAAAAAAAAAAAAAAAECAwT/2gAMAwAA
|
||||
ARECEQAAAarjVybtVOG+5jPMcCuChyEaA7CZWNrkPIpwxyNyMAaHZ/Mp1jSB4tAJyCthaS+qWf
|
||||
0nlp5yPTZ4s0vBc6Ob0k1BwBFkEs9BGnM6ZaPocIMCtD1nrPjaz6DnCZNmaO3Och6LPR4bWyX9
|
||||
MdONaYtKXuGC0w1bJ1qB881EdIjSPjpTp6drxeiP0cZOMHvLeJfEm4pvVL/dI7dTg7h2AlKyHk
|
||||
SCZmpFomDGdI2PRwvX5YZzWiQPP8flTkxN5W6vMr01ReYqzApv5EVDWYeboC1HO0RfVKWeyGkQ
|
||||
ahKmbVmopBOZSRWRaOoDWNqZ4Y51SQwkOJ1oNI7avPPKyho1SXNSxDVO6AsMggZFwAuTzfp9Mf
|
||||
I12vPZ6PO5BVW835tgeiVP0TlDrcPppIRFuZHJ5DnT83Kl597v596hrYzNKZfkm/UYU6Bau5NU
|
||||
08bUudLL3/NVB4y7zb8dMX5cJRdHMsEokCcTZT9qMg0bfcWjyzibuHRmb2Bv3GkAymmXjCrsVO
|
||||
cHlJf/xAAnEAACAgEDBAICAwEAAAAAAAABAgADEQQSIRATIjEFIDJBFCMkM//aAAgBAAABBQJm
|
||||
AO/nuYnei3RbMxjC83TcRN2JvLEjMNmJ3YLeS8DzfHIPTOZiAHI8IbIXhsCgOTLD4qd0Hs1rbG
|
||||
rZCPZA27pv+oO0uwCmznJyN2VRiNnOMQRbdpbFqgQ/TxxkTdgF8QvmbcGinMWoQIMGrxtTERcH
|
||||
UoamrsjtDYYSTPKdmdidiape2rmJ72ZWvgAwGAx03AU4XW15qQndpyNzUh4ulnYWYm2YnyXr2a
|
||||
h5L6AgWYiQDpem5H4s0nnfjH056fIpuo/enWKJvVYNQsFoI7mINcixdZU0Zlaa5Nl/xoyxzB0x
|
||||
1dQy2J27amVay5cOYOJXY4e03B3zuQqRwKrxc80lPYozM9D1zLP72qG6sVePYMKYGiQfyNZSHj
|
||||
0HdXVDQWGrwGpT/R9cwcx81tT+OAZ2xLFCjRKN1gyOAVWGXoLJUmFA+uJjE1df96firTdL3zF1
|
||||
BDLrbDU+9kqvm/Ib81HH2MKK6W19o/vPDRa9xoQozN4jBIi+zPX0E9wDpq/c/T7tyo7RKCY2mb
|
||||
ZWhSZidcTE2HoYDM5muHMDT2MGVBjFOA8PEThOOnPXPJm2VOG1N6CxG8WitFIMVws7gwXla/XE
|
||||
/XqZl160VfG3f6yZqae6MkGAmbzFcxRmKgton6HTnoeI+rVJda1rI5rsVgymajT9wYKsvRFjeC
|
||||
aVts1FfEMx0s1C1my5rI5h6fG27qzFlmkW5TU1bqIJqjiqriVmaug6azvPBqsThgYY0PTSMV1U
|
||||
Hun1q61aj9rNd/0r9Uz5F8adGJEstepv/8QAHhEAAgIDAQEBAQAAAAAAAAAAAAECERASICExMF
|
||||
H/2gAIAQIRAT8BxX5qJoajXHgxCWHmuI/TYUxyEyvb5a9NDUrH95sTLLw30mIsvq/SzY2G+HKh
|
||||
yvFidlEhSFNdL7iWbP/EAB4RAAICAgMBAQAAAAAAAAAAAAABESACEBIwMUEh/9oACAEBEQE/Ad
|
||||
IjbV2zkSSNdC18qyDiJDF5X4STtVaqu+PwgggWNFjJEagajWA8R4Oz81hT/8QAMBAAAQMDAgQD
|
||||
BwUBAAAAAAAAAQACERAhMSBBAxIwUTJxgRMiQlJhkaEEIzNAYrL/2gAIAQAABj8C12Cyj2WFH4
|
||||
QjPTso+5pm5U7qXZQTe4X5X17qHdGBk0mmKYW9IUH0Kg6cVcaBSa22Ur/M15xvrFBrcDvQhQa4
|
||||
0cPpELyTdfN8tJplZrcrKlpU9053bWWnBTmnYqSVINlc0a1oDpQ4bmtZbIpuPMJzm2eMFN9rHP
|
||||
tC5Zl2T0C/dXUD7Lwq8Bc0eSbxN2qQD9lf/lABvK2bkrhu7ORdO3Q5B3XqsLFJNLVgr06E7G+m
|
||||
wsvdZzFDicsHtXPRhwlCDM65Hr1G6PEFfjfhEDjOUHqM/pOYPgF/NFqLTnXzHPRLt9gng/GKSP
|
||||
EFBzqAHiaLfUa7q3vKXFNeNig4YNJHiUGxpihKAXtW+umBcr3joPDOW1+uxXI8QagfM4BBRsVL
|
||||
f43YWV+4LdwpFxqZG9tDnEXbg1/Tj/VSyAQRvWGPLRmF/8QAJBAAAwACAgICAwEBAQAAAAAAAA
|
||||
ERITFBURBhcYGRobHB8NH/2gAIAQAAAT8h3IaPYZNHye0QnsQpcvpGKKT0Zqt0+PZY2oy+ze2i
|
||||
omMKyoclrgfjkTzPgZfBI8Lk7PByFrMGWQWtbIyp/Aw5eCfBeJZy2ZFY1MZJn7j/AES5/wCdDU
|
||||
j77Fg+aMPDNORLkRB/8ImE9/sfacqFs8sfNHzCialH2ZwNbaULIz4espnoTMiZ/YSb2LDHiGyi
|
||||
+BAcNEaBvZ4GOs8Q+JglIbFpjBxQqWmWNajjOG9H7QmRxwPqR7L2dAYE6CRcDTgSQx/k4RaGL2
|
||||
hInH4747EuQtKol1ZQkxsr8qxTihVyhLUGY0SIEn2Df4CiGCIX4MUbCmieCM7thX0ln6EugmYG
|
||||
+jIS7ICbb9CG003o56iLkjlGNMx9PsNQEsDKK6WjeLSIwYK85GbMoCI0N36RhYMJz6MlaM2qdX
|
||||
wOgvFuQWTHVLfyNTcX2yhv4g28jUdkmlW1DDEqdWvylY0Kh+iFbwqSnw7ZH2Zsaw2o2l3CK3nt
|
||||
EJKhaQ8jYJSufZgLs+BmIT+X8GyX9MIDwPca6SPm6orJte5PZDQ0xaHBLZFV33/TYumMeo/lCl
|
||||
oaQkOqyI+ANJhTRgoPnRpJtJcsYvOYXhkIXvxLRATy6DOTk4hSimLXJl4k5JyH7LjWsiyXiM8l
|
||||
GBaz2NdMmCsaEaLmDEsFqMRLngT2KH7EFHC4ZtQmj9P9GcMnE8NlRtbMBoMuyJIx+NieT0I4pQ
|
||||
aKrI050g1+IBm309TK/I6ZezUxHsorMlJaMpTJIh0JNFJPI+si8EZ6GRMnRvsKlJ75EmHJgXQb
|
||||
dE3BVNIhDZqOu/tpDUb2n0xGoxHlFNZs4Ol0NmDMwmTz16H0RI4wxNw2FkN1hCdrI4L/ALGMTH
|
||||
O/2nSwvT6n2UlxNpid0K+B7AzJkleIDCWifcwWfD9jeBEtaL2W93XA42M2kWGI1FXgmXE0xRNo
|
||||
GEqL7J6RD06Mr/UJcGP+0ueGhk0JHujedmoP+B1cHXHhYZVXT8eLp4Zn+F+kaoH9ikxUkdlAUj
|
||||
dC2qzwCs10+r6ErFlGH9L5QoM5yh4aG3iyxNq+B6HL0Y4G2C08XnAKFnH6VHNni8NC7WXJa6rA
|
||||
8U//2gAMAwAAARECEQAAEBWNKazWXc8aOm64Z69D6XbN4QwdsBtN6M0wkhxh20mzHRg/FB2EqO
|
||||
uq8gkt0L9+M6ai/oz/ANKNUg6P/ZgIIB2CAHmAp1wYGdkYLkr/xAAcEQADAQADAQEAAAAAAAAA
|
||||
AAAAAREhEDFBIGH/2gAIAQIRAT8QIaJxpOZwkfg5iggiqPl/gRJYafEzDp2oewSLnsRLQ5WFOx
|
||||
UPQbOS+EhGyhQzaqEvBxJuLxosFBtcEyHOy2Gk5uwgJNHSGG/jobuhWJkUyPOi8IYPRQKCg6wa
|
||||
sYx39MH0ex8UvT//xAAcEQADAQADAQEAAAAAAAAAAAAAAREhEDFBIFH/2gAIAQERAT8QKaEnGH
|
||||
4FguEQSiI8KFo9BGCQlo+hvjQ8Z2HScT064LejgZTWDJRSfFYR3iLGN+lufQ0JKaNJorkFivy1
|
||||
VRqic7G/CViWcUp2QoHJrjYguH6YlHg6H6G2dirEdNGPj00GdD3iI//EACYQAQACAgICAQQDAQ
|
||||
EAAAAAAAEAESExQVFhcYGRobHB0eHwEPH/2gAIAQAAAT8Q1FXJuVkATUv7Sg6eJwRTClaOYJYp
|
||||
8UIsa0x973AcaFH5MQVU8rhQyhIhRdX6vtiTMVjxdY+/0lK+xu394neiNVDZnPmMiri4Lvkj2O
|
||||
aMTs48y9mLgxUxC7TeE2I14gsRwsOujqPBnT5YZtAzfDmokdsp2Bxf8S9e2B48V6h0gKW7z3KI
|
||||
y7VybT8Q33TQHV6euYBqDKC5e1c9MKI9cYODrhRLu9wRu8y0tNbmYrGkFulIlF7r03El+lL4GY
|
||||
1hWhXMuFPPjXgjA+4VqgwVlrX3jCL+w+sJAIKuIku5VIi2SsgGz18zAwdoa+HmVEpkOmIhbRKt
|
||||
wFblby/OZlbPDcxpjWJafR7mecCk+eIlWXBN1s69wBccszJDQ1CAqNfSJEgX2S+jsMlbOoGSiD
|
||||
XbT8wBfcSWD2MwBhHRGhz8yxml9kfJ3BCxR620a2KmIgaRa+cRQyxydse5lGJPyWMIzwTVb5lP
|
||||
m5wHCc8Eg1KaXzjP2lqDG31K0gog6qPGssHhuZE9MTL2HqXJ9sCaqpgDFtXcbGpucomD7riGMs
|
||||
qhmMCgqZxjQcWeIh6VLBUTXqFdZTUGFuWO/UOAsVX2xMICAaIKMkXnmYC5S3pKr3bfCMzgNrMi
|
||||
V1GyVQkAnzDl19xcDxmCXQJcVXQwQzbfNkcBdoOoQOsB5JmLUby5i7DA8u58EAZSD0YYC+cQFV
|
||||
HwGbc7k8cQyI2rcDJU1BtO/mDZOuag1yu4fJKCcVZd4zHbwa34FMX8wmC6D/ZiGTWQsF/JqDdC
|
||||
9aHXsdU9zCYSqurEfQKvFL12QB8ynqNmLh6YhUKbm0WVa0R6jsKsKbSsfiC4jLdnUsNg4/cORE
|
||||
asvIkWwvORT8y8HLVrPrdxixhCrc0+geolRRsVtR+kLvG/MHoOuP2IqQKpQRoXtKtdXNHgiprE
|
||||
Ad61tjNQa6PIwVpcOGYH/hT3MlSnDfUJAqTfOWPWoaqVTrrMCgk6GJstZyXLUYF4AmT4YzVksX
|
||||
aKrxEGCtJ1LEPxcBU1WH9Q0dz5TR94KNL76ZlRlmbFxd7CDXhNuscM3VXAmMD1DJ0w/vk+uYrs
|
||||
q2VOXuCJbMfK6ildRuKVoSmJcWnBQK7uLJqPHFA70xGBgqRWEq1vggK4LL/Ep5IBzxiNvcMLKu
|
||||
JvuAnP53E6LfHUdkfhxT2PDEDAFQUfmEDpmXWHfUoqLkziC3lmdUeldwDFYwrcWZQ0GvA/j/kf
|
||||
QCJYW1cLzckUFjUOkjVDlxTKcZsZr3MKqvcxSkeB/plPBhfV4hLeZhXmZ6V5HEyY+QT7x02zGE
|
||||
dGg3cQXZ3G254RWobgKGsTqksqAfmMxR6mOZVNZtFp+4epGo7A2Tztng+prikBky4SNpbwRhrs
|
||||
7gZDrdQWhtdxKhamg7mn7leXLM0uYlTaW2YEBRM8y9Fjc0MwBNy3UqGKI7ObaD0CvxMSK9Inw1
|
||||
qP6mJuAIXmDlLdMLhDlHQDRdwhPEcbGUPD+4gyIUHV8SgtkiLixulW4slhM7k58zEkOFgjb4vi
|
||||
JHVKnf6hYFgqKKBP6DBM21wI2TycRa6fcbeYNgwehgoUw8DiP48zJzXkTIxalPDMatKfMDAjmt
|
||||
XMhpjuFmmLlbIbVQTRPBpb3HGJoNB0eIoeMa5rf1PzA8BsciRg0yuDgG/DF2yQ/n1EoEucDbxF
|
||||
Yii9BGLxo9uIlXI95/hIlJYs9f5uV5o1Tc3AI5aE7kqKE8BwfLLYW2BgfEBTP3jLMWDnssvf+G
|
||||
HkjOCYOrWBleezxLBJ+Bwj1KahMIC/E6EJ9bYxvK/UQGB2LNZIbErbzN/xAD5FX/7GMZ5/9DyS
|
||||
6AGxbGagTkc+I2pqCEmPa4e6TL4xA08xAHOJjaVsJXHrxDAjV8RRGm1PioFPpFAuAHiKIfZFBY
|
||||
mcI5GZklMsVQvcyZCUgt0can//2Q==
|
||||
X-ABUID:74DABCB2-FF8A-42EF-BE02-7DBBCE975E4D
|
||||
TZ;VALUE=utc-offset:4
|
||||
LANG:ru_RU
|
||||
END:VCARD
|
||||
@@ -0,0 +1,18 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:2.1
|
||||
N;CHARSET=ISO-8859-1:Testovish;Test;;
|
||||
FN;CHARSET=ISO-8859-1:Test Testovish
|
||||
SORT-STRING:test
|
||||
CLASS:PUBLIC
|
||||
EMAIL;TYPE=internet;type=WORK;type=pref:t.test@test.com
|
||||
BDAY:19801201
|
||||
ADR;TYPE=work;CHARSET=ISO-8859-1:;;Bleichstraße;Düsseldorf;Nordrhein-Westfalen;11111 ;Testland
|
||||
ADR;TYPE=home;CHARSET=ISO-8859-1:;;;;;;
|
||||
TEL;TYPE=work:+11-111-111111-11111
|
||||
ORG;CHARSET=ISO-8859-1:Geschäftszweig
|
||||
TITLE;CHARSET=ISO-8859-1:Tester
|
||||
CATEGORIES;CHARSET=ISO-8859-1:Test
|
||||
PHOTO;VALUE=URL;TYPE=JPEG:http://www.test.com/test.jpg
|
||||
NOTE;CHARSET=ISO-8859-1:Test note
|
||||
PRODID:-//Apple Inc.//Mac OS X 10.8.4//EN
|
||||
END:VCARD
|
||||
@@ -0,0 +1,5 @@
|
||||
#;Is company;First Name;Middle Name;Last Name;Job title;Company;Phone;Email;Address;Skype;Website;Birthday;Tags;Background;License;Purchase date
|
||||
46;0;Steven;Anthony;Ballmer;CEO;Microsoft;+1 (425) 706-8448;steveb@microsoft.com;;;;malformed;first, negative, partner;Steven Anthony 'Steve' Ballmer (born March 24, 1956)[4] is an American businessman and the chief executive of Microsoft, having held that post since January 2000.[4] As of 2011, his personal wealth is estimated at US$14.5 billion, ranking number 46 on the Forbes list of billionaires.[2];;
|
||||
12;0;Timothy;D.;Cook;CEO;Apple Inc.;+1 233 943 32 23;tim@apple.com;Cupertino , CA;;;1960-11-01;conference;Independent Director , Nike, Inc. Beaverton , OR Sector: CONSUMER GOODS / Textile - Apparel Footwear & Accessories 50 Years Old Timothy D. Cook, Chief Operating Officer, joined the Company in March 1998. Mr. Cook also served as Executive Vice President, Worldwide Sales and Operations from 2002 to 2005. In 2004, his responsibilities were expanded to include the Company?s Macintosh hardware engineering. From 2000 to 2002, Mr. Cook served as Senior Vice President, Worldwide Operations, Sales, Service and Support. From 1998 to 2000, Mr. Cook served as Senior Vice President, Worldwide Operations. Prior to joining the Company, Mr. Cook was Vice President, Corporate Materials for Compaq Computer Corporation (Compaq). Prior to his work at Compaq, Mr. Cook was Chief Operating Officer of the Reseller Division at Intelligent Electronics. Mr. Cook also spent 12 years with International Business Machines Corporation (IBM), most recently as Director of North American Fulfillment. As CEO, Mr. Jobs will remain involved in major strategic decisions during this leave of absence, and Chief Operating Officer Tim Cook will be responsible for Apple's day to day operations.;;
|
||||
44;0;Bill;Henry;Gates;Chairman;Microsoft;+1 206-709-3100, +1 425-882-8080, +1 (408) 726-4390;billg@microsoft.com;Bill & Melinda Gates Foundation P.O. Box 23350 Seattle, WA 98102;;http://www.thegatesnotes.com/;1955-10-28;conference, IT;William Henry 'Bill' Gates III (born October 28, 1955)[3] is an American business magnate, investor, philanthropist, author, and former CEO and current chairman of Microsoft, the software company he founded with Paul Allen. He is consistently ranked among the world's wealthiest people[4] and was the wealthiest overall from 1995 to 2009, excluding 2008, when he was ranked third.[5] During his career at Microsoft, Gates held the positions of CEO and chief software architect, and remains the largest individual shareholder, with more than 8 percent of the common stock.[6] He has also authored or co-authored several books.;;
|
||||
13;0;Steven;Paul;Jobs;Chairman;Apple Inc.;+1 344 563 93 33;jobs@apple.com;;;;1955-02-24;vip, IT;Steven Paul 'Steve' Jobs;;
|
||||
|
@@ -0,0 +1,41 @@
|
||||
# Read about fixtures at http:__ar.rubyonrails.org_classes_Fixtures.html
|
||||
note_001:
|
||||
id: 1
|
||||
subject: Note 1 subject
|
||||
content: Note 1 _content_ with wiki *syntax*
|
||||
source_id: 1
|
||||
source_type: Contact
|
||||
author_id: 1
|
||||
created_on: "<%= (Time.now - 4.days).to_s(:db) %>"
|
||||
note_002:
|
||||
id: 2
|
||||
subject: Note 2 subject
|
||||
content: Note 2 _content_ with wiki *syntax*
|
||||
source_id: 1
|
||||
source_type: Contact
|
||||
author_id: 2
|
||||
created_on: "<%= (Time.now - 2.days).to_s(:db) %>"
|
||||
note_003:
|
||||
id: 3
|
||||
subject: Note 3 subject
|
||||
content: Note 3 _content_ with wiki *syntax*
|
||||
source_id: 2
|
||||
source_type: Contact
|
||||
author_id: 1
|
||||
created_on: "<%= (Time.now - 1.days).to_s(:db) %>"
|
||||
note_004:
|
||||
id: 4
|
||||
subject: Note 4 subject
|
||||
content: Note 4 _content_ with wiki *syntax*
|
||||
source_id: 3
|
||||
source_type: Contact
|
||||
author_id: 2
|
||||
created_on: "<%= (Time.now + 4.days).to_s(:db) %>"
|
||||
note_005:
|
||||
id: 5
|
||||
subject: Note 5 subject
|
||||
content: Note 5 _content_ with wiki *syntax*
|
||||
source_id: 1
|
||||
source_type: Deal
|
||||
author_id: 2
|
||||
created_on: "<%= (Time.now + 4.days).to_s(:db) %>"
|
||||
@@ -0,0 +1,82 @@
|
||||
contact_queries_002:
|
||||
id: 2
|
||||
project_id: 1
|
||||
<% if Redmine::VERSION.to_s < '2.4' %>
|
||||
is_public: false
|
||||
<% else %>
|
||||
visibility: 2
|
||||
<% end %>
|
||||
type: ContactQuery
|
||||
name: Private contacts query for cookbook
|
||||
filters: |
|
||||
---
|
||||
first_name:
|
||||
:values:
|
||||
- "Ivan"
|
||||
:operator: "="
|
||||
last_name:
|
||||
:values:
|
||||
- "Ivanov"
|
||||
:operator: "="
|
||||
|
||||
user_id: 3
|
||||
contact_queries_003:
|
||||
id: 3
|
||||
project_id:
|
||||
<% if Redmine::VERSION.to_s < '2.4' %>
|
||||
is_public: false
|
||||
<% else %>
|
||||
visibility: 2
|
||||
<% end %>
|
||||
type: ContactQuery
|
||||
name: Private query for all projects
|
||||
filters: |
|
||||
---
|
||||
first_name:
|
||||
:values:
|
||||
- "Ivan"
|
||||
:operator: "="
|
||||
|
||||
user_id: 3
|
||||
contact_queries_004:
|
||||
id: 4
|
||||
project_id:
|
||||
<% if Redmine::VERSION.to_s < '2.4' %>
|
||||
is_public: true
|
||||
<% else %>
|
||||
visibility: 0
|
||||
<% end %>
|
||||
type: ContactQuery
|
||||
name: Public query for all projects
|
||||
filters: |
|
||||
---
|
||||
first_name:
|
||||
:values:
|
||||
- "Ivan"
|
||||
:operator: "="
|
||||
|
||||
user_id: 2
|
||||
contact_queries_005:
|
||||
id: 5
|
||||
project_id:
|
||||
<% if Redmine::VERSION.to_s < '2.4' %>
|
||||
is_public: true
|
||||
<% else %>
|
||||
visibility: 0
|
||||
<% end %>
|
||||
type: ContactQuery
|
||||
name: Open contacts by tags
|
||||
filters: |
|
||||
---
|
||||
tags:
|
||||
:values:
|
||||
- "main"
|
||||
:operator: "="
|
||||
|
||||
user_id: 1
|
||||
sort_criteria: |
|
||||
---
|
||||
- - first_name
|
||||
- desc
|
||||
- - last_name
|
||||
- asc
|
||||
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
one:
|
||||
id: 1
|
||||
viewed_id: 1
|
||||
viewer_id: 1
|
||||
two:
|
||||
id: 2
|
||||
viewed_id: 1
|
||||
viewer_id: 1
|
||||
@@ -0,0 +1,30 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
tagging_001:
|
||||
tag_id: 1
|
||||
taggable_id: 1
|
||||
taggable_type: Contact
|
||||
# context: tags
|
||||
|
||||
tagging_002:
|
||||
tag_id: 2
|
||||
taggable_id: 2
|
||||
taggable_type: Contact
|
||||
# context: tags
|
||||
|
||||
tagging_003:
|
||||
tag_id: 1
|
||||
taggable_id: 3
|
||||
taggable_type: Contact
|
||||
# context: tags
|
||||
|
||||
tagging_004:
|
||||
tag_id: 2
|
||||
taggable_id: 4
|
||||
taggable_type: Contact
|
||||
# context: tags
|
||||
|
||||
tagging_005:
|
||||
tag_id: 2
|
||||
taggable_id: 3
|
||||
taggable_type: Contact
|
||||
# context: tags
|
||||
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
tag_one:
|
||||
id: 1
|
||||
name: main
|
||||
tag_two:
|
||||
id: 2
|
||||
name: test
|
||||
@@ -0,0 +1,148 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class AutoCompletesControllerTest < ActionController::TestCase
|
||||
fixtures :projects, :issues, :issue_statuses,
|
||||
:enumerations, :users, :issue_categories,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:roles,
|
||||
:member_roles,
|
||||
:members,
|
||||
:enabled_modules,
|
||||
:workflows,
|
||||
:journals, :journal_details
|
||||
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
@request.session[:user_id] = 1
|
||||
end
|
||||
|
||||
def test_contacts_should_not_be_case_sensitive
|
||||
compatible_request :get, :contacts, :project_id => 'ecookbook', :q => 'ma'
|
||||
assert_response :success
|
||||
assert response.body.match /Marat/
|
||||
end
|
||||
|
||||
def test_contacts_should_accept_term_param
|
||||
compatible_request :get, :contacts, :project_id => 'ecookbook', :term => 'ma'
|
||||
assert_response :success
|
||||
assert response.body.match /Marat/
|
||||
end
|
||||
|
||||
def test_companies_should_not_be_case_sensitive
|
||||
compatible_request :get, :companies, :project_id => 'ecookbook', :q => 'domo'
|
||||
assert_response :success
|
||||
assert response.body.match /Domoway/
|
||||
end
|
||||
|
||||
def test_companies_witth_spaces_should_be_found
|
||||
compatible_request :get, :companies, :project_id => 'ecookbook', :q => 'my c'
|
||||
assert_response :success
|
||||
assert response.body.match /My company/
|
||||
end
|
||||
|
||||
def test_contacts_should_return_json
|
||||
compatible_request :get, :contacts, :project_id => 'ecookbook', :q => 'marat'
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
contact = json.last
|
||||
assert_kind_of Hash, contact
|
||||
assert_equal 2, contact['id']
|
||||
assert_equal 2, contact['value']
|
||||
assert_equal 'Marat Aminov', contact['name']
|
||||
end
|
||||
|
||||
def test_companies_should_return_json
|
||||
compatible_request :get, :companies, :project_id => 'ecookbook', :q => 'domo'
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
contact = json.first
|
||||
assert_kind_of Hash, contact
|
||||
assert_equal 3, contact['id']
|
||||
assert_equal 'Domoway', contact['value']
|
||||
assert_equal 'Domoway', contact['label']
|
||||
end
|
||||
|
||||
def test_contact_tags_should_return_json
|
||||
compatible_request :get, :contact_tags, :q => 'ma'
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
tag = json.last
|
||||
assert_match 'main', tag
|
||||
end
|
||||
|
||||
def test_taggable_tags_should_return_json
|
||||
compatible_request :get, :taggable_tags, :q => 'ma', :taggable_type => 'contact'
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
tag = json.last
|
||||
assert_match 'main', tag
|
||||
end
|
||||
def test_deals_should_return_json
|
||||
compatible_request :get, :deals, :q => 'redmine'
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_kind_of Array, json
|
||||
deal = json.last
|
||||
assert_kind_of Hash, deal
|
||||
assert_equal 3, deal['id']
|
||||
assert_equal 3, deal['value']
|
||||
assert_match 'Delevelop redmine plugin', deal['label']
|
||||
end
|
||||
|
||||
def test_deals_should_fiend_by_contact_details
|
||||
check_by_contact_details('', 5, 2, 'Second deal with contacts') # Search string is empty
|
||||
check_by_contact_details('Ivanov', 1, 1, 'First deal with contacts') # Contact last name is Ivanov
|
||||
check_by_contact_details('jsmith@somenet.foo', 0) # Contact email is jsmith@somenet.foo
|
||||
check_by_contact_details('Domoway', 4, 2) # Contact first name is Domoway
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_by_contact_details(search_string, expected_number, deal_id = 0, deal_label = '')
|
||||
compatible_request :get, :deals, :q => search_string
|
||||
assert_response :success
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_equal expected_number, json.length
|
||||
|
||||
return if expected_number == 0
|
||||
deal = json.last
|
||||
%w(id value).each { |field| assert_equal deal_id, deal[field] }
|
||||
%w(label text).each { |field| assert_match deal_label, deal[field] }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,158 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactImportsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@csv_file = Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'contacts_cf.csv', 'text/csv')
|
||||
end
|
||||
|
||||
test 'should open contact import form' do
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :success
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
assert_select 'form input#file'
|
||||
else
|
||||
assert_select 'form.new_contact_import'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should create new import object' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :create, :project_id => 1, :file => @csv_file
|
||||
assert_response :redirect
|
||||
assert_equal Import.last.class, ContactKernelImport
|
||||
assert_equal Import.last.user, User.find(1)
|
||||
assert_equal Import.last.project, 1
|
||||
assert_equal Import.last.settings, { 'project' => 1,
|
||||
'separator' => Rails.version >= '5.1' ? ';' : ',',
|
||||
'wrapper' => "\"",
|
||||
'encoding' => 'ISO-8859-1',
|
||||
'date_format' => '%m/%d/%Y' }
|
||||
end
|
||||
end
|
||||
|
||||
test 'should open settings page' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
import = ContactKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.project = Project.find(1)
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :get, :settings, :id => import.filename, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'form#import-form'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should show mapping page' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
import = ContactKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.project = Project.find(1)
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :get, :mapping, :id => import.filename, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select "select[name='import_settings[mapping][is_company]']"
|
||||
assert_select 'select[name="import_settings[mapping][first_name]"]'
|
||||
assert_select 'table.sample-data tr'
|
||||
assert_select 'table.sample-data tr td', 'Monica'
|
||||
assert_select 'table.sample-data tr td', 'ivan@mail.com'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should successfully import from CSV with new import' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
cf = ContactCustomField.create!(:name => 'LIST_FIELD', :field_format => 'list', :multiple => true, :possible_values => %w(1 2 3))
|
||||
@request.session[:user_id] = 1
|
||||
import = ContactKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.project = Project.find(1)
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :post, :mapping, :id => import.filename, :project_id => 1,
|
||||
:import_settings => { :mapping => { :first_name => 2, :email => 8, "cf_#{cf.id}" => 21 } }
|
||||
assert_response :redirect
|
||||
compatible_request :post, :run, :id => import.filename, :project_id => 1, :format => :js
|
||||
assert_equal Contact.last.first_name, 'Monica'
|
||||
assert_equal Contact.last.email, 'ivan@mail.com'
|
||||
assert_equal Contact.last.custom_field_value(cf).sort, ['1', '3']
|
||||
end
|
||||
end
|
||||
|
||||
test 'should successfully import from CSV' do
|
||||
if Redmine::VERSION.to_s < '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference('Contact.count', 4, 'Should add 4 contacts to the database') do
|
||||
compatible_request :post, :create, {
|
||||
:project_id => 1,
|
||||
:contact_import => {
|
||||
:file => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'correct.csv', 'text/comma-separated-values'),
|
||||
:quotes_type => '"'
|
||||
}
|
||||
}
|
||||
assert_redirected_to project_contacts_path(:project_id => 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,753 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries,
|
||||
:addresses])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_index
|
||||
@request.session[:user_id] = 1
|
||||
assert_not_nil Contact.find(1)
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
assert_select 'a', :html => /Domoway/
|
||||
assert_select 'a', :html => /Marat/
|
||||
assert_select 'h3', :html => /Tags/
|
||||
assert_select 'h3', :html => /Recently viewed/
|
||||
assert_select 'div#tags span#single_tags span.tag-label-color a', 'test'
|
||||
assert_select 'div#tags span#single_tags span.tag-label-color a', 'main'
|
||||
end
|
||||
|
||||
test 'should get index in project' do
|
||||
@request.session[:user_id] = 1
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
assert_select 'a', :html => /Domoway/
|
||||
assert_select 'a', :html => /Marat/
|
||||
assert_select 'h3', :html => /Tags/
|
||||
assert_select 'h3', :html => /Recently viewed/
|
||||
end
|
||||
test 'should get index with filters and sorting' do
|
||||
field = ContactCustomField.create!(:name => 'Test custom field', :is_filter => true, :field_format => 'string')
|
||||
contact = Contact.find(1)
|
||||
contact.custom_field_values = { field.id => "This is custom значение" }
|
||||
contact.save
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :index, :sort => 'assigned_to,cf_1,last_name,first_name',
|
||||
:v => { 'first_name' => ['Ivan'] },
|
||||
:f => ['first_name', ''],
|
||||
:op => { 'first_name' => '~' }
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
|
||||
assert_select 'div#content div#contact_list table.contacts td.name h1', 'Ivan Ivanov'
|
||||
end
|
||||
|
||||
def test_get_index_with_all_fields
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get,
|
||||
:index,
|
||||
:set_filter => 1,
|
||||
:project_id => 1,
|
||||
:c => ContactQuery.available_columns.map(&:name),
|
||||
:contacts_list_style => 'list'
|
||||
assert_response :success
|
||||
assert_select 'tr#contact-1 td.id a[href=?]', '/contacts/1'
|
||||
assert_select 'tr#contact-1 td.tags', 'main'
|
||||
end
|
||||
|
||||
def test_index_with_short_filters
|
||||
@request.session[:user_id] = 1
|
||||
to_test = {
|
||||
'tags' => {
|
||||
'main|test' => { :op => '=', :values => ['main', 'test'] },
|
||||
'=main' => { :op => '=', :values => ['main'] },
|
||||
'!test' => { :op => '!', :values => ['test'] } },
|
||||
'country' => {
|
||||
'*' => { :op => '*', :values => [''] },
|
||||
'!*' => { :op => '!*', :values => [''] },
|
||||
'US|RU' => { :op => '=', :values => ['US', 'RU'] } },
|
||||
'first_name' => {
|
||||
'Marat' => { :op => '=', :values => ['Marat'] },
|
||||
'~Mara' => { :op => '~', :values => ['Mara'] },
|
||||
'!~Mara' => { :op => '!~', :values => ['Mara'] } },
|
||||
'created_on' => {
|
||||
'>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
|
||||
'<t-2' => { :op => '<t-', :values => ['2'] },
|
||||
'>t-2' => { :op => '>t-', :values => ['2'] },
|
||||
't-2' => { :op => 't-', :values => ['2'] } },
|
||||
'last_note' => {
|
||||
'>=2011-10-12' => { :op => '>=', :values => ['2011-10-12'] },
|
||||
'<t-2' => { :op => '<t-', :values => ['2'] },
|
||||
'>t-2' => { :op => '>t-', :values => ['2'] },
|
||||
't-2' => { :op => 't-', :values => ['2'] } },
|
||||
'has_deals' => {
|
||||
'c' => { :op => '=', :values => ['c'] },
|
||||
'!c' => { :op => '!', :values => ['c'] } },
|
||||
'has_open_issues' => {
|
||||
'=4' => { :op => '=', :values => ['4'] },
|
||||
'!*' => { :op => '!*', :values => [''] },
|
||||
'*' => { :op => '*', :values => [''] } }
|
||||
}
|
||||
|
||||
default_filter = { 'status_id' => { :operator => 'o', :values => [''] } }
|
||||
|
||||
to_test.each do |field, expression_and_expected|
|
||||
expression_and_expected.each do |filter_expression, expected|
|
||||
compatible_request :get, :index, :set_filter => 1, field => filter_expression
|
||||
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_filter_by_ids_equal
|
||||
@request.session[:user_id] = 1
|
||||
ids = [1, 2]
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '=' }, 'v' => { 'ids' => [ids.join(',')] }
|
||||
assert_response :success
|
||||
assert_equal ids.sort, contacts_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_any
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '*' }
|
||||
assert_response :success
|
||||
assert_equal Project.find(1).contacts.map(&:id).sort, contacts_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_more_than
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '>=' }, 'v' => { 'ids' => [3] }
|
||||
assert_response :success
|
||||
assert_equal [3, 4, 5], contacts_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_less_than
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '<=' }, 'v' => { 'ids' => [2] }
|
||||
assert_response :success
|
||||
assert_equal [1, 2], contacts_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_between
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '><' }, 'v' => { 'ids' => ['1', '3'] }
|
||||
assert_response :success
|
||||
assert_equal [1, 2, 3], contacts_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_index_sort_by_custom_field
|
||||
@request.session[:user_id] = 1
|
||||
cf = ContactCustomField.create!(:name => 'Contact test cf', :is_for_all => true, :field_format => 'string')
|
||||
CustomValue.create!(:custom_field => cf, :customized => Contact.find(1), :value => 'test_1')
|
||||
CustomValue.create!(:custom_field => cf, :customized => Contact.find(2), :value => 'test_2')
|
||||
CustomValue.create!(:custom_field => cf, :customized => Contact.find(3), :value => 'test_3')
|
||||
|
||||
compatible_request :get, :index, :set_filter => 1, :sort => "cf_#{cf.id},id"
|
||||
assert_response :success
|
||||
|
||||
assert_equal [1, 2, 3], contacts_in_list.select { |contact| contact.custom_field_value(cf).present? }.map(&:id).sort
|
||||
end
|
||||
|
||||
def test_should_not_absolute_links
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_no_match %r{localhost}, @response.body
|
||||
end
|
||||
|
||||
def test_should_get_index_deny_user_in_project
|
||||
@request.session[:user_id] = 5
|
||||
|
||||
compatible_request :get, :index, :project_id => 1
|
||||
assert_response :redirect
|
||||
end
|
||||
|
||||
def test_should_get_index_with_filters
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :is_company => ActiveRecord::Base.connection.quoted_true.gsub(/'/, '')
|
||||
assert_response :success
|
||||
assert_select 'div#content div#contact_list table.contacts td.name h1 a', 'Domoway'
|
||||
end
|
||||
def test_should_get_index_as_csv
|
||||
field = ContactCustomField.create!(:name => 'Test custom field', :is_filter => true, :field_format => 'string')
|
||||
contact = Contact.find(1)
|
||||
contact.custom_field_values = { field.id => "This is custom значение" }
|
||||
contact.save
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert_match /Domoway/, @response.body
|
||||
end
|
||||
|
||||
def test_should_get_index_as_VCF
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :format => 'vcf'
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
assert_equal 'text/x-vcard', @response.content_type
|
||||
assert @response.body.starts_with?('BEGIN:VCARD')
|
||||
assert_match /^N:;Domoway/, @response.body
|
||||
end
|
||||
|
||||
def test_should_get_contacts_notes_as_csv
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :contacts_notes, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert @response.body.starts_with?('#,')
|
||||
end
|
||||
|
||||
def test_get_show
|
||||
@request.session[:user_id] = 2
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :show, :id => 3, :project_id => 1
|
||||
assert_response :success
|
||||
|
||||
assert_not_nil contacts_in_list
|
||||
assert_select 'h1', :html => /Domoway/
|
||||
assert_select 'div#tags_data span.tag-label-color a', 'main'
|
||||
assert_select 'div#tags_data span.tag-label-color a', 'test'
|
||||
assert_select 'div#tab-placeholder-contacts'
|
||||
assert_select 'div#comments div#notes table.note_data td.name h4', 4
|
||||
assert_select 'h3', 'Recently viewed'
|
||||
end
|
||||
|
||||
def test_get_show_with_long_note
|
||||
long_note = 'A' * 1500
|
||||
Contact.find(3).notes.create(:content => long_note, :author_id => 1)
|
||||
@request.session[:user_id] = 2
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :show, :id => 3, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select '.note a', '(read more)'
|
||||
end
|
||||
def test_get_show_tab_deals
|
||||
@request.session[:user_id] = 2
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :show, :id => 3, :project_id => 1, :tab => 'deals'
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
assert_select 'h1', :html => /Domoway/
|
||||
assert_select 'div#deals a', 'Delevelop redmine plugin'
|
||||
assert_select 'div#deals a', 'Second deal with contacts'
|
||||
end
|
||||
|
||||
def test_get_show_without_deals
|
||||
@request.session[:user_id] = 4
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :show, :id => 3, :project_id => 1, :tab => 'deals'
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
|
||||
assert_select 'div#deals a', { :count => 0, :text => /Delevelop redmine plugin/ }
|
||||
assert_select 'div#deals a', { :count => 0, :text => /Second deal with contacts/ }
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 2
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'input#contact_first_name'
|
||||
end
|
||||
|
||||
def test_get_new_without_permission
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
def test_post_create
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Contact.count' do
|
||||
compatible_request :post, :create, :project_id => 1, :contact => { :company => 'OOO "GKR"',
|
||||
:is_company => 0,
|
||||
:job_title => 'CFO',
|
||||
:assigned_to_id => 3,
|
||||
:tag_list => 'test,new',
|
||||
:last_name => 'New',
|
||||
:middle_name => 'Ivanovich',
|
||||
:first_name => 'Created' }
|
||||
end
|
||||
|
||||
assert_redirected_to :controller => 'contacts', :action => 'show', :id => Contact.last.id, :project_id => Contact.last.project
|
||||
|
||||
contact = Contact.where(:first_name => 'Created', :last_name => 'New', :middle_name => 'Ivanovich').first
|
||||
assert_not_nil contact
|
||||
assert_equal 'CFO', contact.job_title
|
||||
assert_equal ['new', 'test'], contact.tag_list.sort
|
||||
assert_equal 3, contact.assigned_to_id
|
||||
end
|
||||
def test_post_create_with_custom_fields
|
||||
field = ContactCustomField.create!(:name => 'Test', :is_filter => true, :field_format => 'string')
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Contact.count' do
|
||||
compatible_request :post, :create, :project_id => 1, :contact => { :company => 'OOO "GKR"',
|
||||
:is_company => 0,
|
||||
:job_title => 'CFO',
|
||||
:assigned_to_id => 3,
|
||||
:tag_list => 'test,new',
|
||||
:last_name => 'New',
|
||||
:middle_name => 'Ivanovich',
|
||||
:first_name => 'Created',
|
||||
:custom_field_values => { "#{field.id}" => 'contact one' } }
|
||||
end
|
||||
assert_redirected_to :controller => 'contacts', :action => 'show', :id => Contact.last.id, :project_id => Contact.last.project
|
||||
|
||||
contact = Contact.where(:first_name => 'Created', :last_name => 'New', :middle_name => 'Ivanovich').first
|
||||
assert_equal 'contact one', contact.custom_field_values.last.value
|
||||
end
|
||||
|
||||
def test_post_create_without_permission
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :post, :create, :project_id => 1, :contact => { :company => 'OOO "GKR"',
|
||||
:is_company => 0,
|
||||
:job_title => 'CFO',
|
||||
:assigned_to_id => 3,
|
||||
:tag_list => 'test,new',
|
||||
:last_name => 'New',
|
||||
:middle_name => 'Ivanovich',
|
||||
:first_name => 'Created' }
|
||||
assert_response :forbidden
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', /Editing Contact Information/
|
||||
end
|
||||
|
||||
def test_get_edit_with_duplicates
|
||||
contact = Contact.find(3)
|
||||
contact_clone = contact.dup
|
||||
contact_clone.project = contact.project
|
||||
contact_clone.save!
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :edit, :id => 3
|
||||
assert_response :success
|
||||
assert_select 'div#duplicates', 1
|
||||
assert_select 'div#duplicates h3', /Possible duplicates/
|
||||
ensure
|
||||
contact_clone.delete
|
||||
end
|
||||
|
||||
def test_put_update
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
contact = Contact.find(1)
|
||||
new_firstname = 'Fist name modified by ContactsControllerTest#test_put_update'
|
||||
|
||||
compatible_request :put, :update, :id => 1, :project_id => 1, :contact => { :first_name => new_firstname }
|
||||
assert_redirected_to :action => 'show', :id => '1', :project_id => 1
|
||||
contact.reload
|
||||
assert_equal new_firstname, contact.first_name
|
||||
end
|
||||
|
||||
def test_post_destroy
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :destroy, :id => 1, :project_id => 'ecookbook'
|
||||
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
||||
assert_equal 0, Contact.where(:id => [1]).count
|
||||
end
|
||||
|
||||
def test_post_bulk_destroy
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :post, :bulk_destroy, :ids => [1, 2, 3]
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index'
|
||||
|
||||
assert_equal 0, Contact.where(:id => [1, 2, 3]).count
|
||||
end
|
||||
|
||||
def test_post_bulk_destroy_without_permission
|
||||
@request.session[:user_id] = 4
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
compatible_request :post, :bulk_destroy, :ids => [1, 2]
|
||||
end
|
||||
end
|
||||
def test_bulk_edit_mails
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :edit_mails, :ids => [1, 2]
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
end
|
||||
|
||||
def test_bulk_edit_mails_by_deny_user
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :post, :edit_mails, :ids => [1, 2]
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_bulk_send_mails_by_deny_user
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :post, :send_mails, :ids => [1, 2], :message => 'test message', :subject => 'test subject'
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_bulk_send_mails
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :send_mails, :ids => [2], :from => 'test@mail.from', :bcc => 'test@mail.bcc', :"message-content" => "Hello %%NAME%%\ntest message", :subject => 'test subject'
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
assert_match /Hello Marat/, mail.text_part.body.to_s
|
||||
assert_equal 'test subject', mail.subject
|
||||
assert_equal 'test@mail.from', mail.from.first
|
||||
assert_equal 'test@mail.bcc', mail.bcc.first
|
||||
note = Note.last
|
||||
assert_equal 'test subject', note.subject
|
||||
assert_equal note.type_id, Note.note_types[:email]
|
||||
assert_equal "Hello Marat\ntest message", note.content
|
||||
end
|
||||
|
||||
def test_post_bulk_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :bulk_edit, :ids => [1, 2]
|
||||
assert_response :success
|
||||
assert_not_nil contacts_in_list
|
||||
end
|
||||
|
||||
def test_post_bulk_edit_without_permission
|
||||
@request.session[:user_id] = 4
|
||||
assert_raises ActiveRecord::RecordNotFound do
|
||||
compatible_request :post, :bulk_edit, :ids => [1, 2]
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_bulk_update
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :put, :bulk_update, :ids => [1, 2],
|
||||
:add_tag_list => 'bulk, edit, tags',
|
||||
:delete_tag_list => 'main',
|
||||
:add_projects_list => ['1', '2', '3'],
|
||||
:delete_projects_list => ['3', '4', '5'],
|
||||
:note => { :content => 'Bulk note content' },
|
||||
:contact => { :company => 'Bulk company', :job_title => '' }
|
||||
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index', :project_id => nil
|
||||
contacts = Contact.find([1, 2])
|
||||
contacts.each do |contact|
|
||||
assert_equal 'Bulk company', contact.company
|
||||
tag_list = contact.tag_list # Need for 4 rails
|
||||
assert tag_list.include?('bulk')
|
||||
assert tag_list.include?('edit')
|
||||
assert tag_list.include?('tags')
|
||||
assert !tag_list.include?('main')
|
||||
assert contact.project_ids.include?(1) && contact.project_ids.include?(2)
|
||||
|
||||
assert_equal 'Bulk note content', contact.notes.find_by_content('Bulk note content').content
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_bulk_update_without_permission
|
||||
@request.session[:user_id] = 4
|
||||
|
||||
compatible_request :put, :bulk_update, :ids => [1, 2],
|
||||
:add_tag_list => 'bulk, edit, tags',
|
||||
:delete_tag_list => 'main',
|
||||
:note => { :content => 'Bulk note content' },
|
||||
:contact => { :company => 'Bulk company', :job_title => '' }
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_get_contacts_notes
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
compatible_request :get, :contacts_notes
|
||||
assert_response :success
|
||||
assert_select 'h2', /All notes/
|
||||
assert_select 'div#contacts_notes table.note_data div.note.content.preview', /Note 1/
|
||||
end
|
||||
|
||||
def test_get_context_menu
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :get, :context_menu, :back_url => '/projects/contacts-plugin/contacts', :project_id => 'ecookbook', :ids => ['1', '2']
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_post_index_with_search
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :index, :search => 'Domoway'
|
||||
assert_response :success
|
||||
assert_match 'contacts?search=Domoway', response.body
|
||||
assert_select 'a', :html => /Domoway/
|
||||
end
|
||||
|
||||
def test_post_index_with_search_in_project
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :index, :search => 'Domoway', :project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_match 'contacts?search=Domoway', response.body
|
||||
assert_select 'a', :html => /Domoway/
|
||||
end
|
||||
|
||||
def test_post_contacts_notes_with_search
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :contacts_notes, :search_note => 'Note 1'
|
||||
assert_response :success
|
||||
assert_match 'note_data', response.body
|
||||
assert_select 'table.note_data div.note.content.preview', /Note 1/
|
||||
assert_select 'table.note_data div.note.content.preview', { :count => 0, :text => /Note 2/ }
|
||||
end
|
||||
|
||||
def test_post_contacts_notes_with_search_in_project
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :contacts_notes, :search_note => 'Note 2', :project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_match 'note_data', response.body
|
||||
assert_select 'table.note_data div.note.content.preview', /Note 2/
|
||||
end
|
||||
def test_should_have_import_csv_link_if_authorized_to
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'a#import_from_csv'
|
||||
end
|
||||
|
||||
def test_should_not_have_import_csv_link_if_unauthorized
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :get, :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'a#import_from_csv', false, 'Should not see CSV import link'
|
||||
end
|
||||
|
||||
def test_index_should_omit_page_param_in_csv_export_link
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :page => 2
|
||||
assert_response :success
|
||||
assert_select 'a.csv[href=?]', '/contacts.csv'
|
||||
assert_select 'form#csv-export-form[action=?]', '/contacts.csv'
|
||||
end
|
||||
|
||||
def test_index_should_include_query_params_in_csv_export_form
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get,
|
||||
:index,
|
||||
{:project_id => 1,
|
||||
:set_filter => 1,
|
||||
:has_deals => 1,
|
||||
:c => ['name', 'job_title'],
|
||||
:sort => 'name'}
|
||||
|
||||
assert_select '#csv-export-form[action=?]', '/projects/ecookbook/contacts.csv'
|
||||
assert_select '#csv-export-form[method=?]', 'get'
|
||||
|
||||
assert_select '#csv-export-form' do
|
||||
assert_select 'input[name=?][value=?]', 'set_filter', '1'
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'f[]', 'has_deals'
|
||||
assert_select 'input[name=?][value=?]', 'op[has_deals]', '='
|
||||
assert_select 'input[name=?][value=?]', 'v[has_deals][]', '1'
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'c[]', 'name'
|
||||
assert_select 'input[name=?][value=?]', 'c[]', 'job_title'
|
||||
|
||||
assert_select 'input[name=?][value=?]', 'sort', 'name'
|
||||
end
|
||||
end if Redmine::VERSION::STRING > '3.2.1'
|
||||
|
||||
def test_index_csv_without_filters
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get,
|
||||
:index,
|
||||
{:format => 'csv',
|
||||
:set_filter => 1,
|
||||
:f => ['']}
|
||||
assert_response :success
|
||||
# -1 for headers
|
||||
lines = @response.body.chomp.lines.count - 1
|
||||
assert_equal Contact.count, lines
|
||||
end if Redmine::VERSION::STRING > '3.3'
|
||||
|
||||
def test_index_csv_with_some_filters
|
||||
@request.session[:user_id] = 1
|
||||
filter = {:job_title => 'CEO'}
|
||||
params = {:format => 'csv', :set_filter => 1}.merge(filter)
|
||||
|
||||
compatible_request :get, :index, params
|
||||
assert_response :success
|
||||
# -1 for headers
|
||||
lines = @response.body.chomp.lines.count - 1
|
||||
assert_equal Contact.where(filter).count, lines
|
||||
end if Redmine::VERSION::STRING > '3.3'
|
||||
|
||||
def test_index_csv_with_few_columns
|
||||
@request.session[:user_id] = 1
|
||||
columns = ['id', 'name', 'company', 'job_title']
|
||||
compatible_request :get,
|
||||
:index,
|
||||
:format => 'csv',
|
||||
:c => columns
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert response.body.starts_with?("#,")
|
||||
|
||||
actual_columns = response.body.chomp.lines.first.split(',').count
|
||||
assert_equal columns.count, actual_columns
|
||||
end
|
||||
|
||||
def test_index_csv_with_all_available_columns
|
||||
@request.session[:user_id] = 1
|
||||
all_columns = if Redmine::VERSION::STRING < '3.2'
|
||||
{:columns => 'all'}
|
||||
elsif Redmine::VERSION::STRING < '3.4'
|
||||
{:csv => {:columns => 'all'}}
|
||||
else
|
||||
{:c => ['all_inline']}
|
||||
end
|
||||
params = {:format => 'csv'}.merge(all_columns)
|
||||
|
||||
compatible_request :get, :index, params
|
||||
assert_response :success
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert response.body.starts_with?("#,")
|
||||
|
||||
available_columns = ContactQuery.new.available_columns.count
|
||||
actual_columns = response.body.chomp.lines.first.split(',').count
|
||||
assert_equal available_columns, actual_columns
|
||||
end
|
||||
|
||||
def test_index_with_contacts_as_cards_exports_all_columns
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :contacts_list_style => 'list_cards'
|
||||
assert_response :success
|
||||
assert_select 'a[href^="/contacts.csv"][onclick^=?]', 'showModal', false
|
||||
end
|
||||
|
||||
def test_index_with_contacts_as_list_allows_to_choose_columns
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :contacts_list_style => 'list'
|
||||
assert_response :success
|
||||
assert_select 'a[href^="/contacts.csv"][onclick^=?]', 'showModal'
|
||||
end
|
||||
|
||||
def test_index_properly_exports_tags_as_text_in_csv
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
contact = Contact.find(1)
|
||||
contact.tags = [RedmineCrm::Tag.new(:name => 'foo')]
|
||||
contact.save
|
||||
|
||||
compatible_request :get,
|
||||
:index,
|
||||
:format => 'csv',
|
||||
:c => ['tags']
|
||||
assert_response :success
|
||||
assert_include "foo\n", @response.body.chomp.lines
|
||||
end
|
||||
|
||||
def test_render_tab_partial_on_load_tab
|
||||
@request.session[:user_id] = 4
|
||||
compatible_xhr_request :get, :load_tab, :id => 3, :tab_name => 'notes', :partial => 'notes', :format => :js
|
||||
assert_response :success
|
||||
assert_match 'note_data', response.body
|
||||
end
|
||||
|
||||
def test_post_create_with_avatar
|
||||
image = Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/files/image.jpg'
|
||||
attach = Attachment.create!(:file => Rack::Test::UploadedFile.new(image, 'image/jpeg'), :author => User.find(1))
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Contact.count' do
|
||||
compatible_request :post, :create, :project_id => 1,
|
||||
:attachments => { '0' => { 'filename' => 'image.jpg', 'description' => 'avatar', 'token' => attach.token } },
|
||||
:contact => { :last_name => 'Testov',
|
||||
:middle_name => 'Test',
|
||||
:first_name => 'Testovich' }
|
||||
end
|
||||
|
||||
assert_redirected_to :controller => 'contacts', :action => 'show', :id => Contact.last.id, :project_id => Contact.last.project
|
||||
assert_equal 'Contact', Attachment.last.container_type
|
||||
assert_equal Contact.last.id, Attachment.last.container_id
|
||||
|
||||
assert_equal 'image.jpg', Attachment.last.diskfile[/image\.jpg/]
|
||||
end
|
||||
|
||||
def test_last_notes_for_contact
|
||||
contact = Contact.find(1)
|
||||
note = contact.notes.create(:content => 'note for contact', :author_id => 1)
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_select '.note.content', :text => note.content
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,103 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
# require 'contacts_duplicates_controller'
|
||||
|
||||
class ContactsDuplicatesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_index_duplicates
|
||||
contact = Contact.find(3)
|
||||
contact_clone = contact.dup
|
||||
contact_clone.project = contact.project
|
||||
contact_clone.save!
|
||||
|
||||
@request.session[:user_id] = 2
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :index, :project_id => contact.project, :contact_id => 3
|
||||
assert_response :success
|
||||
assert_select 'ul#contact_duplicates li', 1
|
||||
assert_select 'ul#contact_duplicates li a', contact.name
|
||||
ensure
|
||||
contact_clone.delete
|
||||
end
|
||||
|
||||
def test_get_merge_duplicates
|
||||
@request.session[:user_id] = 1
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :get, :merge, :project_id => 1, :contact_id => 1, :duplicate_id => 2
|
||||
assert_redirected_to :controller => 'contacts', :action => 'show', :id => 2, :project_id => 'ecookbook'
|
||||
|
||||
contact = Contact.find(2)
|
||||
assert_equal contact.emails, ['marat@mail.ru', 'marat@mail.com', 'ivan@mail.com']
|
||||
end
|
||||
|
||||
def test_xhr_get_duplicates
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :get, :duplicates, :project_id => 'ecookbook', :contact => { :first_name => 'marat' }
|
||||
assert_match /Marat Aminov/, @response.body
|
||||
end
|
||||
|
||||
def test_xhr_get_search
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :get, :search, :project_id => 'ecookbook', :contact_id => 2, :q => 'iva'
|
||||
assert_match /Ivan Ivanov/, @response.body
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,138 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsIssuesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_create_issue
|
||||
@request.session[:user_id] = 1
|
||||
@request.env['HTTP_REFERER'] = '/contacts/1'
|
||||
parameters = { :issue => { :subject => 'Test subject', :assigned_to_id => '1', :due_date => Date.today.to_s, :description => 'Test descripiton', :tracker_id => '1' } }
|
||||
assert_difference('Issue.count') do
|
||||
assert_difference('ContactsIssue.count') do
|
||||
compatible_request :post, :create_issue, { :project_id => 1, :id => 1 }.merge!(parameters)
|
||||
end
|
||||
end
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
def test_delete
|
||||
@request.session[:user_id] = 1
|
||||
ContactsIssue.create(:contact_id => 1, :issue_id => 1)
|
||||
assert_difference('ContactsIssue.count', -1) do
|
||||
compatible_xhr_request :delete, :delete, :project_id => 1, :id => 1, :issue_id => 1
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_close
|
||||
@request.session[:user_id] = 1
|
||||
assert_not_nil Issue.find(1)
|
||||
compatible_xhr_request :post, :close, :issue_id => 1
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_autocomplete_for_contact
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :get, :autocomplete_for_contact, :q => 'domo', :issue_id => '1', :project_id => 'ecookbook', :cross_project_contacts => '1'
|
||||
assert_response :success
|
||||
assert_select 'input', :count => 1
|
||||
if ActiveRecord::VERSION::MAJOR >= 4
|
||||
assert_select "input[name='contacts_issue[contact_ids][]'][value='3']"
|
||||
else
|
||||
assert_select 'input[name=?][value=3]', 'contacts_issue[contact_ids][]'
|
||||
end
|
||||
end
|
||||
|
||||
def test_autocomplete_for_contact_cross_contacts
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
compatible_xhr_request :get, :autocomplete_for_contact, :q => 'a', :issue_id => '4', :project_id => 'onlinestore', :cross_project_contacts => '0'
|
||||
assert_response :success
|
||||
assert_select 'span.contact', :count => 1
|
||||
assert_select 'span.contact', /Ivan Ivanov/
|
||||
|
||||
compatible_xhr_request :get, :autocomplete_for_contact, :q => 'a', :issue_id => '4', :project_id => 'onlinestore', :cross_project_contacts => '1'
|
||||
assert_response :success
|
||||
assert_select 'span.contact', :count => 4
|
||||
assert_select 'span.contact', /Domoway/
|
||||
assert_select 'span.contact', /Ivan Ivanov/
|
||||
assert_select 'span.contact', /Marat Aminov/
|
||||
assert_select 'span.contact', /My company/
|
||||
end
|
||||
|
||||
def test_new
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :get, :new, :issue_id => '1'
|
||||
assert_response :success
|
||||
assert_match /ajax-modal/, response.body
|
||||
end
|
||||
|
||||
def test_create_multiple
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference('ContactsIssue.count', 2) do
|
||||
compatible_xhr_request :post, :create, :issue_id => '2', :contacts_issue => {:contact_ids => ['3', '4']}
|
||||
assert_response :success
|
||||
assert_match /contacts/, response.body
|
||||
assert_match /ajax-modal/, response.body
|
||||
end
|
||||
assert Issue.find(2).contact_ids.include?(3)
|
||||
assert Issue.find(2).contact_ids.include?(4)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,75 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsMailerControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/contacts_mailer'
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_should_create_issue
|
||||
# Enable API and set a key
|
||||
Setting.mail_handler_api_enabled = 1
|
||||
Setting.mail_handler_api_key = 'secret'
|
||||
|
||||
compatible_request :post, :index, :key => 'secret', :email => IO.read(File.join(FIXTURES_PATH, 'fwd_new_note_plain.eml'))
|
||||
assert_response 201
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,94 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsProjectsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:time_entries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_delete_destroy
|
||||
@request.session[:user_id] = 1
|
||||
contact = Contact.find(1)
|
||||
assert_equal 2, contact.projects.size
|
||||
compatible_xhr_request :delete, :destroy, :project_id => 1, :id => 2, :contact_id => 1
|
||||
assert_response :success
|
||||
assert_include 'contact_projects', response.body
|
||||
|
||||
contact.reload
|
||||
assert_equal [1], contact.project_ids
|
||||
end
|
||||
|
||||
def test_delete_destroy_last_project
|
||||
@request.session[:user_id] = 1
|
||||
contact = Contact.find(1)
|
||||
assert RedmineContacts::TestCase.is_arrays_equal(contact.project_ids, [1, 2])
|
||||
compatible_xhr_request :delete, :destroy, :project_id => 1, :id => 2, :contact_id => 1
|
||||
assert_response :success
|
||||
compatible_xhr_request :delete, :destroy, :project_id => 1, :id => 1, :contact_id => 1
|
||||
assert_response 403
|
||||
|
||||
contact.reload
|
||||
assert_equal [1], contact.project_ids
|
||||
end
|
||||
|
||||
def test_post_new
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_xhr_request :post, :new, :project_id => 'ecookbook', :id => 2, :contact_id => 2
|
||||
assert_response :success
|
||||
assert_include 'contact_projects', response.body
|
||||
contact = Contact.find(2)
|
||||
assert RedmineContacts::TestCase.is_arrays_equal(contact.project_ids, [1, 2])
|
||||
end
|
||||
|
||||
def test_post_create_without_permissions
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_xhr_request :post, :create, :project_id => 'project6', :id => 2, :contact_id => 2
|
||||
assert_response 403
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,60 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsSettingsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:time_entries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_should_save_setting
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :save, :project_id => 1, :contacts_settings => { :setting1 => 1, :setting2 => 'Hello' }, :tab => 'contacts'
|
||||
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'contacts', :id => 'ecookbook'
|
||||
assert_equal '1', ContactsSetting[:setting1, 1]
|
||||
assert_equal 'Hello', ContactsSetting[:setting2, 1]
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,112 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsTagsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@request.env['HTTP_REFERER'] = '/'
|
||||
end
|
||||
|
||||
def test_should_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
assigned_tag = css_select('#tag_name').map { |tag| tag['value'] }.join
|
||||
assert_not_nil assigned_tag
|
||||
assert_equal RedmineCrm::Tag.find(1).name, assigned_tag
|
||||
end
|
||||
|
||||
def test_should_put_update
|
||||
@request.session[:user_id] = 1
|
||||
tag1 = RedmineCrm::Tag.find(1)
|
||||
new_name = 'updated main'
|
||||
compatible_request :put, :update, :id => 1, :tag => { :name => new_name, :color_name => '#000000' }
|
||||
assert_redirected_to :controller => 'settings', :action => 'plugin', :id => 'redmine_contacts', :tab => 'tags'
|
||||
tag1.reload
|
||||
assert_equal new_name, tag1.name
|
||||
end
|
||||
|
||||
def test_should_delete_destroy
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'RedmineCrm::Tag.count', -1 do
|
||||
compatible_request :post, :destroy, :id => 1
|
||||
assert_response 302
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_get_merge
|
||||
@request.session[:user_id] = 1
|
||||
tag1 = RedmineCrm::Tag.find(1)
|
||||
tag2 = RedmineCrm::Tag.find(2)
|
||||
compatible_request :get, :merge, :ids => [tag1.id, tag2.id]
|
||||
assert_response :success
|
||||
merged_tags = css_select('.tag_list a').map { |tag| tag.to_s.to_s[/.*>(.+?)<\/a>/, 1] }
|
||||
assert_equal 2, merged_tags.size
|
||||
end
|
||||
|
||||
def test_should_post_merge
|
||||
@request.session[:user_id] = 1
|
||||
tag1 = RedmineCrm::Tag.find(1)
|
||||
tag2 = RedmineCrm::Tag.find(2)
|
||||
assert_difference 'RedmineCrm::Tag.count', -1 do
|
||||
compatible_request :post, :merge, :ids => [tag1.id, tag2.id], :tag => { :name => 'main' }
|
||||
assert_redirected_to :controller => 'settings', :action => 'plugin', :id => 'redmine_contacts', :tab => 'tags'
|
||||
end
|
||||
assert_equal 0, Contact.tagged_with('test').count
|
||||
assert_equal 4, Contact.tagged_with('main').count # added one more tagging for tag2
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,107 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsVcfControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
def test_load_from_vcard
|
||||
@request.session[:user_id] = 1
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :post, :load, {
|
||||
:project_id => 1,
|
||||
:contact_vcf => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'kirill_bezrukov.vcf', 'text/x-vcard')
|
||||
}
|
||||
|
||||
assert_redirected_to new_project_contact_path(:project_id => 'ecookbook', :contact => {
|
||||
'background' => 'Текстовое описание на Русском',
|
||||
'birthday' => '1981-05-12',
|
||||
'email' => 'kirill@gmail.com',
|
||||
'first_name' => 'Кирилл',
|
||||
'job_title' => '',
|
||||
'address_attributes' => { 'city' => 'Москва', 'postcode' => '', 'region' => '', 'street1' => 'Миклухи Маклая, 9 к 2, корпус Б' },
|
||||
'last_name' => 'Безруков',
|
||||
'middle_name' => '',
|
||||
'phone' => '+1 (234) 234-11-33'
|
||||
})
|
||||
end
|
||||
|
||||
def test_load_from_vcard_with_umlauts
|
||||
@request.session[:user_id] = 1
|
||||
Setting.default_language = 'en'
|
||||
|
||||
compatible_request :post, :load, {
|
||||
:project_id => 1,
|
||||
:contact_vcf => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'umlaut_card.vcf', 'text/x-vcard')
|
||||
}
|
||||
|
||||
assert_redirected_to new_project_contact_path(:project_id => 'ecookbook', :contact => {
|
||||
'address_attributes' => { 'city' => 'Düsseldorf', 'postcode' => '11111 ', 'region' => 'Nordrhein-Westfalen', 'street1' => 'Bleichstraße' },
|
||||
'background' => 'Test note',
|
||||
'birthday' => '1980-12-01',
|
||||
'company' => 'Geschäftszweig',
|
||||
'email' => 't.test@test.com',
|
||||
'first_name' => 'Test',
|
||||
'job_title' => 'Tester',
|
||||
'last_name' => 'Testovish',
|
||||
'middle_name' => '',
|
||||
'phone' => '+11-111-111111-11111'
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,138 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class CrmQueriesControllerTest < ActionController::TestCase
|
||||
fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :enumerations, :issues
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1
|
||||
end
|
||||
|
||||
def test_get_new_project_query
|
||||
compatible_request :get, :new, :project_id => 1, :object_type => 'contact'
|
||||
assert_response :success
|
||||
att = { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => nil,
|
||||
:disabled => nil }
|
||||
assert_select 'input', :attributes => att
|
||||
end
|
||||
|
||||
def test_get_new_global_query
|
||||
compatible_request :get, :new, :object_type => 'contact'
|
||||
assert_response :success
|
||||
att = { :type => 'checkbox',
|
||||
:name => 'query_is_for_all',
|
||||
:checked => 'checked',
|
||||
:disabled => nil }
|
||||
assert_select 'input', :attributes => att
|
||||
end
|
||||
|
||||
def test_post_create_project_public_query
|
||||
if Redmine::VERSION.to_s < '2.4'
|
||||
query_params = { 'name' => 'test_new_project_public_contacts_query', 'is_public' => '1' }
|
||||
else
|
||||
query_params = { 'name' => 'test_new_project_public_contacts_query', 'visibility' => '2' }
|
||||
end
|
||||
|
||||
compatible_request :post, :create,
|
||||
:project_id => 'ecookbook',
|
||||
:object_type => 'contact',
|
||||
:default_columns => '1',
|
||||
:f => ['first_name', 'last_name'],
|
||||
:op => { 'first_name' => '=', 'last_name' => '=' },
|
||||
:v => { 'first_name' => ['Ivan'], 'last_name' => ['Ivanov'] },
|
||||
:query => query_params
|
||||
|
||||
q = ContactQuery.find_by_name('test_new_project_public_contacts_query')
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
||||
assert q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_post_create_project_private_query
|
||||
|
||||
if Redmine::VERSION.to_s < '2.4'
|
||||
query_params = { 'name' => 'test_new_project_public_contacts_query', 'is_public' => '0' }
|
||||
else
|
||||
query_params = { 'name' => 'test_new_project_public_contacts_query', 'visibility' => '0' }
|
||||
end
|
||||
|
||||
compatible_request :post, :create,
|
||||
:project_id => 'ecookbook',
|
||||
:object_type => 'contact',
|
||||
:default_columns => '1',
|
||||
:f => ['first_name', 'last_name'],
|
||||
:op => { 'first_name' => '=', 'last_name' => '=' },
|
||||
:v => { 'first_name' => ['Ivan'], 'last_name' => ['Ivanov'] },
|
||||
:query => query_params
|
||||
|
||||
q = ContactQuery.find_by_name('test_new_project_public_contacts_query')
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index', :project_id => 'ecookbook', :query_id => q
|
||||
assert !q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_put_update_global_public_query
|
||||
|
||||
if Redmine::VERSION.to_s < '2.4'
|
||||
query_params = { 'name' => 'test_edit_global_public_query', 'is_public' => '1' }
|
||||
else
|
||||
query_params = { 'name' => 'test_edit_global_public_query', 'visibility' => '2' }
|
||||
end
|
||||
|
||||
compatible_request :put, :update,
|
||||
:id => 2,
|
||||
:object_type => 'contact',
|
||||
:default_columns => '1',
|
||||
:fields => ['first_name', 'last_name'],
|
||||
:operators => { 'first_name' => '=', 'last_name' => '=' },
|
||||
:values => { 'first_name' => ['Ivan'], 'last_name' => ['Ivanov'] },
|
||||
:query => query_params
|
||||
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index', :project_id => 'ecookbook', :query_id => 2
|
||||
q = ContactQuery.find_by_name('test_edit_global_public_query')
|
||||
assert q.is_public?
|
||||
assert q.has_default_columns?
|
||||
assert q.valid?
|
||||
end
|
||||
|
||||
def test_delete_destroy
|
||||
compatible_request :delete, :destroy, :id => 2, :object_type => 'contact'
|
||||
assert_redirected_to :controller => 'contacts', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil
|
||||
assert_nil Query.find_by_id(2)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,120 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealCategoriesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:deal_categories,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
category_name = css_select('#category_name').map { |tag| tag['value'] }.join
|
||||
assert_not_nil category_name
|
||||
assert_equal DealCategory.find(1).name, category_name
|
||||
end
|
||||
|
||||
def test_put_update
|
||||
@request.session[:user_id] = 1
|
||||
category1 = DealCategory.find(1)
|
||||
new_name = 'updated main'
|
||||
compatible_request :put, :update, :id => 1, :category => { :name => new_name }
|
||||
assert_redirected_to '/projects/ecookbook/settings/deals'
|
||||
category1.reload
|
||||
assert_equal new_name, category1.name
|
||||
end
|
||||
|
||||
def test_destroy_category_not_in_use
|
||||
compatible_request :delete, :destroy, :id => 2
|
||||
assert_redirected_to '/projects/ecookbook/settings/deals'
|
||||
assert_nil DealCategory.find_by_id(2)
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use
|
||||
compatible_request :delete, :destroy, :id => 1
|
||||
assert_response :success
|
||||
assert_not_nil DealCategory.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use_with_reassignment
|
||||
deal = Deal.where(:category_id => 1).first
|
||||
compatible_request :delete, :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2
|
||||
assert_redirected_to '/projects/ecookbook/settings/deals'
|
||||
assert_nil DealCategory.find_by_id(1)
|
||||
# check that the issue was reassign
|
||||
assert_equal 2, deal.reload.category_id
|
||||
end
|
||||
|
||||
def test_destroy_category_in_use_without_reassignment
|
||||
deal = Deal.where(:category_id => 1).first
|
||||
compatible_request :delete, :destroy, :id => 1, :todo => 'nullify'
|
||||
assert_redirected_to '/projects/ecookbook/settings/deals'
|
||||
assert_nil DealCategory.find_by_id(1)
|
||||
# check that the issue category was nullified
|
||||
assert_nil deal.reload.category_id
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,151 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealImportsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
@controller = DealImportsController.new
|
||||
User.current = nil
|
||||
@csv_file = Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'deals_correct.csv', 'text/csv')
|
||||
end
|
||||
|
||||
test 'should open contact import form' do
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :success
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
assert_select 'form input#file'
|
||||
else
|
||||
assert_select 'form.new_deal_import'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should create new import object' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :create, :project_id => 1, :file => @csv_file
|
||||
assert_response :redirect
|
||||
assert_equal Import.last.class, DealKernelImport
|
||||
assert_equal Import.last.user, User.find(1)
|
||||
assert_equal Import.last.project, 1
|
||||
assert_equal Import.last.settings, { 'project' => 1,
|
||||
'separator' => ';',
|
||||
'wrapper' => "\"",
|
||||
'encoding' => 'ISO-8859-1',
|
||||
'date_format' => '%m/%d/%Y' }
|
||||
end
|
||||
end
|
||||
|
||||
test 'should open settings page' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
import = DealKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.project = Project.find(1)
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :get, :settings, :id => import.filename, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'form#import-form'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should show mapping page' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
@request.session[:user_id] = 1
|
||||
import = DealKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.settings = { 'project' => 1,
|
||||
'separator' => ';',
|
||||
'wrapper' => "\"",
|
||||
'encoding' => 'UTF-8',
|
||||
'date_format' => '%m/%d/%Y' }
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :get, :mapping, :id => import.filename, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select "select[name='import_settings[mapping][name]']"
|
||||
assert_select 'select[name="import_settings[mapping][currency]"]'
|
||||
assert_select 'table.sample-data tr'
|
||||
assert_select 'table.sample-data tr td', 'Сделка века'
|
||||
assert_select 'table.sample-data tr td', 'Кемска волость'
|
||||
end
|
||||
end
|
||||
|
||||
test 'should successfully import from CSV with new import' do
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
cf = DealCustomField.create!(:name => 'LIST_FIELD', :field_format => 'list', :multiple => true, :possible_values => %w(1 2 3))
|
||||
@request.session[:user_id] = 1
|
||||
import = DealKernelImport.new
|
||||
import.user = User.find(1)
|
||||
import.settings = { 'project' => 1,
|
||||
'separator' => ';',
|
||||
'wrapper' => "\"",
|
||||
'encoding' => 'UTF-8',
|
||||
'date_format' => '%m/%d/%Y' }
|
||||
import.file = @csv_file
|
||||
import.save!
|
||||
compatible_request :post, :mapping, :id => import.filename, :project_id => 1, :import_settings => { :mapping => { :name => 1, :background => 2, "cf_#{cf.id}" => 12 } }
|
||||
assert_response :redirect
|
||||
compatible_request :post, :run, :id => import.filename, :project_id => 1, :format => :js
|
||||
assert_equal Deal.last.name, 'Сделка века'
|
||||
assert_equal Deal.last.background, 'Кемска волость'
|
||||
assert_equal Deal.last.custom_field_value(cf).sort, ['1', '3']
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,122 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealStatusesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
@controller = DealStatusesController.new
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index_by_anonymous_should_redirect_to_login_form
|
||||
@request.session[:user_id] = nil
|
||||
compatible_request :get, :index
|
||||
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fdeal_statuses'
|
||||
end
|
||||
|
||||
def test_should_get_new
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :new
|
||||
assert_response :success
|
||||
assert_select 'h2', %r{New}
|
||||
end
|
||||
|
||||
def test_should_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', %r{#{DealStatus.find(1).name}}
|
||||
end
|
||||
|
||||
def test_should_post_update
|
||||
@request.session[:user_id] = 1
|
||||
status1 = DealStatus.find(1)
|
||||
new_name = 'updated main'
|
||||
compatible_request :put, :update, :id => 1, :deal_status => { :name => new_name, :color_name => '#000000' }
|
||||
assert_redirected_to :controller => 'settings', :action => 'plugin', :id => 'redmine_contacts', :tab => 'deal_statuses'
|
||||
status1.reload
|
||||
assert_equal new_name, status1.name
|
||||
end
|
||||
|
||||
def test_assing_to_project
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :put, :assing_to_project, :deal_statuses => ['1', '2'], :project_id => 'ecookbook'
|
||||
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'deals', :id => 'ecookbook'
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 1
|
||||
Deal.where('status_id = 1').delete_all
|
||||
|
||||
assert_difference 'DealStatus.count', -1 do
|
||||
compatible_request :delete, :destroy, :id => '1'
|
||||
end
|
||||
assert_redirected_to :controller => 'settings', :action => 'plugin', :id => 'redmine_contacts', :tab => 'deal_statuses'
|
||||
assert_nil DealStatus.find_by_id(1)
|
||||
end
|
||||
|
||||
def test_destroy_should_block_if_status_in_use
|
||||
@request.session[:user_id] = 1
|
||||
assert_not_nil Deal.find_by_status_id(1)
|
||||
|
||||
assert_no_difference 'DealStatus.count' do
|
||||
compatible_request :delete, :destroy, :id => '1'
|
||||
end
|
||||
assert_redirected_to :controller => 'settings', :action => 'plugin', :id => "redmine_contacts", :tab => "deal_statuses"
|
||||
assert_not_nil DealStatus.find_by_id(1)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,506 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
include RedmineContacts::TestHelper
|
||||
|
||||
class DealsControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:deal_statuses_projects,
|
||||
:notes])
|
||||
if RedmineContacts.products_plugin_installed?
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_products).directory + '/test/fixtures/', [:product_categories,
|
||||
:products,
|
||||
:order_statuses,
|
||||
:orders,
|
||||
:product_lines])
|
||||
end
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_get_index
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'a', /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_list
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :deals_list_style => 'list'
|
||||
assert_response :success
|
||||
assert_select 'table.list.deals'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'a', /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_board
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :deals_list_style => 'list_board'
|
||||
assert_response :success
|
||||
assert_select 'table.list.deal-board'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'a', /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_pipeline
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :deals_list_style => 'list_pipeline'
|
||||
assert_response :success
|
||||
assert_select 'table.list.sales-funnel'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'tr.deal_status_type-0 span', /Pending/
|
||||
end
|
||||
|
||||
def test_get_index_calendar
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :deals_list_style => 'crm_calendars/crm_calendar'
|
||||
assert_response :success
|
||||
assert_select 'table.cal'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'td.even div.deal a', /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_board_with_sorting
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :deals_list_style => 'list_board', :sort => 'due_date'
|
||||
assert_response :success
|
||||
assert_select 'table.list.deal-board'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'a', /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_with_closed
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deals'
|
||||
assert_select 'a', /First deal with contacts/
|
||||
assert_select 'table.contacts.index h1.deal_name a', { :count => 0, :text => /Closed deal/ }
|
||||
end
|
||||
|
||||
def test_get_closed_index_with_pages
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :f => ['']
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deals'
|
||||
assert_select 'table.contacts.index h1.deal_name a', /Closed deal/
|
||||
end
|
||||
|
||||
def test_get_index_with_filters
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :f => ['status_id', ''], :op => { 'status_id' => '=' }, :v => { 'status_id' => ['3'] }
|
||||
assert_equal 1, deals_in_list.count
|
||||
assert_select 'table.contacts.index h1.deal_name a', /Second deal with contacts/
|
||||
assert_select 'table.contacts.index h1.deal_name a', { :count => 0, :text => 'Deal without contact' }
|
||||
end
|
||||
|
||||
def test_get_index_with_project
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :get, :index, :project_id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deals'
|
||||
assert_not_nil deals_in_list
|
||||
assert_select 'a', :html => /First deal with contacts/
|
||||
assert_select 'Second deal with contacts', false
|
||||
assert_select 'h3', :html => /Recently viewed/
|
||||
end
|
||||
|
||||
def test_filter_by_ids
|
||||
@request.session[:user_id] = 1
|
||||
ids = [3, 2]
|
||||
compatible_request :get, :index, :project_id => 2, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '=' }, 'v' => { 'ids' => [ids.join(',')] }
|
||||
assert_response :success
|
||||
assert_equal ids.sort, deals_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_any
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 1, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '*' }
|
||||
assert_response :success
|
||||
assert_equal Project.find(1).deals.map(&:id).sort, deals_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_filter_by_ids_more_than
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 2, :set_filter => 1, 'f' => ['ids', ''], 'op' => { 'ids' => '>=' }, 'v' => { 'ids' => [3] }
|
||||
assert_response :success
|
||||
assert_equal [3, 4, 5], deals_in_list.map(&:id).sort
|
||||
end if Redmine::VERSION.to_s >= '3.3'
|
||||
|
||||
def test_get_index_without_statuses
|
||||
project = Project.find_by_identifier('onlinestore')
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 'onlinestore'
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deals'
|
||||
assert_equal 1, deals_in_list.count
|
||||
|
||||
assert_select 'table.deals_statistics'
|
||||
assert_select'a', :html => /Deal without contact/
|
||||
assert_select'span.tag-label-color a', :text => 'Pending(1)'
|
||||
|
||||
project.deal_statuses.delete_all
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :project_id => 'onlinestore'
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deals'
|
||||
assert_equal 1, deals_in_list.count
|
||||
|
||||
assert_select 'table.deals_statistics', { :count => 0 }
|
||||
assert_select 'a', :html => /Deal without contact/
|
||||
end
|
||||
|
||||
def test_post_create
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Deal.count' do
|
||||
compatible_request :post, :create, :project_id => 1,
|
||||
:deal => { :price => 5500,
|
||||
:name => 'New created deal 1',
|
||||
:background => 'Background of new created deal',
|
||||
:contact_id => 2,
|
||||
:assigned_to_id => 3,
|
||||
:category_id => 1,
|
||||
:probability => 30,
|
||||
:currency => 'RUB' }
|
||||
end
|
||||
assert_redirected_to :controller => 'deals', :action => 'show', :id => Deal.last.id
|
||||
|
||||
deal = Deal.find_by_name('New created deal 1')
|
||||
assert_not_nil deal
|
||||
assert_equal 1, deal.category_id
|
||||
assert_equal 2, deal.contact_id
|
||||
assert_equal 3, deal.assigned_to_id
|
||||
assert_equal 30, deal.probability
|
||||
assert_equal 'RUB', deal.currency
|
||||
end
|
||||
|
||||
def test_post_create_with_formatted_price
|
||||
with_contacts_settings('thousands_delimiter' => '.', 'decimal_separator' => ',') do
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Deal.count' do
|
||||
compatible_request :post, :create, :project_id => 1,
|
||||
:deal => { :price => '1.234,56',
|
||||
:name => 'New created deal 2',
|
||||
:background => 'Background of new created deal',
|
||||
:contact_id => 2,
|
||||
:assigned_to_id => 3,
|
||||
:category_id => 1,
|
||||
:probability => 30,
|
||||
:currency => 'RUB' }
|
||||
end
|
||||
assert_redirected_to :controller => 'deals', :action => 'show', :id => Deal.last.id
|
||||
|
||||
deal = Deal.find_by_name('New created deal 2')
|
||||
assert_not_nil deal
|
||||
assert_equal 1234.56, deal.price
|
||||
end
|
||||
end
|
||||
|
||||
def test_get_show
|
||||
@request.session[:user_id] = 1
|
||||
deal = Deal.find(1)
|
||||
compatible_request :get, :show, :id => deal.id
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deal #1'
|
||||
assert_select 'table.subject_header td.name h1', %r{#{deal.name}}
|
||||
end
|
||||
|
||||
def test_get_show_with_custom_field
|
||||
NoteCustomField.create!(:name => 'TestCustomField', :default_value => 'test text', :field_format => 'string')
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :show, :id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deal #1'
|
||||
assert_match 'TestCustomField', @response.body
|
||||
assert_match 'test text', @response.body
|
||||
end
|
||||
|
||||
def test_get_show_with_statuses
|
||||
project = Project.find(1)
|
||||
project.deal_statuses.delete_all
|
||||
project.deal_statuses << DealStatus.find(1)
|
||||
project.deal_statuses << DealStatus.find(2)
|
||||
project.save
|
||||
|
||||
assert_equal ['Intermediate 1', 'Intermediate 2', 'Lost', 'Pending', 'Won'].sort, DealStatus.all.map(&:name).sort
|
||||
assert_equal ['Pending', 'Won'].sort, project.deal_statuses.map(&:name).sort
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :show, :id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Deal #1'
|
||||
assert_select '#deal_status_id', /Pending/
|
||||
assert_select '#deal_status_id', /Won/
|
||||
assert_select '#deal_status_id', { :count => 0, :text => /Lost/ }
|
||||
end
|
||||
|
||||
def test_get_new
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
project = Project.find(1)
|
||||
project.deal_statuses << DealStatus.default
|
||||
project.save
|
||||
|
||||
compatible_request :get, :new, :project_id => 1
|
||||
assert_response :success
|
||||
assert_equal DealStatus.default, Deal.new.status
|
||||
assert_equal ContactsSetting.default_currency, Deal.new.currency
|
||||
end
|
||||
|
||||
def test_index_should_not_contatin_add_deal_link
|
||||
EnabledModule.where(:name => 'deals').delete_all
|
||||
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_select '[href="/deals/new"]', { :count => 0 }
|
||||
end
|
||||
|
||||
def test_get_edit
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :edit, :id => 1
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Edit deal information'
|
||||
assert_equal Deal.find(1).name, css_select('input#deal_name').map { |tag| tag['value'] }.join
|
||||
end
|
||||
|
||||
def test_put_update
|
||||
@request.session[:user_id] = 1
|
||||
Setting.plugin_redmine_contacts['thousands_delimiter'] = ','
|
||||
Setting.plugin_redmine_contacts['decimal_separator'] = '.'
|
||||
|
||||
deal = Deal.find(3)
|
||||
new_name = 'Name modified by DealControllerTest#test_put_update'
|
||||
|
||||
compatible_request :put, :update, :id => 3, :deal => { :name => new_name, :currency => 'GBP', :price => 23000 }
|
||||
assert_redirected_to :action => 'show', :id => '3'
|
||||
deal.reload
|
||||
assert_equal 23000, deal.price
|
||||
|
||||
compatible_request :get, :show, :id => 3
|
||||
assert_response :success
|
||||
assert_select 'td.subject_info', /23\,000\.0/
|
||||
assert_equal new_name, deal.name
|
||||
end
|
||||
|
||||
def test_should_bulk_edit_deals
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :post, :bulk_edit, :ids => [1, 2, 4]
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Edit all selected deals'
|
||||
assert_not_nil deals_in_list
|
||||
end
|
||||
|
||||
def test_should_not_bulk_edit_deals_by_deny_user
|
||||
@request.session[:user_id] = 4
|
||||
compatible_request :post, :bulk_edit, :ids => [1, 2, 4]
|
||||
assert_response 403
|
||||
end
|
||||
|
||||
def test_should_put_bulk_update
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
compatible_request :put, :bulk_update, :ids => [1, 2, 4],
|
||||
:deal => { :assigned_to_id => 2,
|
||||
:category_id => 2,
|
||||
:currency => 'GBP' },
|
||||
:note => { :content => 'Bulk deals edit note content' }
|
||||
|
||||
assert_redirected_to :controller => 'deals', :action => 'index', :project_id => nil
|
||||
|
||||
deals = Deal.find(1, 2, 4)
|
||||
|
||||
assert_equal [2], deals.collect(&:assigned_to_id).uniq
|
||||
assert_equal [2], deals.collect(&:category_id).uniq
|
||||
assert_equal ['GBP'], deals.collect(&:currency).uniq
|
||||
|
||||
assert_equal 3, Note.where(:content => 'Bulk deals edit note content').count
|
||||
end
|
||||
|
||||
def test_should_delete_bulk_destroy
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :delete, :bulk_destroy, :ids => [1, 2, 4]
|
||||
assert_redirected_to :controller => 'deals', :action => 'index'
|
||||
end
|
||||
|
||||
def test_post_index_live_search
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :index, :search => 'First'
|
||||
assert_response :success
|
||||
assert_select 'table.deals.index'
|
||||
assert_select 'a', :html => /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_should_post_index_live_search_in_project
|
||||
@request.session[:user_id] = 1
|
||||
compatible_xhr_request :post, :index, :search => 'First', :project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_select 'table.deals.index'
|
||||
assert_select 'a', :content => /First deal with contacts/
|
||||
end
|
||||
|
||||
def test_should_get_index_as_csv
|
||||
field = DealCustomField.create!(:name => 'Test custom field', :is_filter => true, :field_format => 'string')
|
||||
deal = Deal.find(1)
|
||||
deal.custom_field_values = { field.id => "This is custom значение" }
|
||||
deal.save
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :format => 'csv'
|
||||
assert_response :success
|
||||
assert_not_nil deals_in_list
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
assert_match 'Test custom field', @response.body
|
||||
assert_match 'This is custom значение', @response.body
|
||||
end
|
||||
|
||||
def test_put_update_recalc_count_in_status
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
project = Project.find 1
|
||||
deal = project.deals.first
|
||||
old_status = deal.status.id
|
||||
new_status_id = old_status + 1
|
||||
new_status = DealStatus.find(new_status_id)
|
||||
next_status_count = Deal.where(:status_id => new_status_id, :project_id => project.id).count
|
||||
compatible_request :put, :update, :id => 1, :deal => { :status_id => new_status_id }, :status_id => '*', :format => 'js', :project_id => 1
|
||||
deal.reload
|
||||
assert_equal new_status, deal.status
|
||||
assert_match "#{new_status.name} (#{next_status_count + 1})", @response.body
|
||||
end
|
||||
|
||||
def test_delete_links_for_watchers
|
||||
deal = Deal.find(1)
|
||||
user = User.find(2)
|
||||
Watcher.create!(:watchable_type => 'Deal', :watchable => deal, :user => user)
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :show, :id => 1
|
||||
assert_response :success
|
||||
assert_select "ul.watchers li.user-#{user.id} a.delete"
|
||||
end
|
||||
def test_create_with_related_product
|
||||
@request.session[:user_id] = 1
|
||||
product = Product.find(1)
|
||||
compatible_request :post, :create, :project_id => 1,
|
||||
:deal => { :price => 5500,
|
||||
:name => 'New deal with product',
|
||||
:background =>'Background of new created deal',
|
||||
:contact_id => 2,
|
||||
:assigned_to_id => 3,
|
||||
:category_id => 1,
|
||||
:probability => 30,
|
||||
:currency => 'RUB',
|
||||
:lines_attributes => { '0' => { :product_id => product.id,
|
||||
:description => '',
|
||||
:quantity => '2',
|
||||
:price => '223.0',
|
||||
:tax => '5.0',
|
||||
:discount => '10',
|
||||
:_destroy => 'false',
|
||||
:position => '' } } }
|
||||
assert_redirected_to :controller => 'deals', :action => 'show', :id => Deal.last.id
|
||||
|
||||
deal = Deal.find_by_name('New deal with product')
|
||||
assert_not_nil deal
|
||||
assert_equal 1, deal.category_id
|
||||
assert_equal 2, deal.contact_id
|
||||
assert_equal 3, deal.assigned_to_id
|
||||
assert_equal 30, deal.probability
|
||||
assert_equal 'RUB', deal.currency
|
||||
assert_equal 1, deal.lines.count
|
||||
assert_equal product, deal.lines.last.product
|
||||
end if RedmineContacts.products_plugin_installed?
|
||||
|
||||
def test_get_show_with_related_product
|
||||
@request.session[:user_id] = 1
|
||||
deal = Deal.find(1)
|
||||
compatible_request :get, :show, :id => deal.id
|
||||
|
||||
assert_response :success
|
||||
assert_select 'table.product-lines tr.line-data', 1
|
||||
end if RedmineContacts.products_plugin_installed?
|
||||
|
||||
def test_get_edit_with_related_product
|
||||
@request.session[:user_id] = 1
|
||||
deal = Deal.find(1)
|
||||
compatible_request :get, :edit, :id => deal.id
|
||||
|
||||
assert_response :success
|
||||
assert_select 'table.product-lines tr.sortable-line', 1
|
||||
end if RedmineContacts.products_plugin_installed?
|
||||
|
||||
def test_get_index_with_product_filter
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :set_filter => '1', :f => ['products', ''], :op => { 'products' => '*' }
|
||||
assert_equal 5, deals_in_list.count
|
||||
assert_select 'table.deals.index h1.deal_name a', /First deal with contacts/
|
||||
end if RedmineContacts.products_plugin_installed?
|
||||
|
||||
def test_get_index_with_product_category_filter
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index, :set_filter => '1', :f => ['product_category_id', ''], :op => { 'product_category_id' => '=' }, :v => { :product_category_id => ['1'] }
|
||||
assert_equal 1, deals_in_list.count
|
||||
assert_select 'table.deals.index h1.deal_name a', /First deal with contacts/
|
||||
end if RedmineContacts.products_plugin_installed?
|
||||
end
|
||||
@@ -0,0 +1,149 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IssuesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@request.session[:user_id] = 1
|
||||
end
|
||||
|
||||
def test_get_show_issue_with_deal_and_contacts
|
||||
compatible_request :get, :show, :id => 1
|
||||
assert_response :success
|
||||
assert_select '#issue_contacts span.contact a', /Marat Aminov/
|
||||
if Redmine::VERSION.to_s >= '3.2'
|
||||
assert_select 'div.value a', /Ivan Ivanov: First deal with contacts/
|
||||
else
|
||||
assert_select 'td a', /Ivan Ivanov: First deal with contacts/
|
||||
end
|
||||
end
|
||||
def test_get_index_with_contacts_and_deals
|
||||
compatible_request :get, :index, :f => ['status_id', 'companies', 'deal', ''],
|
||||
:op => { :status_id => 'o', :companies => '=', :deal => '=' },
|
||||
:v => { :companies => ['3'], :deal => ['2'] },
|
||||
:c => ['subject', 'contacts', 'deal'],
|
||||
:project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_select 'table.list.issues td.contacts span.contact a', /Marat Aminov/
|
||||
assert_select 'table.list.issues td.deal a', /Second deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_issues_without_contacts
|
||||
compatible_request :get, :index, :f => ['status_id', 'contacts', ''],
|
||||
:op => { :status_id => '*', :contacts => '!*' },
|
||||
:c => ['subject', 'contacts'],
|
||||
:project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_select 'table.list.issues td.contacts', ''
|
||||
end
|
||||
|
||||
def test_get_issues_only_with_contacts
|
||||
compatible_request :get, :index, :f => ['status_id', 'contacts', ''],
|
||||
:op => { :status_id => '*', :contacts => '*' },
|
||||
:c => ['subject', 'contacts'],
|
||||
:project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_select 'table.list.issues td.contacts'
|
||||
end
|
||||
|
||||
def test_get_new_with_deal
|
||||
compatible_request :get, :new, :project_id => 'ecookbook', :deal_id => 1
|
||||
assert_response :success
|
||||
assert_select 'select#issue_deals_issue_attributes_deal_id', /First deal with contacts/
|
||||
if ActiveRecord::VERSION::MAJOR >= 4
|
||||
assert_select "#issue_deals_issue_attributes_deal_id option[value='1']"
|
||||
else
|
||||
assert_select '#issue_deals_issue_attributes_deal_id option[value=?]', 1
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_create_with_deal
|
||||
assert_difference 'DealsIssue.count' do
|
||||
compatible_request :post, :create, :issue => { :tracker_id => 3, :subject => 'test', :status_id => 2, :priority_id => 5,
|
||||
:deals_issue_attributes => { :deal_id => 1 } },
|
||||
:project_id => 'ecookbook'
|
||||
end
|
||||
|
||||
issue = Issue.order('id ASC').last
|
||||
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
||||
assert_not_nil issue.deal
|
||||
end
|
||||
|
||||
def test_post_create_with_invalid_deal_id
|
||||
assert_no_difference 'Issue.count' do
|
||||
compatible_request :post, :create, :issue => { :tracker_id => 3, :subject => 'test', :status_id => 2, :priority_id => 5,
|
||||
:deals_issue_attributes => { :deal_id => 'abc' } },
|
||||
:project_id => 'ecookbook'
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_update_form
|
||||
issue = Issue.find(1)
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
compatible_xhr_request :put, :update_form, :issue => { :tracker_id => 2,
|
||||
:deals_issue_attributes => { :deal_id => 2 } },
|
||||
:project_id => issue.project
|
||||
assert_response :success
|
||||
assert_equal 'text/javascript', response.content_type
|
||||
|
||||
issue = assigns(:issue)
|
||||
assert_kind_of Issue, issue
|
||||
assert_equal 2, issue.deals_issue.deal_id
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,91 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class NotesControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
@request.env['HTTP_REFERER'] = '/'
|
||||
end
|
||||
|
||||
def test_should_post_add_note_to_contact
|
||||
@request.session[:user_id] = 1
|
||||
assert_difference 'Note.count' do
|
||||
compatible_request :post, :create, :project_id => 1,
|
||||
:note => { :subject => 'Note subject',
|
||||
:content => 'Note *content*' },
|
||||
:source_type => Contact.to_s,
|
||||
:source_id => 1
|
||||
end
|
||||
|
||||
note = Note.where(:subject => 'Note subject', :content => 'Note *content*').first
|
||||
assert_not_nil note
|
||||
assert_equal 1, note.source_id
|
||||
assert_equal Contact, note.source.class
|
||||
end
|
||||
|
||||
def test_should_put_update
|
||||
@request.session[:user_id] = 1
|
||||
|
||||
note = Note.find(1)
|
||||
new_content = 'New note content'
|
||||
|
||||
compatible_request :put, :update, :id => 1, :project_id => 1, :note => { :content => new_content }
|
||||
assert_redirected_to :action => 'show', :project_id => note.source.project, :id => note.id
|
||||
note.reload
|
||||
assert_equal new_content, note.content
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,45 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
class QueriesControllerTest < ActionController::TestCase
|
||||
fixtures :projects, :enabled_modules,
|
||||
:users, :email_addresses,
|
||||
:members, :member_roles, :roles,
|
||||
:trackers, :issue_statuses, :issue_categories, :enumerations, :versions,
|
||||
:issues, :custom_fields, :custom_values,
|
||||
:queries
|
||||
|
||||
def setup
|
||||
User.current = nil
|
||||
end
|
||||
def test_filter_for_contact_custom_field
|
||||
contact_cf = ContactCustomField.create!(:name => 'contact_cf', :is_filter => true, :field_format => 'company')
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :filter, :params => { :type => 'ContactQuery', :name => contact_cf.name }
|
||||
|
||||
assert_response :success
|
||||
assert_equal 'application/json', response.content_type
|
||||
ensure
|
||||
contact_cf.destroy
|
||||
end if Redmine::VERSION.to_s >= '3.4' || RedmineContacts.unstable_branch?
|
||||
end
|
||||
@@ -0,0 +1,86 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class SearchControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_search_for_contacts
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Search'
|
||||
|
||||
compatible_request :get, :index, :q => 'ivan'
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Search'
|
||||
assert_match Contact.find(1).first_name, response.body
|
||||
end
|
||||
|
||||
def test_search_for_contacts_by_email
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :index
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Search'
|
||||
|
||||
compatible_request :get, :index, :q => 'marat@mail.ru'
|
||||
assert_response :success
|
||||
assert_select 'h2', 'Search'
|
||||
assert_match Contact.find(2).first_name, response.body
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,89 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class TimelogControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
def test_get_report_with_deal
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :report, :columns => 'month', :criteria => ['deal', 'deal_contact'], :project_id => 'ecookbook'
|
||||
assert_response :success
|
||||
assert_select 'table#time-report td', /Domoway/
|
||||
assert_select 'table#time-report td', /First deal with contacts/
|
||||
assert_select 'table#time-report td', /Second deal with contacts/
|
||||
end
|
||||
|
||||
def test_get_index_with_company_cf
|
||||
@request.session[:user_id] = 1
|
||||
project = Project.find(1)
|
||||
company = Contact.find(3)
|
||||
@cfield = IssueCustomField.create!(:name => 'COMPANY', :field_format => 'company', :is_filter => true)
|
||||
@cfield.projects << project
|
||||
compatible_request :get, :index, :set_filter => 1,
|
||||
:f => ["issue.cf_#{@cfield.id}", ''],
|
||||
:op => { "issue.cf_#{@cfield.id}" => '=' },
|
||||
:v => { "issue.cf_#{@cfield.id}" => [company.id] },
|
||||
:c => ['spent_on', 'user', 'issue'],
|
||||
:project_id => project.identifier
|
||||
assert_response :success
|
||||
assert_match "values\":[[\"#{company.name}\",\"#{company.id}\"]]", response.body
|
||||
assert_match "\"field_format\":\"company\"", response.body
|
||||
ensure
|
||||
@cfield.destroy
|
||||
end if Redmine::VERSION.to_s > '2.5'
|
||||
end
|
||||
@@ -0,0 +1,67 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class UsersControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
def test_get_new_from_contact
|
||||
@request.session[:user_id] = 1
|
||||
compatible_request :get, :new_from_contact, :contact_id => 1, :id => 'current'
|
||||
assert_response :success
|
||||
assert_select 'input#user_firstname[value=?]', 'Ivan'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,112 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class WikiControllerTest < ActionController::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:roles,
|
||||
:enabled_modules,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:wikis,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
EnabledModule.create(:project_id => 1, :name => 'wiki')
|
||||
@project = Project.find(1)
|
||||
@wiki = @project.wiki
|
||||
@page_name = 'contact_macro_test'
|
||||
@page = @wiki.find_or_new_page(@page_name)
|
||||
@page.content = WikiContent.new
|
||||
@page.content.text = 'test'
|
||||
@page.content.author = User.find(1)
|
||||
@page.save!
|
||||
end
|
||||
|
||||
def test_show_with_contact_macro
|
||||
@request.session[:user_id] = 1
|
||||
@page.content.text = '{{contact(1)}}'
|
||||
@page.content.save!
|
||||
compatible_request :get, :show, :project_id => 1, :id => @page_name
|
||||
assert_response :success
|
||||
assert_select 'h3', 'Wiki'
|
||||
assert_select 'div.wiki p', /Ivan Ivanov/
|
||||
end
|
||||
|
||||
def test_show_with_contact_avatar_macro
|
||||
@request.session[:user_id] = 1
|
||||
@page.content.text = '{{contact_avatar(1)}}'
|
||||
@page.content.save!
|
||||
compatible_request :get, :show, :project_id => 1, :id => @page_name
|
||||
assert_response :success
|
||||
assert_select 'h3', 'Wiki'
|
||||
assert_select 'div.wiki p img'
|
||||
end
|
||||
|
||||
def test_show_with_note_macro
|
||||
@request.session[:user_id] = 1
|
||||
@page.content.text = '{{contact_note(1)}}'
|
||||
@page.content.save!
|
||||
compatible_request :get, :show, :project_id => 1, :id => @page_name
|
||||
assert_response :success
|
||||
assert_select 'h3', 'Wiki'
|
||||
assert_select 'div.wiki p', /Note 1 content with wiki syntax/
|
||||
end
|
||||
def test_show_with_deal_macro
|
||||
@request.session[:user_id] = 1
|
||||
@page.content.text = '{{deal(1)}}'
|
||||
@page.content.save!
|
||||
compatible_request :get, :show, :project_id => 1, :id => @page_name
|
||||
assert_response :success
|
||||
assert_select 'h3', 'Wiki'
|
||||
assert_select 'div.wiki p', /Ivan Ivanov: First deal with contacts/
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<contact>
|
||||
<first_name>API contact name</first_name>
|
||||
<is_company>true</is_company>
|
||||
<project_id>contacts-plugin</project_id>
|
||||
<custom_fields>
|
||||
|
||||
</custom_fields>
|
||||
</contact>
|
||||
@@ -0,0 +1,89 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
||||
|
||||
class Redmine::ApiTest::NotesTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
Setting.rest_api_enabled = '1'
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
test 'POST /contacts/:contact_id/projects.xml' do
|
||||
parameters = { :project => { :id => 2 } }
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:post, '/contacts/1/projects.xml', parameters, :success_code => :success)
|
||||
end
|
||||
|
||||
compatible_api_request :post, '/contacts/1/projects.xml', parameters, credentials('admin')
|
||||
assert_response :success
|
||||
assert_not_nil Contact.find(1).projects.where(:id => 2)
|
||||
end
|
||||
|
||||
test 'DELETE /contacts/:contact_id/projects.xml' do
|
||||
contact = Contact.find(1)
|
||||
contact.projects << Project.find(2)
|
||||
contact.save
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:delete, '/contacts/1/projects/2.xml', {}, :success_code => :success)
|
||||
end
|
||||
|
||||
compatible_api_request :delete, '/contacts/1/projects/2.xml', {}, credentials('admin')
|
||||
assert_response :success
|
||||
contact.reload
|
||||
assert_nil contact.projects.where(:id => 2).first
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,163 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
||||
|
||||
class Redmine::ApiTest::ContactsTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
Setting.rest_api_enabled = '1'
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
def test_get_contacts_xml
|
||||
# Use a private project to make sure auth is really working and not just
|
||||
# only showing public issues.
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:get, '/projects/private-child/contacts.xml') if ActiveRecord::VERSION::MAJOR < 4
|
||||
|
||||
compatible_api_request :get, '/contacts.xml', {}, credentials('admin')
|
||||
|
||||
att = { :type => 'array', :total_count => 5, :limit => 25, :offset => 0 }
|
||||
assert_select 'contacts', :attributes => att
|
||||
end
|
||||
|
||||
def test_post_contacts_xml
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:post, '/contacts.xml', { :contact => { :project_id => 1, :first_name => 'API test' } },
|
||||
{ :success_code => :created })
|
||||
end
|
||||
|
||||
assert_difference('Contact.count') do
|
||||
compatible_api_request :post, '/contacts.xml', { :contact => { :project_id => 1, :first_name => 'API test' } }, credentials('admin')
|
||||
end
|
||||
|
||||
contact = Contact.order('id DESC').first
|
||||
assert_equal 'API test', contact.first_name
|
||||
|
||||
assert_response :created
|
||||
assert_equal 'application/xml', @response.content_type
|
||||
assert_select 'contact', :child => { :tag => 'id', :content => contact.id.to_s }
|
||||
end
|
||||
|
||||
def test_post_contacts_xml_redirect
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:post, '/contacts.xml', { :contact => { :project_id => 1, :first_name => 'API test' } },
|
||||
{ :success_code => :created })
|
||||
end
|
||||
|
||||
assert_difference('Contact.count') do
|
||||
compatible_api_request :post, '/contacts.xml', { :contact => { :project_id => 1, :first_name => 'API test' }, :redirect_on_success => 'http://ya.ru' }, credentials('admin')
|
||||
end
|
||||
|
||||
assert_redirected_to 'http://ya.ru'
|
||||
end
|
||||
|
||||
# Issue 6 is on a private project
|
||||
def test_put_contacts_1_xml
|
||||
parameters = { :contact => { :first_name => 'API update' } }
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:put, '/contacts/1.xml', { :contact => { :first_name => 'API update' } },
|
||||
{ :success_code => :ok })
|
||||
end
|
||||
|
||||
assert_no_difference('Contact.count') do
|
||||
compatible_api_request :put, '/contacts/1.xml', parameters, credentials('admin')
|
||||
end
|
||||
|
||||
contact = Contact.where(:id => 1).first
|
||||
assert_equal 'API update', contact.first_name
|
||||
end
|
||||
def test_update_contact_with_uploaded_file
|
||||
set_tmp_attachments_directory
|
||||
# upload the file
|
||||
assert_difference 'Attachment.count' do
|
||||
compatible_api_request :post, '/uploads.xml', 'test_upload_with_upload', { 'CONTENT_TYPE' => 'application/octet-stream' }.merge(credentials('admin'))
|
||||
assert_response :created
|
||||
end
|
||||
xml = Hash.from_xml(response.body)
|
||||
token = xml['upload']['token']
|
||||
attachment = Attachment.order('id DESC').first
|
||||
|
||||
# update the issue with the upload's token
|
||||
compatible_api_request :put, '/contacts/1.xml', { :contact => {:name => 'Attachment added', :uploads => [{ :token => token, :filename => 'test.png',
|
||||
:description => 'avatar',
|
||||
:content_type => 'image/png' }] } },
|
||||
credentials('admin')
|
||||
assert_response :ok
|
||||
assert_equal '', @response.body
|
||||
|
||||
contact = Contact.where(:id => 1).first
|
||||
assert_include attachment, contact.attachments
|
||||
assert_equal attachment, contact.avatar
|
||||
end
|
||||
|
||||
def test_should_post_with_custom_fields
|
||||
field = ContactCustomField.create!(:name => 'Test', :field_format => 'int')
|
||||
assert_difference('Contact.count') do
|
||||
compatible_api_request :post, '/contacts.xml', { :contact => { :project_id => 1, :first_name => 'API test',
|
||||
:custom_fields => [{ 'id' => field.id.to_s, 'value' => '12' }] } }, credentials('admin')
|
||||
end
|
||||
contact = Contact.last
|
||||
assert_equal '12', contact.custom_value_for(field.id).value
|
||||
end
|
||||
|
||||
def test_should_put_with_custom_fields
|
||||
field = ContactCustomField.create!(:name => 'Test', :field_format => 'text')
|
||||
assert_no_difference('Contact.count') do
|
||||
compatible_api_request :put, '/contacts/1.xml', { :contact => { :custom_fields => [{ 'id' => field.id.to_s, 'value' => 'Hello' }] } }, credentials('admin')
|
||||
end
|
||||
contact = Contact.where(:id => 1).first
|
||||
assert_equal 'Hello', contact.custom_value_for(field.id).value
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<deal>
|
||||
<name>API deal name</name>
|
||||
<currency>USD</currency>
|
||||
<project_id>contacts-plugin</project_id>
|
||||
</deal>
|
||||
@@ -0,0 +1,128 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
||||
|
||||
class Redmine::ApiTest::DealsTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
Setting.rest_api_enabled = '1'
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
test 'GET /deals.xml' do
|
||||
# Use a private project to make sure auth is really working and not just
|
||||
# only showing public issues.
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:get, '/projects/private-child/deals.xml') if ActiveRecord::VERSION::MAJOR < 4
|
||||
compatible_api_request :get, '/deals.xml', {}, credentials('admin')
|
||||
|
||||
att = { :type => 'array', :total_count => 2, :limit => 25, :offset => 0 }
|
||||
assert_select 'deals', :attributes => att
|
||||
end
|
||||
|
||||
test 'POST /deals.xml' do
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:post, '/deals.xml', { :deal => { :project_id => 1, :name => 'API test', :contact_id => 1 } },
|
||||
{ :success_code => :created })
|
||||
end
|
||||
|
||||
assert_difference('Deal.count') do
|
||||
compatible_api_request :post, '/deals.xml', { :deal => { :project_id => 1, :name => 'API test', :contact_id => 1 } }, credentials('admin')
|
||||
end
|
||||
|
||||
deal = Deal.order('id DESC').first
|
||||
assert_equal 'API test', deal.name
|
||||
|
||||
assert_response :created
|
||||
assert_equal 'application/xml', @response.content_type
|
||||
assert_select 'deal', :child => { :tag => 'id', :content => deal.id.to_s }
|
||||
end
|
||||
|
||||
# Issue 6 is on a private project
|
||||
test 'PUT /deals/1.xml' do
|
||||
@parameters = { :deal => { :name => 'API update' } }
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:put, '/deals/1.xml', { :deal => { :name => 'API update' } },
|
||||
{ :success_code => :ok })
|
||||
end
|
||||
|
||||
assert_no_difference('Deal.count') do
|
||||
compatible_api_request :put, '/deals/1.xml', @parameters, credentials('admin')
|
||||
end
|
||||
|
||||
deal = Deal.where(:id => 1).first
|
||||
assert_equal 'API update', deal.name
|
||||
end
|
||||
|
||||
def test_post_with_custom_fields
|
||||
field = DealCustomField.create!(:name => 'Test', :field_format => 'int')
|
||||
assert_difference('Deal.count') do
|
||||
compatible_api_request :post, '/deals.xml', { :deal => { :project_id => 1, :name => 'API test',
|
||||
:custom_fields => [{ 'id' => field.id.to_s, 'value' => '14' }] } },
|
||||
credentials('admin')
|
||||
end
|
||||
deal = Deal.last
|
||||
assert_equal '14', deal.custom_value_for(field.id).value
|
||||
end
|
||||
|
||||
def test_put_with_custom_fields
|
||||
field = DealCustomField.create!(:name => 'Test', :field_format => 'text')
|
||||
assert_no_difference('Deal.count') do
|
||||
compatible_api_request :put, '/deals/1.xml', { :deal => { :custom_fields => [{ 'id' => field.id.to_s, 'value' => 'Hello deal' }] } },
|
||||
credentials('admin')
|
||||
end
|
||||
deal = Deal.where(:id => 1).first
|
||||
assert_equal 'Hello deal', deal.custom_value_for(field.id).value
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<note>
|
||||
<content>API note content</content>
|
||||
<subject>Test note</subject>
|
||||
</note>
|
||||
@@ -0,0 +1,113 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
||||
|
||||
class Redmine::ApiTest::NotesTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
Setting.rest_api_enabled = '1'
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
test 'POST /notes.xml' do
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:post, '/notes.xml', { :note => { :project_id => 1,
|
||||
:source_id => 1,
|
||||
:source_type => 'Contact',
|
||||
:content => 'API test' } },
|
||||
{ :success_code => :created })
|
||||
end
|
||||
|
||||
assert_difference('Note.count', 1) do
|
||||
compatible_api_request :post, '/notes.xml', { :note => { :content => 'API test' }, :project_id => 1, :source_id => 1, :source_type => 'Contact' }, credentials('admin')
|
||||
end
|
||||
|
||||
note = Note.order('id DESC').first
|
||||
assert_equal 'API test', note.content
|
||||
|
||||
assert_response :created
|
||||
assert_equal 'application/xml', @response.content_type
|
||||
assert_select 'note', :child => { :tag => 'id', :content => note.id.to_s }
|
||||
end
|
||||
|
||||
test 'PUT /notes/1.xml' do
|
||||
@parameters = { :note => { :content => 'API update' } }
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:put, '/notes/1.xml', @parameters, :success_code => :ok)
|
||||
end
|
||||
|
||||
assert_no_difference('Note.count') do
|
||||
compatible_api_request :put, '/notes/1.xml', @parameters, credentials('admin')
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
note = Note.where(:id => 1).first
|
||||
assert_equal 'API update', note.content
|
||||
end
|
||||
|
||||
test 'DELETE /notes/1.xml' do
|
||||
@parameters = { :note => { :content => 'API update' } }
|
||||
|
||||
if ActiveRecord::VERSION::MAJOR < 4
|
||||
Redmine::ApiTest::Base.should_allow_api_authentication(:put, '/notes/1.xml', @parameters, :success_code => :ok)
|
||||
end
|
||||
|
||||
assert_difference('Note.count', -1) do
|
||||
compatible_api_request :delete, '/notes/1.xml', @parameters, credentials('admin')
|
||||
assert_response :success
|
||||
end
|
||||
assert_nil Note.where(:id => 1).first
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,160 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
|
||||
|
||||
|
||||
class RedmineContacts::CommonViewsTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals_issues,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
test 'View user' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/users/2'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contacts activity' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/projects/ecookbook/activity?show_contacts=1'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contacts settings' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/settings/plugin/redmine_contacts'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contacts project settings' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/projects/ecookbook/settings/contacts'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contact tag edit' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/contacts_tags/1/edit'
|
||||
assert_response :success
|
||||
end
|
||||
test 'View deal status edit' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/deal_statuses/1/edit'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View My page with contacts and deals blocks' do
|
||||
log_user('rhill', 'foo')
|
||||
user = User.where(:login => 'rhill').first
|
||||
Contact.all.each { |c| c.assigned_to = user; c.save }
|
||||
preferences = user.pref
|
||||
preferences[:my_page_layout] = { 'top' => ['my_contacts', 'my_deals'] }
|
||||
preferences.save!
|
||||
|
||||
compatible_request :get, '/my/page'
|
||||
assert_response :success
|
||||
assert_select 'span.contact', 'Domoway'
|
||||
end
|
||||
|
||||
def test_new_custom_field
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/custom_fields/new', :type => 'ContactCustomField'
|
||||
assert_response :success
|
||||
|
||||
compatible_request :get, '/custom_fields/new', :type => 'DealCustomField'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'Global search with contacts' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/search?q=Domoway'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contacts project notes list' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/projects/ecookbook/contacts/notes'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View contacts notes list' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/contacts/notes'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View issue contacts' do
|
||||
log_user('admin', 'admin')
|
||||
EnabledModule.create(:project_id => 1, :name => 'issue_tracking')
|
||||
issue = Issue.where(:id => 1).first
|
||||
contact = Contact.where(:id => 1).first
|
||||
issue.contacts << contact
|
||||
issue.save
|
||||
compatible_request :get, '/issues/1'
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'View user with contact relation' do
|
||||
log_user('admin', 'admin')
|
||||
compatible_request :get, '/users/2'
|
||||
assert_response :success
|
||||
# assert_tag :div,
|
||||
# :content => /John Smith/,
|
||||
# :attributes => { :class => 'contact card' }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,63 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class RoutingTest < ActiveRecord::VERSION::MAJOR >= 4 ? Redmine::ApiTest::Base : ActionController::IntegrationTest
|
||||
def test_contacts
|
||||
# REST actions
|
||||
assert_routing({ :path => '/contacts', :method => :get }, { :controller => 'contacts', :action => 'index' })
|
||||
assert_routing({ :path => '/contacts.xml', :method => :get }, { :controller => 'contacts', :action => 'index', :format => 'xml' })
|
||||
assert_routing({ :path => '/contacts.atom', :method => :get }, { :controller => 'contacts', :action => 'index', :format => 'atom' })
|
||||
assert_routing({ :path => '/contacts/notes', :method => :get }, { :controller => 'contacts', :action => 'contacts_notes' })
|
||||
assert_routing({ :path => '/contacts/1', :method => :get }, { :controller => 'contacts', :action => 'show', :id => '1' })
|
||||
assert_routing({ :path => '/contacts/1/edit', :method => :get }, { :controller => 'contacts', :action => 'edit', :id => '1' })
|
||||
assert_routing({ :path => '/contacts/context_menu', :method => :get }, { :controller => 'contacts', :action => 'context_menu' })
|
||||
assert_routing({ :path => '/projects/23/contacts', :method => :get }, { :controller => 'contacts', :action => 'index', :project_id => '23' })
|
||||
assert_routing({ :path => '/projects/23/contacts.xml', :method => :get }, { :controller => 'contacts', :action => 'index', :project_id => '23', :format => 'xml' })
|
||||
assert_routing({ :path => '/projects/23/contacts.atom', :method => :get }, { :controller => 'contacts', :action => 'index', :project_id => '23', :format => 'atom' })
|
||||
assert_routing({ :path => '/projects/23/contacts/notes', :method => :get }, { :controller => 'contacts', :action => 'contacts_notes', :project_id => '23' })
|
||||
|
||||
assert_routing({ :path => '/contacts.xml', :method => :post }, { :controller => 'contacts', :action => 'create', :format => 'xml' })
|
||||
|
||||
assert_routing({ :path => '/contacts/1.xml', :method => :put }, { :controller => 'contacts', :action => 'update', :format => 'xml', :id => '1' })
|
||||
|
||||
assert_routing({ :path => '/contacts/bulk_edit', :method => :post }, { :controller => 'contacts', :action => 'bulk_edit' })
|
||||
assert_routing({ :path => '/contacts/bulk_edit', :method => :get }, { :controller => 'contacts', :action => 'bulk_edit' })
|
||||
assert_routing({ :path => '/contacts/context_menu', :method => :get }, { :controller => 'contacts', :action => 'context_menu' })
|
||||
assert_routing({ :path => '/contacts/send_mails', :method => :post }, { :controller => 'contacts', :action => 'send_mails' })
|
||||
end
|
||||
|
||||
def test_notes
|
||||
# REST actions
|
||||
assert_routing({ :path => '/notes/1', :method => :get }, { :controller => 'notes', :action => 'show', :id => '1' })
|
||||
assert_routing({ :path => '/notes/1/edit', :method => :get }, { :controller => 'notes', :action => 'edit', :id => '1' })
|
||||
assert_routing({ :path => '/notes/1', :method => :put }, { :controller => 'notes', :action => 'update', :id => '1' })
|
||||
assert_routing({ :path => '/notes', :method => :post }, { :controller => 'notes', :action => 'create' })
|
||||
end
|
||||
def test_deals
|
||||
# REST actions
|
||||
assert_routing({ :path => '/deals', :method => :get }, { :controller => 'deals', :action => 'index' })
|
||||
assert_routing({ :path => '/deals/1', :method => :get }, { :controller => 'deals', :action => 'show', :id => '1' })
|
||||
assert_routing({ :path => '/deals/1/edit', :method => :get }, { :controller => 'deals', :action => 'edit', :id => '1' })
|
||||
assert_routing({ :path => '/projects/23/deals', :method => :get }, { :controller => 'deals', :action => 'index', :project_id => '23' })
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,150 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
|
||||
|
||||
def redmine_contacts_fixture_files_path
|
||||
"#{Rails.root}/plugins/redmine_contacts/test/fixtures/files/"
|
||||
end
|
||||
|
||||
# Engines::Testing.set_fixture_path
|
||||
module RedmineContacts
|
||||
module TestHelper
|
||||
def compatible_request(type, action, parameters = {})
|
||||
return send(type, action, :params => parameters) if Rails.version >= '5.1'
|
||||
send(type, action, parameters)
|
||||
end
|
||||
|
||||
def compatible_xhr_request(type, action, parameters = {})
|
||||
return send(type, action, :params => parameters, :xhr => true) if Rails.version >= '5.1'
|
||||
xhr type, action, parameters
|
||||
end
|
||||
|
||||
def compatible_api_request(type, action, parameters = {}, headers = {})
|
||||
return send(type, action, :params => parameters, :headers => headers) if Rails.version >= '5.1'
|
||||
send(type, action, parameters, headers)
|
||||
end
|
||||
|
||||
def issues_in_list
|
||||
ids = css_select('tr.issue td.id').map{ |tag| tag['text'].to_i }
|
||||
Issue.where(:id => ids).sort_by { |issue| ids.index(issue.id) }
|
||||
end
|
||||
|
||||
def contacts_in_list
|
||||
ids = css_select('table.contacts #selected_contacts_').map { |tag| tag['value'].to_i }
|
||||
Contact.where(:id => ids).sort_by { |contact| ids.index(contact.id) }
|
||||
end
|
||||
|
||||
def deals_in_list
|
||||
ids = css_select('.deal_list #ids_').map { |tag| tag['value'].to_i }
|
||||
Deal.where(:id => ids).sort_by { |contact| ids.index(contact.id) }
|
||||
end
|
||||
|
||||
def with_contacts_settings(options, &block)
|
||||
Setting.plugin_redmine_contacts.stubs(:[]).returns(nil)
|
||||
options.each { |k, v| Setting.plugin_redmine_contacts.stubs(:[]).with(k).returns(v) }
|
||||
yield
|
||||
ensure
|
||||
options.each { |_k, _v| Setting.plugin_redmine_contacts.unstub(:[]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class RedmineContacts::TestCase
|
||||
include ActionDispatch::TestProcess
|
||||
def self.plugin_fixtures(plugin, *fixture_names)
|
||||
plugin_fixture_path = "#{Redmine::Plugin.find(plugin).directory}/test/fixtures"
|
||||
if fixture_names.first == :all
|
||||
fixture_names = Dir["#{plugin_fixture_path}/**/*.{yml}"]
|
||||
fixture_names.map! { |f| f[(plugin_fixture_path.size + 1)..-5] }
|
||||
else
|
||||
fixture_names = fixture_names.flatten.map { |n| n.to_s }
|
||||
end
|
||||
|
||||
ActiveRecord::Fixtures.create_fixtures(plugin_fixture_path, fixture_names)
|
||||
end
|
||||
|
||||
def uploaded_test_file(name, mime)
|
||||
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime, true)
|
||||
end
|
||||
|
||||
def self.is_arrays_equal(a1, a2)
|
||||
(a1 - a2) - (a2 - a1) == []
|
||||
end
|
||||
|
||||
def self.create_fixtures(fixtures_directory, table_names, class_names = {})
|
||||
if ActiveRecord::VERSION::MAJOR >= 4
|
||||
ActiveRecord::FixtureSet.create_fixtures(fixtures_directory, table_names, class_names)
|
||||
else
|
||||
ActiveRecord::Fixtures.create_fixtures(fixtures_directory, table_names, class_names)
|
||||
end
|
||||
end
|
||||
|
||||
def self.prepare
|
||||
# User 2 Manager (role 1) in project 1, email jsmith@somenet.foo
|
||||
# User 3 Developer (role 2) in project 1
|
||||
|
||||
Role.where(:id => [1, 2, 3, 4]).each do |r|
|
||||
r.permissions << :view_contacts
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(:id => [1, 2]).each do |r|
|
||||
#user_2, user_3
|
||||
r.permissions << :add_contacts
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(:id => 1).each do |r|
|
||||
#user_2
|
||||
r.permissions << :add_deals
|
||||
r.permissions << :save_contacts_queries
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(:id => [1, 2]).each do |r|
|
||||
r.permissions << :edit_contacts
|
||||
r.save
|
||||
end
|
||||
Role.where(:id => [1, 2, 3]).each do |r|
|
||||
r.permissions << :view_deals
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(:id => 2).each do |r|
|
||||
r.permissions << :edit_deals
|
||||
r.permissions << :manage_contact_issue_relations
|
||||
r.save
|
||||
end
|
||||
|
||||
Role.where(:id => [1, 2]).each do |r|
|
||||
r.permissions << :manage_public_contacts_queries
|
||||
r.save
|
||||
end
|
||||
|
||||
Project.where(:id => [1, 2, 3, 4, 5]).each do |project|
|
||||
EnabledModule.create(:project => project, :name => 'contacts')
|
||||
EnabledModule.create(:project => project, :name => 'deals')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
include RedmineContacts::TestHelper
|
||||
@@ -0,0 +1,137 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class AddressTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
Setting.plugin_redmine_contacts['post_address_format'] = nil
|
||||
end
|
||||
|
||||
def test_should_generate_full_address
|
||||
address = Address.new
|
||||
address.street1 = '300 Boylston Ave E'
|
||||
address.street2 = 'Piso2 Dto.4'
|
||||
address.city = 'Seattle'
|
||||
address.region = 'WA'
|
||||
address.postcode = '98102'
|
||||
address.country_code = 'US'
|
||||
address.save
|
||||
address.reload
|
||||
|
||||
assert_equal '300 Boylston Ave E, Piso2 Dto.4, Seattle, 98102, WA, United States', address.full_address
|
||||
end
|
||||
|
||||
def test_should_generate_to_s
|
||||
address = Address.new
|
||||
address.street1 = '300 Boylston Ave E'
|
||||
address.street2 = 'Piso2 Dto.4'
|
||||
address.city = 'Seattle'
|
||||
address.region = 'WA'
|
||||
address.postcode = '98102'
|
||||
address.country_code = 'US'
|
||||
|
||||
assert_equal '300 Boylston Ave E, Piso2 Dto.4, Seattle, 98102, WA, United States', address.to_s
|
||||
end
|
||||
|
||||
def test_should_generate_particular_full_address
|
||||
address = Address.new
|
||||
address.street1 = '300 Boylston Ave E'
|
||||
address.city = 'Seattle'
|
||||
address.postcode = '98102'
|
||||
address.region = ''
|
||||
address.country_code = 'US'
|
||||
address.save
|
||||
address.reload
|
||||
|
||||
assert_equal '300 Boylston Ave E, Seattle, 98102, United States', address.full_address
|
||||
end
|
||||
|
||||
def test_should_generate_us_post_address
|
||||
address = Address.new
|
||||
address.street1 = '300 Boylston Ave E'
|
||||
address.city = 'Seattle'
|
||||
address.postcode = '98102'
|
||||
address.region = 'WA'
|
||||
address.country_code = 'US'
|
||||
|
||||
assert_equal "300 Boylston Ave E\nSeattle, 98102\nWA\nUnited States", address.post_address
|
||||
end
|
||||
|
||||
def test_should_generate_us_post_address_with_double_spaces
|
||||
Setting.plugin_redmine_contacts['post_address_format'] = "%street1%\n%street2%\n%city% %region% %postcode%\n%country%"
|
||||
address = Address.new
|
||||
address.street1 = '300 Boylston Ave E'
|
||||
address.city = 'Seattle'
|
||||
address.postcode = '98102'
|
||||
address.region = 'WA'
|
||||
address.country_code = 'US'
|
||||
|
||||
assert_equal "300 Boylston Ave E\nSeattle WA 98102\nUnited States", address.post_address
|
||||
end
|
||||
|
||||
def test_should_generate_ru_post_address
|
||||
address = Address.new
|
||||
address.street1 = "ул. Маршала Жукова, 6"
|
||||
address.city = "г. Арзамас"
|
||||
address.postcode = '611137'
|
||||
address.region = "Нижегородская область"
|
||||
address.country_code = 'RU'
|
||||
|
||||
assert_equal "ул. Маршала Жукова, 6\nг. Арзамас, 611137\nНижегородская область\nRussia", address.post_address
|
||||
end
|
||||
|
||||
def test_should_generate_ru_post_address_with_empty_region
|
||||
address = Address.new
|
||||
address.street1 = "ул. Новая Басманная, 14"
|
||||
address.city = "г. Москва"
|
||||
address.postcode = '145013'
|
||||
address.country_code = 'RU'
|
||||
|
||||
assert_equal "ул. Новая Басманная, 14\nг. Москва, 145013\nRussia", address.post_address
|
||||
end
|
||||
|
||||
def test_should_strip_empty_lines_and_punctuation
|
||||
Setting.plugin_redmine_contacts['post_address_format'] = "%street1%,\n,%street2%,,,\n%city%, %postcode%\n%region%\n%country%"
|
||||
|
||||
address = Address.new
|
||||
address.city = 'Seattle'
|
||||
address.region = 'WA'
|
||||
address.country_code = 'US'
|
||||
|
||||
assert_equal "Seattle\nWA\nUnited States", address.post_address
|
||||
end
|
||||
|
||||
def test_should_create_new_address
|
||||
address = Address.new
|
||||
address.street1 = 'ул. Новая Басманная, 14'
|
||||
address.city = 'г. Москва'
|
||||
address.postcode = '145013'
|
||||
address.country_code = 'RU'
|
||||
address.address_type = 'business'
|
||||
address.addressable = Contact.first
|
||||
address.save!
|
||||
|
||||
assert_equal false, address.new_record?
|
||||
assert_equal 'ул. Новая Басманная, 14, г. Москва, 145013, Russia', address.full_address
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,66 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactImportTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :users
|
||||
|
||||
def test_open_correct_csv
|
||||
contact_import = ContactImport.new(
|
||||
:file => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'correct.csv', 'text/comma-separated-values'),
|
||||
:project => Project.first,
|
||||
:quotes_type => '"'
|
||||
)
|
||||
puts contact_import.errors.full_messages unless contact_import.valid?
|
||||
assert_equal 4, contact_import.imported_instances.count, 'Should find 4 contacts in file'
|
||||
assert contact_import.save, 'Should save successfully'
|
||||
end
|
||||
|
||||
def test_should_report_error_line
|
||||
contact_import = ContactImport.new(
|
||||
:file => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'with_data_malformed.csv', 'text/comma-separated-values'),
|
||||
:project => Project.first,
|
||||
:quotes_type => '"'
|
||||
)
|
||||
assert !contact_import.save, 'Should not save with malformed date'
|
||||
assert_equal 1, contact_import.errors.count, 'Should have 1 error'
|
||||
assert contact_import.errors.first.last.include?("Error on line 1"), 'Should mention string number in error message'
|
||||
end
|
||||
|
||||
def test_open_csv_with_custom_fields
|
||||
cf1 = ContactCustomField.create!(:name => 'License', :field_format => 'string')
|
||||
cf2 = ContactCustomField.create!(:name => 'Purchase date', :field_format => 'date')
|
||||
contact_import = ContactImport.new(
|
||||
:file => Rack::Test::UploadedFile.new(redmine_contacts_fixture_files_path + 'contacts_cf.csv', 'text/comma-separated-values'),
|
||||
:project => Project.first,
|
||||
:quotes_type => '"'
|
||||
)
|
||||
assert_equal 1, contact_import.imported_instances.count, 'Should find 1 contact in file'
|
||||
assert contact_import.save, 'Should save successfully'
|
||||
contact = Contact.find_by_first_name('Monica')
|
||||
assert_equal '12345', contact.custom_field_value(cf1.id)
|
||||
assert_equal 'rhill', contact.assigned_to.login
|
||||
assert_equal '123456', contact.postcode
|
||||
assert_equal 'Moscow', contact.city
|
||||
assert_equal 'Russia', contact.country
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,256 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactTest < ActiveSupport::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
end
|
||||
|
||||
def test_find_by_emails_first_email
|
||||
emails = ['marat@mail.ru', 'domoway@mail.ru']
|
||||
assert_equal 2, Contact.find_by_emails(emails).count
|
||||
end
|
||||
|
||||
def test_find_by_emails_second_email
|
||||
emails = ['marat@mail.com']
|
||||
assert_equal 1, Contact.find_by_emails(emails).count
|
||||
end
|
||||
|
||||
def test_scope_live_search
|
||||
assert_equal 4, Contact.live_search('john').first.try(:id)
|
||||
end
|
||||
|
||||
def test_visible_public_contacts
|
||||
project = Project.find(1)
|
||||
contact = Contact.find(1)
|
||||
user = User.find(1) # John Smith
|
||||
|
||||
contact.visibility = Contact::VISIBILITY_PUBLIC
|
||||
contact.save!
|
||||
|
||||
assert contact.visible?(user)
|
||||
end
|
||||
|
||||
def test_visible_scope_for_non_member_without_view_contacts_permissions
|
||||
# Non member user should not see issues without permission
|
||||
Role.non_member.remove_permission!(:view_contacts)
|
||||
user = User.find(9)
|
||||
assert user.projects.empty?
|
||||
contacts = Contact.visible(user).all
|
||||
assert contacts.empty?
|
||||
assert_visibility_match user, contacts
|
||||
end
|
||||
|
||||
def test_visible_scope_for_member
|
||||
user = User.find(2)
|
||||
# User should see issues of projects for which he has view_issues permissions only
|
||||
role = Role.create!(:name => 'CRM', :permissions => [:view_contacts])
|
||||
Role.non_member.remove_permission!(:view_contacts)
|
||||
project = Project.find(2)
|
||||
Contact.delete_all
|
||||
Member.where(:user_id => user).delete_all
|
||||
member = Member.create!(:principal => user, :project_id => project.id, :role_ids => [role.id])
|
||||
contact = Contact.create!(:project => project, :first_name => 'UnitTest', :visibility => Contact::VISIBILITY_PUBLIC)
|
||||
|
||||
contacts = Contact.visible(user).all
|
||||
|
||||
assert contacts.any?
|
||||
assert_nil contacts.detect { |c| c.project.id != project.id }
|
||||
# assert_nil contacts.detect {|c| c.is_private?}
|
||||
assert_visibility_match user, contacts
|
||||
|
||||
contact.visibility = Contact::VISIBILITY_PRIVATE
|
||||
contact.save!
|
||||
contacts = Contact.visible(user).all
|
||||
assert contacts.blank?, 'Private contacts are visible'
|
||||
|
||||
assert user.allowed_to?(:view_contacts, project)
|
||||
contact.visibility = Contact::VISIBILITY_PROJECT
|
||||
contact.save!
|
||||
contacts = Contact.visible(user).all
|
||||
assert contacts.any?, "Project contacts doesn't visible with permissions"
|
||||
|
||||
role.remove_permission!(:view_contacts)
|
||||
user.reload
|
||||
contact.visibility = Contact::VISIBILITY_PROJECT
|
||||
contact.save!
|
||||
contacts = project.contacts.visible(user).all
|
||||
assert contacts.blank?, 'Contacts visible for user without view_contacts permissions'
|
||||
|
||||
role.add_permission!(:view_private_contacts)
|
||||
user.reload
|
||||
contact.visibility = Contact::VISIBILITY_PRIVATE
|
||||
contact.save!
|
||||
contacts = Contact.visible(user).all
|
||||
assert contacts.any?, 'Contacts note visible for user with view_private_contacts permissions'
|
||||
end
|
||||
|
||||
def test_create_should_send_email_notification
|
||||
ActionMailer::Base.deliveries.clear
|
||||
contact = Contact.new(:first_name => 'New contact', :project => Project.find(1))
|
||||
|
||||
with_settings :notified_events => %w(crm_contact_added) do
|
||||
assert contact.save
|
||||
end
|
||||
assert_equal 1, ActionMailer::Base.deliveries.size
|
||||
end
|
||||
|
||||
def assert_visibility_match(user, contacts)
|
||||
assert_equal contacts.collect(&:id).sort, Contact.all.select { |contact| contact.visible?(user) }.collect(&:id).sort
|
||||
end
|
||||
|
||||
def test_that_contact_with_email_containing_plus_is_valid
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'foo+bar-baz@email.example'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_if_email_with_local_domain_is_allowed
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'email@mydomain'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_special_characters_in_email_local_part
|
||||
contact = Contact.find(1)
|
||||
contact.email = "#!$%&'{}@email.example"
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_email_containing_unicode_characters
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'денис@пример.рф'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_that_email_can_include_ip_address
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'foo@[IPv6:2001:db8::1]'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_contact_with_multiple_email_addresses
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'foo@email.example,bar@email.example'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_if_email_without_at_sign_is_invalid
|
||||
contact = Contact.find(1)
|
||||
contact.email = 'hello'
|
||||
assert contact.invalid?
|
||||
end
|
||||
|
||||
def test_email_transformation_on_create
|
||||
assert_equal 'test@test.com', Contact.create!(:project => Project.find(1), :first_name => 'Test', :email => ' test@test.com ').email
|
||||
assert_equal 'test@test.com,foo@bar.com', Contact.create!(:project => Project.find(1), :first_name => 'Test', :email => ' test@test.com , foo@bar.com ').email
|
||||
end
|
||||
|
||||
def test_duplicates_no_middle_name
|
||||
project = Project.find(1)
|
||||
User.current = User.find(1)
|
||||
|
||||
contact1 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => 'Stoyanov')
|
||||
contact2 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => '')
|
||||
assert contact2.duplicates.include?(contact1)
|
||||
assert contact1.duplicates.include?(contact2)
|
||||
end
|
||||
|
||||
def test_duplicates_by_just_email
|
||||
project = Project.find(1)
|
||||
User.current = User.find(1)
|
||||
|
||||
contact1 = Contact.create!(:project => project, :first_name => 'Kristiyan', :email => 'test@test.com')
|
||||
contact2 = Contact.create!(:project => project, :first_name => 'Peter', :email => 'test@test.com')
|
||||
assert contact2.duplicates.include?(contact1)
|
||||
assert contact1.duplicates.include?(contact2)
|
||||
end
|
||||
|
||||
def test_duplicates_no_middle_name_with_last_name
|
||||
project = Project.find(1)
|
||||
User.current = User.find(1)
|
||||
|
||||
contact1 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => '', :last_name => 'Stoyanov')
|
||||
contact2 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => 'Petrov', :last_name => 'Stoyanov')
|
||||
assert contact1.duplicates.include?(contact2)
|
||||
assert contact2.duplicates.include?(contact1)
|
||||
end
|
||||
|
||||
def test_duplicates_no_middle_name_with_last_name_and_email
|
||||
project = Project.find(1)
|
||||
User.current = User.find(1)
|
||||
|
||||
contact1 = Contact.create!(:project => project, :first_name => 'Kristiyan', :last_name => 'Stoyanov', :email => 'test@test.com')
|
||||
contact2 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => 'Petrov', :last_name => 'Stoyanov', :email => 'test@test.com')
|
||||
assert contact1.duplicates.include?(contact2)
|
||||
assert contact2.duplicates.include?(contact1)
|
||||
end
|
||||
|
||||
def test_multiple_duplicates_different_criteria
|
||||
project = Project.find(1)
|
||||
User.current = User.find(1)
|
||||
|
||||
contact1 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => '', :email => 'test@test.com')
|
||||
contact2 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => '', :last_name => 'Stoyanov', :email => 'test@test.com')
|
||||
contact3 = Contact.create!(:project => project, :first_name => 'Kristiyan', :middle_name => 'Petrov', :last_name => 'Stoyanov')
|
||||
contact4 = Contact.create!(:project => project, :first_name => 'Mr.Nobody', :middle_name => '', :last_name => 'Test', :email => 'test@test.com')
|
||||
|
||||
assert contact1.duplicates.include?(contact2)
|
||||
assert contact1.duplicates.include?(contact3)
|
||||
assert contact1.duplicates.include?(contact4)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,31 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsIssuesTest < ActiveSupport::TestCase
|
||||
fixtures :contacts_issues
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,151 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactsMailerTest < ActiveSupport::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/contacts_mailer'
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
|
||||
end
|
||||
|
||||
test 'Should add contact note from to' do
|
||||
# This email contains: 'Project: onlinestore'
|
||||
note = submit_email('new_note.eml').first
|
||||
assert_instance_of ContactNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Contact, note.source.class
|
||||
assert_equal 'New note from email', note.subject
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Contact.find(1).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should add contact note from ID in to' do
|
||||
# This email contains: 'Project: onlinestore'
|
||||
note = submit_email('new_note_by_id.eml').first
|
||||
assert_instance_of ContactNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Contact, note.source.class
|
||||
assert_equal 'New note from email', note.subject
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Contact.find(1).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should add contact note from ID in cc' do
|
||||
# This email contains: 'Project: onlinestore'
|
||||
note = submit_email('new_note_with_cc.eml').first
|
||||
assert_instance_of ContactNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Contact, note.source.class
|
||||
assert_equal 'New note from email by id in cc', note.subject
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Contact.find(1).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should add deal note from ID in to' do
|
||||
# This email contains: 'Project: onlinestore'
|
||||
note = submit_email('new_deal_note_by_id.eml').first
|
||||
assert_instance_of DealNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Deal, note.source.class
|
||||
assert_equal 'New note from email', note.subject
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Deal.find(1).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should add contact note from forwarded' do
|
||||
note = submit_email('fwd_new_note_plain.eml').first
|
||||
assert_instance_of ContactNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Contact, note.source.class
|
||||
assert_equal 'New note from forwarded email', note.subject
|
||||
assert_match 'From: "Marat Aminov" marat@mail.ru', note.content
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Contact.find(2).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should add contact note from forwarded html' do
|
||||
note = submit_email('fwd_new_note_html.eml').first
|
||||
assert_instance_of ContactNote, note
|
||||
assert !note.new_record?
|
||||
note.reload
|
||||
assert_equal Contact, note.source.class
|
||||
assert_equal 'New note from forwarded html email', note.subject
|
||||
assert_match 'From: Marat Aminov <marat@mail.com>', note.content
|
||||
assert_equal User.find_by_login('admin'), note.author
|
||||
assert_equal Contact.find(2).id, note.source_id
|
||||
end
|
||||
|
||||
test 'Should not add contact note from deny user to' do
|
||||
assert !submit_email('new_deny_note.eml')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def submit_email(filename, options = {})
|
||||
raw = IO.read(File.join(FIXTURES_PATH, filename))
|
||||
ContactsMailer.receive(raw, options)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,78 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
include RedmineContacts::TestHelper
|
||||
|
||||
if Redmine::VERSION.to_s > '2.5'
|
||||
class CustomFieldCompanyFormatTest < ActiveSupport::TestCase
|
||||
fixtures :custom_fields, :projects, :members, :users, :member_roles, :trackers, :issues
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'company')
|
||||
@controller = DealStatusesController.new
|
||||
Role.anonymous.remove_permission!(:view_contacts)
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_no_arguments
|
||||
with_contacts_settings('cross_project_contacts' => 0) do
|
||||
User.current = nil
|
||||
assert_equal [], @field.possible_values_options
|
||||
assert_equal [], @field.possible_values_options(nil)
|
||||
end
|
||||
end
|
||||
|
||||
def test_possible_values_options_with_project_resource
|
||||
with_contacts_settings('cross_project_contacts' => 1) do
|
||||
User.current = User.find(1)
|
||||
project = Project.find(1)
|
||||
possible_values_options = @field.possible_values_options(project.issues.first)
|
||||
assert possible_values_options.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def test_cast_blank_value
|
||||
assert_nil @field.cast_value(nil)
|
||||
assert_nil @field.cast_value('')
|
||||
end
|
||||
|
||||
def test_cast_valid_value
|
||||
contact = @field.cast_value('2')
|
||||
assert_kind_of Contact, contact
|
||||
assert_equal Contact.find(2), contact
|
||||
end
|
||||
|
||||
def test_cast_invalid_value
|
||||
assert_nil @field.cast_value('187')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealImportTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :users
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:deal_categories])
|
||||
|
||||
def fixture_files_path
|
||||
"#{File.expand_path('../..', __FILE__)}/fixtures/files/"
|
||||
end
|
||||
|
||||
def test_open_correct_csv
|
||||
deal_import = DealImport.new(
|
||||
:file => Rack::Test::UploadedFile.new(fixture_files_path + 'deals_correct.csv', 'text/comma-separated-values'),
|
||||
:project => Project.first,
|
||||
:quotes_type => '"'
|
||||
)
|
||||
assert_difference('Deal.count', 1, 'Should have 1 deal in the database') do
|
||||
assert_equal 1, deal_import.imported_instances.count, 'Should find 1 deal in file'
|
||||
assert deal_import.save, 'Should save successfully'
|
||||
end
|
||||
deal = Deal.last
|
||||
assert_equal 2, deal.status_id, "Status doesn't mach"
|
||||
assert_equal 1, deal.category_id, 'Category should be Design'
|
||||
assert_equal 'rhill', deal.assigned_to.login, 'Assignee should be rhill'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,77 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class ContactTest < ActiveSupport::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_destroy
|
||||
new_status = DealStatus.create(:name => 'New status', :is_default => false, :status_type => DealStatus::OPEN_STATUS)
|
||||
|
||||
assert_difference 'DealStatus.count', -1 do
|
||||
assert new_status.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_status_in_use
|
||||
status = Deal.find(1).status
|
||||
|
||||
assert_no_difference 'DealStatus.count' do
|
||||
assert_raise(RuntimeError, "Can't delete status") do
|
||||
status.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,56 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :users
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(
|
||||
Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts, :contacts_projects,
|
||||
:deals, :deal_statuses]
|
||||
)
|
||||
|
||||
def test_price_to_s_with_custome_settings
|
||||
Setting.plugin_redmine_contacts['decimal_separator'] = '.'
|
||||
Setting.plugin_redmine_contacts['thousands_delimiter'] = ' '
|
||||
assert_equal '$3 000.00', Deal.find(1).price_to_s
|
||||
end
|
||||
|
||||
def test_count_for_status_scope
|
||||
project = Project.find(2)
|
||||
assert_equal 1, project.deals.with_status(1).count
|
||||
assert_equal 2, project.deals.with_status(2).count
|
||||
assert_equal 1, project.deals.with_status(3).count
|
||||
end
|
||||
|
||||
def test_price_with_big_value
|
||||
Setting.plugin_redmine_contacts['decimal_separator'] = '.'
|
||||
Setting.plugin_redmine_contacts['thousands_delimiter'] = ' '
|
||||
deal = Deal.find(5)
|
||||
price = deal.price
|
||||
deal.update_attributes(:price => 9999999999999)
|
||||
assert_equal '9 999 999 999 999.00 RUB', Deal.find(5).price_to_s
|
||||
ensure
|
||||
deal.update_attributes(:price => price)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,96 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DealsPipelineProcessorTest < ActiveSupport::TestCase
|
||||
fixtures :projects, :users
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:deals,
|
||||
:deal_statuses,
|
||||
:deal_categories])
|
||||
|
||||
def setup
|
||||
Deal.destroy_all
|
||||
@deal_status_new = DealStatus.find(1)
|
||||
@deal_status_won = DealStatus.find(2)
|
||||
@deal_status_lost = DealStatus.find(3)
|
||||
@deal_status_intermediate1 = DealStatus.find(4)
|
||||
@deal_status_intermediate2 = DealStatus.find(5)
|
||||
end
|
||||
|
||||
def test_constructor
|
||||
assert_not_nil DealsPipelineProcessor.new(Deal)
|
||||
end
|
||||
|
||||
def test_closed_deal_counts_in_last_unclosed_status
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_won)
|
||||
assert_equal(1, DealProcess.count)
|
||||
processor = DealsPipelineProcessor.new(Deal)
|
||||
assert_equal(1, processor.deals_for_status(@deal_status_new).count)
|
||||
end
|
||||
|
||||
def test_open_deal_counts_in_last_unclosed_status
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_intermediate1)
|
||||
assert_equal(1, DealProcess.count)
|
||||
processor = DealsPipelineProcessor.new(Deal)
|
||||
assert_equal(1, processor.deals_for_status(@deal_status_new).count)
|
||||
end
|
||||
|
||||
def test_if_asked_in_status_returns_simple_case
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_won)
|
||||
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal 2', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_intermediate1)
|
||||
|
||||
assert_equal(2, DealProcess.count)
|
||||
processor = DealsPipelineProcessor.new(Deal)
|
||||
assert_equal(1, processor.deals_for_status(@deal_status_won).count)
|
||||
end
|
||||
|
||||
def test_if_deal_jumped_over_status
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_intermediate2)
|
||||
|
||||
processor = DealsPipelineProcessor.new(Deal)
|
||||
assert_equal(1, processor.deals_for_status(@deal_status_intermediate1).count)
|
||||
end
|
||||
|
||||
def test_if_deal_returned_from_lost
|
||||
@deal = Deal.create!(:status => @deal_status_new, :name => 'New deal', :project => Project.last)
|
||||
@deal.init_deal_process(User.first)
|
||||
@deal.update_attribute(:status, @deal_status_lost)
|
||||
@deal.update_attribute(:status, @deal_status_intermediate2)
|
||||
|
||||
processor = DealsPipelineProcessor.new(Deal)
|
||||
assert_equal(1, processor.deals_for_status(@deal_status_intermediate1).count)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,87 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class ContactsHelperTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
include ContactsHelper
|
||||
include CustomFieldsHelper
|
||||
include Redmine::I18n
|
||||
include ERB::Util
|
||||
|
||||
fixtures :projects, :trackers, :issue_statuses, :issues,
|
||||
:enumerations, :users, :issue_categories,
|
||||
:versions,
|
||||
:projects_trackers,
|
||||
:member_roles,
|
||||
:members,
|
||||
:groups_users,
|
||||
:enabled_modules
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
super
|
||||
set_language_if_valid('en')
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_contacts_to_xls
|
||||
User.current = User.find(1)
|
||||
xls_result = contacts_to_xls(Contact.all)
|
||||
assert_match /First Name/, xls_result
|
||||
assert_match /Domoway/, xls_result
|
||||
end
|
||||
|
||||
def test_contacts_to_xls_with_multivalue_custom_field
|
||||
User.current = User.find(1)
|
||||
field = ContactCustomField.create!(:name => 'filter', :field_format => 'list',
|
||||
:is_filter => true, :is_for_all => true,
|
||||
:possible_values => ['value1', 'value2', 'value3'],
|
||||
:multiple => true)
|
||||
contact = Contact.find(1)
|
||||
contact.custom_field_values = { field.id => ['value1', 'value2', 'value3'] }
|
||||
contact.save!
|
||||
xls_result = contacts_to_xls([contact])
|
||||
assert_match /First Name/, xls_result
|
||||
assert_match /Domoway/, xls_result
|
||||
assert_match /value1, value2, value3/, xls_result
|
||||
end
|
||||
|
||||
def test_mail_macro
|
||||
field = ContactCustomField.create!(:name => 'Custom field', :field_format => 'string')
|
||||
contact = Contact.find(1)
|
||||
contact.custom_field_values = {field.id => 'test value'}
|
||||
contact.save!
|
||||
message = "Hello %%NAME%%, %%FULL_NAME%% %%COMPANY%% %%LAST_NAME%% %%MIDDLE_NAME%% %%DATE%% %%Custom field%%"
|
||||
|
||||
result_msg = mail_macro(contact, message)
|
||||
assert_equal "Hello Ivan, Ivan Ivanov Domoway Ivanov Ivanovich #{format_date(Date.today)} test value", result_msg
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,76 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class DealsHelperTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
include DealsHelper
|
||||
include CustomFieldsHelper
|
||||
include Redmine::I18n
|
||||
include ERB::Util
|
||||
|
||||
fixtures :projects, :trackers, :issue_statuses, :issues,
|
||||
:enumerations, :users, :issue_categories,
|
||||
:versions,
|
||||
:projects_trackers,
|
||||
:member_roles,
|
||||
:members,
|
||||
:groups_users,
|
||||
:enabled_modules
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
super
|
||||
set_language_if_valid('en')
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_deals_to_csv
|
||||
User.current = User.find(1)
|
||||
csv_result = deals_to_csv(Deal.all)
|
||||
assert_match /Name/, csv_result
|
||||
assert_match /First deal with contacts/, csv_result
|
||||
end
|
||||
|
||||
def test_deals_to_csv_with_multivalue_custom_field
|
||||
User.current = User.find(1)
|
||||
field = DealCustomField.create!(:name => 'filter', :field_format => 'list',
|
||||
:is_filter => true, :is_for_all => true,
|
||||
:possible_values => ['value1', 'value2', 'value3'],
|
||||
:multiple => true)
|
||||
deal = Deal.find(1)
|
||||
deal.custom_field_values = { field.id => ['value1', 'value2', 'value3'] }
|
||||
deal.save!
|
||||
csv_result = deals_to_csv([deal])
|
||||
assert_match /Name/, csv_result
|
||||
assert_match /First deal with contacts/, csv_result
|
||||
assert_match /value1, value2, value3/, csv_result
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,78 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class NotesHelperTest < ActionView::TestCase
|
||||
include ApplicationHelper
|
||||
include NotesHelper
|
||||
include Redmine::I18n
|
||||
include ERB::Util
|
||||
|
||||
fixtures :projects, :trackers, :issue_statuses, :issues,
|
||||
:enumerations, :users, :issue_categories,
|
||||
:versions,
|
||||
:projects_trackers,
|
||||
:member_roles,
|
||||
:members,
|
||||
:groups_users,
|
||||
:enabled_modules
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
super
|
||||
set_language_if_valid('en')
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_authoring_note_without_time
|
||||
RedmineContacts.settings[:note_authoring_time] = false
|
||||
assert_nothing_raised { authoring_note('2012-12-12 10:00'.to_time, User.find(1)) }
|
||||
end
|
||||
|
||||
def test_authoring_note_with_time
|
||||
RedmineContacts.settings[:note_authoring_time] = true
|
||||
assert_nothing_raised { authoring_note('2012-12-12 10:00'.to_time, User.find(1)) }
|
||||
end
|
||||
|
||||
def test_authoring_note_without_time_with_empty_time
|
||||
RedmineContacts.settings[:note_authoring_time] = true
|
||||
assert_nothing_raised { authoring_note(nil, User.find(1)) }
|
||||
end
|
||||
|
||||
def test_authoring_note_without_time_with_empty_time
|
||||
RedmineContacts.settings[:note_authoring_time] = false
|
||||
assert_nothing_raised { authoring_note(nil, User.find(1)) }
|
||||
end
|
||||
|
||||
def test_authoring_note_without_time_with_empty_user
|
||||
RedmineContacts.settings[:note_authoring_time] = true
|
||||
assert_nothing_raised { authoring_note('2012-12-12 10:00'.to_time, nil) }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,82 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# encoding: utf-8
|
||||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class ContactsProjectSettingTest < ActiveSupport::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:contacts_settings,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
def setup
|
||||
Setting.plugin_redmine_contacts['post_address_format'] = nil
|
||||
@project_settings = ContactsProjectSetting.new(Project.find(1), 'redmine_contacts')
|
||||
end
|
||||
|
||||
def test_read_values
|
||||
assert_equal 'String value', @project_settings.string_setting
|
||||
assert_equal true, @project_settings.boolean_setting?
|
||||
end
|
||||
|
||||
def test_read_global_values
|
||||
Setting['plugin_redmine_contacts']['global_value'] = 'Global'
|
||||
assert_equal 'Global', @project_settings.global_value
|
||||
end
|
||||
|
||||
def test_read_default_values
|
||||
assert_equal ['USD', 'EUR', 'GBP', 'RUB', 'CHF'].sort, @project_settings.major_currencies.sort
|
||||
end
|
||||
|
||||
def test_read_default_values_post_address_format
|
||||
assert_equal "%street1%\n%street2%\n%city%, %postcode%\n%region%\n%country%", @project_settings.post_address_format
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,124 @@
|
||||
# encoding: utf-8
|
||||
#
|
||||
# This file is a part of Redmine CRM (redmine_contacts) plugin,
|
||||
# customer relationship management plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2010-2018 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_contacts 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# redmine_contacts 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 redmine_contacts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class MailerPatchTest < ActiveSupport::TestCase
|
||||
fixtures :projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
:member_roles,
|
||||
:issues,
|
||||
:issue_statuses,
|
||||
:versions,
|
||||
:trackers,
|
||||
:projects_trackers,
|
||||
:issue_categories,
|
||||
:enabled_modules,
|
||||
:enumerations,
|
||||
:attachments,
|
||||
:workflows,
|
||||
:custom_fields,
|
||||
:custom_values,
|
||||
:custom_fields_projects,
|
||||
:custom_fields_trackers,
|
||||
:time_entries,
|
||||
:journals,
|
||||
:journal_details,
|
||||
:queries
|
||||
|
||||
fixtures :email_addresses if ActiveRecord::VERSION::MAJOR >= 4
|
||||
|
||||
RedmineContacts::TestCase.create_fixtures(Redmine::Plugin.find(:redmine_contacts).directory + '/test/fixtures/', [:contacts,
|
||||
:contacts_projects,
|
||||
:contacts_issues,
|
||||
:deal_processes,
|
||||
:deals,
|
||||
:notes,
|
||||
:tags,
|
||||
:taggings,
|
||||
:queries])
|
||||
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/contacts_mailer'
|
||||
|
||||
def setup
|
||||
RedmineContacts::TestCase.prepare
|
||||
Setting.host_name = 'mydomain.foo'
|
||||
Setting.protocol = 'http'
|
||||
Setting.plain_text_mail = '0'
|
||||
ActionMailer::Base.deliveries.clear
|
||||
Setting.notified_events = Redmine::Notifiable.all.collect(&:name)
|
||||
end
|
||||
|
||||
def test_crm_note_add
|
||||
note = Note.find(1)
|
||||
assert Mailer.crm_note_add(note).deliver
|
||||
assert_match 'Note 1', last_email.text_part.to_s
|
||||
end
|
||||
|
||||
def test_crm_note_add_to_company
|
||||
note = Note.find(4)
|
||||
assert Mailer.crm_note_add(note).deliver
|
||||
assert_match 'Note 4', last_email.text_part.to_s
|
||||
end
|
||||
|
||||
def test_crm_contact_add
|
||||
contact = Contact.find(1)
|
||||
assert Mailer.crm_contact_add(contact).deliver
|
||||
assert_match 'Contact #1: Ivan Ivanov', last_email.text_part.to_s
|
||||
end
|
||||
def test_crm_note_add_to_deal
|
||||
note = Note.find(5)
|
||||
assert Mailer.crm_note_add(note).deliver
|
||||
assert_match 'Note 5', last_email.text_part.to_s
|
||||
end
|
||||
|
||||
def test_crm_deal_add
|
||||
deal = Deal.find(1)
|
||||
assert Mailer.crm_deal_add(deal).deliver
|
||||
assert_match 'Deal #1', last_email.text_part.to_s
|
||||
end
|
||||
|
||||
def test_crm_deal_updated
|
||||
deal_process = DealProcess.last
|
||||
deal_process.author = User.find(2)
|
||||
deal_process.save
|
||||
assert Mailer.crm_deal_updated(deal_process).deliver
|
||||
assert_match 'John Smith', last_email.text_part.to_s
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def last_email
|
||||
mail = ActionMailer::Base.deliveries.last
|
||||
assert_not_nil mail
|
||||
mail
|
||||
end
|
||||
|
||||
def text_part
|
||||
last_email.parts.detect { |part| part.content_type.include?('text/plain') }
|
||||
end
|
||||
|
||||
def html_part
|
||||
last_email.parts.detect { |part| part.content_type.include?('text/html') }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user