From 324bb3a186da22be2258b310897690d2a14a523c Mon Sep 17 00:00:00 2001 From: szpyxlwoni Date: Fri, 7 Dec 2012 12:18:46 +0800 Subject: [PATCH] fix show maps in profiles/show --- app/assets/javascripts/profiles.js.coffee | 18 ++++++++++++++++++ app/views/profiles/show.html.slim | 1 + config/environments/development.rb | 3 --- config/environments/production.rb | 3 --- lib/team_filter.rb | 2 +- spec/controllers/teams_controller_spec.rb | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/profiles.js.coffee diff --git a/app/assets/javascripts/profiles.js.coffee b/app/assets/javascripts/profiles.js.coffee new file mode 100644 index 0000000..ade0903 --- /dev/null +++ b/app/assets/javascripts/profiles.js.coffee @@ -0,0 +1,18 @@ +$ -> + $('#view_map').each -> + lat = $(this).data('lat') + lng = $(this).data('lng') + + map_options = { + center: new google.maps.LatLng(lat, lng), + zoom: 8, + mapTypeId: google.maps.MapTypeId.ROADMAP + } + + map = new google.maps.Map(this, map_options) + + marker_options = { + position: new google.maps.LatLng(lat, lng), + map: map + } + marker = new google.maps.Marker(marker_options) \ No newline at end of file diff --git a/app/views/profiles/show.html.slim b/app/views/profiles/show.html.slim index d12ccb2..82672f5 100644 --- a/app/views/profiles/show.html.slim +++ b/app/views/profiles/show.html.slim @@ -1,5 +1,6 @@ - content_for :javascript_includes do = javascript_include_tag "http://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_API']}&sensor=false" + = javascript_include_tag "profiles" div.hero-unit.sexy-bg div.row.person div.span4 diff --git a/config/environments/development.rb b/config/environments/development.rb index b012875..1b8380d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -37,9 +37,6 @@ Ocelots::Application.configure do # Expands the lines which load the assets config.assets.debug = true - #config.threadsafe! enables allow_concurrency, cache_classes, dependency_loading and preload_frameworks to make the application threadsafe. - config.threadsafe! - # paperclip will save to public/system/[object] when running local if(ENV['S3_BUCKET'].nil?) config.paperclip_storage_options = {} diff --git a/config/environments/production.rb b/config/environments/production.rb index 0ed89d7..09a705d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -62,9 +62,6 @@ Ocelots::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - #config.threadsafe! enables allow_concurrency, cache_classes, dependency_loading and preload_frameworks to make the application threadsafe. - config.threadsafe! - # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 diff --git a/lib/team_filter.rb b/lib/team_filter.rb index 7612276..d418939 100644 --- a/lib/team_filter.rb +++ b/lib/team_filter.rb @@ -1,6 +1,6 @@ module TeamFilter def with_team - @team = Team.find_by_slug params[:slug] + @team = Team.find_by_slug params[:slug] unless current_person.allowed_to_view_team?(@team) @team = nil end diff --git a/spec/controllers/teams_controller_spec.rb b/spec/controllers/teams_controller_spec.rb index 57ee3ab..c3708ae 100644 --- a/spec/controllers/teams_controller_spec.rb +++ b/spec/controllers/teams_controller_spec.rb @@ -72,7 +72,7 @@ describe TeamsController do assigns(:memberships).should_not be_nil end - it 'not create team with null name' do + it 'not create team with null slug' do lambda do post :create, team: {name: 'CDI', slug: nil}, org_ids: [@organisation.id.to_s] end.should_not change(Team, :count)