end
end
+ describe "POST /api/account/most_recent_notification" do
+ setup [:valid_user]
+ test "without valid credentials", %{conn: conn} do
+ conn = post conn, "/api/account/most_recent_notification.json"
+ assert json_response(conn, 403) == %{"error" => "Invalid credentials."}
+ end
+
+ test "with credentials", %{conn: conn, user: user} do
+ conn = conn
+ |> with_credentials(user.nickname, "test")
+ |> post("/api/account/most_recent_notification.json", %{id: "200"})
+
+ assert json_response(conn, 200)
+ user = User.get_by_nickname(user.nickname)
+ assert user.info["most_recent_notification"] == 200
+ end
+ end
+
describe "POST /statuses/update.json" do
setup [:valid_user]
test "without valid credentials", %{conn: conn} do
describe "GET /statusnet/conversation/:id.json" do
test "returns the statuses in the conversation", %{conn: conn} do
{:ok, _user} = UserBuilder.insert
- {:ok, _activity} = ActivityBuilder.insert(%{"context" => "2hu"})
- {:ok, _activity_two} = ActivityBuilder.insert(%{"context" => "2hu"})
- {:ok, _activity_three} = ActivityBuilder.insert(%{"context" => "3hu"})
+ {:ok, _activity} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
+ {:ok, _activity_two} = ActivityBuilder.insert(%{"type" => "Create", "context" => "2hu"})
+ {:ok, _activity_three} = ActivityBuilder.insert(%{"type" => "Create", "context" => "3hu"})
{:ok, object} = Object.context_mapping("2hu") |> Repo.insert
conn = conn
request_path = "/api/statuses/retweet/#{note_activity.id}.json"
- user = Repo.get_by(User, ap_id: note_activity.data["actor"])
- response = conn
- |> with_credentials(user.nickname, "test")
- |> post(request_path)
- assert json_response(response, 400) == %{"error" => "You cannot repeat your own notice.",
- "request" => request_path}
-
response = conn
|> with_credentials(current_user.nickname, "test")
|> post(request_path)
end
end
+ describe "GET /api/statuses/followers" do
+ test "it returns a user's followers", %{conn: conn} do
+ user = insert(:user)
+ follower_one = insert(:user)
+ follower_two = insert(:user)
+ not_follower = insert(:user)
+
+ {:ok, follower_one} = User.follow(follower_one, user)
+ {:ok, follower_two} = User.follow(follower_two, user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> get("/api/statuses/followers")
+
+ assert json_response(conn, 200) == UserView.render("index.json", %{users: [follower_one, follower_two], for: user})
+ end
+ end
+
+ describe "GET /api/statuses/friends" do
+ test "it returns a user's friends", %{conn: conn} do
+ user = insert(:user)
+ followed_one = insert(:user)
+ followed_two = insert(:user)
+ not_followed = insert(:user)
+
+ {:ok, user} = User.follow(user, followed_one)
+ {:ok, user} = User.follow(user, followed_two)
+
+ conn = conn
+ |> assign(:user, user)
+ |> get("/api/statuses/friends")
+
+ assert json_response(conn, 200) == UserView.render("index.json", %{users: [followed_one, followed_two], for: user})
+ end
+ end
+
+ describe "POST /api/account/update_profile.json" do
+ test "it updates a user's profile" do
+ user = insert(:user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{"name" => "new name", "description" => "new description"})
+
+ user = Repo.get!(User, user.id)
+ assert user.name == "new name"
+ assert user.bio == "new description"
+
+ assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
+ end
+ end
+
defp valid_user(_context) do
user = insert(:user)
[user: user]