test/unit/garb/management/profile_test.rb in garb-0.9.1 vs test/unit/garb/management/profile_test.rb in garb-0.9.7
- old
+ new
@@ -6,22 +6,22 @@
context "The Profile class" do
should "turn entries for path into array of profiles" do
feed = stub(:entries => ["entry1"])
Feed.stubs(:new).returns(feed)
- Profile.stubs(:new_from_entry)
+ Profile.stubs(:new)
Profile.all
assert_received(Feed, :new) {|e| e.with(Session, '/accounts/~all/webproperties/~all/profiles')}
assert_received(feed, :entries)
- assert_received(Profile, :new_from_entry) {|e| e.with("entry1", Session)}
+ assert_received(Profile, :new) {|e| e.with("entry1", Session)}
end
should "find all profiles for a given account" do
Profile.stubs(:all)
Profile.for_account(stub(:session => 'session', :path => '/accounts/123'))
- assert_received(Profile, :all) {|e| e.with('session', '/accounts/123/webproperties/~all/profiles')}
+ assert_received(Profile, :all) {|e| e.with('session', '/accounts/123/webproperties/~all/profiles')}
end
should "find all profiles for a given web_property" do
Profile.stubs(:all)
Profile.for_web_property(stub(:session => 'session', :path => '/accounts/123/webproperties/456'))
@@ -29,46 +29,31 @@
end
end
context "A Profile" do
setup do
- entry = {
- "link" => [{"rel" => "self", "href" => Feed::BASE_URL+"/accounts/1189765/webproperties/UA-1189765-1/profiles/98765"}],
- "dxp:property" => [
- {"name" => "ga:profileId", "value" => "98765"},
- {"name" => "ga:accountId", "value" => "1189765"},
- {"name" => "ga:webPropertyId", "value" => 'UA-1189765-1'},
- {"name" => "ga:profileName", "value" => "example.com"},
- {"name"=>"dxp:tableId", "value"=>"ga:4506"},
- {"name"=>"ga:currency", "value"=>"USD"},
- {"name"=>"ga:timezone", "value"=>"America/New_York"}
- ]
- }
- @profile = Profile.new_from_entry(entry, Session)
+ entry = MultiJson.load(read_fixture("ga_profile_management.json"))["items"].first
+ @profile = Profile.new(entry, Session)
end
- should "have a title" do
- assert_equal "example.com", @profile.title
+ should "have a name" do
+ assert_equal "the profile name", @profile.name
end
should "have an id" do
- assert_equal '98765', @profile.id
+ assert_equal '2', @profile.id
end
should "have an account_id" do
- assert_equal '1189765', @profile.account_id
+ assert_equal '1234', @profile.account_id
end
should "have a web_property_id" do
- assert_equal 'UA-1189765-1', @profile.web_property_id
+ assert_equal 'UA-5555-1', @profile.web_property_id
end
- should "have a table_id (for old Garb::Report)" do
- assert_equal 'ga:4506', @profile.table_id
- end
-
should "have a path" do
- assert_equal "/accounts/1189765/webproperties/UA-1189765-1/profiles/98765", @profile.path
+ assert_equal "/accounts/1234/webproperties/UA-5555-1/profiles/2", @profile.path
end
should "have goals" do
Goal.stubs(:for_profile)
@profile.goals