diff --git a/lib/mural/client/mural_content/areas.rb b/lib/mural/client/mural_content/areas.rb index 27e93f5..84d5de1 100644 --- a/lib/mural/client/mural_content/areas.rb +++ b/lib/mural/client/mural_content/areas.rb @@ -11,7 +11,7 @@ def create_area(mural_id, create_area_params) create_area_params.encode ) - Mural::Widget::Area.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/updatearea @@ -21,7 +21,7 @@ def update_area(mural_id, area_id, update_area_params) update_area_params.encode ) - Mural::Widget::Area.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/arrows.rb b/lib/mural/client/mural_content/arrows.rb index afe17f0..a4fe41b 100644 --- a/lib/mural/client/mural_content/arrows.rb +++ b/lib/mural/client/mural_content/arrows.rb @@ -11,7 +11,7 @@ def create_arrow(mural_id, create_arrow_params) create_arrow_params.encode ) - Mural::Widget::Arrow.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/updatearrow @@ -21,7 +21,7 @@ def update_arrow(mural_id, arrow_id, update_arrow_params) update_arrow_params.encode ) - Mural::Widget::Arrow.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/comments.rb b/lib/mural/client/mural_content/comments.rb index ed5328f..84b4cb7 100644 --- a/lib/mural/client/mural_content/comments.rb +++ b/lib/mural/client/mural_content/comments.rb @@ -15,7 +15,7 @@ def create_comment(mural_id, create_comment_params) create_comment_params.encode ) - Mural::Widget::Comment.decode(json['value']) + Mural::Widget.decode(json['value']) end # Update a comment widget on a mural. @@ -29,7 +29,7 @@ def update_comment(mural_id, comment_id, update_comment_params) update_comment_params.encode ) - Mural::Widget::Comment.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/files.rb b/lib/mural/client/mural_content/files.rb index 6363b2e..68b20ea 100644 --- a/lib/mural/client/mural_content/files.rb +++ b/lib/mural/client/mural_content/files.rb @@ -11,7 +11,7 @@ def create_file(mural_id, params) params.encode ) - Mural::Widget::File.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/getmuralfilewidgets @@ -21,7 +21,7 @@ def list_files(mural_id, next_page: nil) { next: next_page } ) - files = json['value'].map { |f| Mural::Widget::File.decode(f) } + files = json['value'].map { |f| Mural::Widget.decode(f) } [files, json['next']] end @@ -32,7 +32,7 @@ def update_file(mural_id, widget_id:, update_file_params:) update_file_params.encode ) - Mural::Widget::File.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/images.rb b/lib/mural/client/mural_content/images.rb index 54368ca..cc10fa7 100644 --- a/lib/mural/client/mural_content/images.rb +++ b/lib/mural/client/mural_content/images.rb @@ -11,7 +11,7 @@ def create_image(mural_id, create_image_params) create_image_params.encode ) - Mural::Widget::Image.decode(json['value']) + Mural::Widget.decode(json['value']) end # https://developers.mural.co/public/reference/createimage @@ -21,7 +21,7 @@ def update_image(mural_id, image_id, update_image_params) update_image_params.encode ) - Mural::Widget::Image.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/shapes.rb b/lib/mural/client/mural_content/shapes.rb index 5c21d79..a69ac62 100644 --- a/lib/mural/client/mural_content/shapes.rb +++ b/lib/mural/client/mural_content/shapes.rb @@ -15,7 +15,7 @@ def create_shapes(mural_id, create_shape_params) [*create_shape_params].map(&:encode) ) json['value'].map do |json_shape| - Mural::Widget::Shape.decode(json_shape) + Mural::Widget.decode(json_shape) end end @@ -30,7 +30,7 @@ def update_shape(mural_id, shape_id, update_shape_params) update_shape_params.encode ) - Mural::Widget::Shape.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/sticky_notes.rb b/lib/mural/client/mural_content/sticky_notes.rb index 0e4de39..c737d20 100644 --- a/lib/mural/client/mural_content/sticky_notes.rb +++ b/lib/mural/client/mural_content/sticky_notes.rb @@ -15,7 +15,7 @@ def create_sticky_notes(mural_id, create_sticky_note_params) [*create_sticky_note_params].map(&:encode) ) - json['value'].map { |s| Mural::Widget::StickyNote.decode(s) } + json['value'].map { |s| Mural::Widget.decode(s) } end # Update a sticky note widget on a mural. @@ -32,7 +32,7 @@ def update_sticky_note( update_sticky_note_params.encode ) - Mural::Widget::StickyNote.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/text_boxes.rb b/lib/mural/client/mural_content/text_boxes.rb index c6c12e5..04cec57 100644 --- a/lib/mural/client/mural_content/text_boxes.rb +++ b/lib/mural/client/mural_content/text_boxes.rb @@ -15,7 +15,7 @@ def create_text_boxes(mural_id, create_text_box_params) [*create_text_box_params].map(&:encode) ) - json['value'].map { |text_box| Mural::Widget::Text.decode(text_box) } + json['value'].map { |text_box| Mural::Widget.decode(text_box) } end # Update a textbox on a mural @@ -29,7 +29,7 @@ def update_text_box(mural_id, text_box_id, update_text_box_params) update_text_box_params.encode ) - Mural::Widget::Text.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/client/mural_content/titles.rb b/lib/mural/client/mural_content/titles.rb index 3af8ca1..19ec479 100644 --- a/lib/mural/client/mural_content/titles.rb +++ b/lib/mural/client/mural_content/titles.rb @@ -15,7 +15,7 @@ def create_titles(mural_id, create_title_params) [*create_title_params].map(&:encode) ) - json['value'].map { |title| Mural::Widget::Text.decode(title) } + json['value'].map { |title| Mural::Widget.decode(title) } end # Update a title on a mural @@ -29,7 +29,7 @@ def update_title(mural_id, title_id, update_title_params) update_title_params.encode ) - Mural::Widget::Text.decode(json['value']) + Mural::Widget.decode(json['value']) end end end diff --git a/lib/mural/widget/create_area_params.rb b/lib/mural/widget/create_area_params.rb index 0c8d260..7c58ac9 100644 --- a/lib/mural/widget/create_area_params.rb +++ b/lib/mural/widget/create_area_params.rb @@ -5,23 +5,23 @@ class Widget class CreateAreaParams include Mural::Codec + # https://developers.mural.co/public/reference/createarea define_attributes( - **Mural::Widget::Area.attrs.reject do |attr| + **Mural::Widget::Area.attrs.filter do |attr| %i[ - content_edited_by - content_edited_on - created_by - created_on - hide_editor - hide_owner - id - invisible - locked - locked_by_facilitator - rotation - type - updated_by - updated_on + height + hidden + instruction + layout + parent_id + presentation_index + show_title + stacking_order + style + title + width + x + y ].include? attr end ) diff --git a/lib/mural/widget/create_arrow_params.rb b/lib/mural/widget/create_arrow_params.rb index 6c32f96..ae2bbcc 100644 --- a/lib/mural/widget/create_arrow_params.rb +++ b/lib/mural/widget/create_arrow_params.rb @@ -7,26 +7,34 @@ class CreateArrowParams # https://developers.mural.co/public/reference/createarrow define_attributes( - **Mural::Widget::Arrow.attrs.reject do |attr| + **Mural::Widget::Arrow.attrs.filter do |attr| %i[ - content_edited_by - content_edited_on - created_by - created_on - hidden - hide_editor - hide_owner - id - invisible - locked - locked_by_facilitator - type - updated_by - updated_on + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + stacking_order + start_ref_id + style + tip + title + width + x + y ].include? attr end ) + Style = Mural::Widget::Arrow::Style + Label = Mural::Widget::Arrow::Label + Point = Mural::Widget::Arrow::Point + def encode super.tap do |json| json['points']&.map!(&:encode) @@ -34,10 +42,6 @@ def encode json['style'] = json['style']&.encode end end - - Style = Mural::Widget::Arrow::Style - Label = Mural::Widget::Arrow::Label - Point = Mural::Widget::Arrow::Point end end end diff --git a/lib/mural/widget/create_comment_params.rb b/lib/mural/widget/create_comment_params.rb index 3cbddc7..12beb9c 100644 --- a/lib/mural/widget/create_comment_params.rb +++ b/lib/mural/widget/create_comment_params.rb @@ -5,17 +5,19 @@ class Widget class CreateCommentParams include Mural::Codec + # https://developers.mural.co/public/reference/createcomment define_attributes( **Mural::Widget::Comment.attrs.filter do |attr| %i[ - reference_widget_id message + reference_widget_id stacking_order x y ].include? attr end, + # If true, the comment is marked as resolved. resolved: 'resolved' ) end diff --git a/lib/mural/widget/create_file_params.rb b/lib/mural/widget/create_file_params.rb index 5c33c0c..c462fda 100644 --- a/lib/mural/widget/create_file_params.rb +++ b/lib/mural/widget/create_file_params.rb @@ -7,49 +7,24 @@ class CreateFileParams # https://developers.mural.co/public/reference/createfile define_attributes( - # The height of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - height: 'height', - - # If true, the widget is hidden from non-facilitators. Applies only when - # the widget is in the outline. - hidden: 'hidden', - - # The instructions for a section of the outline. This text can only be - # added and modified by a facilitator. - instruction: 'instruction', + **Mural::Widget::File.attrs.filter do |attr| + %i[ + height + hidden + instruction + parent_id + presentation_index + rotation + stacking_order + title + width + x + y + ].include? attr + end, # The name of the file. - name: 'name', - - # The ID of the area widget that contains the widget. - parent_id: 'parentId', - - # The list order of the widget in the outline. - presentation_index: 'presentationIndex', - - # The angle of widget rotation in degrees. - rotation: 'rotation', - - # The z-index stacking order of the widget. - stacking_order: 'stackingOrder', - - # The title in the file widget and in the outline. - title: 'title', - - # The width of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - width: 'width', - - # The horizontal position of the widget in px. This is the distance from - # the left of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the left of the mural. - x: 'x', - - # The vertical position of the widget in px. This is the distance from - # the top of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the top of the mural. - y: 'y' + name: 'name' ) end end diff --git a/lib/mural/widget/create_image_params.rb b/lib/mural/widget/create_image_params.rb index c0a73cc..4b31136 100644 --- a/lib/mural/widget/create_image_params.rb +++ b/lib/mural/widget/create_image_params.rb @@ -5,30 +5,24 @@ class Widget class CreateImageParams include Mural::Codec + # https://developers.mural.co/public/reference/createimage define_attributes( - **Mural::Widget::Image.attrs.reject do |attr| + **Mural::Widget::Image.attrs.filter do |attr| %i[ - aspect_ratio - content_edited_by - content_edited_on - created_by - created_on - expires_in_minutes - hide_editor - hide_owner - id - invisible - link - locked - locked_by_facilitator - mask - natural_height - natural_width - thumbnail_url - type - updated_by - updated_on - url + border + caption + description + height + hidden + instruction + parent_id + presentation_index + rotation + show_caption + stacking_order + width + x + y ].include? attr end, diff --git a/lib/mural/widget/create_shape_params.rb b/lib/mural/widget/create_shape_params.rb index f8b672e..859f34a 100644 --- a/lib/mural/widget/create_shape_params.rb +++ b/lib/mural/widget/create_shape_params.rb @@ -5,6 +5,7 @@ class Widget class CreateShapeParams include Mural::Codec + # https://developers.mural.co/public/reference/createshapewidget define_attributes( **Mural::Widget::Shape.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/create_sticky_note_params.rb b/lib/mural/widget/create_sticky_note_params.rb index 5a5d189..4e3e281 100644 --- a/lib/mural/widget/create_sticky_note_params.rb +++ b/lib/mural/widget/create_sticky_note_params.rb @@ -5,6 +5,7 @@ class Widget class CreateStickyNoteParams include Mural::Codec + # https://developers.mural.co/public/reference/createstickynote define_attributes( **Mural::Widget::StickyNote.attrs.filter do |attr| %i[ @@ -30,14 +31,13 @@ class CreateStickyNoteParams end ) + Style = Mural::Widget::StickyNote::Style + def encode super.tap do |json| json['style'] = json['style']&.encode end.compact end - - # Exact same values, no restrictions - Style = Mural::Widget::StickyNote::Style end end end diff --git a/lib/mural/widget/create_table_cell_params.rb b/lib/mural/widget/create_table_cell_params.rb index 02a80bb..9581147 100644 --- a/lib/mural/widget/create_table_cell_params.rb +++ b/lib/mural/widget/create_table_cell_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTableCellParams include Mural::Codec + # https://developers.mural.co/public/reference/createtable define_attributes( **Mural::Widget::TableCell.attrs.filter do |attr| %i[ @@ -23,15 +24,15 @@ class CreateTableCellParams end ) + Style = Mural::Widget::TableCell::Style + TextContent = Mural::Widget::TableCell::TextContent + def encode super.tap do |json| json['style'] = json['style']&.encode json['textContent'] = json['textContent']&.encode end.compact end - - Style = Mural::Widget::TableCell::Style - TextContent = Mural::Widget::TableCell::TextContent end end end diff --git a/lib/mural/widget/create_table_params.rb b/lib/mural/widget/create_table_params.rb index 37af35b..3a81c33 100644 --- a/lib/mural/widget/create_table_params.rb +++ b/lib/mural/widget/create_table_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTableParams include Mural::Codec + # https://developers.mural.co/public/reference/createtable define_attributes( **Mural::Widget::Table.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/create_text_box_params.rb b/lib/mural/widget/create_text_box_params.rb index c11c82c..a4e4617 100644 --- a/lib/mural/widget/create_text_box_params.rb +++ b/lib/mural/widget/create_text_box_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTextBoxParams include Mural::Codec + # https://developers.mural.co/public/reference/createtextbox define_attributes( **Mural::Widget::Text.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/create_title_params.rb b/lib/mural/widget/create_title_params.rb index 413b565..0d24050 100644 --- a/lib/mural/widget/create_title_params.rb +++ b/lib/mural/widget/create_title_params.rb @@ -5,6 +5,7 @@ class Widget class CreateTitleParams include Mural::Codec + # https://developers.mural.co/public/reference/createtitle define_attributes( **Mural::Widget::Text.attrs.filter do |attr| %i[ diff --git a/lib/mural/widget/update_area_params.rb b/lib/mural/widget/update_area_params.rb index f2db340..d3153a0 100644 --- a/lib/mural/widget/update_area_params.rb +++ b/lib/mural/widget/update_area_params.rb @@ -5,8 +5,11 @@ class Widget class UpdateAreaParams include Mural::Codec + # https://developers.mural.co/public/reference/updatearea define_attributes( - **Mural::Widget::CreateAreaParams.attrs + **Mural::Widget::CreateAreaParams.attrs.reject do |attr| + %i[stacking_order].include? attr + end ) Style = Mural::Widget::Area::Style diff --git a/lib/mural/widget/update_arrow_params.rb b/lib/mural/widget/update_arrow_params.rb index 8abd0ee..bdb2e6b 100644 --- a/lib/mural/widget/update_arrow_params.rb +++ b/lib/mural/widget/update_arrow_params.rb @@ -5,12 +5,17 @@ class Widget class UpdateArrowParams include Mural::Codec + # https://developers.mural.co/public/reference/updatearrow define_attributes( **Mural::Widget::CreateArrowParams.attrs.reject do |attr| %i[stacking_order].include? attr end ) + Style = Mural::Widget::Arrow::Style + Label = Mural::Widget::Arrow::Label + Point = Mural::Widget::Arrow::Point + def encode super.tap do |json| json['points']&.map!(&:encode) @@ -18,10 +23,6 @@ def encode json['style'] = json['style']&.encode end end - - Style = Mural::Widget::Arrow::Style - Label = Mural::Widget::Arrow::Label - Point = Mural::Widget::Arrow::Point end end end diff --git a/lib/mural/widget/update_comment_params.rb b/lib/mural/widget/update_comment_params.rb index a2d6c9d..23a86bf 100644 --- a/lib/mural/widget/update_comment_params.rb +++ b/lib/mural/widget/update_comment_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateCommentParams include Mural::Codec + # https://developers.mural.co/public/reference/updatecomment define_attributes( **Mural::Widget::CreateCommentParams.attrs.reject do |attr| %i[stacking_order].include? attr diff --git a/lib/mural/widget/update_file_params.rb b/lib/mural/widget/update_file_params.rb index 4f5c0fa..ea759e0 100644 --- a/lib/mural/widget/update_file_params.rb +++ b/lib/mural/widget/update_file_params.rb @@ -7,43 +7,9 @@ class UpdateFileParams # https://developers.mural.co/public/reference/updatefile define_attributes( - # The height of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - height: 'height', - - # If true, the widget is hidden from non-facilitators. Applies only when - # the widget is in the outline. - hidden: 'hidden', - - # The instructions for a section of the outline. This text can only be - # added and modified by a facilitator. - instruction: 'instruction', - - # The ID of the area widget that contains the widget. - parent_id: 'parentId', - - # The list order of the widget in the outline. - presentation_index: 'presentationIndex', - - # The angle of widget rotation in degrees. - rotation: 'rotation', - - # The title in the file widget and in the outline. - title: 'title', - - # The width of the widget in px. This value will be overwritten if the - # file has a preview from which the final value will be extracted. - width: 'width', - - # The horizontal position of the widget in px. This is the distance from - # the left of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the left of the mural. - x: 'x', - - # The vertical position of the widget in px. This is the distance from - # the top of the parent widget, such as an area. If the widget has no - # parent widget, this is the distance from the top of the mural. - y: 'y' + **Mural::Widget::CreateFileParams.attrs.reject do |attr| + %i[name stacking_order].include? attr + end ) end end diff --git a/lib/mural/widget/update_image_params.rb b/lib/mural/widget/update_image_params.rb index bb510ac..57394d6 100644 --- a/lib/mural/widget/update_image_params.rb +++ b/lib/mural/widget/update_image_params.rb @@ -7,7 +7,7 @@ class UpdateImageParams define_attributes( **Mural::Widget::CreateImageParams.attrs.reject do |attr| - %i[name].include? attr + %i[name stacking_order].include? attr end ) end diff --git a/lib/mural/widget/update_shape_params.rb b/lib/mural/widget/update_shape_params.rb index 2262804..3e6dcc4 100644 --- a/lib/mural/widget/update_shape_params.rb +++ b/lib/mural/widget/update_shape_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateShapeParams include Mural::Codec + # https://developers.mural.co/public/reference/updateshapewidget define_attributes( **Mural::Widget::CreateShapeParams.attrs.reject do |attr| %i[shape stacking_order].include? attr diff --git a/lib/mural/widget/update_sticky_note_params.rb b/lib/mural/widget/update_sticky_note_params.rb index 2cdb5fe..b58e783 100644 --- a/lib/mural/widget/update_sticky_note_params.rb +++ b/lib/mural/widget/update_sticky_note_params.rb @@ -5,22 +5,20 @@ class Widget class UpdateStickyNoteParams include Mural::Codec + # https://developers.mural.co/public/reference/updatestickynote define_attributes( **Mural::Widget::CreateStickyNoteParams.attrs.reject do |attr| - %i[ - stacking_order - shape - ].include? attr + %i[stacking_order shape].include? attr end ) + Style = Mural::Widget::StickyNote::Style + def encode super.tap do |json| json['style'] = json['style']&.encode end end - - Style = Mural::Widget::StickyNote::Style end end end diff --git a/lib/mural/widget/update_text_box_params.rb b/lib/mural/widget/update_text_box_params.rb index 0010c00..33d5602 100644 --- a/lib/mural/widget/update_text_box_params.rb +++ b/lib/mural/widget/update_text_box_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateTextBoxParams include Mural::Codec + # https://developers.mural.co/public/reference/updatetextbox define_attributes( **Mural::Widget::CreateTextBoxParams.attrs.reject do |attr| %i[stacking_order].include? attr diff --git a/lib/mural/widget/update_title_params.rb b/lib/mural/widget/update_title_params.rb index f2eb3b7..8de4f98 100644 --- a/lib/mural/widget/update_title_params.rb +++ b/lib/mural/widget/update_title_params.rb @@ -5,6 +5,7 @@ class Widget class UpdateTitleParams include Mural::Codec + # https://developers.mural.co/public/reference/updatetitle define_attributes( **Mural::Widget::CreateTitleParams.attrs.reject do |attr| %i[stacking_order].include? attr diff --git a/test/mural/client/mural_content/test_areas.rb b/test/mural/client/mural_content/test_areas.rb index 1835c6d..77f6f46 100644 --- a/test/mural/client/mural_content/test_areas.rb +++ b/test/mural/client/mural_content/test_areas.rb @@ -5,6 +5,45 @@ def setup @client = Mural::Client.new end + def test_create_area_params + want = %i[ + height + hidden + instruction + layout + parent_id + presentation_index + show_title + stacking_order + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateAreaParams.attrs.keys.sort + end + + def test_update_area_params + want = %i[ + height + hidden + instruction + layout + parent_id + presentation_index + show_title + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateAreaParams.attrs.keys.sort + end + def test_create_area mural_id = 'mural-1' @@ -13,7 +52,38 @@ def test_create_area "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/area" ).with(body: { title: 'Nothing to see here' }) .to_return_json( - body: { value: { id: 'area-51' } }, + body: { value: { id: 'area-51', type: 'area' } }, + status: 201 + ) + + create_area_params = Mural::Widget::CreateAreaParams.new.tap do |params| + params.title = 'Nothing to see here' + end + + area = @client.mural_content.create_area(mural_id, create_area_params) + + assert_instance_of Mural::Widget::Area, area + end + + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/area" + ).with(body: { title: 'Nothing to see here' }) + .to_return_json( + body: { + value: { + id: 'area-51', + contentEditedBy: { + id: 'user-1', + firstName: 'John', + lastName: 'Doe' + }, + type: 'area' + } + }, status: 201 ) @@ -24,6 +94,7 @@ def test_create_area area = @client.mural_content.create_area(mural_id, create_area_params) assert_instance_of Mural::Widget::Area, area + assert_equal 'John', area.content_edited_by.first_name end def test_create_area_with_style @@ -36,7 +107,7 @@ def test_create_area_with_style body: { title: 'Todo', style: { backgroundColor: '#FFFFFF33' } } ) .to_return_json( - body: { value: { id: 'area-1' } }, + body: { value: { id: 'area-1', type: 'area' } }, status: 201 ) @@ -61,7 +132,7 @@ def test_update_area "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ "/area/#{area_id}" ).with(body: { title: 'updated title' }) - .to_return_json(body: { value: { id: 'area-1' } }) + .to_return_json(body: { value: { id: 'area-1', type: 'area' } }) update_area_params = Mural::Widget::UpdateAreaParams.new.tap do |params| params.title = 'updated title' @@ -83,7 +154,7 @@ def test_update_area_with_style "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ "/area/#{area_id}" ).with(body: { style: { backgroundColor: '#FAFAFAFF' } }) - .to_return_json(body: { value: { id: 'area-1' } }) + .to_return_json(body: { value: { id: 'area-1', type: 'area' } }) update_area_params = Mural::Widget::UpdateAreaParams.new.tap do |params| params.style = Mural::Widget::UpdateAreaParams::Style.new.tap do |style| diff --git a/test/mural/client/mural_content/test_arrows.rb b/test/mural/client/mural_content/test_arrows.rb index e823f70..e0c2a7e 100644 --- a/test/mural/client/mural_content/test_arrows.rb +++ b/test/mural/client/mural_content/test_arrows.rb @@ -5,6 +5,55 @@ def setup @client = Mural::Client.new end + def test_create_arrow_params + want = %i[ + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + stacking_order + start_ref_id + style + tip + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateArrowParams.attrs.keys.sort + end + + def test_update_arrow_params + want = %i[ + arrow_type + end_ref_id + height + instruction + label + parent_id + points + presentation_index + rotation + stackable + start_ref_id + style + tip + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateArrowParams.attrs.keys.sort + end + def test_create_minimal_arrow mural_id = 'mural-1' @@ -23,7 +72,59 @@ def test_create_minimal_arrow ] } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, + status: 201 + ) + + create_arrow_params = Mural::Widget::CreateArrowParams.new.tap do |params| + params.height = 1 + params.width = 216 + params.x = 0 + params.y = 0 + + params.points = [ + Mural::Widget::Arrow::Point.new.tap do |p| + p.x = 216 + p.y = 0 + end, + Mural::Widget::Arrow::Point.new.tap do |p| + p.x = 0 + p.y = 0 + end + ] + end + + arrow = @client.mural_content.create_arrow(mural_id, create_arrow_params) + + assert_instance_of Mural::Widget::Arrow, arrow + assert_equal 'arrow-1', arrow.id + end + + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/arrow" + ).with( + body: { + height: 1, + width: 216, + x: 0, + y: 0, + points: [ + { x: 216, y: 0 }, + { x: 0, y: 0 } + ] + } + ).to_return_json( + body: { + value: { + id: 'arrow-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'arrow' + } + }, status: 201 ) @@ -49,6 +150,7 @@ def test_create_minimal_arrow assert_instance_of Mural::Widget::Arrow, arrow assert_equal 'arrow-1', arrow.id + assert_equal 'John', arrow.content_edited_by.first_name end def test_create_arrow_without_points @@ -111,7 +213,7 @@ def test_create_arrow_with_style_and_formatted_label label: { format: { fontFamily: 'proxima-nova' } } } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, status: 201 ) @@ -173,7 +275,7 @@ def test_create_arrow_with_unformatted_labels } } ).to_return_json( - body: { value: { id: 'arrow-1' } }, + body: { value: { id: 'arrow-1', type: 'arrow' } }, status: 201 ) @@ -228,7 +330,7 @@ def test_update_arrow { x: 0, y: 0 } ] } - ).to_return_json(body: { value: { id: 'arrow-1' } }) + ).to_return_json(body: { value: { id: 'arrow-1', type: 'arrow' } }) update_arrow_params = Mural::Widget::UpdateArrowParams.new.tap do |params| params.points = [ @@ -266,7 +368,7 @@ def test_update_arrow_with_style_and_formatted_label style: { strokeColor: '#FAFAFAFF' }, label: { format: { fontFamily: 'proxima-nova' } } } - ).to_return_json(body: { value: { id: 'arrow-1' } }) + ).to_return_json(body: { value: { id: 'arrow-1', type: 'arrow' } }) update_arrow_params = Mural::Widget::UpdateArrowParams.new.tap do |params| params.style = Mural::Widget::UpdateArrowParams::Style.new.tap do |style| diff --git a/test/mural/client/mural_content/test_comments.rb b/test/mural/client/mural_content/test_comments.rb index f973717..674d326 100644 --- a/test/mural/client/mural_content/test_comments.rb +++ b/test/mural/client/mural_content/test_comments.rb @@ -5,6 +5,32 @@ def setup @client = Mural::Client.new end + def test_create_comment_params + want = %i[ + message + reference_widget_id + resolved + stacking_order + x + y + ] + + assert_equal want, Mural::Widget::CreateCommentParams.attrs.keys.sort + end + + def test_update_comment_params + want = %i[ + message + reference_widget_id + replies + resolved + x + y + ] + + assert_equal want, Mural::Widget::UpdateCommentParams.attrs.keys.sort + end + def test_create_comment mural_id = 'mural-1' @@ -14,7 +40,13 @@ def test_create_comment ) .with(body: { message: 'This is a test', x: 0, y: 0 }) .to_return_json( - body: { value: { id: 'comment-1', message: 'This is a test' } }, + body: { + value: { + id: 'comment-1', + message: 'This is a test', + type: 'comment' + } + }, status: 201 ) @@ -33,6 +65,40 @@ def test_create_comment assert_equal 'This is a test', comment.message end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/comment" + ) + .with(body: { message: 'This is a test', x: 0, y: 0 }) + .to_return_json( + body: { + value: { + id: 'comment-1', + message: 'This is a test', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'comment' + } + }, + status: 201 + ) + + create_comment_params = Mural::Widget::CreateCommentParams.new.tap do |c| + c.message = 'This is a test' + c.x = 0 + c.y = 0 + end + + comment = @client + .mural_content + .create_comment(mural_id, create_comment_params) + + assert_instance_of Mural::Widget::Comment, comment + assert_equal 'John', comment.content_edited_by.first_name + end + def test_update_comment mural_id = 'mural-1' comment_id = 'comment-1' @@ -50,7 +116,8 @@ def test_update_comment message: 'This is a test', replies: [ { created: 1, message: 'And it succeeded', user: 'user-1' } - ] + ], + type: 'comment' } }, status: 201 diff --git a/test/mural/client/mural_content/test_files.rb b/test/mural/client/mural_content/test_files.rb index 995ca7f..ee5a4b4 100644 --- a/test/mural/client/mural_content/test_files.rb +++ b/test/mural/client/mural_content/test_files.rb @@ -7,6 +7,42 @@ def setup @client = Mural::Client.new end + def test_create_file_params + want = %i[ + height + hidden + instruction + name + parent_id + presentation_index + rotation + stacking_order + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateFileParams.attrs.keys.sort + end + + def test_update_file_params + want = %i[ + height + hidden + instruction + parent_id + presentation_index + rotation + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateFileParams.attrs.keys.sort + end + def test_create_file mural_id = 'mural-1' @@ -16,7 +52,7 @@ def test_create_file ) .with(body: { name: 'my file', x: 5, y: 10 }) .to_return_json( - body: { value: { id: 'widget-1' } }, + body: { value: { id: 'widget-1', type: 'file' } }, status: 201 ) @@ -32,6 +68,37 @@ def test_create_file assert_equal 'widget-1', file.id end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/file" + ) + .with(body: { name: 'my file', x: 5, y: 10 }) + .to_return_json( + body: { + value: { + id: 'widget-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'file' + } + }, + status: 201 + ) + + params = Mural::Widget::CreateFileParams.new.tap do |params| + params.name = 'my file' + params.x = 5 + params.y = 10 + end + + file = @client.mural_content.create_file(mural_id, params) + + assert_instance_of Mural::Widget::File, file + assert_equal 'John', file.content_edited_by.first_name + end + def test_list_files mural_id = 'mural-2' diff --git a/test/mural/client/mural_content/test_images.rb b/test/mural/client/mural_content/test_images.rb index e9f52c1..d4aad68 100644 --- a/test/mural/client/mural_content/test_images.rb +++ b/test/mural/client/mural_content/test_images.rb @@ -7,6 +7,50 @@ def setup @client = Mural::Client.new end + def test_create_image_params + want = %i[ + border + caption + description + height + hidden + hyperlink + instruction + name + parent_id + presentation_index + rotation + show_caption + stacking_order + width + x + y + ] + + assert_equal want, Mural::Widget::CreateImageParams.attrs.keys.sort + end + + def test_update_image_params + want = %i[ + border + caption + description + height + hidden + hyperlink + instruction + parent_id + presentation_index + rotation + show_caption + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateImageParams.attrs.keys.sort + end + def test_create_image mural_id = 'mural-1' @@ -19,7 +63,8 @@ def test_create_image body: { value: { id: 'image-1', - thumbnailUrl: 'https://example.com/thumbnail.jpg' + thumbnailUrl: 'https://example.com/thumbnail.jpg', + type: 'image' } }, status: 201 @@ -36,6 +81,39 @@ def test_create_image assert_equal 'https://example.com/thumbnail.jpg', image.thumbnail_url end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/image" + ) + .with(body: { name: 'my image' }) + .to_return_json( + body: { + value: { + id: 'image-1', + thumbnailUrl: 'https://example.com/thumbnail.jpg', + contentEditedBy: { + id: 'user-1', + firstName: 'John' + }, + type: 'image' + } + }, + status: 201 + ) + + params = Mural::Widget::CreateImageParams.new.tap do |params| + params.name = 'my image' + end + + image = @client.mural_content.create_image(mural_id, params) + + assert_instance_of Mural::Widget::Image, image + assert_equal 'John', image.content_edited_by.first_name + end + def test_update_image mural_id = 'mural-1' image_id = 'image-1' @@ -47,7 +125,7 @@ def test_update_image ) .with(body: { showCaption: false }) .to_return_json( - body: { value: { id: 'image-1' } }, + body: { value: { id: 'image-1', type: 'image' } }, status: 201 ) diff --git a/test/mural/client/mural_content/test_shapes.rb b/test/mural/client/mural_content/test_shapes.rb index 0458e11..a8573f9 100644 --- a/test/mural/client/mural_content/test_shapes.rb +++ b/test/mural/client/mural_content/test_shapes.rb @@ -5,6 +5,48 @@ def setup @client = Mural::Client.new end + def test_create_shape_params + want = %i[ + height + hidden + html_text + instruction + parent_id + presentation_index + rotation + shape + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateShapeParams.attrs.keys.sort + end + + def test_update_shape_params + want = %i[ + height + hidden + html_text + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateShapeParams.attrs.keys.sort + end + def test_create_shapes mural_id = 'mural-1' @@ -26,11 +68,12 @@ def test_create_shapes .to_return_json( body: { value: [ - { id: 'shape-1', shape: 'rectangle' }, + { id: 'shape-1', shape: 'rectangle', type: 'shape' }, { id: 'shape-2', shape: 'ellipse', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'shape' } ] }, @@ -73,6 +116,51 @@ def test_create_shapes assert_equal '#FAFAFAFF', ellipse.style.background_color end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/shape" + ) + .with(body: [{ shape: 'rectangle', x: 0, y: 0 }]) + .to_return_json( + body: { + value: [ + { + id: 'shape-1', + shape: 'rectangle', + contentEditedBy: { + id: 'user-1', + firstName: 'John' + }, + type: 'shape' + } + ] + }, + status: 201 + ) + + create_shape_params = + Mural::Widget::CreateShapeParams.new.tap do |params| + params.shape = 'rectangle' + params.x = 0 + params.y = 0 + end + + shapes = @client.mural_content.create_shapes( + mural_id, + create_shape_params + ) + + assert_equal 1, shapes.size + + rectangle = shapes.find { |s| s.shape == 'rectangle' } + + assert_instance_of Mural::Widget::Shape, rectangle + assert_equal 'John', rectangle.content_edited_by.first_name + end + def test_update_shape mural_id = 'mural-1' shape_id = 'shape-1' @@ -84,7 +172,7 @@ def test_update_shape ) .with(body: { title: 'dat shape' }) .to_return_json( - body: { value: { id: 'shape-1', title: 'dat shape' } }, + body: { value: { id: 'shape-1', title: 'dat shape', type: 'shape' } }, status: 201 ) @@ -115,7 +203,7 @@ def test_update_shape_with_style ) .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( - body: { value: { id: 'shape-1' } }, + body: { value: { id: 'shape-1', type: 'shape' } }, status: 201 ) diff --git a/test/mural/client/mural_content/test_sticky_notes.rb b/test/mural/client/mural_content/test_sticky_notes.rb index f60c974..0b3a878 100644 --- a/test/mural/client/mural_content/test_sticky_notes.rb +++ b/test/mural/client/mural_content/test_sticky_notes.rb @@ -7,6 +7,54 @@ def setup @client = Mural::Client.new end + def test_create_sticky_note_params + want = %i[ + height + hidden + html_text + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + shape + stacking_order + style + tags + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateStickyNoteParams.attrs.keys.sort + end + + def test_update_sticky_note_params + want = %i[ + height + hidden + html_text + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + tags + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateStickyNoteParams.attrs.keys.sort + end + def test_create_sticky_notes mural_id = 'some-mural-1' @@ -16,7 +64,10 @@ def test_create_sticky_notes '/sticky-note' ) .with(body: [{ text: 'My sticky' }]) - .to_return_json(body: { value: [{ id: 'sticky-1' }] }, status: 201) + .to_return_json( + body: { value: [{ id: 'sticky-1', type: 'sticky note' }] }, + status: 201 + ) create_sticky_note_params = Mural::Widget::CreateStickyNoteParams.new.tap do |sticky_note| @@ -29,9 +80,50 @@ def test_create_sticky_notes .create_sticky_notes(mural_id, create_sticky_note_params) assert_equal 1, created_sticky_notes.size + assert_instance_of Mural::Widget::StickyNote, created_sticky_notes.first assert_equal 'sticky-1', created_sticky_notes.first.id end + def test_should_decode_content_edited_by + mural_id = 'some-mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets" \ + '/sticky-note' + ) + .with(body: [{ text: 'My sticky' }]) + .to_return_json( + body: { + value: [ + { + id: 'sticky-1', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'sticky note' + } + ] + }, + status: 201 + ) + + create_sticky_note_params = + Mural::Widget::CreateStickyNoteParams.new.tap do |sticky_note| + sticky_note.text = 'My sticky' + end + + created_sticky_notes = + @client + .mural_content + .create_sticky_notes(mural_id, create_sticky_note_params) + + assert_equal 1, created_sticky_notes.size + + sticky_note = created_sticky_notes.first + + assert_equal 'sticky-1', sticky_note.id + assert_instance_of Mural::Widget::StickyNote, sticky_note + end + def test_create_sticky_notes_with_style mural_id = 'some-mural-1' @@ -44,7 +136,7 @@ def test_create_sticky_notes_with_style body: [{ text: 'My sticky', style: { backgroundColor: '#FAFAFAFF' } }] ) .to_return_json( - body: { value: [{ id: 'sticky-1' }] }, + body: { value: [{ id: 'sticky-1', type: 'sticky note' }] }, status: 201 ) @@ -63,6 +155,7 @@ def test_create_sticky_notes_with_style .create_sticky_notes(mural_id, create_sticky_note_params) assert_equal 1, created_sticky_notes.size + assert_instance_of Mural::Widget::StickyNote, created_sticky_notes.first assert_equal 'sticky-1', created_sticky_notes.first.id end @@ -76,7 +169,7 @@ def test_update_sticky_note "/sticky-note/#{widget_id}" ) .with(body: { text: 'updated text' }) - .to_return_json(body: { value: { id: widget_id } }) + .to_return_json(body: { value: { id: widget_id, type: 'sticky note' } }) update_params = Mural::Widget::UpdateStickyNoteParams.new.tap do |params| @@ -87,6 +180,7 @@ def test_update_sticky_note .update_sticky_note(mural_id, widget_id, update_params) assert_equal widget_id, updated.id + assert_instance_of Mural::Widget::StickyNote, updated end def test_update_sticky_note_with_style @@ -99,7 +193,7 @@ def test_update_sticky_note_with_style "/sticky-note/#{widget_id}" ) .with(body: { style: { bold: true } }) - .to_return_json(body: { value: { id: widget_id } }) + .to_return_json(body: { value: { id: widget_id, type: 'sticky note' } }) update_params = Mural::Widget::UpdateStickyNoteParams.new.tap do |params| @@ -113,5 +207,6 @@ def test_update_sticky_note_with_style .update_sticky_note(mural_id, widget_id, update_params) assert_equal widget_id, updated.id + assert_instance_of Mural::Widget::StickyNote, updated end end diff --git a/test/mural/client/mural_content/test_tables.rb b/test/mural/client/mural_content/test_tables.rb index 76d35ea..7a1c391 100644 --- a/test/mural/client/mural_content/test_tables.rb +++ b/test/mural/client/mural_content/test_tables.rb @@ -5,6 +5,47 @@ def setup @client = Mural::Client.new end + def test_create_table_cell_params + want = %i[ + col_span + column_id + height + rotation + row_id + row_span + style + text_content + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTableCellParams.attrs.keys.sort + end + + def test_create_table_params + want = %i[ + auto_resize + cells + columns + height + hidden + instruction + parent_id + presentation_index + rotation + rows + stacking_order + style + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTableParams.attrs.keys.sort + end + def test_create_table mural_id = 'mural-1' diff --git a/test/mural/client/mural_content/test_text_boxes.rb b/test/mural/client/mural_content/test_text_boxes.rb index 88ea977..3b1fe05 100644 --- a/test/mural/client/mural_content/test_text_boxes.rb +++ b/test/mural/client/mural_content/test_text_boxes.rb @@ -5,6 +5,89 @@ def setup @client = Mural::Client.new end + def test_create_text_box_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTextBoxParams.attrs.keys.sort + end + + def test_update_text_box_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateTextBoxParams.attrs.keys.sort + end + + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/textbox" + ) + .with(body: [{ text: 'Hello world' }]) + .to_return_json( + body: { value: [ + { + id: 'text-box-1', + text: 'Hello world', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'text' + } + ] }, + status: 201 + ) + + create_text_box_params = [ + Mural::Widget::CreateTextBoxParams.new.tap do |t| + t.text = 'Hello world' + end + ] + + text_boxes = @client.mural_content.create_text_boxes( + mural_id, + create_text_box_params + ) + + assert_equal 1, text_boxes.size + + text_box = text_boxes.first + + assert_instance_of Mural::Widget::Text, text_box + assert_equal 'Hello world', text_box.text + assert_equal 'John', text_box.content_edited_by.first_name + end + def test_create_text_boxes mural_id = 'mural-1' @@ -20,11 +103,12 @@ def test_create_text_boxes ) .to_return_json( body: { value: [ - { id: 'text-box-1', text: 'Hello world' }, + { id: 'text-box-1', text: 'Hello world', type: 'text' }, { id: 'text-box-2', text: 'Bonjour monde', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' } ] }, status: 201 @@ -73,7 +157,7 @@ def test_update_text_box ) .with(body: { text: 'Hola mundo' }) .to_return_json( - body: { value: { id: text_box_id, text: 'Hola mundo' } } + body: { value: { id: text_box_id, text: 'Hola mundo', type: 'text' } } ) update_text_box_params = Mural::Widget::UpdateTextBoxParams.new.tap do |t| @@ -101,7 +185,11 @@ def test_update_text_box_with_style .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( body: { - value: { id: text_box_id, style: { backgroundColor: '#FAFAFAFF' } } + value: { + id: text_box_id, + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' + } } ) diff --git a/test/mural/client/mural_content/test_titles.rb b/test/mural/client/mural_content/test_titles.rb index 23266e5..3a7f3f5 100644 --- a/test/mural/client/mural_content/test_titles.rb +++ b/test/mural/client/mural_content/test_titles.rb @@ -5,6 +5,49 @@ def setup @client = Mural::Client.new end + def test_create_title_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + stacking_order + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::CreateTitleParams.attrs.keys.sort + end + + def test_update_title_params + want = %i[ + height + hidden + hyperlink + hyperlink_title + instruction + parent_id + presentation_index + rotation + style + text + title + width + x + y + ] + + assert_equal want, Mural::Widget::UpdateTitleParams.attrs.keys.sort + end + def test_create_titles mural_id = 'mural-1' @@ -20,11 +63,12 @@ def test_create_titles ) .to_return_json( body: { value: [ - { id: 'title-1', text: 'Hello world' }, + { id: 'title-1', text: 'Hello world', type: 'text' }, { id: 'title-2', text: 'Bonjour monde', - style: { backgroundColor: '#FAFAFAFF' } + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' } ] }, status: 201 @@ -59,6 +103,43 @@ def test_create_titles assert_equal '#FAFAFAFF', title_with_style.style.background_color end + def test_should_decode_content_edited_by + mural_id = 'mural-1' + + stub_request( + :post, + "https://app.mural.co/api/public/v1/murals/#{mural_id}/widgets/title" + ) + .with(body: [{ text: 'Hello world' }]) + .to_return_json( + body: { + value: [ + { + id: 'title-1', + text: 'Hello world', + contentEditedBy: { id: 'user-1', firstName: 'John' }, + type: 'text' + } + ] + }, + status: 201 + ) + + create_title_params = + Mural::Widget::CreateTitleParams.new.tap do |t| + t.text = 'Hello world' + end + + titles = @client.mural_content.create_titles(mural_id, create_title_params) + + assert_equal 1, titles.size + + title = titles.first + + assert_instance_of Mural::Widget::Text, title + assert_equal 'John', title.content_edited_by.first_name + end + def test_update_title mural_id = 'mural-1' title_id = 'title-1' @@ -70,7 +151,7 @@ def test_update_title ) .with(body: { text: 'Hola mundo' }) .to_return_json( - body: { value: { id: title_id, text: 'Hola mundo' } } + body: { value: { id: title_id, text: 'Hola mundo', type: 'text' } } ) update_title_params = Mural::Widget::UpdateTitleParams.new.tap do |t| @@ -98,7 +179,11 @@ def test_update_title_with_style .with(body: { style: { backgroundColor: '#FAFAFAFF' } }) .to_return_json( body: { - value: { id: title_id, style: { backgroundColor: '#FAFAFAFF' } } + value: { + id: title_id, + style: { backgroundColor: '#FAFAFAFF' }, + type: 'text' + } } )