Gallery page and front-page mobile responsive (#762)

* add warpables and users relationship

* make front-ui mobile responsive

* clean and reorganize images

* handle maps with no images

* gallery page

* link to all maps if no location selected

* test warpables and user relationship

* add test/reports to gitignore

* add pagination for mappers
This commit is contained in:
Cess
2019-06-28 18:56:50 +03:00
committed by Jeffrey Warren
parent 2064621e20
commit 21504ea363
27 changed files with 189 additions and 377 deletions

3
.gitignore vendored
View File

@@ -32,7 +32,6 @@ config/amazon_s3.yml
config/initializers/recaptcha.rb
config/config.yml
config/initializers/site_keys.rb
Gemfile.lock
vendor/bundle
app/assets/bower_components
app/assets/node_modules
@@ -43,6 +42,6 @@ todo.txt
.sass-cache
.byebug_history
coverage_report/
test/reports/
test/reports/*
yarn-error.log

View File

Before

Width:  |  Height:  |  Size: 737 KiB

After

Width:  |  Height:  |  Size: 737 KiB

View File

@@ -30,12 +30,16 @@ It was originally created by Caroline Hadilaksono: http://www.hadilaksono.com
background-attachment: fixed;
background-repeat: no-repeat;
background-size: cover;
}
.text-block {
height: 350px;
width: 500px;
margin-bottom: 5px;
padding-top:30px;
padding-bottom:50px;
background-color: white;
display: inline-block;
// font-family: Verdana; //Nunito; // 'Ubuntu', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;
.btn {
width: 45%;
font-size: 1em;
}
}
@@ -45,7 +49,6 @@ It was originally created by Caroline Hadilaksono: http://www.hadilaksono.com
.jumbotron-text {
text-shadow: 1px 1px 2px #080707;
// color: white;
}
.map-list .map-img {
@@ -232,11 +235,6 @@ label small {
letter-spacing: -0.2px;
}
.icon-landing {
width: 120px;
height: 120px;
object-fit: contain;
}
.item-description {
font-size: 18px;
@@ -247,42 +245,6 @@ label small {
color: #a2aaad;
}
.blue-background {
background-color: #17a2b8;
width: 1000px;
}
.section-blue-background {
max-height: 100px;
background-color: #17a2b8;
margin: 20px 0;
color: white;
}
.section-blue-background a {
display: flex;
justify-content: center;
font-size: 26px;
font-weight: 500;
font-style: normal;
font-stretch: normal;
line-height: 1.17;
letter-spacing: -0.5px;
color: #ffffff;
padding: 30px 0 40px 0;
justify-content: center !important;
}
.section-blue-background a:hover {
color: #ffffff;
text-decoration: none;
}
@media(max-width: 360px) {
#get-started-button {
margin-bottom: 10px;
}
}
#info {
.fa-stack {
@@ -294,3 +256,10 @@ label small {
padding-bottom: 20px;
}
}
#all-maps {
img {
display: block;
width: 200px;
height: 200px;
}
}

View File

@@ -1,4 +1,6 @@
# Shadow Controller for the new front page
require 'will_paginate/array'
class FrontUiController < ApplicationController
protect_from_forgery except: :save_location
@@ -18,9 +20,11 @@ class FrontUiController < ApplicationController
lat = session[:lat]
lon = session[:lon]
@nearby_maps = Map.maps_nearby(lat: lat, lon: lon, dist: 10)
.page(params[:page])
.per_page(12)
end
@all_mappers = Map.featured_authors
@all_mappers = Map.featured_authors.paginate(page: params[:page], per_page: 12)
end
def save_location
@@ -33,4 +37,13 @@ class FrontUiController < ApplicationController
end
def about; end
def gallery
@maps = Map.page(params[:page])
.per_page(20)
.where(archived: false, password: '')
.order('updated_at DESC')
.group('maps.id')
@authors = Map.featured_authors.paginate(page: params[:page], per_page: 20)
end
end

View File

@@ -1,5 +1,13 @@
module FrontUiHelper
def profile_image(author)
author.maps.last.warpables.last.image.url
author.warpables.last.image.url
end
def anonymous(maps)
maps.anonymous
end
def featured(maps)
maps.featured
end
end

View File

@@ -47,6 +47,10 @@ class Map < ActiveRecord::Base
author == "" || user_id.zero?
end
def self.anonymous
Map.where(user_id: 0)
end
def self.bbox(minlat, minlon, maxlat, maxlon)
Map.where(['lat > ? AND lat < ? AND lon > ? AND lon < ?',
minlat, maxlat, minlon, maxlon])

View File

@@ -5,6 +5,7 @@ class User < ActiveRecord::Base
has_many :tags
has_many :comments
has_many :exports
has_many :warpables, through: :maps
validates_presence_of :login
validates_length_of :login, within: 3..40

View File

@@ -14,3 +14,5 @@
</div>
<% end %>
</div>
<br style="clear:both;" />
<%= will_paginate mappers, list_classes: %w(pagination justify-content-center), previous_label: 'Prev', next_label: 'Next', renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>

View File

@@ -4,7 +4,7 @@
<div class="card card-without-border">
<a href="/maps/<%= map.slug %>">
<% if map.warpables.length > 0 %>
<img class="card-img-top map-img" src="<%= map.warpables.first.image.url(:small) %>" alt="<%= map.name %>">
<img class="card-img-top map-img" src="<%= map.warpables.first.image.url %>" alt="<%= map.name %>">
<% else %>
<img class="card-img-top" src="<%= asset_path('image.png') %>" alt="Map without image" style="max-height: 400px !important;">
<% end %>
@@ -28,3 +28,5 @@
</div>
<% end %>
</div>
<br style="clear:both;" />
<%= will_paginate maps, list_classes: %w(pagination justify-content-center), previous_label: 'Prev', next_label: 'Next', renderer: WillPaginate::ActionView::BootstrapLinkRenderer unless @unpaginated %>

View File

@@ -0,0 +1,40 @@
<div class="section-header mt-4" id="all-maps" >
<h2 class="section-title text-center">Maps Gallery</h2>
<br> <br>
<ul class="nav nav-pills nav-tabs justify-content-center" >
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#featured" role="tab" aria-selected="true"><%= @title ||= "Featured" %></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#anonymous" role="tab" aria-selected="false">Anonymous</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#all" role="tab" aria-selected="false">All</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#authors" role="tab" aria-selected="false">Authors</a>
</li>
<% if params[:controller] == "tags" %>
<li class="nav-item">
<a class="nav-link" role="tab" href="/feeds/tag/<%= params[:id] %>" aria-selected="false">RSS</a>
</li>
<% end %>
</ul>
<br>
<div class="tab-content">
<div class="tab-pane fade show active" id="featured" role="tabpanel">
<%= render :partial => 'maps', :locals => { :maps => featured(@maps) } %>
</div>
<div class="tab-pane fade" id="all" role="tabpanel">
<%= render :partial => 'maps', :locals => { :maps => @maps } %>
</div>
<div class="tab-pane fade" id="anonymous" role="tabpanel">
<%= render :partial => 'maps', :locals => { :maps => anonymous(@maps) } %>
</div>
<div class="tab-pane fade" id="authors" role="tabpanel">
<%= render :partial => 'featured_mappers', :locals => { :mappers => @authors } %>
</div>
</div>
</div>

View File

@@ -8,38 +8,42 @@
<%= javascript_include_tag('/lib/leaflet-spin/example/leaflet.spin.min.js') %>
<!-- jumbotron with background-image -->
<div class="jumbotron jumbotron-fluid text-center" id="hero">
<div class="container">
<div class="text-block">
<br><br><h1>MapKnitter</h1>
<p> A Community Atlas hosted by <a href="publiclag.org">PublicLab</a></p>
<div class="container-fluid jumbotron jumbotron-fluid text-center" id="hero">
<div class="row">
<div class= "col-md-4 offset-md-4 text-block">
<h1>MapKnitter</h1>
<p> A Community Atlas hosted by <a href="https://publiclab.org">PublicLab</a></p>
<p>Use a kite, balloon, pole, or drone to take an aerial photo and tell your own visual story of the place. <a href="/about" class="alert-link">Learn more</a></p>
<%# <p class="lead"> %>
<p>
<a class="btn btn-primary btn-lg" href= 'https://store.publiclab.org/collections/mapping-kits'>
Get a mapping kit <i class="fa fa-angle-double-right fa-fw" style="font-size:20px;color:white;"></i>
Get a mapping kit <i class="fa fa-angle-double-right fa-fw" style="font-size:18px;color:white;"></i>
</a>
<a class="btn btn-primary btn-lg" href="<%= new_map_url %>">
Add your images <i class="fa fa-plus fa-fw" style="font-size:15px;color:white;"></i>
Add your images <i class="fa fa-plus fa-fw" style="font-size:12px;color:white;"></i>
</a>
</p>
</div>
</div>
</div>
</div>
<div id="mapknitter-unique" class="mx-auto" style="height: 450px; width: 100%;"></div>
<%= link_to 'Nearby Maps', 'front_ui/nearby_mappers' %>
<% if @mappers.any? %>
<%# <hr> %>
<div class="section-header text-center">
<h2 class="section-title">Featured Mappers</h2>
</div>
<%= render :partial => 'featured_mappers', :locals => { :mappers => @mappers } %>
<div class="section-header text-center">
<a href="/mappers" class="alert-link"><u>More nearby people & maps <i class="fa fa-angle-double-right"></i></u></a>
</div>
<% end %>
<div class="section-header text-center">
<% if session[:lat].present? %>
<a href="/mappers" class="alert-link">More nearby people & maps <i class="fa fa-angle-double-right"> </i></a>
<% else %>
<a href="/gallery" class="alert-link">View all maps <i class="fa fa-angle-double-right"></i></a>
<% end %>
<hr style="max-width: 300px;">
</div>
<br>

View File

@@ -82,7 +82,7 @@
</button>
<!-- Write a research note on Public Lab -->
<a target="_blank" class="btn btn-outline-secondary" title="Post a research note on Public Lab" href="//publiclab.org/post?title=MapKnitter map of <%= @map.name %>&tags=lat:<%= @map.lat %>,lon:<%= @map.lon %>,mapknitter&body=%3Cimg src=%22<%= @map.warpables.first.image.url(:medium) %>%22%3E%3C/img%3E%3Ciframe%20src=%22https://mapknitter.org/embed/<%= @map.slug %>%22%20style=%22border:none%22%20width=%22100%25%22%20height=%22400px%22%3E%3C/iframe%3E%3Cbr /%3E%3Cbr /%3E<%= @map.description %>%3Cbr /%3Ehttps://mapknitter.org/embed/<%= @map.slug %>" type="button">
<a target="_blank" class="btn btn-outline-secondary" title="Post a research note on Public Lab" href="//publiclab.org/post?title=MapKnitter map of <%= @map.name %>&tags=lat:<%= @map.lat %>,lon:<%= @map.lon %>,mapknitter&body=%3Cimg src=%22<%= @map.warpables.first&.image&.url(:medium) %>%22%3E%3C/img%3E%3Ciframe%20src=%22https://mapknitter.org/embed/<%= @map.slug %>%22%20style=%22border:none%22%20width=%22100%25%22%20height=%22400px%22%3E%3C/iframe%3E%3Cbr /%3E%3Cbr /%3E<%= @map.description %>%3Cbr /%3Ehttps://mapknitter.org/embed/<%= @map.slug %>" type="button">
<span class="d-none d-sm-block"><span class="fa fa-file"></span> Post</span>
</a>

View File

@@ -4,6 +4,7 @@ Mapknitter::Application.routes.draw do
get 'front-page' => 'front_ui#index'
get 'mappers' => 'front_ui#nearby_mappers'
get 'gallery' => 'front_ui#gallery'
post "save_location" => 'front_ui#save_location'
get 'about' => 'front_ui#about'
get 'all_maps' => 'front_ui#all_maps'

View File

@@ -1,162 +0,0 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20190420025012) do
create_table "annotations", :force => true do |t|
t.integer "map_id"
t.integer "user_id"
t.string "annotation_type"
t.string "text"
t.string "style"
t.string "coordinates"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "comments", :force => true do |t|
t.string "user_id"
t.string "body"
t.integer "map_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "exports", :force => true do |t|
t.integer "map_id", :default => 0
t.integer "size", :default => 0
t.integer "width", :default => 0
t.integer "height", :default => 0
t.float "cm_per_pixel", :default => 0.0
t.string "status", :default => "none"
t.boolean "tms", :default => false
t.boolean "jpg", :default => false
t.boolean "geotiff", :default => false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "zip", :default => false, :null => false
t.text "bands_string", :null => false
t.string "export_type", :default => "normal", :null => false
t.integer "user_id", :default => 0
t.string "export_url"
end
create_table "maps", :force => true do |t|
t.string "name", :default => ""
t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0
t.integer "version", :default => 1
t.string "password", :default => ""
t.text "styles"
t.datetime "created_at"
t.datetime "updated_at"
t.text "description"
t.string "author", :default => "anonymous"
t.decimal "zoom", :precision => 15, :scale => 10, :default => 2.0
t.string "location", :default => ""
t.string "static_data", :default => ""
t.boolean "vectors", :default => false, :null => false
t.string "tiles", :default => "google", :null => false
t.string "email", :default => "", :null => false
t.boolean "archived", :default => false, :null => false
t.text "tile_url"
t.text "tile_layer"
t.string "license", :default => "copyright"
t.integer "user_id", :default => 0
t.boolean "anon_annotatable", :default => false
t.string "slug"
end
add_index "maps", ["slug"], :name => "index_maps_on_slug", :unique => true
create_table "nodes", :force => true do |t|
t.string "color", :default => "red"
t.string "author", :default => "anonymous"
t.decimal "lat", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon", :precision => 20, :scale => 10, :default => 0.0
t.integer "way_id", :default => 0
t.integer "order", :default => 0
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", :default => ""
t.string "description", :default => ""
t.integer "map_id", :default => 0
t.integer "way_order", :default => 0
t.text "body"
end
create_table "tags", :force => true do |t|
t.string "user_id"
t.string "name"
t.integer "map_id"
t.integer "warpable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "tags", ["map_id"], :name => "index_tags_on_map_id"
add_index "tags", ["user_id"], :name => "index_tags_on_user_id"
add_index "tags", ["warpable_id"], :name => "index_tags_on_warpable_id"
create_table "users", :force => true do |t|
t.string "login", :limit => 40
t.string "name", :limit => 100, :default => ""
t.string "email", :limit => 100
t.string "crypted_password", :limit => 40
t.string "salt", :limit => 40
t.string "identity_url"
t.string "role", :limit => 40, :default => "basic"
t.datetime "created_at"
t.datetime "updated_at"
t.string "remember_token", :limit => 40
t.datetime "remember_token_expires_at"
end
add_index "users", ["login"], :name => "index_users_on_login", :unique => true
create_table "warpables", :force => true do |t|
t.integer "parent_id"
t.string "image_content_type"
t.string "image_file_name"
t.string "thumbnail"
t.integer "image_file_size"
t.integer "width"
t.integer "height"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "map_id", :default => 0
t.string "nodes", :default => ""
t.boolean "locked", :default => false, :null => false
t.boolean "deleted", :default => false, :null => false
t.text "history", :null => false
t.float "cm_per_pixel", :default => 0.0, :null => false
end
create_table "ways", :force => true do |t|
t.string "color", :default => "red"
t.string "author", :default => "anonymous"
t.decimal "lat1", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lat2", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon1", :precision => 20, :scale => 10, :default => 0.0
t.decimal "lon2", :precision => 20, :scale => 10, :default => 0.0
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", :default => ""
t.string "description", :default => ""
t.boolean "complete", :default => true
t.integer "map_id", :default => 0
t.text "body"
end
end

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="ExportTest" filepath="/home/k/proj/mapknitter/test/unit/export_test.rb" skipped="0" failures="0" errors="0" tests="2" assertions="7" time="0.1806370220001554">
<testcase name="test_count_methods" lineno="4" classname="ExportTest" assertions="6" time="0.17920688500453252">
</testcase>
<testcase name="test_export_running" lineno="14" classname="ExportTest" assertions="1" time="0.0014301369956228882">
</testcase>
</testsuite>
</testsuites>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="MapTest" filepath="/home/k/proj/mapknitter/test/unit/map_test.rb" skipped="0" failures="0" errors="0" tests="3" assertions="30" time="0.03067347500473261">
<testcase name="test_basics" lineno="5" classname="MapTest" assertions="24" time="0.012606176009285264">
</testcase>
<testcase name="test_tag_basics" lineno="99" classname="MapTest" assertions="3" time="0.013976358997751959">
</testcase>
<testcase name="test_histograms" lineno="83" classname="MapTest" assertions="3" time="0.004090939997695386">
</testcase>
</testsuite>
</testsuites>

View File

@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="MapsControllerTest" filepath="/home/k/proj/mapknitter/test/functional/maps_controller_test.rb" skipped="0" failures="0" errors="1" tests="26" assertions="78" time="3.00662421900779">
<testcase name="test_embed" lineno="249" classname="MapsControllerTest" assertions="2" time="2.2494869669899344">
</testcase>
<testcase name="test_should_annotate_maps" lineno="243" classname="MapsControllerTest" assertions="1" time="0.06807511499209795">
</testcase>
<testcase name="test_should_not_update_unless_logged_in" lineno="230" classname="MapsControllerTest" assertions="2" time="0.0039022870041662827">
</testcase>
<testcase name="test_should_get_map_of_maps" lineno="52" classname="MapsControllerTest" assertions="3" time="0.009347153987619095">
</testcase>
<testcase name="test_featured" lineno="288" classname="MapsControllerTest" assertions="1" time="0.035135833008098416">
</testcase>
<testcase name="test_should_get_index" lineno="30" classname="MapsControllerTest" assertions="4" time="0.024817559999064542">
</testcase>
<testcase name="test_should_search_for_maps_by_description" lineno="82" classname="MapsControllerTest" assertions="3" time="0.020067279998329468">
</testcase>
<testcase name="test_should_not_delete_map_if_not_owner" lineno="163" classname="MapsControllerTest" assertions="4" time="0.008421691993135028">
</testcase>
<testcase name="test_should_not_display_archived_maps" lineno="40" classname="MapsControllerTest" assertions="4" time="0.040099802004988305">
</testcase>
<testcase name="test_should_display_image_url_for_maps_by_region" lineno="16" classname="MapsControllerTest" assertions="2" time="0.010083747009048238">
</testcase>
<testcase name="test_should_update_map" lineno="207" classname="MapsControllerTest" assertions="8" time="0.03921118000289425">
</testcase>
<testcase name="test_should_create_map_if_logged_in" lineno="91" classname="MapsControllerTest" assertions="6" time="0.1147474500030512">
</testcase>
<testcase name="test_should_get_show" lineno="183" classname="MapsControllerTest" assertions="2" time="0.06256500899326056">
</testcase>
<testcase name="test_it_returns_the_images" lineno="255" classname="MapsControllerTest" assertions="2" time="0.018422578999889083">
</testcase>
<testcase name="test_should_search_for_maps_by_location" lineno="73" classname="MapsControllerTest" assertions="3" time="0.04014417600410525">
</testcase>
<testcase name="test_should_create_map_if_not_logged_in" lineno="110" classname="MapsControllerTest" assertions="6" time="0.023595759994350374">
</testcase>
<testcase name="test_should_delete_map_if_owner" lineno="173" classname="MapsControllerTest" assertions="4" time="0.04676445900986437">
</testcase>
<testcase name="test_should_render_new_if_map_not_created" lineno="148" classname="MapsControllerTest" assertions="0" time="0.031077706007636152">
<error type="test_should_render_new_if_map_not_created" message="ActionView::Template::Error: No route matches {:action=&gt;&quot;index&quot;, :controller=&gt;&quot;warpables&quot;, :map_id=&gt;nil} missing required keys: [:map_id]...">
Failure:
test_should_render_new_if_map_not_created(Minitest::Result) [/home/k/.rvm/gems/ruby-2.4.6/gems/actionpack-4.2.11.1/lib/action_dispatch/routing/route_set.rb:234]:
ActionView::Template::Error: No route matches {:action=&gt;"index", :controller=&gt;"warpables", :map_id=&gt;nil} missing required keys: [:map_id]
app/views/images/_new.html.erb:13:in `_app_views_images__new_html_erb___582794143336601479_47432368697160'
app/views/layouts/knitter2.html.erb:195:in `_app_views_layouts_knitter__html_erb__1554220659803257588_47432335059940'
app/controllers/maps_controller.rb:41:in `create'
test/functional/maps_controller_test.rb:151:in `block in &lt;class:MapsControllerTest&gt;'
</error>
</testcase>
<testcase name="test_assigns_current_user_as_map_author_if_logged_in" lineno="128" classname="MapsControllerTest" assertions="6" time="0.026720677997218445">
</testcase>
<testcase name="test_should_not_archive_map_without_enough_permissions" lineno="198" classname="MapsControllerTest" assertions="3" time="0.013543893001042306">
</testcase>
<testcase name="test_should_get_new" lineno="58" classname="MapsControllerTest" assertions="2" time="0.01243473100475967">
</testcase>
<testcase name="test_returns_the_exports" lineno="278" classname="MapsControllerTest" assertions="1" time="0.006508196005597711">
</testcase>
<testcase name="test_license" lineno="283" classname="MapsControllerTest" assertions="1" time="0.019753675995161757">
</testcase>
<testcase name="test_should_archive_map" lineno="189" classname="MapsControllerTest" assertions="3" time="0.01554052100982517">
</testcase>
<testcase name="test_should_display_maps_by_region" lineno="235" classname="MapsControllerTest" assertions="2" time="0.028362469995045103">
</testcase>
<testcase name="test_should_search_for_maps_by_name" lineno="64" classname="MapsControllerTest" assertions="3" time="0.03779429799760692">
</testcase>
</testsuite>
</testsuites>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="UserTest" filepath="/home/k/proj/mapknitter/test/unit/user_test.rb" skipped="0" failures="0" errors="0" tests="5" assertions="15" time="0.05865451000863686">
<testcase name="test_should_require_login" lineno="15" classname="UserTest" assertions="4" time="0.016862381002283655">
</testcase>
<testcase name="test_user_simple_query_methods" lineno="33" classname="UserTest" assertions="4" time="0.006921756998053752">
</testcase>
<testcase name="test_should_require_email" lineno="24" classname="UserTest" assertions="4" time="0.016311457002302632">
</testcase>
<testcase name="test_should_create_user" lineno="8" classname="UserTest" assertions="2" time="0.011182418995304033">
</testcase>
<testcase name="test_should_not_create_user" lineno="3" classname="UserTest" assertions="1" time="0.00737649601069279">
</testcase>
</testsuite>
</testsuites>

View File

@@ -1,4 +1,21 @@
require 'test_helper'
class FrontUiHelperTest < ActionView::TestCase
def setup
@user = users(:quentin)
@maps = Map.all
end
test 'should return profile_image' do
last_image = @user.warpables.last.image
assert_equal last_image.url, profile_image(@user)
end
test 'should return anonymous maps' do
assert_equal @maps.anonymous, anonymous(@maps)
end
test 'should return featured maps' do
assert_equal @maps.featured, featured(@maps)
end
end

View File

@@ -27,7 +27,7 @@ class MapTest < ActiveSupport::TestCase
assert_not_nil map.comments
assert_not_nil map.user
assert_not_nil map.private
assert_not_nil map.anonymous?
assert_not map.anonymous?
assert_not_nil map.images_histogram
assert_not_nil map.grouped_images_histogram(10)
assert_not_nil map.nearby_maps(100) # in degrees lat/lon
@@ -117,4 +117,11 @@ class MapTest < ActiveSupport::TestCase
assert map.add_tag('test', User.first)
assert map.has_tag('test')
end
test 'anonymous' do
map = Map.create(name: 'Nakuru', lat: '-0.3030988', lon: '36.080026', location: 'Kenya' )
assert_includes(Map.anonymous, map)
assert map.anonymous?
end
end

View File

@@ -39,6 +39,14 @@ class UserTest < ActiveSupport::TestCase
assert_equal map.updated_at, user.last_action
end
test 'warpables through maps relationship' do
user = users(:quentin)
map_images = user.maps.map(&:warpables)
assert_equal Warpable::ActiveRecord_Associations_CollectionProxy, user.warpables.class
assert_equal map_images.flatten, user.warpables
end
# def test_should_authenticate_user
# assert_equal users(:quentin), User.authenticate('quentin', 'monkey')
# end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB