From bc6e2e8aa52b05c8a51fcac52cab0f9bce1ce827 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Fri, 13 Sep 2013 05:25:45 -0400 Subject: [PATCH 1/6] Add failing test. --- spec/unit/map_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/unit/map_spec.rb b/spec/unit/map_spec.rb index 0e87a3d..478604e 100644 --- a/spec/unit/map_spec.rb +++ b/spec/unit/map_spec.rb @@ -30,6 +30,17 @@ describe "map properties" do @map.annotations.count.should == 6 end + it "should return custom annotation parameters" do + ann = { + longitude: -82.966093558105, + latitude: 35.092520895652, + title: "Custom", + another_value: "Mark" + } + @map.add_annotation(ann) + @map.annotations.last.another_value.should == "Mark" + end + it "should clear annotations" do @map.clear_annotations @map.annotations.count.should == 0 From 36c59f52c2e7255e9586ba42e4e0db9f8928350f Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Fri, 13 Sep 2013 05:33:52 -0400 Subject: [PATCH 2/6] Implement method_missing on the map annotations to try and return a parameter named what the user asked for. --- lib/ProMotion/map/map_screen_annotation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ProMotion/map/map_screen_annotation.rb b/lib/ProMotion/map/map_screen_annotation.rb index 267a408..6e5c68a 100644 --- a/lib/ProMotion/map/map_screen_annotation.rb +++ b/lib/ProMotion/map/map_screen_annotation.rb @@ -52,5 +52,13 @@ module ProMotion @params end + def method_missing(meth, *args) + if @params[meth.to_sym] + @params[meth.to_sym] + else + PM.logger.warn "The annotation parameter \"#{meth}\" does not exist on this pin." + end + end + end end From 6343a0ff739def7274c38c382687e29f61219bee Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Fri, 13 Sep 2013 05:34:05 -0400 Subject: [PATCH 3/6] Make the map centering test less specific. --- spec/functional/func_map_screen_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/functional/func_map_screen_spec.rb b/spec/functional/func_map_screen_spec.rb index 1418751..6a8e49d 100644 --- a/spec/functional/func_map_screen_spec.rb +++ b/spec/functional/func_map_screen_spec.rb @@ -19,8 +19,8 @@ describe "ProMotion::TestMapScreen functionality" do it "should have the map properly centered" do center_coordinate = @map.center - center_coordinate.latitude.should.be.close 35.090648651123, 0.001 - center_coordinate.longitude.should.be.close -82.965972900391, 0.001 + center_coordinate.latitude.should.be.close 35.090648651123, 0.02 + center_coordinate.longitude.should.be.close -82.965972900391, 0.02 end it "should move the map center" do From 315c511c82aebdec895d6a96946df2c659e51796 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Fri, 13 Sep 2013 05:37:42 -0400 Subject: [PATCH 4/6] Test annotation parameters that don't exist to be nil. --- lib/ProMotion/map/map_screen_annotation.rb | 1 + spec/unit/map_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/ProMotion/map/map_screen_annotation.rb b/lib/ProMotion/map/map_screen_annotation.rb index 6e5c68a..a42a0b5 100644 --- a/lib/ProMotion/map/map_screen_annotation.rb +++ b/lib/ProMotion/map/map_screen_annotation.rb @@ -57,6 +57,7 @@ module ProMotion @params[meth.to_sym] else PM.logger.warn "The annotation parameter \"#{meth}\" does not exist on this pin." + nil end end diff --git a/spec/unit/map_spec.rb b/spec/unit/map_spec.rb index 478604e..072d482 100644 --- a/spec/unit/map_spec.rb +++ b/spec/unit/map_spec.rb @@ -41,6 +41,17 @@ describe "map properties" do @map.annotations.last.another_value.should == "Mark" end + it "should return nil for custom annotation parameters that don't exist" do + ann = { + longitude: -82.966093558105, + latitude: 35.092520895652, + title: "Custom", + another_value: "Mark" + } + @map.add_annotation(ann) + @map.annotations.last.another_value_fake.should == nil + end + it "should clear annotations" do @map.clear_annotations @map.annotations.count.should == 0 From 4e0b16d458f2f99d234f20551662c5daac960801 Mon Sep 17 00:00:00 2001 From: Arkan Date: Tue, 24 Sep 2013 11:25:18 +0200 Subject: [PATCH 5/6] DelegateNotifications: Fix an issue with the bitmask --- lib/ProMotion/delegate/delegate_notifications.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ProMotion/delegate/delegate_notifications.rb b/lib/ProMotion/delegate/delegate_notifications.rb index 185269b..e861580 100644 --- a/lib/ProMotion/delegate/delegate_notifications.rb +++ b/lib/ProMotion/delegate/delegate_notifications.rb @@ -27,10 +27,10 @@ module ProMotion mask = UIApplication.sharedApplication.enabledRemoteNotificationTypes types = [] - types << :badge if mask & UIRemoteNotificationTypeBadge - types << :sound if mask & UIRemoteNotificationTypeSound - types << :alert if mask & UIRemoteNotificationTypeAlert - types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability + types << :badge if mask & UIRemoteNotificationTypeBadge > 0 + types << :sound if mask & UIRemoteNotificationTypeSound > 0 + types << :alert if mask & UIRemoteNotificationTypeAlert > 0 + types << :newsstand if mask & UIRemoteNotificationTypeNewsstandContentAvailability > 0 types end @@ -53,9 +53,9 @@ module ProMotion def application(application, didReceiveRemoteNotification:notification) received_push_notification(notification, application.applicationState != UIApplicationStateActive) end - + protected - + def map_notification_symbol(symbol) { none: UIRemoteNotificationTypeNone, From 02b43c619343e7551ce816c23f451fd7a5b36a5f Mon Sep 17 00:00:00 2001 From: Arkan Date: Wed, 25 Sep 2013 09:27:32 +0200 Subject: [PATCH 6/6] Add a test for DelegateNotifications#registered_push_notifications --- spec/unit/delegate_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/unit/delegate_spec.rb b/spec/unit/delegate_spec.rb index 00a568d..ccf8737 100644 --- a/spec/unit/delegate_spec.rb +++ b/spec/unit/delegate_spec.rb @@ -27,6 +27,24 @@ describe "PM::Delegate" do end + it "should return the registered push notification types as an array" do + @subject.registered_push_notifications.should == [] + bits = 0 + types = [] + { badge: UIRemoteNotificationTypeBadge, + sound: UIRemoteNotificationTypeSound, + alert: UIRemoteNotificationTypeAlert, + newsstand: UIRemoteNotificationTypeNewsstandContentAvailability }.each do |symbol, bit| + UIApplication.sharedApplication.stub!(:enabledRemoteNotificationTypes, return: bit) + @subject.registered_push_notifications.should == [symbol] + + bits |= bit + types << symbol + UIApplication.sharedApplication.stub!(:enabledRemoteNotificationTypes, return: bits) + @subject.registered_push_notifications.should == types + end + end + it "should return false for was_launched if the app is currently active on screen" do @subject.mock!(:on_push_notification) do |notification, was_launched| was_launched.should.be.false