Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PropTrackr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mdmuradalahi
PropTrackr
Commits
5e310d64
Commit
5e310d64
authored
4 months ago
by
snaqvi
Browse files
Options
Downloads
Patches
Plain Diff
fixes and test correct
parent
179ebb97
No related branches found
No related tags found
1 merge request
!113
fixes and test correct
Pipeline
#47235
passed
4 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/proptracker_web/controllers/advertisement_html/show.html.heex
+4
-3
4 additions, 3 deletions
...tracker_web/controllers/advertisement_html/show.html.heex
test/proptracker_web/controllers/3.7_search_order_test.exs
+121
-0
121 additions, 0 deletions
test/proptracker_web/controllers/3.7_search_order_test.exs
with
125 additions
and
3 deletions
lib/proptracker_web/controllers/advertisement_html/show.html.heex
+
4
−
3
View file @
5e310d64
...
@@ -195,9 +195,10 @@
...
@@ -195,9 +195,10 @@
<%=
String
.
capitalize
(
@advertisement
.
state
)
%>
<%=
String
.
capitalize
(
@advertisement
.
state
)
%>
</span></p>
</span></p>
<p><strong>
Reference:
</strong>
<%=
@advertisement
.
reference
%>
</p>
<p><strong>
Reference:
</strong>
<%=
@advertisement
.
reference
%>
</p>
<a
href=
"https://www.facebook.com/sharer/sharer.php?u=http://193.40.11.154/advertisements/{@advertisement.id}"
target=
"_blank"
>
<a
href=
{"https://www.facebook.com/sharer/sharer.php?u=http://193.40.11.154/advertisements/#{@advertisement.id}"}
target=
"_blank"
>
<button
class=
"social-button facebook"
>
Share on Facebook
</button>
<button
class=
"social-button facebook"
>
Share on Facebook
</button>
</a>
</a>
<!-- Contact Button -->
<!-- Contact Button -->
<button
class=
"contact-button"
onclick=
"toggleContactInfo()"
>
+ Owner Contact Info
</button>
<button
class=
"contact-button"
onclick=
"toggleContactInfo()"
>
+ Owner Contact Info
</button>
...
...
This diff is collapsed.
Click to expand it.
test/proptracker_web/controllers/3.7_search_order_test.exs
+
121
−
0
View file @
5e310d64
defmodule
ProptrackerWeb
.
AdvertisementOrderTest
do
use
ProptrackerWeb
.
ConnCase
alias
Proptracker
.
Accounts
.
{
User
,
Advertisement
}
alias
Proptracker
.
Repo
@valid_user_attrs
%{
name:
"Test User"
,
username:
"test_username"
,
password:
"password123"
,
date_of_birth:
~D[1990-01-01]
,
phone_number:
"987654321"
}
@valid_advertisement_attrs
%{
title:
"Available Ad"
,
pictures:
[
"path/to/image1.jpg"
,
"path/to/image2.jpg"
],
description:
"Available Advertisement"
,
type:
"rent"
,
price:
Decimal
.
new
(
"1000.00"
),
square_meters:
100
,
location:
"City 1"
,
rooms:
2
,
floor:
1
,
total_floors:
5
,
state:
"available"
}
@reserved_advertisement_attrs
%{
title:
"Reserved Ad"
,
pictures:
[
"path/to/image3.jpg"
],
description:
"Reserved Advertisement"
,
type:
"rent"
,
price:
Decimal
.
new
(
"1500.00"
),
square_meters:
80
,
location:
"City 2"
,
rooms:
3
,
floor:
2
,
total_floors:
5
,
state:
"reserved"
}
@sold_advertisement_attrs
%{
title:
"Sold Ad"
,
pictures:
[
"path/to/image4.jpg"
],
description:
"Sold Advertisement"
,
type:
"rent"
,
price:
Decimal
.
new
(
"2000.00"
),
square_meters:
120
,
location:
"City 3"
,
rooms:
4
,
floor:
3
,
total_floors:
5
,
state:
"sold/rented"
}
defp
create_user
(
_
)
do
{
:ok
,
user
}
=
Repo
.
insert
(%
User
{}
|>
User
.
changeset
(
@valid_user_attrs
))
%{
user:
user
}
end
defp
create_advertisements
(%{
user:
user
})
do
available_attrs
=
Map
.
put
(
@valid_advertisement_attrs
,
:user_id
,
user
.
id
)
{
:ok
,
available_ad
}
=
Repo
.
insert
(
Advertisement
.
changeset
(%
Advertisement
{},
available_attrs
))
reserved_attrs
=
Map
.
put
(
@reserved_advertisement_attrs
,
:user_id
,
user
.
id
)
{
:ok
,
reserved_ad
}
=
Repo
.
insert
(
Advertisement
.
changeset
(%
Advertisement
{},
reserved_attrs
))
sold_attrs
=
Map
.
put
(
@sold_advertisement_attrs
,
:user_id
,
user
.
id
)
{
:ok
,
sold_ad
}
=
Repo
.
insert
(
Advertisement
.
changeset
(%
Advertisement
{},
sold_attrs
))
%{
available_ad:
available_ad
,
reserved_ad:
reserved_ad
,
sold_ad:
sold_ad
,
user:
user
}
end
defp
login_user
(
conn
,
user
)
do
post
(
conn
,
"/login"
,
user:
%{
username:
user
.
username
,
password:
user
.
password
})
end
describe
"advertisement order"
do
setup
[
:create_user
,
:create_advertisements
]
test
"shows advertisements in correct order (available -> reserved -> sold)"
,
%{
conn:
conn
,
available_ad:
available_ad
,
reserved_ad:
reserved_ad
,
sold_ad:
sold_ad
,
user:
user
}
do
conn
=
login_user
(
conn
,
user
)
assert
get_session
(
conn
,
:user_id
)
==
user
.
id
conn
=
get
(
conn
,
~p"/advertisements"
)
response
=
html_response
(
conn
,
200
)
ad_titles
=
Floki
.
find
(
response
,
".advertisement-box .advertisement-title"
)
|>
Enum
.
map
(
&
String
.
trim
(
Floki
.
text
(
&1
)))
assert
"Title:
#{
available_ad
.
title
}
"
in
ad_titles
assert
"Title:
#{
reserved_ad
.
title
}
"
in
ad_titles
assert
"Title:
#{
sold_ad
.
title
}
"
in
ad_titles
available_ad_index
=
Enum
.
find_index
(
ad_titles
,
fn
title
->
title
==
"Title:
#{
available_ad
.
title
}
"
end
)
reserved_ad_index
=
Enum
.
find_index
(
ad_titles
,
fn
title
->
title
==
"Title:
#{
reserved_ad
.
title
}
"
end
)
sold_ad_index
=
Enum
.
find_index
(
ad_titles
,
fn
title
->
title
==
"Title:
#{
sold_ad
.
title
}
"
end
)
assert
available_ad_index
<
reserved_ad_index
assert
reserved_ad_index
<
sold_ad_index
end
test
"ensures ads do not appear in the incorrect order"
,
%{
conn:
conn
,
available_ad:
available_ad
,
reserved_ad:
reserved_ad
,
sold_ad:
sold_ad
,
user:
user
}
do
conn
=
login_user
(
conn
,
user
)
assert
get_session
(
conn
,
:user_id
)
==
user
.
id
conn
=
get
(
conn
,
~p"/advertisements"
)
response
=
html_response
(
conn
,
200
)
ad_titles
=
Floki
.
find
(
response
,
".advertisement-box .advertisement-title"
)
|>
Enum
.
map
(
&
String
.
trim
(
Floki
.
text
(
&1
)))
assert
"Title:
#{
available_ad
.
title
}
"
in
ad_titles
assert
"Title:
#{
reserved_ad
.
title
}
"
in
ad_titles
assert
"Title:
#{
sold_ad
.
title
}
"
in
ad_titles
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment